This commit is contained in:
fullwall 2012-10-26 15:28:48 +08:00
parent 798c713394
commit bb36e8ea27
4 changed files with 9 additions and 7 deletions

View File

@ -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.
}

View File

@ -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());
}
}

View File

@ -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);
}

View File

@ -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);