From 680427950f931a644edff0522f0adfedbe532f4e Mon Sep 17 00:00:00 2001 From: DNx5 Date: Sat, 18 Jun 2016 15:41:05 +0700 Subject: [PATCH 1/5] derp --- .../authme/process/register/ProcessSyncPasswordRegister.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java index 16f1ad360..3076e7f1a 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java @@ -27,7 +27,7 @@ import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; -import static fr.xephi.authme.settings.properties.RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN; +import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN; /** */ @@ -98,7 +98,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess { Utils.teleportToSpawn(player); - if (service.getProperty(HIDE_TABLIST_BEFORE_LOGIN) && plugin.inventoryProtector != null) { + if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN) && plugin.inventoryProtector != null) { RestoreInventoryEvent event = new RestoreInventoryEvent(player); bukkitService.callEvent(event); if (!event.isCancelled()) { From 12533a90f67fb8891eb802b76943e512ce8c617a Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 19 Jun 2016 10:40:20 +0200 Subject: [PATCH 2/5] Join/PreLogin event listener changes --- .../authme/listener/AuthMePlayerListener.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 84fff695d..dfd519e17 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -192,31 +192,28 @@ public class AuthMePlayerListener implements Listener { @EventHandler(priority = EventPriority.LOW) public void onPlayerJoin(PlayerJoinEvent event) { final Player player = event.getPlayer(); - if (player != null) { - // Schedule login task so works after the prelogin - // (Fix found by Koolaid5000) - bukkitService.runTask(new Runnable() { - @Override - public void run() { - management.performJoin(player); - } - }); - } + management.performJoin(player); } // Note ljacqu 20160528: AsyncPlayerPreLoginEvent is not fired by all servers in offline mode // e.g. CraftBukkit does not. So we need to run crucial things in onPlayerLogin, too + + // Note sgdc3 20160619: No performance improvements if we do the same thing on the Sync method + // let's try to remove this, about the single session issue, + // i tried to use the low priority to the sync handler + + /* @EventHandler(priority = EventPriority.HIGHEST) public void onPreLogin(AsyncPlayerPreLoginEvent event) { final String name = event.getName().toLowerCase(); - final boolean isAuthAvailable = dataSource.isAuthAvailable(event.getName()); + //final boolean isAuthAvailable = dataSource.isAuthAvailable(event.getName()); try { // Potential performance improvement: make checkAntiBot not require `isAuthAvailable` info and use // "checkKickNonRegistered" as last -> no need to query the DB before checking antibot / name - onJoinVerifier.checkAntibot(name, isAuthAvailable); - onJoinVerifier.checkKickNonRegistered(isAuthAvailable); - onJoinVerifier.checkIsValidName(name); + // onJoinVerifier.checkAntibot(name, isAuthAvailable); + // onJoinVerifier.checkKickNonRegistered(isAuthAvailable); + // onJoinVerifier.checkIsValidName(name); // Note #760: Single session must be checked here - checking with PlayerLoginEvent is too late and // the first connection will have been kicked. This means this feature doesn't work on CraftBukkit. onJoinVerifier.checkSingleSession(name); @@ -225,8 +222,9 @@ public class AuthMePlayerListener implements Listener { event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); } } + */ - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.LOW) public void onPlayerLogin(PlayerLoginEvent event) { final Player player = event.getPlayer(); if (Utils.isUnrestricted(player)) { @@ -242,6 +240,7 @@ public class AuthMePlayerListener implements Listener { final boolean isAuthAvailable = (auth != null); try { + onJoinVerifier.checkSingleSession(name); onJoinVerifier.checkAntibot(name, isAuthAvailable); onJoinVerifier.checkKickNonRegistered(isAuthAvailable); onJoinVerifier.checkIsValidName(name); From e1d697d386a1cd94fd09a02654cd7d9eaf854cfe Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 19 Jun 2016 11:07:17 +0200 Subject: [PATCH 3/5] Fix #780 --- .../fr/xephi/authme/listener/AuthMePlayerListener.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index dfd519e17..ec0368a6e 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -235,13 +235,14 @@ public class AuthMePlayerListener implements Listener { return; } - final String name = player.getName().toLowerCase(); + final String name = player.getName(); + final String lowerName = name.toLowerCase(); final PlayerAuth auth = dataSource.getAuth(player.getName()); final boolean isAuthAvailable = (auth != null); try { - onJoinVerifier.checkSingleSession(name); - onJoinVerifier.checkAntibot(name, isAuthAvailable); + onJoinVerifier.checkSingleSession(lowerName); + onJoinVerifier.checkAntibot(lowerName, isAuthAvailable); onJoinVerifier.checkKickNonRegistered(isAuthAvailable); onJoinVerifier.checkIsValidName(name); onJoinVerifier.checkNameCasing(player, auth); From 03fa0e1fece2136dc27aa0482a4acb6859e37468 Mon Sep 17 00:00:00 2001 From: games647 Date: Sun, 19 Jun 2016 12:40:15 +0200 Subject: [PATCH 4/5] Fix disabling tablist adapter on old versions (Fixes #775) --- .../listener/AuthMeTablistPacketAdapter.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java index 17b4a60a9..01be3235a 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java @@ -14,20 +14,24 @@ import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction; import com.comphenix.protocol.wrappers.PlayerInfoData; import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.WrappedGameProfile; + import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.util.BukkitService; -import org.bukkit.entity.Player; -import javax.inject.Inject; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.logging.Level; +import javax.inject.Inject; + +import org.bukkit.entity.Player; + public class AuthMeTablistPacketAdapter extends PacketAdapter { private final BukkitService bukkitService; + private boolean isRegistered; @Inject public AuthMeTablistPacketAdapter(AuthMe plugin, BukkitService bukkitService) { @@ -50,6 +54,10 @@ public class AuthMeTablistPacketAdapter extends PacketAdapter { } public void sendTablist(Player receiver) { + if (!isRegistered) { + return; + } + WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(receiver); ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); @@ -85,6 +93,7 @@ public class AuthMeTablistPacketAdapter extends PacketAdapter { public void register() { if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.BOUNTIFUL_UPDATE)) { ProtocolLibrary.getProtocolManager().addPacketListener(this); + isRegistered = true; } else { ConsoleLogger.info("The hideTablist feature is not compatible with your minecraft version"); ConsoleLogger.info("It requires 1.8+. Disabling the hideTablist feature..."); @@ -93,5 +102,6 @@ public class AuthMeTablistPacketAdapter extends PacketAdapter { public void unregister() { ProtocolLibrary.getProtocolManager().removePacketListener(this); + isRegistered = false; } } From d848a2ad1686ba5b45032ef371676425bb9444a4 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 19 Jun 2016 15:14:12 +0200 Subject: [PATCH 5/5] Fix #645 #783 --- .../process/logout/ProcessSynchronousPlayerLogout.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java b/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java index c70f4cd08..88a13e306 100644 --- a/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/ProcessSynchronousPlayerLogout.java @@ -49,9 +49,10 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess { } private void restoreSpeedEffect(Player player) { - if (service.getProperty(RestrictionSettings.REMOVE_SPEED)) { - player.setWalkSpeed(0.0F); - player.setFlySpeed(0.0F); + if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT) + && service.getProperty(RestrictionSettings.REMOVE_SPEED)) { + player.setFlySpeed(0.0f); + player.setWalkSpeed(0.0f); } }