This commit is contained in:
fullwall 2012-10-26 13:47:33 +08:00
parent 66f3ce1a0e
commit dc8ff67001
2 changed files with 4 additions and 4 deletions

View File

@ -671,8 +671,9 @@ public class NPCCommands {
else if (args.hasFlag('r'))
remove = true;
npc.data().setPersistent("removefromplayerlist", remove);
NMS.addOrRemoveFromPlayerList(npc.getBukkitEntity(), remove);
Messaging.sendTr(sender, remove ? Messages.ADDED_TO_PLAYERLIST : Messages.REMOVED_FROM_PLAYERLIST,
if (npc.isSpawned())
NMS.addOrRemoveFromPlayerList(npc.getBukkitEntity(), remove);
Messaging.sendTr(sender, remove ? Messages.REMOVED_FROM_PLAYERLIST : Messages.ADDED_TO_PLAYERLIST,
npc.getName());
}

View File

@ -12,7 +12,6 @@ import net.minecraft.server.DamageSource;
import net.minecraft.server.Entity;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityMonster;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityTypes;
import net.minecraft.server.MobEffectList;
import net.minecraft.server.Navigation;
@ -50,7 +49,7 @@ public class NMS {
public static void addOrRemoveFromPlayerList(LivingEntity bukkitEntity, boolean remove) {
EntityLiving handle = ((CraftLivingEntity) bukkitEntity).getHandle();
if (handle.world == null || !(handle instanceof EntityPlayer))
if (handle.world == null)
return;
if (remove)
handle.world.players.remove(handle);