From 029214c080a4cef4e9b518ac0bb581a2a677f799 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 1 Dec 2015 01:29:56 +0700 Subject: [PATCH 01/11] Fix npe after register. --- .../xephi/authme/cache/limbo/LimboCache.java | 10 ++-- .../xephi/authme/cache/limbo/LimboPlayer.java | 21 ++++++++- .../authme/process/join/AsynchronousJoin.java | 8 ++-- .../ProcessSyncronousPasswordRegister.java | 46 +++++++++++-------- 4 files changed, 55 insertions(+), 30 deletions(-) diff --git a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java index 69774e221..33cef3ded 100644 --- a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java +++ b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java @@ -117,7 +117,10 @@ public class LimboCache { * @param name String */ public void deleteLimboPlayer(String name) { - cache.remove(name); + if(cache.containsKey(name)) { + cache.get(name).clearTask(); + cache.remove(name); + } } /** @@ -148,8 +151,9 @@ public class LimboCache { * @param player Player */ public void updateLimboPlayer(Player player) { - if (this.hasLimboPlayer(player.getName().toLowerCase())) { - this.deleteLimboPlayer(player.getName().toLowerCase()); + String name = player.getName().toLowerCase(); + if (hasLimboPlayer(name)) { + deleteLimboPlayer(name); } addLimboPlayer(player); } diff --git a/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java b/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java index 96c5a9ee9..76ed21e8e 100644 --- a/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java +++ b/src/main/java/fr/xephi/authme/cache/limbo/LimboPlayer.java @@ -108,8 +108,9 @@ public class LimboPlayer { * @param i BukkitTask */ public void setTimeoutTaskId(BukkitTask i) { - if (this.timeoutTaskId != null) + if (this.timeoutTaskId != null) { this.timeoutTaskId.cancel(); + } this.timeoutTaskId = i; } @@ -128,11 +129,27 @@ public class LimboPlayer { * @param messageTaskId BukkitTask */ public void setMessageTaskId(BukkitTask messageTaskId) { - if (this.messageTaskId != null) + if (this.messageTaskId != null) { this.messageTaskId.cancel(); + } this.messageTaskId = messageTaskId; } + /** + * Method clearTask. + * + */ + public void clearTask() { + if (messageTaskId != null) { + messageTaskId.cancel(); + } + messageTaskId = null; + if (timeoutTaskId != null) { + timeoutTaskId.cancel(); + } + timeoutTaskId = null; + } + /** * Method isFlying. * diff --git a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java index aa49d3f29..01724b3a1 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -50,14 +50,12 @@ public class AsynchronousJoin { } public void process() { - if (AuthMePlayerListener.gameMode.containsKey(name)) - AuthMePlayerListener.gameMode.remove(name); - AuthMePlayerListener.gameMode.putIfAbsent(name, player.getGameMode()); - - if (Utils.isNPC(player) || Utils.isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } + AuthMePlayerListener.gameMode.put(name, player.getGameMode()); + if (plugin.ess != null && Settings.disableSocialSpy) { plugin.ess.getUser(player).setSocialSpyEnabled(false); } diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java index 28faa5bf3..bd1bb174f 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java @@ -41,15 +41,13 @@ public class ProcessSyncronousPasswordRegister implements Runnable { this.plugin = plugin; } - protected void forceCommands() { + private void forceCommands() { for (String command : Settings.forceRegisterCommands) { - try { - player.performCommand(command.replace("%p", player.getName())); - } catch (Exception ignored) { - } + player.performCommand(command.replace("%p", player.getName())); } for (String command : Settings.forceRegisterCommandsAsConsole) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.replace("%p", player.getName())); + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), + command.replace("%p", player.getName())); } } @@ -58,20 +56,21 @@ public class ProcessSyncronousPasswordRegister implements Runnable { * * @param player Player */ - protected void forceLogin(Player player) { + private void forceLogin(Player player) { Utils.teleportToSpawn(player); - if (LimboCache.getInstance().hasLimboPlayer(name)) - LimboCache.getInstance().deleteLimboPlayer(name); - LimboCache.getInstance().addLimboPlayer(player); + LimboCache cache = LimboCache.getInstance(); + cache.updateLimboPlayer(player); int delay = Settings.getRegistrationTimeout * 20; int interval = Settings.getWarnMessageInterval; BukkitScheduler sched = plugin.getServer().getScheduler(); + BukkitTask task; if (delay != 0) { - BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay); - LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id); + task = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay); + cache.getLimboPlayer(name).setTimeoutTaskId(task); } - BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.retrieve(MessageKey.LOGIN_MESSAGE), interval)); - LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT); + task = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, + m.retrieve(MessageKey.LOGIN_MESSAGE), interval)); + cache.getLimboPlayer(name).setMessageTaskId(task); if (player.isInsideVehicle() && player.getVehicle() != null) { player.getVehicle().eject(); } @@ -97,33 +96,39 @@ public class ProcessSyncronousPasswordRegister implements Runnable { } } - limbo.getTimeoutTaskId().cancel(); - limbo.getMessageTaskId().cancel(); LimboCache.getInstance().deleteLimboPlayer(name); } if (!Settings.getRegisteredGroup.isEmpty()) { Utils.setGroup(player, Utils.GroupType.REGISTERED); } + m.send(player, MessageKey.REGISTER_SUCCESS); - if (!Settings.getmailAccount.isEmpty()) + + if (!Settings.getmailAccount.isEmpty()) { m.send(player, MessageKey.ADD_EMAIL_MESSAGE); + } if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) { player.setAllowFlight(false); player.setFlying(false); } - if (Settings.applyBlindEffect) + + if (Settings.applyBlindEffect) { player.removePotionEffect(PotionEffectType.BLINDNESS); + } + if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) { player.setWalkSpeed(0.2f); player.setFlySpeed(0.1f); } + // The LoginEvent now fires (as intended) after everything is processed plugin.getServer().getPluginManager().callEvent(new LoginEvent(player, true)); player.saveData(); - if (!Settings.noConsoleSpam) + if (!Settings.noConsoleSpam) { ConsoleLogger.info(player.getName() + " registered " + plugin.getIP(player)); + } // Kick Player after Registration is enabled, kick the player if (Settings.forceRegKick) { @@ -138,7 +143,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable { } // Register is finish and player is logged, display welcome message - if (Settings.useWelcomeMessage) + if (Settings.useWelcomeMessage) { if (Settings.broadcastWelcomeMessage) { for (String s : Settings.welcomeMsg) { plugin.getServer().broadcastMessage(plugin.replaceAllInfo(s, player)); @@ -148,6 +153,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable { player.sendMessage(plugin.replaceAllInfo(s, player)); } } + } // Register is now finish , we can force all commands forceCommands(); From d6925300351ad4d48bbcbbfc8f1e88069053e1e5 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 1 Dec 2015 01:35:30 +0700 Subject: [PATCH 02/11] Moved is player can connect check into prelogin event. --- .../authme/listener/AuthMePlayerListener.java | 6 ++++++ .../authme/process/join/AsynchronousJoin.java | 15 --------------- 2 files changed, 6 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 8400d572f..ae0e83ca0 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -198,6 +198,12 @@ public class AuthMePlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onPreLogin(AsyncPlayerPreLoginEvent event) { + if (!plugin.canConnect()) { + event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); + event.setKickMessage("Server is loading, please wait before joining!"); + return; + } + final String name = event.getName().toLowerCase(); final Player player = Utils.getPlayer(name); if (player == null || Utils.isNPC(player)) { diff --git a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java index 01724b3a1..407554637 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -60,21 +60,6 @@ public class AsynchronousJoin { plugin.ess.getUser(player).setSocialSpyEnabled(false); } - if (!plugin.canConnect()) { - final GameMode gM = AuthMePlayerListener.gameMode.get(name); - sched.scheduleSyncDelayedTask(plugin, new Runnable() { - - @Override - public void run() { - AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true); - player.setGameMode(gM); - player.kickPlayer("Server is loading, please wait before joining!"); - } - - }); - return; - } - final String ip = plugin.getIP(player); if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) { final GameMode gM = AuthMePlayerListener.gameMode.get(name); From e387a801f78bc67c858212b801ea3877408b6e17 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 1 Dec 2015 02:06:51 +0700 Subject: [PATCH 03/11] Removed some unnecessary player check. --- .../authme/listener/AuthMePlayerListener.java | 95 +++++++++---------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index ae0e83ca0..fef123bbb 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -54,7 +54,7 @@ public class AuthMePlayerListener implements Listener { final Player player = event.getPlayer(); - if(Utils.checkAuth(player)) { + if (Utils.checkAuth(player)) { for (Player p : Utils.getOnlinePlayers()) { if (!PlayerCache.getInstance().isAuthenticated(p.getName())) { event.getRecipients().remove(p); // TODO: it should be configurable @@ -206,32 +206,26 @@ public class AuthMePlayerListener implements Listener { final String name = event.getName().toLowerCase(); final Player player = Utils.getPlayer(name); - if (player == null || Utils.isNPC(player)) { + if (player == null) { return; } // Check if forceSingleSession is set to true, so kick player that has // joined with same nick of online player - if (Settings.isForceSingleSessionEnabled && player.isOnline()) { - event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, m.getString("same_nick")); - if (LimboCache.getInstance().hasLimboPlayer(name)) - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - - @Override - public void run() { - LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name); - if (limbo != null && PlayerCache.getInstance().isAuthenticated(name)) { - Utils.addNormal(player, limbo.getGroup()); - LimboCache.getInstance().deleteLimboPlayer(name); - } - } - }); + if (Settings.isForceSingleSessionEnabled) { + event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); + event.setKickMessage(m.retrieveSingle(MessageKey.USERNAME_ALREADY_ONLINE_ERROR)); + LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name); + if (limbo != null && PlayerCache.getInstance().isAuthenticated(name)) { + Utils.addNormal(player, limbo.getGroup()); + LimboCache.getInstance().deleteLimboPlayer(name); + } } } @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerLogin(PlayerLoginEvent event) { - if (event.getPlayer() == null) { + if (event.getPlayer() == null || Utils.isUnrestricted(event.getPlayer())) { return; } @@ -266,10 +260,6 @@ public class AuthMePlayerListener implements Listener { return; } - if (Utils.isNPC(player) || Utils.isUnrestricted(player)) { - return; - } - final String name = player.getName().toLowerCase(); boolean isAuthAvailable = plugin.database.isAuthAvailable(name); @@ -333,7 +323,7 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); - if (!Utils.checkAuth(player) && Settings.delayJoinLeaveMessages) { + if (Settings.delayJoinLeaveMessages && !Utils.checkAuth(player)) { event.setQuitMessage(null); } @@ -346,7 +336,8 @@ public class AuthMePlayerListener implements Listener { return; } - if ((!Settings.isForceSingleSessionEnabled) && (event.getReason().contains(m.getString("same_nick")))) { + if ((!Settings.isForceSingleSessionEnabled) + && (event.getReason().equals(m.retrieveSingle(MessageKey.USERNAME_ALREADY_ONLINE_ERROR)))) { event.setCancelled(true); return; } @@ -357,31 +348,34 @@ public class AuthMePlayerListener implements Listener { @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onPlayerPickupItem(PlayerPickupItemEvent event) { - if (Utils.checkAuth(event.getPlayer())) + if (Utils.checkAuth(event.getPlayer())) { return; + } event.setCancelled(true); } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerInteract(PlayerInteractEvent event) { - Player player = event.getPlayer(); - if (player == null || Utils.checkAuth(player)) + if (Utils.checkAuth(event.getPlayer())) { return; + } event.setCancelled(true); } @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) public void onPlayerConsumeItem(PlayerItemConsumeEvent event) { - if (Utils.checkAuth(event.getPlayer())) + if (Utils.checkAuth(event.getPlayer())) { return; + } event.setCancelled(true); } @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onPlayerInventoryOpen(InventoryOpenEvent event) { final Player player = (Player) event.getPlayer(); - if (Utils.checkAuth(player)) + if (Utils.checkAuth(player)) { return; + } event.setCancelled(true); /* @@ -389,7 +383,6 @@ public class AuthMePlayerListener implements Listener { * real, cause no packet is send to server by client for the main inv */ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - @Override public void run() { player.closeInventory(); @@ -414,46 +407,51 @@ public class AuthMePlayerListener implements Listener { if (!(damager instanceof Player)) { return; } - if (Utils.checkAuth((Player) damager)) + if (Utils.checkAuth((Player) damager)) { return; - + } event.setCancelled(true); } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { - Player player = event.getPlayer(); - if (player == null || Utils.checkAuth(player)) + if (Utils.checkAuth(event.getPlayer())) { return; + } event.setCancelled(true); } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerDropItem(PlayerDropItemEvent event) { - if (Utils.checkAuth(event.getPlayer())) + if (Utils.checkAuth(event.getPlayer())) { return; + } event.setCancelled(true); } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerBedEnter(PlayerBedEnterEvent event) { - if (Utils.checkAuth(event.getPlayer())) + if (Utils.checkAuth(event.getPlayer())) { return; + } event.setCancelled(true); } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onSignChange(SignChangeEvent event) { - if (Utils.checkAuth(event.getPlayer())) + if (Utils.checkAuth(event.getPlayer())) { return; + } event.setCancelled(true); } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onPlayerRespawn(PlayerRespawnEvent event) { - Player player = event.getPlayer(); - if (player == null || Utils.checkAuth(player)) + if (Utils.checkAuth(event.getPlayer())) { return; + } + + Player player = event.getPlayer(); String name = player.getName().toLowerCase(); Location spawn = plugin.getSpawnLocation(player); if (Settings.isSaveQuitLocationEnabled && plugin.database.isAuthAvailable(name)) { @@ -467,13 +465,14 @@ public class AuthMePlayerListener implements Listener { @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) { + if (Utils.checkAuth(event.getPlayer())) { + return; + } + Player player = event.getPlayer(); - if (player == null) - return; - if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)) - return; - if (Utils.checkAuth(player)) + if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)) { return; + } String name = player.getName().toLowerCase(); if (causeByAuthMe.containsKey(name)) { @@ -485,17 +484,17 @@ public class AuthMePlayerListener implements Listener { @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) public void onPlayerShear(PlayerShearEntityEvent event) { - Player player = event.getPlayer(); - if (player == null || Utils.checkAuth(player)) + if (Utils.checkAuth(event.getPlayer())) { return; + } event.setCancelled(true); } @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) public void onPlayerFish(PlayerFishEvent event) { - Player player = event.getPlayer(); - if (player == null || Utils.checkAuth(player)) + if (Utils.checkAuth(event.getPlayer())) { return; + } event.setCancelled(true); } From 8a6ab3edb51d8972f4b1350b00046766d1914a96 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 1 Dec 2015 02:14:28 +0700 Subject: [PATCH 04/11] Setup unrestricted names into lowercase. --- src/main/java/fr/xephi/authme/settings/Settings.java | 9 +++++++-- src/main/java/fr/xephi/authme/util/Utils.java | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index 7a2096808..f9ed10be2 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -184,7 +184,12 @@ public final class Settings extends YamlConfiguration { getMySQLColumnRealName = configFile.getString("DataSource.mySQLRealName", "realname"); getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1); unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", ""); - getUnrestrictedName = configFile.getStringList("settings.unrestrictions.UnrestrictedName"); + + getUnrestrictedName = new ArrayList<>(); + for (String name : configFile.getStringList("settings.unrestrictions.UnrestrictedName")) { + getUnrestrictedName.add(name.toLowerCase()); + } + getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", ""); getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier", true); @@ -689,7 +694,7 @@ public final class Settings extends YamlConfiguration { /** * Saves current configuration (plus defaults) to disk. - *

