From bb36e8ea2710fcc42db48cfc1079f8fd08f20cc6 Mon Sep 17 00:00:00 2001 From: fullwall Date: Fri, 26 Oct 2012 15:28:48 +0800 Subject: [PATCH] Stuff --- src/main/java/net/citizensnpcs/EventListen.java | 3 +-- .../java/net/citizensnpcs/command/command/NPCCommands.java | 5 ++--- src/main/java/net/citizensnpcs/npc/CitizensNPC.java | 4 ++++ .../java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/citizensnpcs/EventListen.java b/src/main/java/net/citizensnpcs/EventListen.java index 64dd632cd..63ec67ef0 100644 --- a/src/main/java/net/citizensnpcs/EventListen.java +++ b/src/main/java/net/citizensnpcs/EventListen.java @@ -185,8 +185,7 @@ public class EventListen implements Listener { EntityPlayer handle = ((CraftPlayer) event.getPlayer()).getHandle(); if (!(handle instanceof EntityHumanNPC)) return; - if (Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean()) - ((CraftServer) Bukkit.getServer()).getHandle().players.remove(handle); + ((CraftServer) Bukkit.getServer()).getHandle().players.remove(handle); // on teleport, player NPCs are added to the server player list. this is // undesirable as player NPCs are not real players and confuse plugins. } diff --git a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java index 4f4954174..98d58988d 100644 --- a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java @@ -664,7 +664,7 @@ public class NPCCommands { permission = "npc.playerlist") @Requirements(types = EntityType.PLAYER) public void playerlist(CommandContext args, CommandSender sender, NPC npc) { - boolean remove = !npc.data().getPersistent("removefromplayerlist", + boolean remove = !npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean()); if (args.hasFlag('a')) remove = false; @@ -984,10 +984,9 @@ public class NPCCommands { if (args.hasFlag('t')) { npc.data().set(NPC.DEFAULT_PROTECTED_METADATA, vulnerable); } else { - vulnerable = !npc.data().getPersistent(NPC.DEFAULT_PROTECTED_METADATA, true); npc.data().setPersistent(NPC.DEFAULT_PROTECTED_METADATA, vulnerable); } - String key = vulnerable ? Messages.VULNERABLE_SET : Messages.VULNERABLE_STOPPED; + String key = vulnerable ? Messages.VULNERABLE_STOPPED : Messages.VULNERABLE_SET; Messaging.sendTr(sender, key, npc.getName()); } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/CitizensNPC.java b/src/main/java/net/citizensnpcs/npc/CitizensNPC.java index f5965c4b0..4526dd6f8 100644 --- a/src/main/java/net/citizensnpcs/npc/CitizensNPC.java +++ b/src/main/java/net/citizensnpcs/npc/CitizensNPC.java @@ -140,6 +140,10 @@ public abstract class CitizensNPC extends AbstractNPC { PersistenceLoader.save(trait, traitKey); removedTraits.remove(trait.getName()); } + removeTraitData(root); + } + + private void removeTraitData(DataKey root) { for (String name : removedTraits) { root.removeKey("traits." + name); } diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java index 5581de20b..3cffec4da 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java @@ -38,8 +38,8 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable { // set the head yaw in another tick - if done immediately, // minecraft will not update it. boolean removeFromPlayerList = Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean(); - NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList - || data().getPersistent("removefromplayerlist", removeFromPlayerList)); + NMS.addOrRemoveFromPlayerList(getBukkitEntity(), + removeFromPlayerList || data().get("removefromplayerlist", removeFromPlayerList)); } }, 5); handle.getBukkitEntity().setSleepingIgnored(true);