[Help] Having issue with reading text on sign

Discussion in 'Plugin Development' started by LukesComputers, Oct 26, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    LukesComputers

    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent event) {
    3. Action action = event.getAction();
    4. if(action.equals(Action.RIGHT_CLICK_BLOCK)){
    5. Block b = event.getClickedBlock();
    6. if(b instanceof Sign){
    7. Sign sign = (Sign) b.getState();
    8.  
    9. for(String line: sign.getLines()){
    10. if(line.equalsIgnoreCase("t")){
    11. Bukkit.getServer().broadcastMessage("IT worked!");
    12. return;


    This should do: If a user clicks the sign it should broadcast "It Worked!". Please help me
     
  2. Offline

    HeroWorkbrine

    I think its
    Sign sign = (Sign) b;
    And not
    Sign sign = (Sign) b.getState();
     
  3. no it is b.getState(), but did you register your events?
     
  4. Offline

    nisovin

    You can't do b instanceof Sign, because a Block is never a Sign. Just check the Material instead.
     
Thread Status:
Not open for further replies.

Share This Page