From 98e1af0f662e4c028551420d466c397060477fc6 Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Sun, 19 Jun 2011 17:07:03 -0600 Subject: [PATCH] Add fancy permissions (/mv) --- .../MultiverseCore/command/CommandManager.java | 12 +++++++++++- .../MultiverseCore/command/commands/HelpCommand.java | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/com/onarandombox/MultiverseCore/command/CommandManager.java b/src/com/onarandombox/MultiverseCore/command/CommandManager.java index 52b4161b..32d7e01a 100644 --- a/src/com/onarandombox/MultiverseCore/command/CommandManager.java +++ b/src/com/onarandombox/MultiverseCore/command/CommandManager.java @@ -69,10 +69,21 @@ public class CommandManager { this.commands.remove(command); } + @Deprecated public List getCommands() { return this.commands; } + public List getCommands(CommandSender sender) { + ArrayList playerCommands = new ArrayList(); + for(BaseCommand c : this.commands) { + if(this.hasPermission(sender, c.permission, c.isOpRequired())) { + playerCommands.add(c); + } + } + return playerCommands; + } + /** * Combines all quoted strings * @@ -134,7 +145,6 @@ public class CommandManager { return true; } Player player = (Player) sender; - System.out.print("Checking permissions for " + player.getName()); if (player.isOp()) { // If Player is Op we always let them use it. diff --git a/src/com/onarandombox/MultiverseCore/command/commands/HelpCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/HelpCommand.java index c71c63b1..289f5ee2 100644 --- a/src/com/onarandombox/MultiverseCore/command/commands/HelpCommand.java +++ b/src/com/onarandombox/MultiverseCore/command/commands/HelpCommand.java @@ -42,7 +42,8 @@ public class HelpCommand extends BaseCommand { } } - List commands = plugin.getCommandManager().getCommands(); + // Get only the commands this player has access to + List commands = plugin.getCommandManager().getCommands(sender); int numPages = commands.size() / CMDS_PER_PAGE; if (commands.size() % CMDS_PER_PAGE != 0) {