Solved Can't update signs

Discussion in 'Plugin Development' started by keywc, Nov 10, 2013.

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

    keywc

    I've been trying this for weeks now, and it doesn't work.

    Code:java
    1.  
    2. private void updateSign(Location loc)
    3. {
    4. Sign sign = (Sign) loc.getBlock().getState();
    5.  
    6. World targetWorld = plugin.getServer().getWorld(sign.getLine(1));
    7. if(targetWorld == null)
    8. {
    9. sign.setLine(1, ChatColor.DARK_RED + sign.getLine(1));
    10. sign.setLine(2, ChatColor.BLACK + ("0 / 8"));
    11. }
    12. else
    13. {
    14. sign.setLine(1, ChatColor.DARK_GREEN + sign.getLine(1));
    15. sign.setLine(2, ChatColor.BLACK + (targetWorld.getPlayers().size() + " / 8"));
    16. }
    17.  
    18. sign.setLine(0, "");
    19. sign.setLine(3, "");
    20.  
    21. sign.update();
    22. }


    The sign only updates when the location is sent from a database, but not from signchangeevent (event.getBlock().getLocation()).
    How can I fix this ?
     
  2. "signchangeevent"

    I guess you did get the sign in the event, you cancelled the event, and you also used your void right?
     
    keywc likes this.
  3. Offline

    keywc

    I didn't think about cancelling the event, thanks :)
     
    DreTaX likes this.
  4. Alright, also make sure to register your events.
     
Thread Status:
Not open for further replies.

Share This Page