From 0923bf443a2adc21fb86fa02179bd8ee9afeeb85 Mon Sep 17 00:00:00 2001 From: axemwa Date: Sat, 17 Aug 2019 00:59:45 +0930 Subject: [PATCH] Add permission required message for reload command & rename permission required message for toggle --- .../me/shanodekono/nostrip/commands/NoStripCommand.java | 6 +++++- .../nostrip/listeners/PlayerInteractListener.java | 2 +- src/main/java/me/shanodekono/nostrip/utils/ConfigUtils.java | 2 ++ src/main/resources/config.yml | 3 ++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/shanodekono/nostrip/commands/NoStripCommand.java b/src/main/java/me/shanodekono/nostrip/commands/NoStripCommand.java index a9eac57..7fad39a 100644 --- a/src/main/java/me/shanodekono/nostrip/commands/NoStripCommand.java +++ b/src/main/java/me/shanodekono/nostrip/commands/NoStripCommand.java @@ -49,7 +49,11 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if (sender.hasPermission("nostrip.reload")) { cfgUtils.reloadConfig(sender); } + if (!sender.hasPermission("nostrip.reload")) { + sender.sendMessage(cfgUtils.color(cfgUtils.prefix + " " + cfgUtils.noPermission)); + } return true; + } if (args[0].equalsIgnoreCase("toggle")) { @@ -62,7 +66,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St String permission; if (!player.hasPermission("nostrip.toggle")) { permission = "&cnostrip.toggle"; - player.sendMessage(cfgUtils.color(cfgUtils.prefix + " " + cfgUtils.noPermission + player.sendMessage(cfgUtils.color(cfgUtils.prefix + " " + cfgUtils.noTogglePermission .replace("{permission}", permission))); return true; } diff --git a/src/main/java/me/shanodekono/nostrip/listeners/PlayerInteractListener.java b/src/main/java/me/shanodekono/nostrip/listeners/PlayerInteractListener.java index 7ea8b02..9def62d 100644 --- a/src/main/java/me/shanodekono/nostrip/listeners/PlayerInteractListener.java +++ b/src/main/java/me/shanodekono/nostrip/listeners/PlayerInteractListener.java @@ -100,7 +100,7 @@ private void onInteract(PlayerInteractEvent event) { event.getPlayer().sendMessage(cfgUtils.color(cfgUtils.prefix + " " + cfgUtils.toggleMessage .replace("{status}", status .replace("{astatus}", astatus)))); - event.getPlayer().sendMessage(cfgUtils.color(cfgUtils.noPermission + event.getPlayer().sendMessage(cfgUtils.color(cfgUtils.noTogglePermission .replace("{permission}", permission))); } event.setCancelled(true); diff --git a/src/main/java/me/shanodekono/nostrip/utils/ConfigUtils.java b/src/main/java/me/shanodekono/nostrip/utils/ConfigUtils.java index 0718cbb..1c54d6d 100644 --- a/src/main/java/me/shanodekono/nostrip/utils/ConfigUtils.java +++ b/src/main/java/me/shanodekono/nostrip/utils/ConfigUtils.java @@ -27,6 +27,7 @@ public ConfigUtils(NoStrip pl) { public String unknownCommand; public String mustBePlayer; public String noPermission; + public String noTogglePermission; public String noAxePermission; public String toggleMessage; @@ -45,6 +46,7 @@ public void loadConfig() { unknownCommand = messages.getString("unknown-command"); mustBePlayer = messages.getString("must-be-player"); noPermission = messages.getString("no-permission"); + noTogglePermission = messages.getString("no-toggle-permission"); noAxePermission = messages.getString("no-axe-permission"); toggleMessage = messages.getString("toggle-message"); configReloaded = messages.getString("config-reloaded"); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0e873bf..a36260f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -24,7 +24,8 @@ messages: prefix: '&8&l[&c&l⦸ &4&lNo&c&lStrip &c&l⦸&8&l]' unknown-command: '&cUnknown Command' must-be-player: '&cYou Must Be A Player To Use This Command!' - no-permission: '&cPermission {permission} Required! Contact server admin!' + no-permission: '&cYou do not have permission to use that command' + no-toggle-permission: '&cPermission {permission} Required! Contact server admin!' no-axe-permission: '&cAxe Is Denied! Permission Required!' toggle-message: '&2Log Stripping {status}' config-reloaded: '&2Config Reloaded!' \ No newline at end of file