I am trying to get text on a sign as a string when the player clicks a sign. Following the new changes made in Minecraft which allow signs to be edited on both sides, many of the old methods for doing this have been depreciated. With the new signs, you first have to getSide() before reading the sign lines. Unfortunately, it doesn't seem that the PlayerInteract event offers a method for returning a SignSide, with the closest thing being a BlockFace.
My current code looks like this:
@EventHandler(ignoreCancelled = true)
void onPlayerInteract(PlayerInteractEvent event) {
//Check that the player clicked a block
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
//Check that the block is a sign
Block block = event.getClickedBlock();
if (block == null) {
return;
}
if (!(block.getState() instanceof Sign)) {
return;
}
//Here is where I need to get the clicked face of the sign, and return a given
//line on the sign as a String
}
If anyone could provide a bit more info on how this could be done, it would be much appreciated.