Browse Source

Further updating the permissions for the /mcrank command.

Glitchfinder 12 years ago
parent
commit
93ffd950e9

+ 20 - 0
src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java

@@ -8,11 +8,15 @@ import org.bukkit.entity.Player;
 
 import com.gmail.nossr50.commands.CommandHelper;
 import com.gmail.nossr50.config.Config;
+import com.gmail.nossr50.datatypes.McMMOPlayer;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.runnables.McRankAsync;
 import com.gmail.nossr50.skills.utilities.SkillTools;
 import com.gmail.nossr50.skills.utilities.SkillType;
 import com.gmail.nossr50.util.Leaderboard;
+import com.gmail.nossr50.util.Misc;
+import com.gmail.nossr50.util.Permissions;
+import com.gmail.nossr50.util.Users;
 
 public class McrankCommand implements CommandExecutor {
     @Override
@@ -44,6 +48,22 @@ public class McrankCommand implements CommandExecutor {
             }
 
             playerName = args[0];
+
+            McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName);
+
+            if (mcmmoPlayer != null) {
+                Player target = mcmmoPlayer.getPlayer();
+
+                if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.hasPermission(sender, "mcmmo.commands.mcrank.others.far")) {
+                    sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
+                    return true;
+                }
+            }
+            else if (sender instanceof Player && !Permissions.hasPermission(sender, "mcmmo.commands.mcrank.others.offline")) {
+                sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
+                return true;
+            }
+
             break;
 
         default:

+ 15 - 1
src/main/resources/plugin.yml

@@ -715,7 +715,7 @@ permissions:
             mcmmo.commands.mcgod: true
             mcmmo.commands.mcgod.others: true
             mcmmo.commands.mcpurge: true
-            mcmmo.commands.mcrank.others: true
+            mcmmo.commands.mcrank.others.all: true
             mcmmo.commands.mmoedit: true
             mcmmo.commands.mmoedit.others: true
             mcmmo.commands.mmoupdate: true
@@ -774,8 +774,22 @@ permissions:
         description: Allows access to the mcpurge command
     mcmmo.commands.mcrank:
         description: Allows access to the mcrank command
+    mcmmo.commands.mcrank.others.*:
+        description: Implies access to all mcmmo.commands.mcrank.others permissions
+        children:
+            mcmmo.commands.mcrank.others.all: true
+    mcmmo.commands.mcrank.others.all:
+        description: Implies access to all mcmmo.commands.mcrank.others permissions
+        children:
+            mcmmo.commands.mcrank.others: true
+            mcmmo.commands.mcrank.others.far: true
+            mcmmo.commands.mcrank.others.offline: true
     mcmmo.commands.mcrank.others:
         description: Allows access to the mcrank command for other players
+    mcmmo.commands.mcrank.others.far:
+        description: Allows access to the mcrank command for far players
+    mcmmo.commands.mcrank.others.offline:
+        description: Allows access to the mcrank command for offline players
     mcmmo.commands.mcstats:
         description: Allows access to the mcstats command
     mcmmo.commands.mctop: