What is the best approach to remove signs with data on restarts?

Discussion in 'Spigot Plugin Development' started by SuperMonis, Jul 26, 2018.

  1. SuperMonis

    Supporter

    As part of a minigame feature we have 100+ signs spread across a world with [Role] on the top line, these signs have various stats on them such as the amount of players who are occupying a role and the number updates whenever someone leaves the network, removes their role or when more players occupy the role.

    [​IMG]

    The problem is that on server restart the number on the sign does not reset since chunks are unloaded. We want to remove all of these signs on server restarts but aren't sure of the best approach. We can't just reset the world, as this is part of a creative server.

    The only idea we have at the moment is to store the location of all these signs in a config file when created, and check this config file on startup or on a timer. On startup we'd have to load all the chunks containing each sign, so this doesn't seem scalable, and so the timer seems like the best option.

    Any thoughts about this? Perhaps there's an approach we haven't thought of where we don't need to store the location in a config file? Looking for an optimised solution as my server generally has around 500+ players.
     
  2. Maybe use a ChunkUnloadEvent and check if a sign is in that chunk? I don't really see an option where you don't store the sign locations. A timer sounds more efficient in the long run, but you could probably work up something easy and unoptimized onDisable.