change to selection, add /npc remove command for permanent removal

This commit is contained in:
aPunch 2012-02-17 22:53:28 -06:00
parent f82119f702
commit ee35f698f8
3 changed files with 20 additions and 3 deletions

View File

@ -90,9 +90,9 @@ public class EventListen implements Listener {
NPC npc = npcManager.getNPC(event.getEntity());
Player player = (Player) event.getTarget();
if (!npcManager.isNPCSelectedByPlayer(player, npc)) {
if (player.hasPermission("citizens.npc.select")
&& player.getItemInHand().getTypeId() == Setting.SELECTION_ITEM.asInt()
&& npc.getTrait(Owner.class).getOwner().equals(player.getName())) {
if (player.getItemInHand().getTypeId() == Setting.SELECTION_ITEM.asInt()
&& (npc.getTrait(Owner.class).getOwner().equals(player.getName()) || player
.hasPermission("citizens.npc.override-selection"))) {
npcManager.selectNPC(player, npc);
Messaging.sendWithNPC(player, Setting.SELECTION_MESSAGE.asString(), npc);
if (!Setting.QUICK_SELECT.asBoolean())

View File

@ -108,6 +108,20 @@ public class NPCCommands {
npc.despawn();
Messaging.send(player, ChatColor.GREEN + "You despawned " + StringHelper.wrap(npc.getName()) + ".");
}
@Command(
aliases = { "npc" },
usage = "remove",
desc = "Remove an NPC",
modifiers = { "remove" },
min = 1,
max = 1,
permission = "npc.remove")
public void removeNPC(CommandContext args, Player player, NPC npc) {
npc.remove();
Messaging.send(player,
ChatColor.GREEN + "You permanently removed " + StringHelper.wrap(npc.getName()) + ".");
}
@Command(
aliases = { "npc" },

View File

@ -1,5 +1,6 @@
package net.citizensnpcs.npc;
import net.citizensnpcs.Citizens;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.event.NPCDespawnEvent;
import net.citizensnpcs.api.event.NPCSpawnEvent;
@ -76,6 +77,8 @@ public abstract class CitizensNPC extends AbstractNPC {
if (isSpawned())
despawn();
manager.remove(this);
((Citizens) Bukkit.getServer().getPluginManager().getPlugin("Citizens")).getStorage().getKey("npc").removeKey(
String.valueOf(getId()));
}
@Override