From 3500ee6fb77b3c00dad0c0f8b9f199f8ea1eca3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Fri, 20 Nov 2015 20:23:03 +0100 Subject: [PATCH] Replaced code that used legacy deprecated permissions methods --- src/main/java/fr/xephi/authme/AuthMe.java | 2 +- .../executable/authme/ForceLoginCommand.java | 2 +- .../fr/xephi/authme/command/help/HelpPrinter.java | 2 +- .../authme/listener/AuthMePlayerListener.java | 14 +++++++++----- .../authme/process/email/AsyncChangeEmail.java | 2 +- .../xephi/authme/process/join/AsyncronousJoin.java | 2 +- .../authme/process/login/AsyncronousLogin.java | 4 ++-- .../authme/process/register/AsyncRegister.java | 6 +++--- src/main/java/fr/xephi/authme/util/Utils.java | 2 +- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 270e3ca83..30f680162 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -642,7 +642,7 @@ public class AuthMe extends JavaPlugin { public Player generateKickPlayer(Collection collection) { Player player = null; for (Player p : collection) { - if (!(authmePermissible(p, "authme.vip"))) { + if (!getPermissionsManager().hasPermission(p, "authme.vip")) { player = p; break; } diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/ForceLoginCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/ForceLoginCommand.java index 17c5d8a4a..42632a416 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/ForceLoginCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/ForceLoginCommand.java @@ -37,7 +37,7 @@ public class ForceLoginCommand extends ExecutableCommand { sender.sendMessage("Player needs to be online!"); return true; } - if (!plugin.authmePermissible(player, "authme.canbeforced")) { + if (!plugin.getPermissionsManager().hasPermission(player, "authme.canbeforced")) { sender.sendMessage("You cannot force login for the player " + playerName + "!"); return true; } diff --git a/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java b/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java index 4f28eb293..9ad398c74 100644 --- a/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java +++ b/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java @@ -105,7 +105,7 @@ public class HelpPrinter { for(String node : permissions.getPermissionNodes()) { boolean nodePermission = true; if(sender instanceof Player) - nodePermission = AuthMe.getInstance().authmePermissible((Player) sender, node); + nodePermission = AuthMe.getInstance().getPermissionsManager().hasPermission((Player) sender, node); final String nodePermsString = ChatColor.GRAY + (nodePermission ? ChatColor.ITALIC + " (Permission!)" : ChatColor.ITALIC + " (No Permission!)"); sender.sendMessage(" " + ChatColor.YELLOW + ChatColor.ITALIC + node + nodePermsString); } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index bcc5bc8fa..bdb97b074 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.PatternSyntaxException; +import fr.xephi.authme.permission.PermissionsManager; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -165,7 +166,7 @@ public class AuthMePlayerListener implements Listener { private void checkAntiBotMod(final Player player) { if (plugin.delayedAntiBot || plugin.antibotMod) return; - if (plugin.authmePermissible(player, "authme.bypassantibot")) + if (plugin.getPermissionsManager().hasPermission(player, "authme.bypassantibot")) return; if (antibot.size() > Settings.antiBotSensibility) { plugin.switchAntiBotMod(true); @@ -265,8 +266,11 @@ public class AuthMePlayerListener implements Listener { return; } + // Get the permissions manager + PermissionsManager permsMan = plugin.getPermissionsManager(); + boolean isAuthAvailable = plugin.database.isAuthAvailable(name); - if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !plugin.authmePermissible(player, "authme.bypassantibot")) { + if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, "authme.bypassantibot")) { String code = Utils.getCountryCode(event.getAddress().getHostAddress()); if (((code == null) || Settings.countriesBlacklist.contains(code))) { event.setKickMessage(m.send("country_banned")[0]); @@ -274,7 +278,7 @@ public class AuthMePlayerListener implements Listener { return; } } - if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !plugin.authmePermissible(player, "authme.bypassantibot")) { + if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, "authme.bypassantibot")) { String code = Utils.getCountryCode(event.getAddress().getHostAddress()); if (((code == null) || !Settings.countries.contains(code))) { event.setKickMessage(m.send("country_banned")[0]); @@ -343,7 +347,7 @@ public class AuthMePlayerListener implements Listener { } if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL) return; - if (!plugin.authmePermissible(player, "authme.vip")) { + if (!permsMan.hasPermission(player, "authme.vip")) { event.setKickMessage(m.send("kick_fullserver")[0]); event.setResult(PlayerLoginEvent.Result.KICK_FULL); return; @@ -510,7 +514,7 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); if (player == null) return; - if (plugin.authmePermissible(player, "authme.bypassforcesurvival")) + if (plugin.getPermissionsManager().hasPermission(player, "authme.bypassforcesurvival")) return; if (Utils.checkAuth(player)) return; diff --git a/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java b/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java index 6fa9ac7ee..0b8f7c644 100644 --- a/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java +++ b/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java @@ -38,7 +38,7 @@ public class AsyncChangeEmail { String playerName = player.getName().toLowerCase(); if (Settings.getmaxRegPerEmail > 0) { - if (!plugin.authmePermissible(player, "authme.allow2accounts") && plugin.database.getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) { + if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && plugin.database.getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) { m.send(player, "max_reg"); return; } 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 d4678ec10..60aae9437 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java @@ -91,7 +91,7 @@ public class AsyncronousJoin { }); return; } - if (Settings.getMaxJoinPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) { + if (Settings.getMaxJoinPerIp > 0 && !plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) { if (plugin.hasJoinedIp(player.getName(), ip)) { sched.scheduleSyncDelayedTask(plugin, new Runnable() { diff --git a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java index 4879ea8b7..4144bd08a 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java @@ -96,7 +96,7 @@ public class AsyncronousLogin { } return null; } - if (Settings.getMaxLoginPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) { + if (Settings.getMaxLoginPerIp > 0 && !plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) { if (plugin.isLoggedIp(name, getIP())) { m.send(player, "logged_in"); return null; @@ -236,7 +236,7 @@ public class AsyncronousLogin { * uuidaccounts + "."; } } */ for (Player player : Utils.getOnlinePlayers()) { - if (plugin.authmePermissible(player, "authme.seeOtherAccounts")) { + if (plugin.getPermissionsManager().hasPermission(player, "authme.seeOtherAccounts")) { player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts"); player.sendMessage(message.toString()); // player.sendMessage(uuidaccounts.replace("%size%", 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 b7abdf5b8..6a42abba0 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -62,7 +62,7 @@ public class AsyncRegister { m.send(player, "user_regged"); return false; } else if (Settings.getmaxRegPerIp > 0) { - if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp && !getIp().equalsIgnoreCase("127.0.0.1") && !getIp().equalsIgnoreCase("localhost")) { + if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp && !getIp().equalsIgnoreCase("127.0.0.1") && !getIp().equalsIgnoreCase("localhost")) { m.send(player, "max_reg"); return false; } @@ -76,7 +76,7 @@ public class AsyncRegister { return; if (!email.isEmpty() && !email.equals("")) { if (Settings.getmaxRegPerEmail > 0) { - if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) { + if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) { m.send(player, "max_reg"); return; } @@ -94,7 +94,7 @@ public class AsyncRegister { protected void emailRegister() throws Exception { if (Settings.getmaxRegPerEmail > 0) { - if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) { + if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) { m.send(player, "max_reg"); return; } diff --git a/src/main/java/fr/xephi/authme/util/Utils.java b/src/main/java/fr/xephi/authme/util/Utils.java index 2775f694c..8af65cb8c 100644 --- a/src/main/java/fr/xephi/authme/util/Utils.java +++ b/src/main/java/fr/xephi/authme/util/Utils.java @@ -225,7 +225,7 @@ public class Utils { * Used for force player GameMode */ public static void forceGM(Player player) { - if (!plugin.authmePermissible(player, "authme.bypassforcesurvival")) + if (!plugin.getPermissionsManager().hasPermission(player, "authme.bypassforcesurvival")) player.setGameMode(GameMode.SURVIVAL); }