diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 5c3b87a6..e94e71cc 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -145,7 +145,7 @@ com.destroystokyo.paper paper-api - 1.15.2-R0.1-SNAPSHOT + 1.16.5-R0.1-SNAPSHOT provided 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 0fc6d7ee..a24dcf23 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 @@ -25,6 +25,7 @@ */ package com.github.games647.fastlogin.bukkit; +import com.destroystokyo.paper.event.player.PlayerHandshakeEvent; import com.github.games647.fastlogin.bukkit.command.CrackedCommand; import com.github.games647.fastlogin.bukkit.command.PremiumCommand; import com.github.games647.fastlogin.bukkit.listener.ConnectionListener; @@ -51,6 +52,8 @@ import java.util.concurrent.ConcurrentMap; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.slf4j.Logger; @@ -64,10 +67,9 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin loginSession = CommonUtil.buildCache(1, -1); private final Map premiumPlayers = new ConcurrentHashMap<>(); private final Logger logger; - + private final BukkitScheduler scheduler; private boolean serverStarted; private BungeeManager bungeeManager; - private final BukkitScheduler scheduler; private FastLoginCore core; private PremiumPlaceholder premiumPlaceholder; @@ -88,17 +90,26 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin - * Writes to Log if the value is invalid. - *

- * This should be used for: - *

    - *
  • allowFloodgateNameConflict - *
  • autoLoginFloodgate - *
  • autoRegisterFloodgate - *
- *

- * - * @param key the key of the entry in config.yml - * @return true if the entry's value is "true", "false", or "linked" - */ - private boolean isValidFloodgateConfigString(String key) { - String value = core.getConfig().get(key).toString().toLowerCase(Locale.ENGLISH); - if (!value.equals("true") && !value.equals("linked") && !value.equals("false") && !value.equals("no-conflict")) { - logger.error("Invalid value detected for {} in FastLogin/config.yml.", key); - return false; - } - return true; - } - - /** - * Checks if a plugin is installed on the server - * @param name the name of the plugin - * @return true if the plugin is installed - */ - @Override - public boolean isPluginInstalled(String name) { - // the plugin may be enabled after FastLogin, so isPluginEnabled() won't work here - return Bukkit.getServer().getPluginManager().getPlugin(name) != null; - } /** - * Send warning messages to log if incompatible plugins are used + * Checks if a config entry (related to Floodgate) is valid.
+ * Writes to Log if the value is invalid. + *

+ * This should be used for: + *

    + *
  • allowFloodgateNameConflict + *
  • autoLoginFloodgate + *
  • autoRegisterFloodgate + *
+ *

+ * + * @param key the key of the entry in config.yml + * @return true if the entry's value is "true", "false", or "linked" + */ + private boolean isValidFloodgateConfigString(String key) { + String value = core.getConfig().get(key).toString().toLowerCase(Locale.ENGLISH); + if (!value.equals("true") && !value.equals("linked") && !value.equals("false") && !value.equals("no-conflict")) { + logger.error("Invalid value detected for {} in FastLogin/config.yml.", key); + return false; + } + return true; + } + + /** + * Checks if a plugin is installed on the server + * + * @param name the name of the plugin + * @return true if the plugin is installed + */ + @Override + public boolean isPluginInstalled(String name) { + // the plugin may be enabled after FastLogin, so isPluginEnabled() won't work here + return Bukkit.getServer().getPluginManager().getPlugin(name) != null; + } + + /** + * Send warning messages to log if incompatible plugins are used */ private void dependencyWarnings() { if (isPluginInstalled("floodgate-bukkit")) { @@ -303,13 +310,13 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin @@ -75,7 +77,7 @@ public class AuthMeHook implements AuthPlugin, Listener { public void onSessionRestore(RestoreSessionEvent restoreSessionEvent) { Player player = restoreSessionEvent.getPlayer(); - BukkitLoginSession session = plugin.getSession(player.getAddress()); + BukkitLoginSession session = plugin.getSession(player.spigot().getRawAddress()); 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 0a4fcef8..fd9a31c3 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 @@ -126,7 +126,7 @@ public class BungeeListener implements PluginMessageListener { private void startLoginTaskIfReady(Player player, BukkitLoginSession session) { session.setVerified(true); - plugin.putSession(player.getAddress(), session); + plugin.putSession(player.spigot().getRawAddress(), session); // only start a new login task if the join event fired earlier. This event then didn boolean result = plugin.getBungeeManager().didJoinEventFired(player); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java index 10ce38d9..96138a69 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java @@ -72,7 +72,7 @@ public class ConnectionListener implements Listener { // session exists so the player is ready for force login // cases: Paper (firing BungeeCord message before PlayerJoinEvent) or not running BungeeCord and already // having the login session from the login process - BukkitLoginSession session = plugin.getSession(player.getAddress()); + BukkitLoginSession session = plugin.getSession(player.spigot().getRawAddress()); boolean isFloodgateLogin = false; if (Bukkit.getServer().getPluginManager().isPluginEnabled("floodgate")) { @@ -86,7 +86,7 @@ public class ConnectionListener implements Listener { if (!isFloodgateLogin) { if (session == null) { - String sessionId = plugin.getSessionId(player.getAddress()); + String sessionId = plugin.getSessionId(player.spigot().getRawAddress()); plugin.getLog().info("No on-going login session for player: {} with ID {}", player, sessionId); } else { Runnable forceLoginTask = new ForceLoginTask(plugin.getCore(), player, session); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java index 638ffaed..72e25963 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java @@ -188,7 +188,7 @@ public class VerifyResponseTask implements Runnable { //https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/LoginListener.java#L182 if (!Arrays.equals(requestVerify, EncryptionUtil.decrypt(serverKey.getPrivate(), responseVerify))) { - //check if the verify token are equal to the server sent one + //check if the verify-token are equal to the server sent one disconnect("invalid-verify-token", true , "GameProfile {0} ({1}) tried to login with an invalid verify token. Server: {2} Client: {3}" , session.getRequestUsername(), packetEvent.getPlayer().getAddress(), requestVerify, responseVerify); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java index 2e98178b..0e182b4b 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java @@ -51,7 +51,7 @@ public class ProtocolLoginSource implements LoginSource { @Override public InetSocketAddress getAddress() { - return loginStartEvent.getAddress(); + return loginStartEvent.getConnection().getRawAddress(); } public PlayerLoginStartEvent getLoginStartEvent() { diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolSupportListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolSupportListener.java index d25bb492..4d8bf945 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolSupportListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolSupportListener.java @@ -71,7 +71,7 @@ public class ProtocolSupportListener extends JoinManagement