Allow /npc remove to be used by the server

This commit is contained in:
fullwall 2013-08-03 20:57:56 +08:00
parent d568dfb886
commit cfcd046d4e

View File

@ -895,17 +895,14 @@ public class NPCCommands {
Messaging.sendTr(sender, Messages.REMOVED_ALL_NPCS); Messaging.sendTr(sender, Messages.REMOVED_ALL_NPCS);
return; return;
} }
if (!(sender instanceof Player))
throw new CommandException(Messages.COMMAND_MUST_BE_INGAME);
Player player = (Player) sender;
if (npc == null) if (npc == null)
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED); throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
if (!npc.getTrait(Owner.class).isOwnedBy(player)) if (!npc.getTrait(Owner.class).isOwnedBy(sender))
throw new CommandException(Messages.COMMAND_MUST_BE_OWNER); throw new CommandException(Messages.COMMAND_MUST_BE_OWNER);
if (!player.hasPermission("citizens.npc.remove") && !player.hasPermission("citizens.admin")) if (!sender.hasPermission("citizens.npc.remove") && !sender.hasPermission("citizens.admin"))
throw new NoPermissionsException(); throw new NoPermissionsException();
npc.destroy(); npc.destroy();
Messaging.sendTr(player, Messages.NPC_REMOVED, npc.getName()); Messaging.sendTr(sender, Messages.NPC_REMOVED, npc.getName());
} }
@Command( @Command(