mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-27 05:05:20 +01:00
Merge branch 'master' of github.com:CitizensDev/Citizens2
This commit is contained in:
commit
33b224a882
@ -1045,21 +1045,37 @@ public class NPCCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "remove|rem (all)",
|
usage = "remove|rem (all|id|name)",
|
||||||
desc = "Remove a NPC",
|
desc = "Remove a NPC",
|
||||||
modifiers = { "remove", "rem" },
|
modifiers = { "remove", "rem" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2)
|
max = 2)
|
||||||
@Requirements
|
@Requirements
|
||||||
public void remove(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
|
||||||
if (args.argsLength() == 2) {
|
if (args.argsLength() == 2) {
|
||||||
if (!args.getString(1).equalsIgnoreCase("all"))
|
if (args.getString(1).equalsIgnoreCase("all")) {
|
||||||
throw new CommandException(Messages.REMOVE_INCORRECT_SYNTAX);
|
if (!sender.hasPermission("citizens.admin.remove.all") && !sender.hasPermission("citizens.admin"))
|
||||||
if (!sender.hasPermission("citizens.admin.remove.all") && !sender.hasPermission("citizens.admin"))
|
throw new NoPermissionsException();
|
||||||
throw new NoPermissionsException();
|
npcRegistry.deregisterAll();
|
||||||
npcRegistry.deregisterAll();
|
Messaging.sendTr(sender, Messages.REMOVED_ALL_NPCS);
|
||||||
Messaging.sendTr(sender, Messages.REMOVED_ALL_NPCS);
|
return;
|
||||||
return;
|
} else {
|
||||||
|
NPCCommandSelector.Callback callback = new NPCCommandSelector.Callback() {
|
||||||
|
@Override
|
||||||
|
public void run(NPC npc) throws CommandException {
|
||||||
|
if (npc == null)
|
||||||
|
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
|
||||||
|
if (!(sender instanceof ConsoleCommandSender) && !npc.getTrait(Owner.class).isOwnedBy(sender))
|
||||||
|
throw new CommandException(Messages.COMMAND_MUST_BE_OWNER);
|
||||||
|
if (!sender.hasPermission("citizens.npc.remove") && !sender.hasPermission("citizens.admin"))
|
||||||
|
throw new NoPermissionsException();
|
||||||
|
npc.destroy();
|
||||||
|
Messaging.sendTr(sender, Messages.NPC_REMOVED, npc.getName());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NPCCommandSelector.startWithCallback(callback, npcRegistry, sender, args, args.getString(1));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
|
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
|
||||||
@ -1247,7 +1263,7 @@ public class NPCCommands {
|
|||||||
trait.describe(sender);
|
trait.describe(sender);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int size = Math.max(1, args.getInteger(1));
|
int size = Math.max(-2, args.getInteger(1));
|
||||||
trait.setSize(size);
|
trait.setSize(size);
|
||||||
Messaging.sendTr(sender, Messages.SIZE_SET, npc.getName(), size);
|
Messaging.sendTr(sender, Messages.SIZE_SET, npc.getName(), size);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user