mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Add some basic permissions checks
This commit is contained in:
parent
d241cdb370
commit
20423c0375
@ -422,6 +422,8 @@ public class NPCCommands {
|
||||
} else if (action.equalsIgnoreCase("add")) {
|
||||
if (args.argsLength() == 2)
|
||||
throw new CommandUsageException();
|
||||
if (args.hasFlag('o') && !sender.hasPermission("citizens.admin"))
|
||||
throw new NoPermissionsException();
|
||||
String command = args.getJoinedStrings(2);
|
||||
CommandTrait.Hand hand = args.hasFlag('l') && args.hasFlag('r') ? CommandTrait.Hand.BOTH
|
||||
: args.hasFlag('l') ? CommandTrait.Hand.LEFT : CommandTrait.Hand.RIGHT;
|
||||
@ -452,6 +454,8 @@ public class NPCCommands {
|
||||
commands.removeCommandById(id);
|
||||
Messaging.sendTr(sender, Messages.COMMAND_REMOVED, id);
|
||||
} else if (action.equalsIgnoreCase("permissions") || action.equalsIgnoreCase("perms")) {
|
||||
if (!sender.hasPermission("citizens.admin"))
|
||||
throw new NoPermissionsException();
|
||||
List<String> temporaryPermissions = Arrays.asList(args.getSlice(2));
|
||||
commands.setTemporaryPermissions(temporaryPermissions);
|
||||
Messaging.sendTr(sender, Messages.COMMAND_TEMPORARY_PERMISSIONS_SET,
|
||||
@ -603,6 +607,7 @@ public class NPCCommands {
|
||||
Messaging.send(sender, "An in-memory registry has been created named [[" + name + "]].");
|
||||
}
|
||||
}
|
||||
|
||||
if (args.hasFlag('t')) {
|
||||
registry = temporaryRegistry;
|
||||
}
|
||||
@ -646,6 +651,8 @@ public class NPCCommands {
|
||||
}
|
||||
|
||||
if (at != null) {
|
||||
if (!sender.hasPermission("citizens.npc.create-at-location"))
|
||||
throw new NoPermissionsException();
|
||||
spawnLoc = at;
|
||||
spawnLoc.getChunk().load();
|
||||
}
|
||||
|
@ -55,10 +55,12 @@ public class TraitCommands {
|
||||
addTrait(npc, clazz, sender);
|
||||
added.add(StringHelper.wrap(traitName));
|
||||
}
|
||||
if (added.size() > 0)
|
||||
if (added.size() > 0) {
|
||||
Messaging.sendTr(sender, Messages.TRAITS_ADDED, Joiner.on(", ").join(added));
|
||||
if (failed.size() > 0)
|
||||
}
|
||||
if (failed.size() > 0) {
|
||||
Messaging.sendTr(sender, Messages.TRAITS_FAILED_TO_ADD, Joiner.on(", ").join(failed));
|
||||
}
|
||||
}
|
||||
|
||||
private void addTrait(NPC npc, Class<? extends Trait> clazz, CommandSender sender) {
|
||||
|
Loading…
Reference in New Issue
Block a user