mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
change to selection, add /npc remove command for permanent removal
This commit is contained in:
parent
f82119f702
commit
ee35f698f8
@ -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())
|
||||
|
@ -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" },
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user