Ver código fonte

Added permission node to prevent inspecting hidden players

TfT_02 12 anos atrás
pai
commit
375fa4f75c

+ 1 - 0
Changelog.txt

@@ -28,6 +28,7 @@ Version 1.4.06-dev
  + Added multiplier to Archery XP based on bow force
  + Added information about /party itemshare and /party expshare to the party help page
  + Added option to use scoreboards for power level display instead of Spout.
+ + Added permission node to prevent inspecting hidden players
  = Fixed bug where custom Spout titles were overwritten by mcMMO.
  = Fixed bug where Nether Quartz wasn't included in Smelting or item sharing
  = Fixed bug where players were able to join the same party multiple times

+ 4 - 0
src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java

@@ -73,6 +73,10 @@ public class InspectCommand implements TabExecutor {
                         return true;
                     }
 
+                    if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
+                        return true;
+                    }
+
                     if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
                         ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer);
                         return true;

+ 1 - 0
src/main/java/com/gmail/nossr50/util/Permissions.java

@@ -48,6 +48,7 @@ public final class Permissions {
 
     public static boolean inspect(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect")); }
     public static boolean inspectFar(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.far")); }
+    public static boolean inspectHidden(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.hidden")); }
     public static boolean inspectOffline(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.offline")); }
 
     public static boolean kraken(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.kraken"); }

+ 9 - 0
src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java

@@ -55,6 +55,15 @@ public final class CommandUtils {
         return false;
     }
 
+    public static boolean hidden(CommandSender sender, Player target, boolean hasPermission) {
+        if (sender instanceof Player && ((Player)sender).canSee(target) && !hasPermission) {
+            sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
+            return true;
+        }
+
+        return false;
+    }
+
     public static boolean noConsoleUsage(CommandSender sender) {
         if (sender instanceof Player) {
             return false;

+ 10 - 0
src/main/resources/plugin.yml

@@ -612,6 +612,7 @@ permissions:
             mcmmo.bypass.hardcoremode: true
             mcmmo.bypass.kraken: true
             mcmmo.commands.inspect.far: true
+            mcmmo.commands.inspect.hidden: true
             mcmmo.commands.inspect.offline: true
     mcmmo.bypass.arcanebypass:
         default: false
@@ -627,6 +628,11 @@ permissions:
         description: Allows user to bypass Inspect's distance requirements
         children:
             mcmmo.commands.inspect.far: true
+    mcmmo.bypass.inspect.hidden:
+        default: false
+        description: Allows user to bypass Inspect's hidden player requirements
+        children:
+            mcmmo.commands.inspect.hidden: true
     mcmmo.bypass.inspect.offline:
         default: false
         description: Allows user to bypass Inspect's offline player requirements
@@ -701,6 +707,7 @@ permissions:
             mcmmo.commands.defaults: true
             mcmmo.commands.hardcore.all: true
             mcmmo.commands.inspect.far: true
+            mcmmo.commands.inspect.hidden: true
             mcmmo.commands.inspect.offline: true
             mcmmo.commands.kraken: true
             mcmmo.commands.kraken.others: true
@@ -772,11 +779,14 @@ permissions:
         children:
             mcmmo.commands.inspect: true
             mcmmo.commands.inspect.far: true
+            mcmmo.commands.inspect.hidden: true
             mcmmo.commands.inspect.offline: true
     mcmmo.commands.inspect:
         description: Allows access to the inspect command
     mcmmo.commands.inspect.far:
         description: Allows access to the inspect command for far players
+    mcmmo.commands.inspect.hidden:
+        description: Allows access to the inspect command for hidden players
     mcmmo.commands.inspect.offline:
         description: Allows access to the inspect command for offline players
     mcmmo.commands.kraken: