Double check that a Player is not an NPC when loading profiles

This commit is contained in:
nossr50
2019-06-17 07:00:39 -07:00
parent 73ce7e729c
commit 218b2a1a75
8 changed files with 29 additions and 21 deletions

View File

@ -39,13 +39,20 @@ public final class Misc {
private Misc() {};
public static boolean isNPCEntity(Entity entity) {
public static boolean isNPCEntityExcludingVillagers(Entity entity) {
return (entity == null
|| (entity.hasMetadata("NPC") && !(entity instanceof Villager))
|| (entity instanceof NPC && !(entity instanceof Villager))
|| entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
}
public static boolean isNPCIncludingVillagers(Player entity) {
return (entity == null
|| (entity.hasMetadata("NPC"))
|| (entity instanceof NPC)
|| entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
}
/**
* Determine if two locations are near each other.
*