Make sure the action was a right click on a block. Then check if this block is a WALL_SIGN or a SIGN_POST, and if so, cast the block to a sign. Then you can do "mySign.getLines()" or mySign.getLine(linenumber). Line numbers are 0 to 3.
You would make sure that your are right clicking a block by using the PlayerInteractEvent.getAction(). The you would get the block that was clicked (PlayerInteractEvent.getClickedBlock()). Then check if the block is a sign by using... Code:java if(e.getClickedBlock().getState().getData() instanceof Sign) Then using the cast it to a Sing and use getLines(). Hope that helps
Code:java Sign s = (Sign) e.getClickedBlock().getState().getData(); Don't put e put the event name. and if your still getting errors post the code.
ERROR: org.bukkit.material.sign cannot be cast to org.bukkit.block.sign. Code: if (event.getClickedBlock().getType().equals(Material.WALL_SIGN)) { Sign sm = (Sign) event.getClickedBlock().getState().getData(); String l1 = sm.getLine(1); String l2 = sm.getLine(2); String l3 = sm.getLine(3); String l4 = sm.getLine(4);
Import the following path: org.bukkit.block.sign And as I said, the lines of the sign are indexed with 0 to 3 and not 1 to 4.