Merge branch 'master' of github.com:CitizensDev/Citizens2

This commit is contained in:
fullwall 2014-06-27 14:16:51 -07:00
commit 33b224a882

View File

@ -1045,21 +1045,37 @@ public class NPCCommands {
@Command(
aliases = { "npc" },
usage = "remove|rem (all)",
usage = "remove|rem (all|id|name)",
desc = "Remove a NPC",
modifiers = { "remove", "rem" },
min = 1,
max = 2)
@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.getString(1).equalsIgnoreCase("all"))
throw new CommandException(Messages.REMOVE_INCORRECT_SYNTAX);
if (!sender.hasPermission("citizens.admin.remove.all") && !sender.hasPermission("citizens.admin"))
throw new NoPermissionsException();
npcRegistry.deregisterAll();
Messaging.sendTr(sender, Messages.REMOVED_ALL_NPCS);
return;
if (args.getString(1).equalsIgnoreCase("all")) {
if (!sender.hasPermission("citizens.admin.remove.all") && !sender.hasPermission("citizens.admin"))
throw new NoPermissionsException();
npcRegistry.deregisterAll();
Messaging.sendTr(sender, Messages.REMOVED_ALL_NPCS);
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)
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
@ -1247,7 +1263,7 @@ public class NPCCommands {
trait.describe(sender);
return;
}
int size = Math.max(1, args.getInteger(1));
int size = Math.max(-2, args.getInteger(1));
trait.setSize(size);
Messaging.sendTr(sender, Messages.SIZE_SET, npc.getName(), size);
}