Replaced code that used legacy deprecated permissions methods

This commit is contained in:
Tim Visée 2015-11-20 20:23:03 +01:00
parent 33ca2691b2
commit 3500ee6fb7
9 changed files with 20 additions and 16 deletions

View File

@ -642,7 +642,7 @@ public class AuthMe extends JavaPlugin {
public Player generateKickPlayer(Collection<? extends Player> collection) { public Player generateKickPlayer(Collection<? extends Player> collection) {
Player player = null; Player player = null;
for (Player p : collection) { for (Player p : collection) {
if (!(authmePermissible(p, "authme.vip"))) { if (!getPermissionsManager().hasPermission(p, "authme.vip")) {
player = p; player = p;
break; break;
} }

View File

@ -37,7 +37,7 @@ public class ForceLoginCommand extends ExecutableCommand {
sender.sendMessage("Player needs to be online!"); sender.sendMessage("Player needs to be online!");
return true; 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 + "!"); sender.sendMessage("You cannot force login for the player " + playerName + "!");
return true; return true;
} }

View File

@ -105,7 +105,7 @@ public class HelpPrinter {
for(String node : permissions.getPermissionNodes()) { for(String node : permissions.getPermissionNodes()) {
boolean nodePermission = true; boolean nodePermission = true;
if(sender instanceof Player) 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!)"); final String nodePermsString = ChatColor.GRAY + (nodePermission ? ChatColor.ITALIC + " (Permission!)" : ChatColor.ITALIC + " (No Permission!)");
sender.sendMessage(" " + ChatColor.YELLOW + ChatColor.ITALIC + node + nodePermsString); sender.sendMessage(" " + ChatColor.YELLOW + ChatColor.ITALIC + node + nodePermsString);
} }

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
import fr.xephi.authme.permission.PermissionsManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -165,7 +166,7 @@ public class AuthMePlayerListener implements Listener {
private void checkAntiBotMod(final Player player) { private void checkAntiBotMod(final Player player) {
if (plugin.delayedAntiBot || plugin.antibotMod) if (plugin.delayedAntiBot || plugin.antibotMod)
return; return;
if (plugin.authmePermissible(player, "authme.bypassantibot")) if (plugin.getPermissionsManager().hasPermission(player, "authme.bypassantibot"))
return; return;
if (antibot.size() > Settings.antiBotSensibility) { if (antibot.size() > Settings.antiBotSensibility) {
plugin.switchAntiBotMod(true); plugin.switchAntiBotMod(true);
@ -265,8 +266,11 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
// Get the permissions manager
PermissionsManager permsMan = plugin.getPermissionsManager();
boolean isAuthAvailable = plugin.database.isAuthAvailable(name); 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()); String code = Utils.getCountryCode(event.getAddress().getHostAddress());
if (((code == null) || Settings.countriesBlacklist.contains(code))) { if (((code == null) || Settings.countriesBlacklist.contains(code))) {
event.setKickMessage(m.send("country_banned")[0]); event.setKickMessage(m.send("country_banned")[0]);
@ -274,7 +278,7 @@ public class AuthMePlayerListener implements Listener {
return; 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()); String code = Utils.getCountryCode(event.getAddress().getHostAddress());
if (((code == null) || !Settings.countries.contains(code))) { if (((code == null) || !Settings.countries.contains(code))) {
event.setKickMessage(m.send("country_banned")[0]); event.setKickMessage(m.send("country_banned")[0]);
@ -343,7 +347,7 @@ public class AuthMePlayerListener implements Listener {
} }
if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL) if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL)
return; return;
if (!plugin.authmePermissible(player, "authme.vip")) { if (!permsMan.hasPermission(player, "authme.vip")) {
event.setKickMessage(m.send("kick_fullserver")[0]); event.setKickMessage(m.send("kick_fullserver")[0]);
event.setResult(PlayerLoginEvent.Result.KICK_FULL); event.setResult(PlayerLoginEvent.Result.KICK_FULL);
return; return;
@ -510,7 +514,7 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player == null) if (player == null)
return; return;
if (plugin.authmePermissible(player, "authme.bypassforcesurvival")) if (plugin.getPermissionsManager().hasPermission(player, "authme.bypassforcesurvival"))
return; return;
if (Utils.checkAuth(player)) if (Utils.checkAuth(player))
return; return;

View File

@ -38,7 +38,7 @@ public class AsyncChangeEmail {
String playerName = player.getName().toLowerCase(); String playerName = player.getName().toLowerCase();
if (Settings.getmaxRegPerEmail > 0) { 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"); m.send(player, "max_reg");
return; return;
} }

View File

@ -91,7 +91,7 @@ public class AsyncronousJoin {
}); });
return; 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)) { if (plugin.hasJoinedIp(player.getName(), ip)) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {

View File

@ -96,7 +96,7 @@ public class AsyncronousLogin {
} }
return null; 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())) { if (plugin.isLoggedIp(name, getIP())) {
m.send(player, "logged_in"); m.send(player, "logged_in");
return null; return null;
@ -236,7 +236,7 @@ public class AsyncronousLogin {
* uuidaccounts + "."; } } * uuidaccounts + "."; } }
*/ */
for (Player player : Utils.getOnlinePlayers()) { 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("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts");
player.sendMessage(message.toString()); player.sendMessage(message.toString());
// player.sendMessage(uuidaccounts.replace("%size%", // player.sendMessage(uuidaccounts.replace("%size%",

View File

@ -62,7 +62,7 @@ public class AsyncRegister {
m.send(player, "user_regged"); m.send(player, "user_regged");
return false; return false;
} else if (Settings.getmaxRegPerIp > 0) { } 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"); m.send(player, "max_reg");
return false; return false;
} }
@ -76,7 +76,7 @@ public class AsyncRegister {
return; return;
if (!email.isEmpty() && !email.equals("")) { if (!email.isEmpty() && !email.equals("")) {
if (Settings.getmaxRegPerEmail > 0) { 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"); m.send(player, "max_reg");
return; return;
} }
@ -94,7 +94,7 @@ public class AsyncRegister {
protected void emailRegister() throws Exception { protected void emailRegister() throws Exception {
if (Settings.getmaxRegPerEmail > 0) { 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"); m.send(player, "max_reg");
return; return;
} }

View File

@ -225,7 +225,7 @@ public class Utils {
* Used for force player GameMode * Used for force player GameMode
*/ */
public static void forceGM(Player player) { public static void forceGM(Player player) {
if (!plugin.authmePermissible(player, "authme.bypassforcesurvival")) if (!plugin.getPermissionsManager().hasPermission(player, "authme.bypassforcesurvival"))
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
} }