From 4e275eeb1d979b7ec42ddd5e7b315b16b104701a Mon Sep 17 00:00:00 2001 From: DNx5 Date: Sun, 20 Sep 2015 14:11:17 +0700 Subject: [PATCH] change Utils to static class. --- src/main/java/fr/xephi/authme/AuthMe.java | 5 +- src/main/java/fr/xephi/authme/Utils.java | 29 ++++------ src/main/java/fr/xephi/authme/api/API.java | 7 +-- src/main/java/fr/xephi/authme/api/NewAPI.java | 5 +- .../xephi/authme/commands/AdminCommand.java | 2 +- .../authme/commands/UnregisterCommand.java | 4 +- .../authme/listener/AuthMeBlockListener.java | 4 +- .../listener/AuthMeChestShopListener.java | 2 +- .../authme/listener/AuthMeEntityListener.java | 15 +++-- .../authme/listener/AuthMePlayerListener.java | 57 +++++++++---------- .../authme/process/join/AsyncronousJoin.java | 9 ++- .../login/ProcessSyncronousPlayerLogin.java | 4 +- .../process/logout/AsyncronousLogout.java | 3 +- .../authme/process/quit/AsyncronousQuit.java | 5 +- .../ProcessSyncronousEmailRegister.java | 2 +- .../ProcessSyncronousPasswordRegister.java | 25 ++++---- 16 files changed, 79 insertions(+), 99 deletions(-) diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 6be444cd6..c6385f3e1 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -57,7 +57,6 @@ public class AuthMe extends JavaPlugin { private final Logger authmeLogger = Logger.getLogger("AuthMe"); public Management management; public NewAPI api; - private Utils utils = Utils.getInstance(); public SendMailSSL mail; private Settings settings; private Messages m; @@ -535,7 +534,7 @@ public class AuthMe extends JavaPlugin { // Save Player Data public void savePlayer(Player player) { - if ((utils.isNPC(player)) || (Utils.getInstance().isUnrestricted(player))) { + if ((Utils.isNPC(player)) || (Utils.isUnrestricted(player))) { return; } String name = player.getName().toLowerCase(); @@ -552,7 +551,7 @@ public class AuthMe extends JavaPlugin { if (!Settings.noTeleport) { player.teleport(limbo.getLoc()); } - this.utils.addNormal(player, limbo.getGroup()); + Utils.addNormal(player, limbo.getGroup()); player.setOp(limbo.getOperator()); limbo.getTimeoutTaskId().cancel(); LimboCache.getInstance().deleteLimboPlayer(name); diff --git a/src/main/java/fr/xephi/authme/Utils.java b/src/main/java/fr/xephi/authme/Utils.java index b0feda6bb..88b6d9d2d 100644 --- a/src/main/java/fr/xephi/authme/Utils.java +++ b/src/main/java/fr/xephi/authme/Utils.java @@ -21,16 +21,12 @@ import java.util.Iterator; public class Utils { private static boolean getOnlinePlayersIsCollection; - private String currentGroup; private static Utils singleton; private static Method getOnlinePlayers; - public final AuthMe plugin; - - public Utils(AuthMe plugin) { - this.plugin = plugin; - } + public static AuthMe plugin; static { + plugin = AuthMe.getInstance(); try { Method m = Bukkit.class.getDeclaredMethod("getOnlinePlayers"); getOnlinePlayersIsCollection = m.getReturnType() == Collection.class; @@ -38,17 +34,18 @@ public class Utils { } } - public void setGroup(Player player, GroupType group) { + public static void setGroup(Player player, GroupType group) { setGroup(player.getName(), group); } @SuppressWarnings("deprecation") - public void setGroup(String player, GroupType group) { + public static void setGroup(String player, GroupType group) { if (!Settings.isPermissionCheckEnabled) return; if (plugin.permission == null) return; String name = player; + String currentGroup; try { World world = null; currentGroup = plugin.permission.getPrimaryGroup(world, name); @@ -88,11 +85,10 @@ public class Utils { break; } } - return; } @SuppressWarnings("deprecation") - public boolean addNormal(Player player, String group) { + public static boolean addNormal(Player player, String group) { if (!useGroupSystem()) { return false; } @@ -123,20 +119,15 @@ public class Utils { } } - public boolean isUnrestricted(Player player) { + public static boolean isUnrestricted(Player player) { return Settings.isAllowRestrictedIp && !(Settings.getUnrestrictedName == null || Settings.getUnrestrictedName.isEmpty()) && (Settings.getUnrestrictedName.contains(player.getName())); } - public static Utils getInstance() { - singleton = new Utils(AuthMe.getInstance()); - return singleton; - } - - private boolean useGroupSystem() { + private static boolean useGroupSystem() { return Settings.isPermissionCheckEnabled && !Settings.getUnloggedinGroup.isEmpty(); } - public void packCoords(double x, double y, double z, String w, + public static void packCoords(double x, double y, double z, String w, final Player pl) { World theWorld; if (w.equals("unavailableworld")) { @@ -216,7 +207,7 @@ public class Utils { return Collections.emptyList(); } - public boolean isNPC(final Entity player) { + public static boolean isNPC(final Entity player) { try { if (player.hasMetadata("NPC")) { return true; diff --git a/src/main/java/fr/xephi/authme/api/API.java b/src/main/java/fr/xephi/authme/api/API.java index 026a9577a..11eba8613 100644 --- a/src/main/java/fr/xephi/authme/api/API.java +++ b/src/main/java/fr/xephi/authme/api/API.java @@ -19,7 +19,6 @@ public class API { public static final String newline = System.getProperty("line.separator"); public static AuthMe instance; - private Utils utils = Utils.getInstance(); @Deprecated public API(AuthMe instance) { @@ -65,7 +64,7 @@ public class API { */ @Deprecated public boolean isaNPC(Player player) { - return utils.isNPC(player); + return Utils.isNPC(player); } /** @@ -75,7 +74,7 @@ public class API { */ @Deprecated public boolean isNPC(Player player) { - return utils.isNPC(player); + return Utils.isNPC(player); } /** @@ -85,7 +84,7 @@ public class API { */ @Deprecated public static boolean isUnrestricted(Player player) { - return Utils.getInstance().isUnrestricted(player); + return Utils.isUnrestricted(player); } @Deprecated diff --git a/src/main/java/fr/xephi/authme/api/NewAPI.java b/src/main/java/fr/xephi/authme/api/NewAPI.java index b31f9ab28..937a8abe3 100644 --- a/src/main/java/fr/xephi/authme/api/NewAPI.java +++ b/src/main/java/fr/xephi/authme/api/NewAPI.java @@ -22,7 +22,6 @@ public class NewAPI { public static final String newline = System.getProperty("line.separator"); public static NewAPI singleton; public AuthMe plugin; - private Utils utils = Utils.getInstance(); public NewAPI(AuthMe plugin) { this.plugin = plugin; @@ -68,7 +67,7 @@ public class NewAPI { * @return true if player is a npc */ public boolean isNPC(Player player) { - return utils.isNPC(player); + return Utils.isNPC(player); } /** @@ -77,7 +76,7 @@ public class NewAPI { * @return true if the player is unrestricted */ public boolean isUnrestricted(Player player) { - return Utils.getInstance().isUnrestricted(player); + return Utils.isUnrestricted(player); } public Location getLastLocation(Player player) { diff --git a/src/main/java/fr/xephi/authme/commands/AdminCommand.java b/src/main/java/fr/xephi/authme/commands/AdminCommand.java index 569088b31..0376f12e9 100644 --- a/src/main/java/fr/xephi/authme/commands/AdminCommand.java +++ b/src/main/java/fr/xephi/authme/commands/AdminCommand.java @@ -464,7 +464,7 @@ public class AdminCommand implements CommandExecutor { @SuppressWarnings("deprecation") Player target = Bukkit.getPlayer(name); PlayerCache.getInstance().removePlayer(name); - Utils.getInstance().setGroup(name, GroupType.UNREGISTERED); + Utils.setGroup(name, GroupType.UNREGISTERED); if (target != null) { if (target.isOnline()) { if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) { diff --git a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java index 6d8196e5f..ce02aee6b 100644 --- a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java +++ b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java @@ -84,7 +84,7 @@ public class UnregisterCommand implements CommandExecutor { player.saveData(); PlayerCache.getInstance().removePlayer(player.getName().toLowerCase()); if (!Settings.getRegisteredGroup.isEmpty()) - Utils.getInstance().setGroup(player, GroupType.UNREGISTERED); + Utils.setGroup(player, GroupType.UNREGISTERED); LimboCache.getInstance().addLimboPlayer(player); int delay = Settings.getRegistrationTimeout * 20; int interval = Settings.getWarnMessageInterval; @@ -99,7 +99,7 @@ public class UnregisterCommand implements CommandExecutor { return; } if (!Settings.unRegisteredGroup.isEmpty()) { - Utils.getInstance().setGroup(player, Utils.GroupType.UNREGISTERED); + Utils.setGroup(player, Utils.GroupType.UNREGISTERED); } PlayerCache.getInstance().removePlayer(player.getName().toLowerCase()); // check if Player cache File Exist and delete it, preventing diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java index d6c64582b..e6903ce34 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java @@ -28,7 +28,7 @@ public class AuthMeBlockListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (Utils.getInstance().isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } @@ -53,7 +53,7 @@ public class AuthMeBlockListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (Utils.getInstance().isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeChestShopListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeChestShopListener.java index bafa9c4c2..3577dc341 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeChestShopListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeChestShopListener.java @@ -28,7 +28,7 @@ public class AuthMeChestShopListener implements Listener { Player player = event.getClient(); String name = player.getName().toLowerCase(); - if (Utils.getInstance().isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java index e1bfea52b..f85e24971 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java @@ -14,7 +14,6 @@ import org.bukkit.event.entity.*; public class AuthMeEntityListener implements Listener { public AuthMe instance; - private Utils utils = Utils.getInstance(); public AuthMeEntityListener(AuthMe instance) { this.instance = instance; @@ -28,11 +27,11 @@ public class AuthMeEntityListener implements Listener { return; } - if (Utils.getInstance().isUnrestricted((Player) entity)) { + if (Utils.isUnrestricted((Player) entity)) { return; } - if (utils.isNPC(entity)) + if (Utils.isNPC(entity)) return; Player player = (Player) entity; @@ -61,7 +60,7 @@ public class AuthMeEntityListener implements Listener { return; } - if (utils.isNPC(entity)) + if (Utils.isNPC(entity)) return; Player player = (Player) entity; @@ -111,7 +110,7 @@ public class AuthMeEntityListener implements Listener { return; } - if (utils.isNPC(entity)) + if (Utils.isNPC(entity)) return; Player player = (Player) entity; @@ -138,7 +137,7 @@ public class AuthMeEntityListener implements Listener { return; } - if (utils.isNPC(entity)) + if (Utils.isNPC(entity)) return; Player player = (Player) entity; @@ -167,7 +166,7 @@ public class AuthMeEntityListener implements Listener { Player player = (Player) event.getEntity(); String name = player.getName().toLowerCase(); - if (Utils.getInstance().isUnrestricted(player) || utils.isNPC(player)) + if (Utils.isUnrestricted(player) || Utils.isNPC(player)) return; if (PlayerCache.getInstance().isAuthenticated(player.getName())) { @@ -191,7 +190,7 @@ public class AuthMeEntityListener implements Listener { Player player = (Player) event.getEntity(); String name = player.getName().toLowerCase(); - if (Utils.getInstance().isUnrestricted(player) || utils.isNPC(player)) + if (Utils.isUnrestricted(player) || Utils.isNPC(player)) return; if (PlayerCache.getInstance().isAuthenticated(player.getName())) { diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 93884b283..afd1b0858 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -39,7 +39,6 @@ public class AuthMePlayerListener implements Listener { public static ConcurrentHashMap joinMessage = new ConcurrentHashMap<>(); private Messages m = Messages.getInstance(); public AuthMe plugin; - private Utils utils = Utils.getInstance(); public static ConcurrentHashMap causeByAuthMe = new ConcurrentHashMap<>(); private List antibot = new ArrayList<>(); @@ -55,7 +54,7 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) + if (Utils.isUnrestricted(player)) return; if (PlayerCache.getInstance().isAuthenticated(name)) @@ -89,7 +88,7 @@ public class AuthMePlayerListener implements Listener { final Player player = event.getPlayer(); final String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) + if (Utils.isUnrestricted(player)) return; if (PlayerCache.getInstance().isAuthenticated(name)) @@ -125,7 +124,7 @@ public class AuthMePlayerListener implements Listener { final Player player = event.getPlayer(); final String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) + if (Utils.isUnrestricted(player)) return; if (PlayerCache.getInstance().isAuthenticated(name)) @@ -161,7 +160,7 @@ public class AuthMePlayerListener implements Listener { final Player player = event.getPlayer(); final String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) + if (Utils.isUnrestricted(player)) return; if (PlayerCache.getInstance().isAuthenticated(name)) @@ -197,7 +196,7 @@ public class AuthMePlayerListener implements Listener { final Player player = event.getPlayer(); final String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) + if (Utils.isUnrestricted(player)) return; if (PlayerCache.getInstance().isAuthenticated(name)) @@ -233,7 +232,7 @@ public class AuthMePlayerListener implements Listener { final Player player = event.getPlayer(); final String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) + if (Utils.isUnrestricted(player)) return; if (PlayerCache.getInstance().isAuthenticated(name)) { @@ -270,7 +269,7 @@ public class AuthMePlayerListener implements Listener { final Player player = event.getPlayer(); final String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) + if (Utils.isUnrestricted(player)) return; if (PlayerCache.getInstance().isAuthenticated(name)) @@ -305,7 +304,7 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isNPC(player) || utils.isUnrestricted(player)) { + if (Utils.isNPC(player) || Utils.isUnrestricted(player)) { return; } @@ -423,7 +422,7 @@ public class AuthMePlayerListener implements Listener { public void run() { LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase()); if (limbo != null && PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { - utils.addNormal(player, limbo.getGroup()); + Utils.addNormal(player, limbo.getGroup()); LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase()); } } @@ -440,7 +439,7 @@ public class AuthMePlayerListener implements Listener { final String name = player.getName().toLowerCase(); boolean isAuthAvailable = plugin.database.isAuthAvailable(name); - if (utils.isNPC(player) || utils.isUnrestricted(player)) { + if (Utils.isNPC(player) || Utils.isUnrestricted(player)) { return; } @@ -604,11 +603,11 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } - if (utils.isNPC(player)) + if (Utils.isNPC(player)) return; if (PlayerCache.getInstance().isAuthenticated(name)) { @@ -632,11 +631,11 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } - if (utils.isNPC(player)) + if (Utils.isNPC(player)) return; if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { @@ -663,11 +662,11 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } - if (utils.isNPC(player)) { + if (Utils.isNPC(player)) { return; } @@ -690,10 +689,10 @@ public class AuthMePlayerListener implements Listener { return; final Player player = (Player) event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } - if (utils.isNPC(player)) + if (Utils.isNPC(player)) return; if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { return; @@ -728,11 +727,11 @@ public class AuthMePlayerListener implements Listener { Player player = (Player) event.getWhoClicked(); String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } - if (utils.isNPC(player)) + if (Utils.isNPC(player)) return; if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { @@ -758,11 +757,11 @@ public class AuthMePlayerListener implements Listener { Player player = (Player) damager; String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } - if (utils.isNPC(player)) { + if (Utils.isNPC(player)) { return; } @@ -786,7 +785,7 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isNPC(player) || utils.isUnrestricted(player)) { + if (Utils.isNPC(player) || Utils.isUnrestricted(player)) { return; } @@ -810,7 +809,7 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player) || utils.isNPC(player)) + if (Utils.isUnrestricted(player) || Utils.isNPC(player)) return; if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { @@ -833,7 +832,7 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } @@ -856,7 +855,7 @@ public class AuthMePlayerListener implements Listener { } Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player)) { + if (Utils.isUnrestricted(player)) { return; } if (PlayerCache.getInstance().isAuthenticated(name)) { @@ -879,7 +878,7 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player) || utils.isNPC(player)) + if (Utils.isUnrestricted(player) || Utils.isNPC(player)) return; if (PlayerCache.getInstance().isAuthenticated(name)) @@ -911,7 +910,7 @@ public class AuthMePlayerListener implements Listener { String name = player.getName().toLowerCase(); - if (utils.isUnrestricted(player) || utils.isNPC(player)) + if (Utils.isUnrestricted(player) || Utils.isNPC(player)) return; if (PlayerCache.getInstance().isAuthenticated(name)) diff --git a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java index 7099486be..dbe71d20d 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java @@ -38,7 +38,6 @@ public class AsyncronousJoin { protected DataSource database; protected AuthMe plugin; protected String name; - private Utils utils = Utils.getInstance(); private Messages m = Messages.getInstance(); private JsonCache playerBackup; @@ -56,7 +55,7 @@ public class AsyncronousJoin { AuthMePlayerListener.gameMode.putIfAbsent(name, player.getGameMode()); BukkitScheduler sched = plugin.getServer().getScheduler(); - if (utils.isNPC(player) || Utils.getInstance().isUnrestricted(player)) { + if (Utils.isNPC(player) || Utils.isUnrestricted(player)) { return; } @@ -163,7 +162,7 @@ public class AsyncronousJoin { }); } if (!Settings.unRegisteredGroup.isEmpty()) { - utils.setGroup(player, Utils.GroupType.UNREGISTERED); + Utils.setGroup(player, Utils.GroupType.UNREGISTERED); } if (!Settings.isForcedRegistrationEnabled) { return; @@ -205,9 +204,9 @@ public class AsyncronousJoin { if (!LimboCache.getInstance().hasLimboPlayer(name)) LimboCache.getInstance().addLimboPlayer(player); if (database.isAuthAvailable(name)) { - utils.setGroup(player, GroupType.NOTLOGGEDIN); + Utils.setGroup(player, GroupType.NOTLOGGEDIN); } else { - utils.setGroup(player, GroupType.UNREGISTERED); + Utils.setGroup(player, GroupType.UNREGISTERED); } sched.scheduleSyncDelayedTask(plugin, new Runnable() { diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java index 2ad48153e..2f70bfcfc 100644 --- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java @@ -63,7 +63,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable { } protected void packQuitLocation() { - Utils.getInstance().packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player); + Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player); } protected void teleportBackFromSpawn() { @@ -166,7 +166,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable { Utils.forceGM(player); // Restore Permission Group - Utils.getInstance().setGroup(player, GroupType.LOGGEDIN); + Utils.setGroup(player, GroupType.LOGGEDIN); // Cleanup no longer used temporary data LimboCache.getInstance().deleteLimboPlayer(name); diff --git a/src/main/java/fr/xephi/authme/process/logout/AsyncronousLogout.java b/src/main/java/fr/xephi/authme/process/logout/AsyncronousLogout.java index 1f44b3a3e..d1f890ad4 100644 --- a/src/main/java/fr/xephi/authme/process/logout/AsyncronousLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/AsyncronousLogout.java @@ -25,7 +25,6 @@ public class AsyncronousLogout { protected DataSource database; protected boolean canLogout = true; private Messages m = Messages.getInstance(); - private Utils utils = Utils.getInstance(); private JsonCache playerBackup; public AsyncronousLogout(Player player, AuthMe plugin, @@ -79,7 +78,7 @@ public class AsyncronousLogout { if (LimboCache.getInstance().hasLimboPlayer(name)) LimboCache.getInstance().deleteLimboPlayer(name); LimboCache.getInstance().addLimboPlayer(player); - utils.setGroup(player, GroupType.NOTLOGGEDIN); + Utils.setGroup(player, GroupType.NOTLOGGEDIN); if (Settings.protectInventoryBeforeLogInEnabled) { player.getInventory().clear(); // create cache file for handling lost of inventories on unlogged in diff --git a/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java b/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java index 9a05229a9..da594606b 100644 --- a/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java @@ -22,7 +22,6 @@ public class AsyncronousQuit { protected AuthMe plugin; protected DataSource database; protected Player player; - protected Utils utils = Utils.getInstance(); private String name; private ItemStack[] armor = null; private ItemStack[] inv = null; @@ -43,7 +42,7 @@ public class AsyncronousQuit { public void process() { if (player == null) return; - if (utils.isNPC(player) || Utils.getInstance().isUnrestricted(player)) { + if (Utils.isNPC(player) || Utils.isUnrestricted(player)) { return; } @@ -66,7 +65,7 @@ public class AsyncronousQuit { armor = limbo.getArmour(); } if (limbo.getGroup() != null && !limbo.getGroup().equals("")) - utils.addNormal(player, limbo.getGroup()); + Utils.addNormal(player, limbo.getGroup()); needToChange = true; isOp = limbo.getOperator(); isFlying = limbo.isFlying(); diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java index 64eec84db..280daa295 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java @@ -31,7 +31,7 @@ public class ProcessSyncronousEmailRegister implements Runnable { public void run() { LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name); if (!Settings.getRegisteredGroup.isEmpty()) { - Utils.getInstance().setGroup(player, Utils.GroupType.REGISTERED); + Utils.setGroup(player, Utils.GroupType.REGISTERED); } m.send(player, "vb_nonActiv"); int time = Settings.getRegistrationTimeout * 20; 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 60e1f9def..409895d43 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java @@ -1,13 +1,5 @@ package fr.xephi.authme.process.register; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.scheduler.BukkitScheduler; -import org.bukkit.scheduler.BukkitTask; - import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.Utils; @@ -21,6 +13,13 @@ import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.TimeoutTask; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitScheduler; +import org.bukkit.scheduler.BukkitTask; public class ProcessSyncronousPasswordRegister implements Runnable { @@ -39,7 +38,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable { for (String command : Settings.forceRegisterCommands) { try { player.performCommand(command.replace("%p", player.getName())); - } catch (Exception e) { + } catch (Exception ignored) { } } for (String command : Settings.forceRegisterCommandsAsConsole) { @@ -71,10 +70,8 @@ public class ProcessSyncronousPasswordRegister implements Runnable { } BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval)); LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT); - try { - if (player.isInsideVehicle()) - player.getVehicle().eject(); - } catch (NullPointerException npe) { + if (player.isInsideVehicle() && player.getVehicle() != null) { + player.getVehicle().eject(); } } @@ -108,7 +105,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable { } if (!Settings.getRegisteredGroup.isEmpty()) { - Utils.getInstance().setGroup(player, Utils.GroupType.REGISTERED); + Utils.setGroup(player, Utils.GroupType.REGISTERED); } m.send(player, "registered"); if (!Settings.getmailAccount.isEmpty())