diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/AbstractCommand.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/AbstractCommand.java
index 9e751ac3..870d8bae 100644
--- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/AbstractCommand.java
+++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/AbstractCommand.java
@@ -115,7 +115,7 @@ public abstract class AbstractCommand implements TabExecutor{
if (len == subCommandIndex || len == subCommandIndex + 1){
String arg = len == subCommandIndex ? "" : args[subCommandIndex].trim().toLowerCase();
for (AbstractCommand> cmd : subCommands.values()){
- if (cmd.label.startsWith(arg) && (cmd.permission == null || sender.hasPermission(cmd.permission))){
+ if (cmd.label.startsWith(arg) && cmd.testPermission(sender, command, alias, args)){
// Only completes the label (!).
choices.add(cmd.label);
}
@@ -124,7 +124,7 @@ public abstract class AbstractCommand implements TabExecutor{
else if (len > subCommandIndex + 1){
String arg = args[subCommandIndex].trim().toLowerCase();
AbstractCommand> subCommand = subCommands.get(arg);
- if (subCommand != null && (subCommand.permission == null || sender.hasPermission(subCommand.permission))){
+ if (subCommand != null && subCommand.testPermission(sender, command, alias, args)){
return subCommand.onTabComplete(sender, command, alias, args);
}
}
@@ -142,7 +142,7 @@ public abstract class AbstractCommand implements TabExecutor{
String arg = args[subCommandIndex].trim().toLowerCase();
AbstractCommand> subCommand = subCommands.get(arg);
if (subCommand != null){
- if (subCommand.permission != null && !sender.hasPermission(subCommand.permission)){
+ if (!subCommand.testPermission(sender, command, alias, args)){
sender.sendMessage(ChatColor.DARK_RED + "You don't have permission.");
return true;
}
@@ -152,5 +152,15 @@ public abstract class AbstractCommand implements TabExecutor{
// Usage.
return false;
}
+
+ /**
+ * Test if the CommandSender has the permission necessary to run THIS command (not meant for checking sub-command permissions recursively).
+ *
Override for more complex specialized permissions.
+ * @param sender
+ * @return
+ */
+ public boolean testPermission(CommandSender sender, Command command, String alias, String args[]){
+ return permission == null || sender.hasPermission(permission);
+ }
}
diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/NoCheatPlusCommand.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/NoCheatPlusCommand.java
index 4119a921..1b744560 100644
--- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/NoCheatPlusCommand.java
+++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/NoCheatPlusCommand.java
@@ -154,7 +154,7 @@ public class NoCheatPlusCommand extends BaseCommand{
// Check sub-commands.
if (args.length > 0){
AbstractCommand> subCommand = subCommands.get(args[0].trim().toLowerCase());
- if (subCommand != null && sender.hasPermission(subCommand.permission)){
+ if (subCommand.testPermission(sender, command, commandLabel, args)){
// Sender has permission to run the command.
return subCommand.onCommand(sender, command, commandLabel, args);
}
@@ -214,7 +214,7 @@ public class NoCheatPlusCommand extends BaseCommand{
// }
// else{
// final NCPCommand cmd = commands.get(subLabel);
-// if (cmd != null && sender.hasPermission(cmd.permission)){
+// if (cmd.testPermission...){
// // Delegate the tab-completion.
// return cmd.onTabComplete(sender, command, alias, args);
// }
diff --git a/NCPPlugin/src/main/resources/plugin.yml b/NCPPlugin/src/main/resources/plugin.yml
index 6c7feea0..caa89ff4 100644
--- a/NCPPlugin/src/main/resources/plugin.yml
+++ b/NCPPlugin/src/main/resources/plugin.yml
@@ -348,14 +348,14 @@ permissions:
# Shortcut: convenient testing.
nocheatplus.tester:
- description: Monitoring and debugging permissions, including removing data and exemption handling for oneself.
+ description: Monitoring and debugging permissions, including removing data and exemption.
children:
- # TODO: Might just inherit from shortcut.info.
+ # TODO: Might just inherit from shortcut.info, might implement exempt.self etc.
nocheatplus.shortcut.monitor: true
nocheatplus.admin.debug: true
- nocheatplus.command.exempt.self: true
- nocheatplus.command.unexempt.self: true
- nocheatplus.command.removeplayer.self: true
+ nocheatplus.command.exempt: true
+ nocheatplus.command.unexempt: true
+ nocheatplus.command.removeplayer: true
# Shortcut: full administrator without check-bypass-permissions:
nocheatplus.admin: