From 83b944eb4bbe62aab5351382309399e421310368 Mon Sep 17 00:00:00 2001 From: Ali Moghnieh Date: Fri, 22 Jul 2016 15:33:26 +0100 Subject: [PATCH] Use User#isAuthorized() instead of Player#hasPermission(). --- .../earth2me/essentials/EssentialsPlayerListener.java | 3 ++- .../earth2me/essentials/commands/Commandgamemode.java | 10 +++++----- .../com/earth2me/essentials/commands/Commandsudo.java | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 5d8990080..a7299d086 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -385,7 +385,8 @@ public class EssentialsPlayerListener implements Listener { return; } if (ess.getSettings().getSocialSpyCommands().contains(cmd) || ess.getSettings().getSocialSpyCommands().contains("*")) { - if (!player.hasPermission("essentials.chat.spy.exempt")) { + User user = ess.getUser(player); + if (!user.isAuthorized("essentials.chat.spy.exempt")) { for (User spyer : ess.getOnlineUsers()) { if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) { spyer.sendMessage(player.getDisplayName() + " : " + event.getMessage()); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java index 034ea7406..3afbe360a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java @@ -58,7 +58,7 @@ public class Commandgamemode extends EssentialsCommand { gameMode = user.getBase().getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : user.getBase().getGameMode() == GameMode.CREATIVE ? GameMode.ADVENTURE : GameMode.SURVIVAL; } - if (!canChangeToMode(user.getBase(), gameMode)) { + if (!canChangeToMode(user, gameMode)) { user.sendMessage(tl("cantGamemode", gameMode.name())); return; } @@ -72,7 +72,7 @@ public class Commandgamemode extends EssentialsCommand { throw new NotEnoughArgumentsException(tl("gameModeInvalid")); } - if (sender.isPlayer() && !canChangeToMode(sender.getPlayer(), gameMode)) { + if (sender.isPlayer() && !canChangeToMode(ess.getUser(sender.getPlayer()), gameMode)) { sender.sendMessage(tl("cantGamemode", gameMode.name())); return; } @@ -95,8 +95,8 @@ public class Commandgamemode extends EssentialsCommand { } // essentials.gamemode will let them change to any but essentials.gamemode.survival would only let them change to survival. - private boolean canChangeToMode(Player player, GameMode to) { - return player.hasPermission("essentials.gamemode.all") || player.hasPermission("essentials.gamemode." + to.name().toLowerCase()); + private boolean canChangeToMode(User user, GameMode to) { + return user.isAuthorized("essentials.gamemode.all") || user.isAuthorized("essentials.gamemode." + to.name().toLowerCase()); } private GameMode matchGameMode(String modeString) throws NotEnoughArgumentsException { @@ -116,4 +116,4 @@ public class Commandgamemode extends EssentialsCommand { } return mode; } -} \ No newline at end of file +} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java index 384c61ab0..6940afd76 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java @@ -28,7 +28,7 @@ public class Commandsudo extends EssentialsLoopCommand { } final String command = getFinalArg(arguments, 0); - boolean multiple = sender.getSender().hasPermission("essentials.sudo.multiple"); + boolean multiple = !sender.isPlayer() ? true : ess.getUser(sender.getPlayer()).isAuthorized("essentials.sudo.multiple"); sender.sendMessage(tl("sudoRun", args[0], command, "")); loopOnlinePlayers(server, sender, multiple, multiple, args[0], new String[]{command});