mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Add specific permissions to /npc controllable
This commit is contained in:
parent
e03a6814c6
commit
d2815fe805
@ -101,6 +101,10 @@ public class CommandContext {
|
||||
this.args = copied.toArray(new String[copied.size()]);
|
||||
}
|
||||
|
||||
public CommandContext(String[] args) {
|
||||
this(null, args);
|
||||
}
|
||||
|
||||
public int argsLength() {
|
||||
return args.length - 1;
|
||||
}
|
||||
@ -193,7 +197,7 @@ public class CommandContext {
|
||||
}
|
||||
|
||||
public Location getSenderLocation() {
|
||||
if (location != null)
|
||||
if (location != null || sender == null)
|
||||
return location;
|
||||
if (sender instanceof Player)
|
||||
location = ((Player) sender).getLocation();
|
||||
|
@ -210,9 +210,12 @@ public class NPCCommands {
|
||||
modifiers = { "controllable", "control" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
flags = "f",
|
||||
permission = "npc.controllable")
|
||||
public void controllable(CommandContext args, CommandSender sender, NPC npc) {
|
||||
flags = "f")
|
||||
public void controllable(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
if ((npc.isSpawned() && !sender.hasPermission("citizens.npc.controllable."
|
||||
+ npc.getBukkitEntity().getType().toString().toLowerCase()))
|
||||
|| !sender.hasPermission("citizens.npc.controllable"))
|
||||
throw new NoPermissionsException();
|
||||
Controllable trait = npc.getTrait(Controllable.class);
|
||||
boolean enabled = trait.toggle();
|
||||
String key = enabled ? Messages.CONTROLLABLE_SET : Messages.CONTROLLABLE_REMOVED;
|
||||
|
Loading…
Reference in New Issue
Block a user