Solved Signs not updating

Discussion in 'Plugin Development' started by exload, Nov 25, 2013.

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

    exload

    As the title says my signs are not updating!

    Here is the code:
    Code:java
    1. public final void updateSign()
    2. {
    3. clearSign();
    4. this.setLine(0, ChatColor.BOLD+ArenaManager.getArenaSettings(map).getType());
    5.  
    6. this.setLine(2, arenaName.split("_")[1]);
    7. if(!ArenaManager.isArenaRunning(arenaName))
    8. {
    9. this.setLine(1, ChatColor.RED+WordUtils.capitalize(map));
    10. this.setLine(3, "");
    11. }else
    12. {
    13. this.setLine(1, ChatColor.GREEN+WordUtils.capitalize(map));
    14. Arena arena = ArenaManager.getArena(arenaName);
    15. int playersInArena;
    16. if(ArenaPlayerManager.getPlayersInArena(arenaName) == null)
    17. {
    18. playersInArena = 0;
    19. }else
    20. {
    21. playersInArena = ArenaPlayerManager.getPlayersInArena(arenaName).size();
    22. }
    23. System.out.println(playersInArena+" =====");
    24. int maxPlayers = arena.getSettings().getMaxPlayers();
    25. this.setLine(3, playersInArena+"/"+maxPlayers);
    26. }
    27. update();
    28. }


    This method is called when a player quits and joins an arena. And yes, it is actually called. For example, I will join an arena and the sign might read "1/5" after I join. If I quit the sign will still read "1/5" even though the variable 'playersInArena' is equal to 0.

    I have read that this could be due the SignChangeEvent being called after the sign.update() method so I made a listener and that event is not called at all when I call the sign.update().

    Figured it out. For whatever reason Bukkit does not want to update the sign during the same tick as when I set the lines on the sign. I just delayed the update() call 1 tick and it now works perfectly.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  2. Offline

    exload

    I take it back. That only partially solved my problem. The signs still won't update properly. I am having the exact same issue as before only it won't change a line to a certain color and line 3 won't clear. Does a player have to be in the world for them to actually update?
     
  3. Offline

    calebbfmv

    Just keep the chunk loaded and there shouldn't be a problem
     
  4. Offline

    exload

    calebbfmv I now load the chunk before I do anything with the sign yet it still does not update the sign. Also I have double verified and all values are correctly being given to the sign its just that the sign is not updating.
     
  5. Offline

    calebbfmv

    What I would do is cast a Sign parameter in this, then on checking the SignChangeEvent, call the event after all necessary checks.
     
  6. Offline

    exload

    calebbfmv I have a listener for the SignChangeEvent, however, that event is never called throughout this process. And yes, the event is registered.
     
  7. Offline

    calebbfmv

    exload
    Sorry went out shopping wit my family:
    Could you post your whole Listener class?
     
  8. Offline

    exload

    calebbfmv Figured it out. Stupid mistake. A new sign object is created every time a chunk is loaded/unloaded.
     
  9. Offline

    calebbfmv

Thread Status:
Not open for further replies.

Share This Page