From 8bd9569c1486686c6b895343c2f4a1bbcf62225c Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Tue, 1 Mar 2016 22:19:33 +0100 Subject: [PATCH 1/9] Disable the tablist hider due to bugs! (Invisible player, missing data resend after login...) --- .../authme/listener/AuthMeTablistPacketAdapter.java | 9 +++++++-- 1 file changed, 7 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 d85a5c5e9..8c0001fed 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java @@ -30,10 +30,15 @@ public class AuthMeTablistPacketAdapter extends PacketAdapter { } public void register() { - ProtocolLibrary.getProtocolManager().addPacketListener(this); + // TODO: + // FIXME: + // This listener hides every player not only from the tablist... From everything! (Invisible players issue) + // WE NEED ALSO TO RESEND THE DATA AFTER THE PLAYER LOGIN + ConsoleLogger.info("The HideTablistBeforeLogin feature is currently unavariable due to stability issues!"); + //ProtocolLibrary.getProtocolManager().addPacketListener(this); } public void unregister() { - ProtocolLibrary.getProtocolManager().removePacketListener(this); + //ProtocolLibrary.getProtocolManager().removePacketListener(this); } } From c5c0535fcd526060a99d7dec8e9744f928bb3949 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Wed, 2 Mar 2016 00:33:26 +0100 Subject: [PATCH 2/9] Ok, nevermind, it works. --- .../authme/listener/AuthMeTablistPacketAdapter.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java index 8c0001fed..d85a5c5e9 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java @@ -30,15 +30,10 @@ public class AuthMeTablistPacketAdapter extends PacketAdapter { } public void register() { - // TODO: - // FIXME: - // This listener hides every player not only from the tablist... From everything! (Invisible players issue) - // WE NEED ALSO TO RESEND THE DATA AFTER THE PLAYER LOGIN - ConsoleLogger.info("The HideTablistBeforeLogin feature is currently unavariable due to stability issues!"); - //ProtocolLibrary.getProtocolManager().addPacketListener(this); + ProtocolLibrary.getProtocolManager().addPacketListener(this); } public void unregister() { - //ProtocolLibrary.getProtocolManager().removePacketListener(this); + ProtocolLibrary.getProtocolManager().removePacketListener(this); } } From 681e352bdcad7cdd43aec113e8c6cb3a137e8418 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Wed, 2 Mar 2016 17:06:02 +0100 Subject: [PATCH 3/9] Fix #570 add max_acc and reg_acc placeholders --- src/main/java/fr/xephi/authme/output/MessageKey.java | 2 +- .../xephi/authme/process/register/AsyncRegister.java | 10 ++++++---- src/main/resources/messages/messages_en.yml | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/xephi/authme/output/MessageKey.java b/src/main/java/fr/xephi/authme/output/MessageKey.java index 0c96b6667..1ab8aaa4a 100644 --- a/src/main/java/fr/xephi/authme/output/MessageKey.java +++ b/src/main/java/fr/xephi/authme/output/MessageKey.java @@ -41,7 +41,7 @@ public enum MessageKey { REGISTER_EMAIL_MESSAGE("reg_email_msg"), - MAX_REGISTER_EXCEEDED("max_reg", "%acc_nb"), + MAX_REGISTER_EXCEEDED("max_reg", "%max_acc", "%reg_acc"), USAGE_REGISTER("usage_reg"), diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java index 97344ba04..0d71c6b8d 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -73,6 +73,7 @@ public class AsyncRegister { //check this in both possiblities so don't use 'else if' Integer size = 0; + Integer maxReg = Settings.getmaxRegPerIp; if (database.isAuthAvailable(name)) { m.send(player, MessageKey.NAME_ALREADY_REGISTERED); return false; @@ -80,8 +81,8 @@ public class AsyncRegister { && !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS) && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost") - && (size = database.getAllAuthsByIp(ip).size()) >= Settings.getmaxRegPerIp) { - m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, size.toString()); + && (size = database.getAllAuthsByIp(ip).size()) >= maxReg) { + m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, maxReg.toString(), size.toString()); return false; } return true; @@ -98,11 +99,12 @@ public class AsyncRegister { } private void emailRegister() { + Integer maxReg = Settings.getmaxRegPerIp; Integer size = 0; if (Settings.getmaxRegPerEmail > 0 && !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS) - && (size = database.countAuthsByEmail(email)) >= Settings.getmaxRegPerEmail) { - m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, size.toString()); + && (size = database.getAllAuthsByIp(ip).size()) >= maxReg) { + m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, maxReg.toString(), size.toString()); return; } final HashedPassword hashedPassword = plugin.getPasswordSecurity().computeHash(password, name); diff --git a/src/main/resources/messages/messages_en.yml b/src/main/resources/messages/messages_en.yml index 4e155bcfe..6c0189a36 100644 --- a/src/main/resources/messages/messages_en.yml +++ b/src/main/resources/messages/messages_en.yml @@ -12,7 +12,7 @@ login: '&2Successful login!' vb_nonActiv: '&cYour account isn''t activated yet, please check your emails!' user_regged: '&cYou already have registered this username!' usage_reg: '&cUsage: /register ' -max_reg: '&cYou have exceeded the maximum number of registrations (%acc_nb) for your connection!' +max_reg: '&cYou have exceeded the maximum number of registrations (%reg_acc/%max_acc) for your connection!' no_perm: '&4You don''t have the permission to perform this action!' error: '&4An unexpected error occurred, please contact an administrator!' login_msg: '&cPlease, login with the command "/login "' From 1e0d31ebb721a5a918310e69a76e47c75f00ee5c Mon Sep 17 00:00:00 2001 From: DNx Date: Thu, 3 Mar 2016 11:11:56 +0700 Subject: [PATCH 4/9] Don't lowercase the real name, also.. the password. Fix #578 --- .../command/executable/authme/RegisterAdminCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java index 7b9299526..a33f3eb39 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java @@ -22,8 +22,8 @@ public class RegisterAdminCommand implements ExecutableCommand { public void executeCommand(final CommandSender sender, List arguments, final CommandService commandService) { // Get the player name and password - final String playerName = arguments.get(0).toLowerCase(); - final String playerPass = arguments.get(1).toLowerCase(); + final String playerName = arguments.get(0); + final String playerPass = arguments.get(1); final String playerNameLowerCase = playerName.toLowerCase(); final String playerPassLowerCase = playerPass.toLowerCase(); From e4d2747fae25b8199214a43ddcdffa67e1768f14 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 3 Mar 2016 21:05:19 +0100 Subject: [PATCH 5/9] Finally fix #570 --- .../java/fr/xephi/authme/output/MessageKey.java | 2 +- .../authme/process/register/AsyncRegister.java | 16 +++++++++------- src/main/resources/messages/messages_en.yml | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/fr/xephi/authme/output/MessageKey.java b/src/main/java/fr/xephi/authme/output/MessageKey.java index 1ab8aaa4a..3fd7c747b 100644 --- a/src/main/java/fr/xephi/authme/output/MessageKey.java +++ b/src/main/java/fr/xephi/authme/output/MessageKey.java @@ -41,7 +41,7 @@ public enum MessageKey { REGISTER_EMAIL_MESSAGE("reg_email_msg"), - MAX_REGISTER_EXCEEDED("max_reg", "%max_acc", "%reg_acc"), + MAX_REGISTER_EXCEEDED("max_reg", "%max_acc", "%reg_count", "%reg_names"), USAGE_REGISTER("usage_reg"), diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java index 0d71c6b8d..d30d08366 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -1,5 +1,7 @@ package fr.xephi.authme.process.register; +import java.util.List; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -99,13 +101,13 @@ public class AsyncRegister { } private void emailRegister() { - Integer maxReg = Settings.getmaxRegPerIp; - Integer size = 0; - if (Settings.getmaxRegPerEmail > 0 - && !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS) - && (size = database.getAllAuthsByIp(ip).size()) >= maxReg) { - m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, maxReg.toString(), size.toString()); - return; + if(Settings.getmaxRegPerEmail > 0 && !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) { + Integer maxReg = Settings.getmaxRegPerIp; + List otherAccounts = database.getAllAuthsByIp(ip); + if (otherAccounts.size() >= maxReg) { + m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, maxReg.toString(), Integer.toString(otherAccounts.size()), otherAccounts.toString()); + return; + } } final HashedPassword hashedPassword = plugin.getPasswordSecurity().computeHash(password, name); PlayerAuth auth = PlayerAuth.builder() diff --git a/src/main/resources/messages/messages_en.yml b/src/main/resources/messages/messages_en.yml index 6c0189a36..5b474e2dc 100644 --- a/src/main/resources/messages/messages_en.yml +++ b/src/main/resources/messages/messages_en.yml @@ -12,7 +12,7 @@ login: '&2Successful login!' vb_nonActiv: '&cYour account isn''t activated yet, please check your emails!' user_regged: '&cYou already have registered this username!' usage_reg: '&cUsage: /register ' -max_reg: '&cYou have exceeded the maximum number of registrations (%reg_acc/%max_acc) for your connection!' +max_reg: '&cYou have exceeded the maximum number of registrations (%reg_count/%max_acc %reg_names) for your connection!' no_perm: '&4You don''t have the permission to perform this action!' error: '&4An unexpected error occurred, please contact an administrator!' login_msg: '&cPlease, login with the command "/login "' From b0d230be600af128dcc948680198739919621753 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 3 Mar 2016 21:17:38 +0100 Subject: [PATCH 6/9] Forgot about this... #570 --- .../process/register/AsyncRegister.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java index d30d08366..b73fd58cd 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -74,18 +74,19 @@ public class AsyncRegister { } //check this in both possiblities so don't use 'else if' - Integer size = 0; - Integer maxReg = Settings.getmaxRegPerIp; if (database.isAuthAvailable(name)) { m.send(player, MessageKey.NAME_ALREADY_REGISTERED); return false; - } else if (Settings.getmaxRegPerIp > 0 - && !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS) + } else if(Settings.getmaxRegPerIp > 0 && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost") - && (size = database.getAllAuthsByIp(ip).size()) >= maxReg) { - m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, maxReg.toString(), size.toString()); - return false; + && !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) { + Integer maxReg = Settings.getmaxRegPerIp; + List otherAccounts = database.getAllAuthsByIp(ip); + if (otherAccounts.size() >= maxReg) { + m.send(player, MessageKey.MAX_REGISTER_EXCEEDED, maxReg.toString(), Integer.toString(otherAccounts.size()), otherAccounts.toString()); + return false; + } } return true; } @@ -101,7 +102,10 @@ public class AsyncRegister { } private void emailRegister() { - if(Settings.getmaxRegPerEmail > 0 && !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) { + if(Settings.getmaxRegPerEmail > 0 + && !ip.equalsIgnoreCase("127.0.0.1") + && !ip.equalsIgnoreCase("localhost") + && !plugin.getPermissionsManager().hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS)) { Integer maxReg = Settings.getmaxRegPerIp; List otherAccounts = database.getAllAuthsByIp(ip); if (otherAccounts.size() >= maxReg) { From c4684fd5f1b7caeb8d84ab607ad07a588d6720f5 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 3 Mar 2016 21:42:50 +0100 Subject: [PATCH 7/9] Booo we don't like UUIDS! (We need to keep 1.7.X compatibility!) - Removed the useless OtherAccounts class! --- README.md | 2 +- src/main/java/fr/xephi/authme/AuthMe.java | 5 - .../process/login/AsynchronousLogin.java | 1 - .../process/register/AsyncRegister.java | 1 - .../xephi/authme/settings/OtherAccounts.java | 96 ------------------- 5 files changed, 1 insertion(+), 104 deletions(-) delete mode 100644 src/main/java/fr/xephi/authme/settings/OtherAccounts.java diff --git a/README.md b/README.md index 5f82e5241..934112c01 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ McStats: http://mcstats.org/plugin/AuthMe #####"The best authentication plugin for the Bukkit/Spigot API!" -

Prevent username stealing on your server! Fully compatible with UUIDs and Craftbukkit/Spigot 1.8.X!
+

Prevent username stealing on your server!
Use it to secure your Offline mode server or to increase your Online mode server's protection!

AuthMeReloaded disallows players who aren't authenticated to do actions like placing blocks, moving,
diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 047cf4088..571fdbbe5 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -46,7 +46,6 @@ import fr.xephi.authme.process.ProcessService; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.crypts.SHA256; import fr.xephi.authme.settings.NewSetting; -import fr.xephi.authme.settings.OtherAccounts; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.SettingsMigrationService; import fr.xephi.authme.settings.Spawn; @@ -121,7 +120,6 @@ public class AuthMe extends JavaPlugin { public NewAPI api; public SendMailSSL mail; public DataManager dataManager; - public OtherAccounts otherAccounts; public Location essentialsSpawn; /* * Plugin Hooks @@ -258,9 +256,6 @@ public class AuthMe extends JavaPlugin { permsMan = initializePermissionsManager(); commandHandler = initializeCommandHandler(permsMan, messages, passwordSecurity, newSettings); - // Setup otherAccounts file - this.otherAccounts = OtherAccounts.getInstance(); - // Set up Metrics MetricsStarter.setupMetrics(plugin, newSettings); diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index d6f1f3278..757789df3 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -185,7 +185,6 @@ public class AsynchronousLogin { // makes player isLoggedin via API PlayerCache.getInstance().addPlayer(auth); database.setLogged(name); - plugin.otherAccounts.addPlayer(player.getUniqueId()); // As the scheduling executes the Task most likely after the current // task, we schedule it in the end diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java index b73fd58cd..6ff41bf60 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -157,7 +157,6 @@ public class AsyncRegister { plugin.getManagement().performLogin(player, "dontneed", true); } - plugin.otherAccounts.addPlayer(player.getUniqueId()); ProcessSyncPasswordRegister sync = new ProcessSyncPasswordRegister(player, plugin, settings); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, sync); diff --git a/src/main/java/fr/xephi/authme/settings/OtherAccounts.java b/src/main/java/fr/xephi/authme/settings/OtherAccounts.java deleted file mode 100644 index 6e2796a32..000000000 --- a/src/main/java/fr/xephi/authme/settings/OtherAccounts.java +++ /dev/null @@ -1,96 +0,0 @@ -package fr.xephi.authme.settings; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -/** - * @author Xephi59 - * @version $Revision: 1.0 $ - */ -public class OtherAccounts extends CustomConfiguration { - - private static OtherAccounts others = null; - - public OtherAccounts() { - super(new File("." + File.separator + "plugins" + File.separator + "AuthMe" + File.separator + "otheraccounts.yml")); - others = this; - load(); - save(); - } - - /** - * Method getInstance. - * - * @return OtherAccounts - */ - public static OtherAccounts getInstance() { - if (others == null) { - others = new OtherAccounts(); - } - return others; - } - - /** - * Method clear. - * - * @param uuid UUID - */ - public void clear(UUID uuid) { - set(uuid.toString(), new ArrayList()); - save(); - } - - /** - * Method addPlayer. - * - * @param uuid UUID - */ - public void addPlayer(UUID uuid) { - try { - Player player = Bukkit.getPlayer(uuid); - if (player == null) - return; - if (!this.getStringList(uuid.toString()).contains(player.getName())) { - this.getStringList(uuid.toString()).add(player.getName()); - save(); - } - } catch (NoSuchMethodError | Exception e) { - //ignore - } - } - - /** - * Method removePlayer. - * - * @param uuid UUID - */ - public void removePlayer(UUID uuid) { - try { - Player player = Bukkit.getPlayer(uuid); - if (player == null) - return; - if (this.getStringList(uuid.toString()).contains(player.getName())) { - this.getStringList(uuid.toString()).remove(player.getName()); - save(); - } - } catch (NoSuchMethodError | Exception e) { - //ignore - } - } - - /** - * Method getAllPlayersByUUID. - * - * @param uuid UUID - * - * @return StringList - */ - public List getAllPlayersByUUID(UUID uuid) { - return this.getStringList(uuid.toString()); - } -} From a23e0a6d30d348c68357935f1cdbf1e377f35bc1 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sat, 5 Mar 2016 13:50:58 +0100 Subject: [PATCH 8/9] Update HikariCP --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5c83dbec4..909181398 100644 --- a/pom.xml +++ b/pom.xml @@ -334,7 +334,7 @@ com.zaxxer HikariCP - 2.4.3 + 2.4.5-SNAPSHOT compile From aa914b9aa7f92300899957024123ddf0f49177f6 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sat, 5 Mar 2016 13:55:40 +0100 Subject: [PATCH 9/9] Add a message about the workaround with MC 1.9 --- src/main/java/fr/xephi/authme/AuthMe.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 571fdbbe5..cff146830 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -242,6 +242,8 @@ public class AuthMe extends JavaPlugin { try { setupDatabase(newSettings); } catch (Exception e) { + ConsoleLogger.showError("If you are using CraftBukkit/Spigot 1.9 please add the " + + "-Dfile.encoding=UTF-8 argument in your server startup script!"); ConsoleLogger.logException("Fatal error occurred during database connection! " + "Authme initialization aborted!", e); stopOrUnload();