fix: Fixed AutoLogin inconsistency

This commit is contained in:
Adrian 2023-07-29 10:55:27 -05:00
parent ee3d7b74dc
commit 9536b98b7d
No known key found for this signature in database
GPG Key ID: FB8EF84DCE1BE452
3 changed files with 10 additions and 4 deletions

View File

@ -49,7 +49,7 @@ public final class AuthMeListener implements Listener {
if (!preSendLoginEvent.isCancelled()) {
plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName());
plugin.getLogger().info("LoginEvent | PreSendLoginEvent allowed");
plugin.logDebug("LoginEvent | PreSendLoginEvent allowed");
}
}

View File

@ -38,7 +38,7 @@ public final class MessageListener implements PluginMessageListener {
@Override
public void onPluginMessageReceived(
final @NotNull String identifier,
final @NotNull Player player,
final @NotNull Player $,
final byte @NotNull [] bytes
) {
if (identifier.equals("authmevelocity:main")) {
@ -46,13 +46,18 @@ public final class MessageListener implements PluginMessageListener {
final ByteArrayDataInput input = ByteStreams.newDataInput(bytes);
final String data = input.readUTF();
processData(player, data);
final String username = input.readUTF();
processData(username, data);
plugin.logDebug("PluginMessage | AuthMeVelocity identifier processed");
}
}
private void processData(Player player, String data) {
private void processData(String name, String data) {
if (MessageType.LOGIN.toString().equals(data)) {
final Player player = this.plugin.getServer().getPlayer(name);
if (player == null) {
return;
}
plugin.logDebug("PluginMessage | Login Message");
Bukkit.getPluginManager().callEvent(new LoginByProxyEvent(player));
AuthMeApi.getInstance().forceLogin(player);

View File

@ -62,6 +62,7 @@ public final class PostConnectListener implements Listener<ServerPostConnectEven
plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server");
final ByteArrayDataOutput buf = ByteStreams.newDataOutput();
buf.writeUTF("LOGIN");
buf.writeUTF(player.getUsername());
final byte[] byteArray = buf.toByteArray();
plugin.logDebug("ServerPostConnectEvent | Sending LOGIN data");