When an NPC is spawned its CraftPlayer is given the "NPC" Metadata. When a real CraftPlayer instance (actual player) is checked for the 'NPC' metadata, and an NPC has the name of the player, then it returns true. This is due to the way Player metadata is stored, it's stored 'name:key', this is a rather big issue and can easily be prevented.
1) Override the NPCEntity's CraftPlayer PlayerMetadataStore to store by entity id or something.
2) when checking for isNPC, return entity instanceof NPCEntity
When an NPC is spawned its CraftPlayer is given the "NPC" Metadata. When a real CraftPlayer instance (actual player) is checked for the 'NPC' metadata, and an NPC has the name of the player, then it returns true. This is due to the way Player metadata is stored, it's stored 'name:key', this is a rather big issue and can easily be prevented.
1) Override the NPCEntity's CraftPlayer PlayerMetadataStore to store by entity id or something.
2) when checking for isNPC, return entity instanceof NPCEntity
I'd recommend the former.