command and permission fixes

This commit is contained in:
aPunch 2012-02-25 01:57:04 -06:00
parent 35dc3ce40a
commit d6dedc8858
3 changed files with 12 additions and 13 deletions

View File

@ -182,8 +182,7 @@ public class CommandManager {
// Returns whether a player has access to a command.
private boolean hasPermission(Method method, Player player) {
Command cmd = method.getAnnotation(Command.class);
if (cmd.permission().isEmpty() || hasPermission(player, cmd.permission())
|| hasPermission(player, "citizens.admin"))
if (cmd.permission().isEmpty() || hasPermission(player, cmd.permission()) || hasPermission(player, "admin"))
return true;
return false;

View File

@ -65,15 +65,13 @@ public class HelpCommands {
int startIndex = LINES_PER_PAGE * page - LINES_PER_PAGE;
int endIndex = page * LINES_PER_PAGE;
Messaging.send(
player,
StringHelper.wrapHeader("<e>"
+ (baseCommand.equalsIgnoreCase("npc") ? "NPC" : StringHelper.capitalize(baseCommand
.toLowerCase())) + " Help <f>" + page + "/" + pages));
Messaging.send(player, StringHelper.wrapHeader("<e>"
+ (baseCommand.equalsIgnoreCase("npc") ? "NPC" : StringHelper.capitalize(baseCommand.toLowerCase()))
+ " Help <f>" + page + "/" + pages));
if (lines.size() < endIndex)
endIndex = lines.size() - 1;
for (String line : lines.subList(startIndex, endIndex))
for (String line : lines.subList(startIndex, endIndex == -1 ? 0 : endIndex))
Messaging.send(player, line);
return true;
}
@ -83,10 +81,12 @@ public class HelpCommands {
Set<Command> cmds = new HashSet<Command>();
List<String> lines = new ArrayList<String>();
for (Command cmd : cmdManager.getCommands(baseCommand)) {
if (cmds.contains(cmd) || !player.hasPermission("citizens." + cmd.permission()))
if (cmds.contains(cmd)
|| (!player.hasPermission("citizens.admin") && !player
.hasPermission("citizens." + cmd.permission())))
continue;
lines.add(StringHelper.parseColors("<7>/<c>" + cmd.aliases()[0]
+ (cmd.usage().isEmpty() ? "" : " " + cmd.usage()) + " <7>- <e>" + cmd.desc()));
lines.add("<7>/<c>" + cmd.aliases()[0] + (cmd.usage().isEmpty() ? "" : " " + cmd.usage()) + " <7>- <e>"
+ cmd.desc());
if (cmd.modifiers().length > 1)
cmds.add(cmd);
}

View File

@ -116,7 +116,7 @@ public class NPCCommands {
@Requirements
public void removeNPC(CommandContext args, Player player, NPC npc) {
if (args.argsLength() == 2) {
if (!player.hasPermission("citizens.npc.remove.all")) {
if (!player.hasPermission("citizens.npc.remove.all") && !player.hasPermission("citizens.admin")) {
Messaging.sendError(player, "You don't have permission to execute that command.");
return;
}
@ -132,7 +132,7 @@ public class NPCCommands {
Messaging.sendError(player, "You must be the owner of this NPC to execute that command.");
return;
}
if (!player.hasPermission("citizens.npc.remove")) {
if (!player.hasPermission("citizens.npc.remove") && !player.hasPermission("citizens.admin")) {
Messaging.sendError(player, "You don't have permission to execute that command.");
return;
}