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