Don't look at invisible players in LookClose

This commit is contained in:
fullwall 2017-08-22 20:44:29 +08:00
parent 20306de9a3
commit 8bd543c035
2 changed files with 10 additions and 1 deletions

View File

@ -555,7 +555,14 @@ public class EventListen implements Listener {
} }
continue; continue;
} }
ids.remove(i--); try {
ids.remove(i--);
} catch (IndexOutOfBoundsException ex) {
// something caused toRespawn to get modified?
Messaging.debug("Some strange chunk loading happened while spawning", npc.getId(),
" - check all your NPCs in chunk [" + coord.x + "," + coord.z + "] are spawned");
break;
}
if (Messaging.isDebugging()) { if (Messaging.isDebugging()) {
Messaging.debug("Spawned id", npc.getId(), "due to chunk event at [" + coord.x + "," + coord.z + "]"); Messaging.debug("Spawned id", npc.getId(), "due to chunk event at [" + coord.x + "," + coord.z + "]");
} }

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.CitizensAPI;
@ -59,6 +60,7 @@ public class LookClose extends Trait implements Toggleable, CommandConfigurable
}); });
for (Entity entity : nearby) { for (Entity entity : nearby) {
if (entity.getType() != EntityType.PLAYER || ((Player) entity).getGameMode() == GameMode.SPECTATOR if (entity.getType() != EntityType.PLAYER || ((Player) entity).getGameMode() == GameMode.SPECTATOR
|| ((Player) entity).hasPotionEffect(PotionEffectType.INVISIBILITY)
|| entity.getLocation(CACHE_LOCATION).getWorld() != NPC_LOCATION.getWorld() || entity.getLocation(CACHE_LOCATION).getWorld() != NPC_LOCATION.getWorld()
|| CitizensAPI.getNPCRegistry().getNPC(entity) != null) || CitizensAPI.getNPCRegistry().getNPC(entity) != null)
continue; continue;