Add fancy permissions (/mv)

This commit is contained in:
Eric Stokes 2011-06-19 17:07:03 -06:00
parent 82429ee7de
commit 98e1af0f66
2 changed files with 13 additions and 2 deletions

View File

@ -69,10 +69,21 @@ public class CommandManager {
this.commands.remove(command); this.commands.remove(command);
} }
@Deprecated
public List<BaseCommand> getCommands() { public List<BaseCommand> getCommands() {
return this.commands; return this.commands;
} }
public List<BaseCommand> getCommands(CommandSender sender) {
ArrayList<BaseCommand> playerCommands = new ArrayList<BaseCommand>();
for(BaseCommand c : this.commands) {
if(this.hasPermission(sender, c.permission, c.isOpRequired())) {
playerCommands.add(c);
}
}
return playerCommands;
}
/** /**
* Combines all quoted strings * Combines all quoted strings
* *
@ -134,7 +145,6 @@ public class CommandManager {
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
System.out.print("Checking permissions for " + player.getName());
if (player.isOp()) { if (player.isOp()) {
// If Player is Op we always let them use it. // If Player is Op we always let them use it.

View File

@ -42,7 +42,8 @@ public class HelpCommand extends BaseCommand {
} }
} }
List<BaseCommand> commands = plugin.getCommandManager().getCommands(); // Get only the commands this player has access to
List<BaseCommand> commands = plugin.getCommandManager().getCommands(sender);
int numPages = commands.size() / CMDS_PER_PAGE; int numPages = commands.size() / CMDS_PER_PAGE;
if (commands.size() % CMDS_PER_PAGE != 0) { if (commands.size() % CMDS_PER_PAGE != 0) {