Przeglądaj źródła

Adding a new permissions for the /mcability command.

Glitchfinder 12 lat temu
rodzic
commit
c34d269f33

+ 18 - 2
src/main/java/com/gmail/nossr50/commands/mc/McabilityCommand.java

@@ -1,10 +1,12 @@
 package com.gmail.nossr50.commands.mc;
 
+import org.bukkit.OfflinePlayer;
 import org.bukkit.command.Command;
 import org.bukkit.command.CommandExecutor;
 import org.bukkit.command.CommandSender;
 import org.bukkit.entity.Player;
 
+import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.commands.CommandHelper;
 import com.gmail.nossr50.datatypes.PlayerProfile;
 import com.gmail.nossr50.locale.LocaleLoader;
@@ -17,11 +19,25 @@ public class McabilityCommand implements CommandExecutor {
             return true;
         }
 
-        if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ability")) {
+        // DEPRECATED PERMISSION
+        boolean oldPermission = !CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ability");
+
+        if (!oldPermission && CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability")) {
             return true;
         }
 
-        PlayerProfile profile = Users.getProfile((Player) sender);
+        PlayerProfile profile = null;
+
+        if(args.length > 0 && args[0] != null) {
+            if (!oldPermission && CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability.others")) {
+                return true;
+            }
+
+            OfflinePlayer modifiedPlayer = mcMMO.p.getServer().getOfflinePlayer(args[0]);
+            profile = Users.getProfile(modifiedPlayer);
+        }
+	else
+            profile = Users.getProfile((Player) sender);
 
         if (profile == null) {
             sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));

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

@@ -347,6 +347,7 @@ permissions:
     mcmmo.tools.mcrefresh:
         description: Allows access to mcrefresh command
     mcmmo.tools.mmoedit:
+        default: false
         description: Allows access to mmoedit command
     mcmmo.tools.mcgod:
         description: Allows access to mcgod command
@@ -710,6 +711,7 @@ permissions:
             mcmmo.commands.defaults: true
             mcmmo.commands.inspect.far: true
             mcmmo.commands.inspect.offline: true
+            mcmmo.commands.mcability.others: true
             mcmmo.commands.mmoedit: true
             mcmmo.commands.mmoedit.others: true
             mcmmo.commands.mmoupdate: true
@@ -718,12 +720,13 @@ permissions:
     mcmmo.commands.defaults:
         description: Implies all default mcmmo.commands permissions.
         children:
-            mcmmo.commands.ability: true
             mcmmo.commands.inspect: true
+            mcmmo.commands.mcability: true
             mcmmo.commands.mcstats: true
             mcmmo.commands.party.all: true
             mcmmo.commands.ptp: true
     mcmmo.commands.ability:
+        default: false
         description: Allows access to the mcability command
     mcmmo.commands.addlevels:
         description: Allows access to the addlevels command
@@ -749,6 +752,10 @@ permissions:
         description: Allows access to the inspect command for far players
     mcmmo.commands.inspect.offline:
         description: Allows access to the inspect command for offline players
+    mcmmo.commands.mcability:
+        description: Allows access to the mcability command
+    mcmmo.commands.mcability.others:
+        description: Allows access to the mcability command for other players
     mcmmo.commands.mmoedit:
         description: Allows access to the mmoedit command
     mcmmo.commands.mmoedit.others:
@@ -986,4 +993,5 @@ permissions:
     mcmmo.skills.smelting:
         description: Allows access to the Smelting skill
     mcmmo.skillreset:
+        default: false
         description: Allow reset of skill levels