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