Solved Saving sign into a list

Discussion in 'Plugin Development' started by tkuiyeager1, Jul 7, 2018.

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

    tkuiyeager1

    Hello everyone,
    I am trying to save a sign to a list and then from the main class change it's first line every 1 second to the amount of online players.

    Creating the list:
    Code:
    public static List<Sign> signList = new ArrayList<>();
    Adding the sign to the list - used getState() because I get error if only just using getBlock():
    Code:
    Listeners.signList.add((Sign) e.getBlock().getState());
    The repeating task in onEnable function:
    Code:
    Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    Bukkit.getServer().broadcastMessage("loop is working!");
                    for (int i = 0; i < Listeners.signList.size(); i++) {
                        Listeners.signList.get(i).setLine(0, String.valueOf(Bukkit.getServer().getOnlinePlayers().size()));
                    }
                }
            }, 0L, 20L);
    The problem is that the sign doesn't change, I get no errors in the console, anyone knows where is the problem?
     
  2. @tkuiyeager1
    from the sign call the method update(true);
     
  3. Offline

    tkuiyeager1

    what do you mean?
     
  4. @tkuiyeager1

    Listeners.signList.get(i).update(true);
    put that after you set the line
     
  5. Offline

    tkuiyeager1

    Thanks, it worked!
    Also, I am trying to think of a way that the sign will be updated although server reloads or restarts, meaning I have to save it in a config because the list resets when plugin restarts, do you have anything better than saveing the coordinates of the sign?

    EDIT:
    By the way now the sign is unbreakable, what to do?
     
  6. @tkuiyeager1
    Im not sure of anything besides saving the coords, and im not sure why its unbreakable, i don't know what would effect that, maybe when you break the sign make an event and remove it from the list so it stops updating that sign
     
  7. Offline

    tkuiyeager1

    Thanks, do you know how to do that each player sees something different on a sign?
     
  8. Online

    timtower Administrator Administrator Moderator

  9. Offline

    tkuiyeager1

  10. Online

    timtower Administrator Administrator Moderator

    @tkuiyeager1 Depends, multiple signs per player or just one?
     
  11. Offline

    tkuiyeager1

    Nevermind, I will try to fix things up, thanks for all the help.
     
Thread Status:
Not open for further replies.

Share This Page