From bc9717d6501fbc639d97e4ad636c47fd3963eacb Mon Sep 17 00:00:00 2001 From: games647 Date: Sat, 2 Jul 2016 12:25:33 +0200 Subject: [PATCH] Remove tablist hider because it's useless and produces too much issues (Related #810) --- .../AuthMeTablistPacketAdapter.java | 120 ------------------ .../protocollib/ProtocolLibService.java | 29 +---- .../process/login/ProcessSyncPlayerLogin.java | 4 - .../register/ProcessSyncPasswordRegister.java | 5 - .../properties/RestrictionSettings.java | 4 - src/main/resources/config.yml | 2 - 6 files changed, 1 insertion(+), 163 deletions(-) delete mode 100644 src/main/java/fr/xephi/authme/listener/protocollib/AuthMeTablistPacketAdapter.java diff --git a/src/main/java/fr/xephi/authme/listener/protocollib/AuthMeTablistPacketAdapter.java b/src/main/java/fr/xephi/authme/listener/protocollib/AuthMeTablistPacketAdapter.java deleted file mode 100644 index 75e06cd57..000000000 --- a/src/main/java/fr/xephi/authme/listener/protocollib/AuthMeTablistPacketAdapter.java +++ /dev/null @@ -1,120 +0,0 @@ -package fr.xephi.authme.listener.protocollib; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.ProtocolManager; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.utility.MinecraftVersion; -import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode; -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 com.google.common.collect.Lists; -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.Bukkit; -import org.bukkit.entity.Player; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; -import java.util.logging.Level; - -class AuthMeTablistPacketAdapter extends PacketAdapter { - - private final BukkitService bukkitService; - private boolean isRegistered; - - public AuthMeTablistPacketAdapter(AuthMe plugin, BukkitService bukkitService) { - super(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO); - this.bukkitService = bukkitService; - } - - @Override - public void onPacketSending(PacketEvent packetEvent) { - Player receiver = packetEvent.getPlayer(); - if (packetEvent.getPacketType() == PacketType.Play.Server.PLAYER_INFO - && !PlayerCache.getInstance().isAuthenticated(receiver.getName().toLowerCase())) { - //this hides the tablist for the new joining players. Already playing users will see the new player - try { - PacketContainer packet = packetEvent.getPacket(); - PlayerInfoAction playerInfoAction = packet.getPlayerInfoAction().read(0); - if (playerInfoAction == PlayerInfoAction.ADD_PLAYER) { - List playerInfoList = Lists.newArrayList(packet.getPlayerInfoDataLists().read(0)); - for (Iterator iterator = playerInfoList.iterator(); iterator.hasNext();) { - PlayerInfoData current = iterator.next(); - UUID uuid = current.getProfile().getUUID(); - if (Bukkit.getPlayer(uuid) == null) { - //player is not online -> a NPC - iterator.remove(); - } - } - - packet.getPlayerInfoDataLists().write(0, playerInfoList); - } - } catch (Exception ex) { - ConsoleLogger.logException("Couldn't modify outgoing tablist packet", ex); - } - } - } - - public void sendTablist(Player receiver) { - if (!isRegistered) { - return; - } - - WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(receiver); - - ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); - NativeGameMode gamemode = NativeGameMode.fromBukkit(receiver.getGameMode()); - - WrappedChatComponent displayName = WrappedChatComponent.fromText(receiver.getDisplayName()); - PlayerInfoData playerInfoData = new PlayerInfoData(gameProfile, 0, gamemode, displayName); - - //add info containing the skin data - PacketContainer addInfo = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO); - addInfo.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER); - addInfo.getPlayerInfoDataLists().write(0, Arrays.asList(playerInfoData)); - - try { - //adds the skin - protocolManager.sendServerPacket(receiver, addInfo); - } catch (InvocationTargetException ex) { - plugin.getLogger().log(Level.SEVERE, "Exception sending instant skin change packet", ex); - } - - //triggers an update for others player to see them - for (Player onlinePlayer : bukkitService.getOnlinePlayers()) { - if (onlinePlayer.equals(receiver) || !receiver.canSee(onlinePlayer)) { - continue; - } - - //removes the entity and display them - receiver.hidePlayer(onlinePlayer); - receiver.showPlayer(onlinePlayer); - } - } - - 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..."); - } - } - - public void unregister() { - ProtocolLibrary.getProtocolManager().removePacketListener(this); - isRegistered = false; - } -} diff --git a/src/main/java/fr/xephi/authme/listener/protocollib/ProtocolLibService.java b/src/main/java/fr/xephi/authme/listener/protocollib/ProtocolLibService.java index a38595279..d0db26647 100644 --- a/src/main/java/fr/xephi/authme/listener/protocollib/ProtocolLibService.java +++ b/src/main/java/fr/xephi/authme/listener/protocollib/ProtocolLibService.java @@ -15,12 +15,10 @@ public class ProtocolLibService implements SettingsDependent { /* Packet Adapters */ private AuthMeInventoryPacketAdapter inventoryPacketAdapter; private AuthMeTabCompletePacketAdapter tabCompletePacketAdapter; - private AuthMeTablistPacketAdapter tablistPacketAdapter; /* Settings */ private boolean protectInvBeforeLogin; private boolean denyTabCompleteBeforeLogin; - private boolean hideTablistBeforeLogin; /* Service */ private boolean isEnabled; @@ -44,12 +42,10 @@ public class ProtocolLibService implements SettingsDependent { if (protectInvBeforeLogin) { ConsoleLogger.showError("WARNING! The protectInventory feature requires ProtocolLib! Disabling it..."); } + if (denyTabCompleteBeforeLogin) { ConsoleLogger.showError("WARNING! The denyTabComplete feature requires ProtocolLib! Disabling it..."); } - if (hideTablistBeforeLogin) { - ConsoleLogger.showError("WARNING! The hideTablist feature requires ProtocolLib! Disabling it..."); - } this.isEnabled = false; return; @@ -70,13 +66,6 @@ public class ProtocolLibService implements SettingsDependent { tabCompletePacketAdapter.unregister(); tabCompletePacketAdapter = null; } - if (hideTablistBeforeLogin && tablistPacketAdapter == null) { - tablistPacketAdapter = new AuthMeTablistPacketAdapter(plugin, bukkitService); - tablistPacketAdapter.register(); - } else if (tablistPacketAdapter != null) { - tablistPacketAdapter.unregister(); - tablistPacketAdapter = null; - } this.isEnabled = true; } @@ -92,10 +81,6 @@ public class ProtocolLibService implements SettingsDependent { tabCompletePacketAdapter.unregister(); tabCompletePacketAdapter = null; } - if (tablistPacketAdapter != null) { - tablistPacketAdapter.unregister(); - tablistPacketAdapter = null; - } } /** @@ -120,21 +105,9 @@ public class ProtocolLibService implements SettingsDependent { } } - /** - * Send a tab list packet to a player. - * - * @param player The player to send the packet to. - */ - public void sendTabList(Player player) { - if (isEnabled && tablistPacketAdapter != null) { - tablistPacketAdapter.sendTablist(player); - } - } - @Override public void loadSettings(NewSetting settings) { this.protectInvBeforeLogin = settings.getProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN); this.denyTabCompleteBeforeLogin = settings.getProperty(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN); - this.hideTablistBeforeLogin = settings.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN); } } diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java index 783a4ed36..1752e33be 100644 --- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java @@ -112,10 +112,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess { restoreInventory(player); } - if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN)) { - protocolLibService.sendTabList(player); - } - // Clean up no longer used temporary data limboCache.deleteLimboPlayer(name); } 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 524d6b1c4..94b353043 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java @@ -17,7 +17,6 @@ import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; -import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.task.LimboPlayerTaskManager; import fr.xephi.authme.util.BukkitService; @@ -96,10 +95,6 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess { final String name = player.getName().toLowerCase(); LimboPlayer limbo = limboCache.getLimboPlayer(name); if (limbo != null) { - if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN)) { - protocolLibService.sendTabList(player); - } - Utils.teleportToSpawn(player); if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) { diff --git a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java index 3fd7b40b1..e2b8d039f 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java @@ -141,10 +141,6 @@ public class RestrictionSettings implements SettingsClass { public static final Property DENY_TABCOMPLETE_BEFORE_LOGIN = newProperty("settings.restrictions.DenyTabCompleteBeforeLogin", true); - @Comment("Should we hide the tablist before logging in? Requires ProtocolLib.") - public static final Property HIDE_TABLIST_BEFORE_LOGIN = - newProperty("settings.restrictions.HideTablistBeforeLogin", true); - @Comment({ "Should we display all other accounts from a player when he joins?", "permission: /authme.admin.accounts"}) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 99cc3a2b9..7c6d0cae6 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -141,8 +141,6 @@ settings: ProtectInventoryBeforeLogIn: true # Should we deny the tabcomplete feature before logging in? Requires ProtocolLib. DenyTabCompleteBeforeLogin: true - # Should we hide the tablist before logging in? Requires ProtocolLib. - HideTablistBeforeLogin: true # Should we display all other accounts from a player when he joins? # permission: /authme.admin.accounts displayOtherAccounts: true