Get player from block


I’m working on a signs plugin and I want to enable PlaceholderAPI, but I don’t know how to get the player viewing the sign.


By “viewing the sign” do you mean a player who happens to be near a sign, or a player that clicks on a sign?

If you’re looking for when a player clicks a sign, listen for the InteractBlockEvent.
For finding players near a block, you can use getNearbyEntities on an Extent (world or chunk object).


I’m wanting it to be localized.
Don’t know if that’s the right word, but I’m looking for a way…for example…each player can see their own name on the sign.


Ah thats sending BlockState to player only

Player player;
player.sendBlockChange(Vector blockLoc, BlockState toshow);

Im not sure if TileEntity data is held in BlockState. But give it a try.


Currently I’m just setting SignData. Don’t know how I’d do it like that

I could probably just get players in a radius of it and send the change.
Will have to see if I can send SignData upon block change or something like that


I would check MoveEvent (Player) and if the signs location gets within that players view distance then send the change to that player.


Simon suggested using

Could I call that on the block?


Sure. The problem with that is it will only get the players close when called. So if another players comes along after you called it and before you call it again, the players would see the normal sign


Ok, so call getNearbyEntities on the player move event to get all the nearby signs?


GetNearbyEntities gets all Entities close to a location. What Simon was suggesting was if you wanted all the players near the sign. This was before we had a idea of what you wanted.

What I would suggest is on MoveEvent (Player) check the distance between the sign and the current players location. From there if it is 20 or so blocks or less, then send the block state change to that player to show there name on the sign.


Do I use a function to “get signs” in that radius, or keep the positions of the signs using the plugin in memory, and compare those


In “Future API” “Soon™” This would be covered by contextual data.

You would be able to define how the data looks per viewer, if I understand the idea of contextual data correctly.

For now, you will need to (ab)use packets.

Or sooner then coltextual data you could track player movements, and register all signs that get loaded in a R-Tree (if you want to be efficient) and track ‘active’ ones on player move, and send them the new data. But it would need to use the API added by the following OPEN ticket (, so make sure to comment stating your usecase, it helps us priortize which order to add API.