mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-26 02:57:39 +01:00
command and permission fixes
This commit is contained in:
parent
100f256dcc
commit
c2491d2df0
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user