Add check for Citizens NPC before teleporting it outside entry:deny region
LadyCailinBot opened this issue ยท 0 comments
WORLDGUARD-3749 - Reported by Iwitrag
Good day!
=About problem=
There is well known problem that leads to Citizens NPCs being teleported outside regions with entry:deny flag by WorldGuard.
Sadly, setting fake-player-build-override to true doesn't affect entry flag. This flag is used only to override build flag.
=Workaround=
Current only workaround is to add permission nodes to bypass WorldGuard checks to each NPC separately.
This is really not good workaround because of these reasons:
- Custom permissions can be added only to Citizens with legit Minecraft name (so no color codes are supported)
- Those bypass permission nodes will apply to players with the same Minecraft name too, which is serious security leak
- Permission nodes must be applied to each NPC separately - one by one, which is not really efficient.
=Solution suggestion=
--Solution is simple, all you need is to add NPC check when entity is about to be ported outside region with entry:deny.--
if (e.getPlayer().hasMetadata("NPC")) {
/* Don't teleport */
}
EDIT: did some research and suggested solution does not work - that's because Citizens NPC are assigned custom metadata with delay, which does not allow to check for them on server start.
My new suggestion would be to check for name beginning with [ and ending with ] - same like fake-player-build-override but for all teleports and movements.
This would totally fix this known issue.