+ *

* If defaults and configuration are empty, saves blank file. * * @return True if saved successfully diff --git a/src/main/java/fr/xephi/authme/util/Utils.java b/src/main/java/fr/xephi/authme/util/Utils.java index e3e298b94..e94dd94ee 100644 --- a/src/main/java/fr/xephi/authme/util/Utils.java +++ b/src/main/java/fr/xephi/authme/util/Utils.java @@ -156,8 +156,9 @@ public final class Utils { } public static boolean isUnrestricted(Player player) { - return Settings.isAllowRestrictedIp && !Settings.getUnrestrictedName.isEmpty() - && (Settings.getUnrestrictedName.contains(player.getName())); + return Settings.isAllowRestrictedIp + && !Settings.getUnrestrictedName.isEmpty() + && (Settings.getUnrestrictedName.contains(player.getName().toLowerCase())); } /** From 37b24d4e724f58dce23425ebee5419ea5401187c Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 1 Dec 2015 02:17:07 +0700 Subject: [PATCH 05/11] Fix "new config options message" always printed on reload. --- src/main/java/fr/xephi/authme/settings/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index f9ed10be2..b1bd141b2 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -681,7 +681,7 @@ public final class Settings extends YamlConfiguration { set("DataSource.mySQLRealName", "realname"); changes = true; } - if (!contains("DataSource.mySQLQueryCache")) { + if (!contains("DataSource.mySQLWebsite")) { set("DataSource.mySQLWebsite", false); changes = true; } From 2fdd5ef3252fae58d45de128919ce81e1167cba7 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 1 Dec 2015 02:36:44 +0700 Subject: [PATCH 06/11] Handle country blacklist effectively --- .../authme/listener/AuthMePlayerListener.java | 32 ++++++++----------- .../authme/listener/AuthMeServerListener.java | 16 +++------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index fef123bbb..fa783ec3c 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -204,6 +204,20 @@ public class AuthMePlayerListener implements Listener { return; } + if (Settings.enableProtection) { + String countryCode = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress()); + if (!Settings.countriesBlacklist.isEmpty() && Settings.countriesBlacklist.contains(countryCode)) { + event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); + event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR)); + return; + } + if (!Settings.countries.isEmpty() && !Settings.countries.contains(countryCode)) { + event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); + event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR)); + return; + } + } + final String name = event.getName().toLowerCase(); final Player player = Utils.getPlayer(name); if (player == null) { @@ -263,24 +277,6 @@ public class AuthMePlayerListener implements Listener { final String name = player.getName().toLowerCase(); boolean isAuthAvailable = plugin.database.isAuthAvailable(name); - if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, UserPermission.BYPASS_ANTIBOT)) { - String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress()); - if (Settings.countriesBlacklist.contains(code)) { - event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR)); - event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - return; - } - } - - if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, UserPermission.BYPASS_ANTIBOT)) { - String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress()); - if (!Settings.countries.contains(code)) { - event.setKickMessage(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR)); - event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - return; - } - } - // TODO: Add message to the messages file!!! if (Settings.isKickNonRegisteredEnabled && !isAuthAvailable) { if (Settings.antiBotInAction) { diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java index 3b5a3c803..2866fd755 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java @@ -43,19 +43,13 @@ public class AuthMeServerListener implements Listener { } String countryCode = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress()); - if (!Settings.countriesBlacklist.isEmpty()) { - if (Settings.countriesBlacklist.contains(countryCode)) { - event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR)); - return; - } + if (!Settings.countriesBlacklist.isEmpty() && Settings.countriesBlacklist.contains(countryCode)) { + event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR)); + return; } - if (!Settings.countries.isEmpty()) { - if (Settings.countries.contains(countryCode)) { - event.setMotd(plugin.getServer().getMotd()); - } else { - event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR)); - } + if (!Settings.countries.isEmpty() && !Settings.countries.contains(countryCode)) { + event.setMotd(m.retrieveSingle(MessageKey.COUNTRY_BANNED_ERROR)); } } From 92f57090bee728849d40874559057ce600b2a717 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 1 Dec 2015 16:07:58 +0700 Subject: [PATCH 07/11] Set default value for the Builder --- .../xephi/authme/cache/auth/PlayerAuth.java | 93 +++++++++---------- 1 file changed, 45 insertions(+), 48 deletions(-) diff --git a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java index 01622c177..618c50189 100644 --- a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java +++ b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java @@ -23,9 +23,8 @@ public class PlayerAuth { /** * */ - public PlayerAuth(String serialized) - { - this.unserialize(serialized); + public PlayerAuth(String serialized) { + this.deserialize(serialized); } /** @@ -455,47 +454,45 @@ public class PlayerAuth { } /** - * Method to serialize playerauth + * Method to serialize PlayerAuth * * @return String */ - public String serialize() - { - StringBuilder str = new StringBuilder(); - str.append(this.nickname).append(';'); - str.append(this.realName).append(';'); - str.append(this.ip).append(';'); - str.append(this.email).append(';'); - str.append(this.hash).append(';'); - str.append(this.salt).append(';'); - str.append(this.groupId).append(';'); - str.append(this.lastLogin).append(';'); - str.append(this.world).append(';'); - str.append(this.x).append(';'); - str.append(this.y).append(';'); - str.append(this.z); - return str.toString(); + public String serialize() { + StringBuilder str = new StringBuilder(); + char d = ';'; + str.append(this.nickname).append(d); + str.append(this.realName).append(d); + str.append(this.ip).append(d); + str.append(this.email).append(d); + str.append(this.hash).append(d); + str.append(this.salt).append(d); + str.append(this.groupId).append(d); + str.append(this.lastLogin).append(d); + str.append(this.world).append(d); + str.append(this.x).append(d); + str.append(this.y).append(d); + str.append(this.z); + return str.toString(); } /** - * Method to unserialize playerauth - * + * Method to deserialize PlayerAuth */ - public void unserialize(String str) - { - String[] args = str.split(";"); - this.nickname = args[0]; - this.realName = args[1]; - this.ip = args[2]; - this.email = args[3]; - this.hash = args[4]; - this.salt = args[5]; - this.groupId = Integer.parseInt(args[6]); - this.lastLogin = Long.parseLong(args[7]); - this.world = args[8]; - this.x = Double.parseDouble(args[9]); - this.y = Double.parseDouble(args[10]); - this.z = Double.parseDouble(args[11]); + public void deserialize(String str) { + String[] args = str.split(";"); + this.nickname = args[0]; + this.realName = args[1]; + this.ip = args[2]; + this.email = args[3]; + this.hash = args[4]; + this.salt = args[5]; + this.groupId = Integer.parseInt(args[6]); + this.lastLogin = Long.parseLong(args[7]); + this.world = args[8]; + this.x = Double.parseDouble(args[9]); + this.y = Double.parseDouble(args[10]); + this.z = Double.parseDouble(args[11]); } public static Builder builder() { @@ -504,17 +501,17 @@ public class PlayerAuth { public static final class Builder { private String name; - private String realName; - private String hash; - private String salt; - private String ip; - private String world; - private double x; - private double y; - private double z; - private long lastLogin; - private int groupId; - private String email; + private String realName = "Player"; + private String hash = ""; + private String salt = ""; + private String ip = "127.0.0.1"; + private String world = "world"; + private double x = 0.0f; + private double y = 0.0f; + private double z = 0.0f; + private long lastLogin = System.currentTimeMillis(); + private int groupId = -1; + private String email = "your@email.com"; public PlayerAuth build() { return new PlayerAuth( From 7ec79afe4a36537d1831c918c32d5680767e34c5 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Wed, 2 Dec 2015 03:22:27 +0700 Subject: [PATCH 08/11] Set speed into 0.0 --- .../process/register/ProcessSyncronousPasswordRegister.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java index bd1bb174f..27f060e14 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java @@ -118,8 +118,8 @@ public class ProcessSyncronousPasswordRegister implements Runnable { } if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) { - player.setWalkSpeed(0.2f); - player.setFlySpeed(0.1f); + player.setWalkSpeed(0.0f); + player.setFlySpeed(0.0f); } // The LoginEvent now fires (as intended) after everything is processed From e02af46d65506e4506bd2bd1643cf629592d2930 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Wed, 2 Dec 2015 04:10:56 +0700 Subject: [PATCH 09/11] Lowercase the name input. --- src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java index 618c50189..5339ac3a3 100644 --- a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java +++ b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java @@ -528,7 +528,7 @@ public class PlayerAuth { } public Builder name(String name) { - this.name = name; + this.name = name.toLowerCase(); return this; } From 8d9e212b15f151de329d7b3aed5ff12d5ede4848 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Wed, 2 Dec 2015 04:14:18 +0700 Subject: [PATCH 10/11] Improve register process. * Removed double check for email settings * Use builder for PlayerAuth * Handle exceptions in process method --- .../process/register/AsyncRegister.java | 89 ++++++++++--------- 1 file changed, 45 insertions(+), 44 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 0007ccf3c..22f5b65a0 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -12,9 +12,6 @@ import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Settings; import org.bukkit.entity.Player; -import java.security.NoSuchAlgorithmException; -import java.util.Date; - /** */ public class AsyncRegister { @@ -22,7 +19,8 @@ public class AsyncRegister { protected final Player player; protected final String name; protected final String password; - protected String email = ""; + private final String ip; + private String email = ""; private final AuthMe plugin; private final DataSource database; private final Messages m; @@ -35,13 +33,10 @@ public class AsyncRegister { this.email = email; this.plugin = plugin; this.database = data; + this.ip = plugin.getIP(player); } - protected String getIp() { - return plugin.getIP(player); - } - - protected boolean preRegisterCheck() throws Exception { + private boolean preRegisterCheck() throws Exception { String passLow = password.toLowerCase(); if (PlayerCache.getInstance().isAuthenticated(name)) { m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); @@ -65,10 +60,10 @@ public class AsyncRegister { m.send(player, MessageKey.NAME_ALREADY_REGISTERED); return false; } else if (Settings.getmaxRegPerIp > 0 - && !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS) - && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp - && !getIp().equalsIgnoreCase("127.0.0.1") - && !getIp().equalsIgnoreCase("localhost")) { + && !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS) + && !ip.equalsIgnoreCase("127.0.0.1") + && !ip.equalsIgnoreCase("localhost") + && database.getAllAuthsByIp(ip).size() >= Settings.getmaxRegPerIp) { m.send(player, MessageKey.MAX_REGISTER_EXCEEDED); return false; } @@ -81,16 +76,10 @@ public class AsyncRegister { return; } if (!email.isEmpty() && !email.equals("")) { - if (Settings.getmaxRegPerEmail > 0 - && !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS) - && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) { - m.send(player, MessageKey.MAX_REGISTER_EXCEEDED); - return; - } emailRegister(); - return; + } else { + passwordRegister(); } - passwordRegister(); } catch (Exception e) { ConsoleLogger.showError(e.getMessage()); ConsoleLogger.writeStackTrace(e); @@ -98,20 +87,32 @@ public class AsyncRegister { } } - protected void emailRegister() throws Exception { + private void emailRegister() throws Exception { if (Settings.getmaxRegPerEmail > 0 - && !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS) - && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) { + && !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS) + && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) { m.send(player, MessageKey.MAX_REGISTER_EXCEEDED); return; } - PlayerAuth auth; final String hashNew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name); - auth = new PlayerAuth(name, hashNew, getIp(), 0, (int) player.getLocation().getX(), (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email, player.getName()); - if (PasswordSecurity.userSalt.containsKey(name)) { - auth.setSalt(PasswordSecurity.userSalt.get(name)); + final String salt = PasswordSecurity.userSalt.get(name); + PlayerAuth auth = PlayerAuth.builder() + .name(name) + .realName(player.getName()) + .hash(hashNew) + .ip(ip) + .locWorld(player.getLocation().getWorld().getName()) + .locX(player.getLocation().getX()) + .locY(player.getLocation().getY()) + .locZ(player.getLocation().getZ()) + .email(email) + .salt(salt != null ? salt : "") + .build(); + + if (!database.saveAuth(auth)) { + m.send(player, MessageKey.ERROR); + return; } - database.saveAuth(auth); database.updateEmail(auth); database.updateSession(auth); plugin.mail.main(auth, password); @@ -120,21 +121,21 @@ public class AsyncRegister { } - protected void passwordRegister() { - PlayerAuth auth; - String hash; - try { - hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name); - } catch (NoSuchAlgorithmException e) { - ConsoleLogger.showError(e.getMessage()); - m.send(player, MessageKey.ERROR); - return; - } - if (Settings.getMySQLColumnSalt.isEmpty() && !PasswordSecurity.userSalt.containsKey(name)) { - auth = new PlayerAuth(name, hash, getIp(), new Date().getTime(), "your@email.com", player.getName()); - } else { - auth = new PlayerAuth(name, hash, PasswordSecurity.userSalt.get(name), getIp(), new Date().getTime(), player.getName()); - } + private void passwordRegister() throws Exception { + final String hashNew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name); + final String salt = PasswordSecurity.userSalt.get(name); + PlayerAuth auth = PlayerAuth.builder() + .name(name) + .realName(player.getName()) + .hash(hashNew) + .ip(ip) + .locWorld(player.getLocation().getWorld().getName()) + .locX(player.getLocation().getX()) + .locY(player.getLocation().getY()) + .locZ(player.getLocation().getZ()) + .salt(salt != null ? salt : "") + .build(); + if (!database.saveAuth(auth)) { m.send(player, MessageKey.ERROR); return; From fda7822644a5fabf9e26554a6eeeef3c8a1f15d5 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Sat, 5 Dec 2015 03:45:52 +0700 Subject: [PATCH 11/11] Merge please --- .../xephi/authme/cache/limbo/LimboCache.java | 22 ++++++++--------- .../authme/listener/AuthMePlayerListener.java | 24 ++++++++----------- .../process/register/AsyncRegister.java | 8 +++---- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java index 2495d68b6..b1f957de8 100644 --- a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java +++ b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java @@ -14,6 +14,8 @@ import org.bukkit.entity.Player; import java.util.concurrent.ConcurrentHashMap; +import static com.google.common.base.Preconditions.checkNotNull; + /** */ public class LimboCache { @@ -117,9 +119,8 @@ public class LimboCache { * @param name String */ public void deleteLimboPlayer(String name) { - if (name == null) - return; - cache.remove(name); + checkNotNull(name); + cache.remove(name.toLowerCase()); } /** @@ -130,9 +131,8 @@ public class LimboCache { * @return LimboPlayer */ public LimboPlayer getLimboPlayer(String name) { - if (name == null) - return null; - return cache.get(name); + checkNotNull(name); + return cache.get(name.toLowerCase()); } /** @@ -143,9 +143,8 @@ public class LimboCache { * @return boolean */ public boolean hasLimboPlayer(String name) { - if (name == null) - return false; - return cache.containsKey(name); + checkNotNull(name); + return cache.containsKey(name.toLowerCase()); } /** @@ -154,9 +153,8 @@ public class LimboCache { * @param player Player */ public void updateLimboPlayer(Player player) { - if (this.hasLimboPlayer(player.getName().toLowerCase())) { - this.deleteLimboPlayer(player.getName().toLowerCase()); - } + checkNotNull(player); + deleteLimboPlayer(player.getName().toLowerCase()); addLimboPlayer(player); } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 6451f270c..96139ce32 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -9,10 +9,10 @@ import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboPlayer; +import fr.xephi.authme.output.MessageKey; +import fr.xephi.authme.output.Messages; import fr.xephi.authme.permission.PermissionsManager; -import fr.xephi.authme.permission.UserPermission; -import fr.xephi.authme.settings.MessageKey; -import fr.xephi.authme.settings.Messages; +import fr.xephi.authme.permission.PlayerPermission; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.util.GeoLiteAPI; import fr.xephi.authme.util.Utils; @@ -32,8 +32,6 @@ import org.bukkit.event.player.*; import java.util.concurrent.ConcurrentHashMap; -import static fr.xephi.authme.output.MessageKey.USERNAME_ALREADY_ONLINE_ERROR; - /** */ public class AuthMePlayerListener implements Listener { @@ -169,20 +167,21 @@ public class AuthMePlayerListener implements Listener { } } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.LOWEST) public void onPlayerJoin(PlayerJoinEvent event) { if (event.getPlayer() == null || Utils.isNPC(event.getPlayer())) { return; } final Player player = event.getPlayer(); - final String name = player.getName().toLowerCase(); - final String joinMsg = event.getJoinMessage(); - final boolean delay = Settings.delayJoinLeaveMessages && joinMsg != null; + String name = player.getName().toLowerCase(); + String joinMsg = event.getJoinMessage(); + boolean delay = Settings.delayJoinLeaveMessages && joinMsg != null; // Remove the join message while the player isn't logging in if (delay) { event.setJoinMessage(null); + joinMessage.put(name, joinMsg); } // Shedule login task so works after the prelogin @@ -190,9 +189,6 @@ public class AuthMePlayerListener implements Listener { Bukkit.getScheduler().runTask(plugin, new Runnable() { @Override public void run() { - if (delay) { - joinMessage.put(name, joinMsg); - } plugin.getManagement().performJoin(player); } }); @@ -453,7 +449,7 @@ public class AuthMePlayerListener implements Listener { String name = player.getName().toLowerCase(); Location spawn = plugin.getSpawnLocation(player); if (Settings.isSaveQuitLocationEnabled && plugin.database.isAuthAvailable(name)) { - final PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName(), player.getName()); + PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName(), player.getName()); plugin.database.updateQuitLoc(auth); } if (spawn != null && spawn.getWorld() != null) { @@ -468,7 +464,7 @@ public class AuthMePlayerListener implements Listener { } Player player = event.getPlayer(); - if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)) { + if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)) { return; } 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 f9ceddb97..7a6352cf7 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -5,10 +5,10 @@ import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.datasource.DataSource; -import fr.xephi.authme.permission.PlayerPermission; -import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; +import fr.xephi.authme.permission.PlayerPermission; +import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.settings.Settings; import org.bukkit.entity.Player; @@ -60,7 +60,7 @@ public class AsyncRegister { m.send(player, MessageKey.NAME_ALREADY_REGISTERED); return false; } else if (Settings.getmaxRegPerIp > 0 - && !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS) + && !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS) && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost") && database.getAllAuthsByIp(ip).size() >= Settings.getmaxRegPerIp) { @@ -89,7 +89,7 @@ public class AsyncRegister { private void emailRegister() throws Exception { if (Settings.getmaxRegPerEmail > 0 - && !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS) + && !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS) && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) { m.send(player, MessageKey.MAX_REGISTER_EXCEEDED); return;