diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index c5a26048..1c3fb05d 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -60,6 +60,7 @@ import fr.xephi.authme.listener.AuthMePlayerListener16; import fr.xephi.authme.listener.AuthMePlayerListener18; import fr.xephi.authme.listener.AuthMeServerListener; import fr.xephi.authme.listener.AuthMeTabCompletePacketAdapter; +import fr.xephi.authme.listener.AuthMeTablistPacketAdapter; import fr.xephi.authme.mail.SendMailSSL; import fr.xephi.authme.output.ConsoleFilter; import fr.xephi.authme.output.Log4JFilter; @@ -132,6 +133,7 @@ public class AuthMe extends JavaPlugin { public CombatTagPlus combatTagPlus; public AuthMeInventoryPacketAdapter inventoryProtector; public AuthMeTabCompletePacketAdapter tabComplete; + public AuthMeTablistPacketAdapter tablistHider; /* * Maps and stuff @@ -664,10 +666,14 @@ public class AuthMe extends JavaPlugin { inventoryProtector.unregister(); inventoryProtector = null; } - if (tabComplete == null) { + if (tabComplete == null && newSettings.getProperty(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN)) { tabComplete = new AuthMeTabCompletePacketAdapter(this); tabComplete.register(); } + if (tablistHider == null && newSettings.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN)) { + tablistHider = new AuthMeTablistPacketAdapter(this); + tablistHider.register(); + } } // Save Player Data diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 1a55556e..8a363b4f 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -202,7 +202,7 @@ public class AuthMePlayerListener implements Listener { if (joinMsg == null) { return; } - event.setJoinMessage(null); + event.setJoinMessage((String)null); joinMessage.put(name, joinMsg); } @@ -358,7 +358,7 @@ public class AuthMePlayerListener implements Listener { } if (Settings.delayJoinLeaveMessages && !Utils.checkAuth(player)) { - event.setQuitMessage(null); + event.setQuitMessage((String)null); } plugin.getManagement().performQuit(player, false); diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java new file mode 100644 index 00000000..f4321b40 --- /dev/null +++ b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java @@ -0,0 +1,44 @@ +package fr.xephi.authme.listener; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.ListenerPriority; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.reflect.FieldAccessException; + +import fr.xephi.authme.AuthMe; +import fr.xephi.authme.ConsoleLogger; +import fr.xephi.authme.cache.auth.PlayerCache; + +public class AuthMeTablistPacketAdapter extends PacketAdapter { + + public AuthMeTablistPacketAdapter(AuthMe plugin) { + super(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO); + } + + @Override + public void onPacketReceiving(PacketEvent event) + { + if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO) { + try + { + if (!PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase())) { + event.setCancelled(true); + } + } + catch (FieldAccessException e) + { + ConsoleLogger.showError("Couldn't access field."); + } + } + } + + public void register() { + ProtocolLibrary.getProtocolManager().addPacketListener(this); + } + + public void unregister() { + ProtocolLibrary.getProtocolManager().removePacketListener(this); + } +} 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 386e130c..c140a67a 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java @@ -126,10 +126,18 @@ public class RestrictionSettings implements SettingsClass { public static final Property ENABLE_PASSWORD_CONFIRMATION = newProperty("settings.restrictions.enablePasswordConfirmation", true); - @Comment("Should we protect the player inventory before logging in?") + @Comment("Should we protect the player inventory before logging in? Requires ProtocolLib.") public static final Property PROTECT_INVENTORY_BEFORE_LOGIN = newProperty("settings.restrictions.ProtectInventoryBeforeLogIn", true); + @Comment("Should we deny the tabcomplete feature before logging in? Requires ProtocolLib.") + 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 151bc753..cfa7cb01 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -132,8 +132,12 @@ settings: # when it's true, registration require that kind of command: # /register enablePasswordConfirmation: true - # Should we protect the player inventory before logging in? + # Should we protect the player inventory before logging in? Requires ProtocolLib. 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