diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java index 61106d89..768fff57 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java @@ -18,6 +18,7 @@ import com.github.games647.fastlogin.core.shared.PlatformPlugin; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; +import java.net.InetSocketAddress; import java.nio.file.Path; import java.util.Map; import java.util.UUID; @@ -145,6 +146,21 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin getPremiumPlayers() { return premiumPlayers; } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/AuthMeHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/AuthMeHook.java index 23cbe5ff..f872c780 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/AuthMeHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/AuthMeHook.java @@ -33,8 +33,7 @@ public class AuthMeHook implements AuthPlugin, Listener { public void onSessionRestore(RestoreSessionEvent restoreSessionEvent) { Player player = restoreSessionEvent.getPlayer(); - String id = '/' + player.getAddress().getAddress().getHostAddress() + ':' + player.getAddress().getPort(); - BukkitLoginSession session = plugin.getLoginSessions().get(id); + BukkitLoginSession session = plugin.getSession(player.getAddress()); if (session != null && session.isVerified()) { restoreSessionEvent.setCancelled(true); } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java index de477b35..1e3985c3 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java @@ -78,11 +78,10 @@ public class BungeeListener implements PluginMessageListener { Type type = message.getType(); InetSocketAddress address = player.getAddress(); - String id = '/' + address.getAddress().getHostAddress() + ':' + address.getPort(); if (type == Type.LOGIN) { BukkitLoginSession playerSession = new BukkitLoginSession(playerName, true); playerSession.setVerified(true); - plugin.getLoginSessions().put(id, playerSession); + plugin.putSession(address, playerSession); Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new ForceLoginTask(plugin.getCore(), player), 10L); } else if (type == Type.REGISTER) { @@ -93,7 +92,7 @@ public class BungeeListener implements PluginMessageListener { if (authPlugin == null || !authPlugin.isRegistered(playerName)) { BukkitLoginSession playerSession = new BukkitLoginSession(playerName, false); playerSession.setVerified(true); - plugin.getLoginSessions().put(id, playerSession); + plugin.putSession(address, playerSession); new ForceLoginTask(plugin.getCore(), player).run(); } } catch (Exception ex) { diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java index 0d46909f..67249722 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java @@ -7,11 +7,11 @@ import com.github.games647.fastlogin.bukkit.FastLoginBukkit; import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPreLoginEvent; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.shared.JoinManagement; +import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent; import java.security.PublicKey; import java.util.Random; -import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -74,7 +74,7 @@ public class NameCheckTask extends JoinManagement { public ForceLoginTask(FastLoginCore core, Player player) { - super(core, player, getSession(core.getPlugin(), player)); - } - - private static BukkitLoginSession getSession(FastLoginBukkit plugin, Player player) { - //remove the bungeecord identifier if there is ones - String id = '/' + player.getAddress().getAddress().getHostAddress() + ':' + player.getAddress().getPort(); - return plugin.getLoginSessions().remove(id); + super(core, player, core.getPlugin().getSession(player.getAddress())); } @Override diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java index 59808e2e..7897feb2 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java @@ -74,8 +74,9 @@ public class ConnectListener implements Listener { try { UUID offlineUUID = UUIDAdapter.generateOfflineId(username); - //bungeecord doesn't support overriding the premium uuid - //so we have to do it with reflection + // BungeeCord only allows setting the UUID in PreLogin events and before requesting online mode + // However if online mode is requested, it will override previous values + // So we have to do it with reflection Field idField = InitialHandler.class.getDeclaredField("uniqueId"); idField.setAccessible(true); idField.set(connection, offlineUUID); @@ -85,7 +86,7 @@ public class ConnectListener implements Listener { } if (!plugin.getCore().getConfig().get("forwardSkin", true)) { - //this is null on offline mode + // this is null on offline mode LoginResult loginProfile = initialHandler.getLoginProfile(); if (loginProfile != null) { loginProfile.setProperties(emptyProperties);