From a5200fd5c101f6daa6bf346d0cde1ef9b9373ae8 Mon Sep 17 00:00:00 2001 From: DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com> Date: Tue, 27 Mar 2018 17:43:17 +0300 Subject: [PATCH] Check for permissions instead of isOp() (#6) --- .../placeholderapi/commands/PlaceholderAPICommands.java | 8 ++++---- .../clip/placeholderapi/updatechecker/UpdateChecker.java | 2 +- src/main/java/me/clip/placeholderapi/util/Msg.java | 3 +-- src/main/resources/plugin.yml | 8 ++++++++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/commands/PlaceholderAPICommands.java b/src/main/java/me/clip/placeholderapi/commands/PlaceholderAPICommands.java index 8b4cf6d..386d645 100644 --- a/src/main/java/me/clip/placeholderapi/commands/PlaceholderAPICommands.java +++ b/src/main/java/me/clip/placeholderapi/commands/PlaceholderAPICommands.java @@ -74,7 +74,7 @@ public class PlaceholderAPICommands implements CommandExecutor { "&b/papi reload", "&fReload the config settings"); - if (s.isOp()) { + if (s.hasPermission("placeholderapi.ecloud")) { if (plugin.getExpansionCloud() == null) { Msg.msg(s, "&b/papi enablecloud", "&fEnable the expansion cloud"); @@ -97,7 +97,7 @@ public class PlaceholderAPICommands implements CommandExecutor { return true; } else if (args[0].equalsIgnoreCase("ecloud")) { - if (!s.isOp()) { + if (!s.hasPermission("placeholderapi.ecloud")) { Msg.msg(s, "&cYou don't have permission to do that!"); return true; } @@ -110,7 +110,7 @@ public class PlaceholderAPICommands implements CommandExecutor { return eCloud.onCommand(s, c, label, args); } else if (args[0].equalsIgnoreCase("enablecloud")) { - if (!s.isOp()) { + if (!s.hasPermission("placeholderapi.ecloud")) { Msg.msg(s, "&cYou don't have permission to do that!"); return true; } @@ -127,7 +127,7 @@ public class PlaceholderAPICommands implements CommandExecutor { } else if (args[0].equalsIgnoreCase("disablecloud")) { - if (!s.isOp()) { + if (!s.hasPermission("placeholderapi.ecloud")) { Msg.msg(s, "&cYou don't have permission to do that!"); return true; } diff --git a/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java b/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java index 7cabfc6..6bbc0fb 100644 --- a/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java +++ b/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java @@ -46,7 +46,7 @@ public class UpdateChecker implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onJoin(PlayerJoinEvent e) { - if (e.getPlayer().isOp()) { + if (e.getPlayer().hasPermission("placeholderapi.updatenotify")) { e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bAn update for &fPlaceholder&7API &e(&fPlaceholder&7API &fv" + getLatestVersion() + "&e)")); e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bis available at &ehttps://www.spigotmc.org/resources/placeholderapi." + resourceId + "/")); } diff --git a/src/main/java/me/clip/placeholderapi/util/Msg.java b/src/main/java/me/clip/placeholderapi/util/Msg.java index 97d87e3..23a51c2 100644 --- a/src/main/java/me/clip/placeholderapi/util/Msg.java +++ b/src/main/java/me/clip/placeholderapi/util/Msg.java @@ -28,8 +28,7 @@ import java.util.Arrays; public class Msg { public static void msg(CommandSender s, String... msg) { - Arrays.stream(msg).forEach(text -> - s.sendMessage(ChatColor.translateAlternateColorCodes('&', text))); + Arrays.stream(msg).forEach(text -> s.sendMessage(ChatColor.translateAlternateColorCodes('&', text))); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index addce9c..daf8022 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -13,10 +13,12 @@ permissions: children: placeholderapi.list: true placeholderapi.reload: true + placeholderapi.ecloud: true placeholderapi.parse: true placeholderapi.injector.chat.bypass: true placeholderapi.injector.signs.bypass: true placeholderapi.injector.anvil.bypass: true + placeholderapi.updatenotify: true placeholderapi.list: description: ability to use the list command default: op @@ -26,6 +28,12 @@ permissions: placeholderapi.parse: description: ability to use parse command default: op + placeholderapi.ecloud: + description: allows the usage of ecloud commands + default: op + placeholderapi.updatenotify: + description: notifies you when there is a PAPI update + default: op commands: placeholderapi: description: PlaceholderAPI command