Change sign test (on event onPlayerHitSign)

Discussion in 'Plugin Development' started by D4RKKNIGH7, Jun 8, 2012.

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

    D4RKKNIGH7

    Hey,

    How do i change the text of a sign on the event "onPlayerHitSign"?

    The code i have so far is

    Code:
    if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                Player player = event.getPlayer();
                Block block = event.getClickedBlock();
    //WRITE NAME ON SIGN
                Sign sign = (Sign) block.getState();
                String pname = player.toString();
                sign.setLine(2, pname);
                player.sendMessage(ChatColor.GREEN + "You can now use the room");
    }
    
    No errors, but when I right click the sign in game line 3 doesnt change :(
     
  2. Offline

    Njol

    You have to update the sign for your changes to take effect:
    Code:
    sign.update(true);
     
    ferrybig likes this.
  3. Offline

    D4RKKNIGH7

    Solved, Cheers
     
Thread Status:
Not open for further replies.

Share This Page