Hey guys, usually you know the Plugin Citiziens. With the help of this plugin you can spawn fake NPC's. You've got an option where u can configurate things like sending messages when you are next to the NPC. But I dont know how to code that. I will sending a Message when im next to an NPC/an other player. I think you can do that with the PlayerMoveEvent but I dont know how to check if there's an NPC next to you. Hope you can help me
You could have a runnable running comparing the distanceSquared between every player and your NPC every now and then, I guess. No need for PlayerMoveEvent in this case. BTW - wow, I haven't been around for a while.
Not sure which part you want help with, but Citizens puts an "NPC" metadata tag on NPC entities so you can easily identify them.
I'm not sure if Citizens' NPC is considered an Entity (or if it's just a fake entity controlled by packets sent to client only), but there is an Entity#getNearbyEntities method. Like I said though, you probably should keep your NPCs stored in some form (HashSet for example) and compare their Location to the Locations of your players.
Well you have two choices - scan for nearby entities or scan a list of know NPC locations. Neither of these will be super efficient, so keep in mind that the PlayerMoveEvent is called a LOT!