I have a Java-based Bukkit plugin (fairly irrelevant to the issue at hand but noteworthy) that will, every 30 minutes, query a web API for updates to pass on to users.
Here is the existing method, which works fine to pass every user to the API:
public ApiMessenger()
{
TASK_ID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin,new Runnable()
{
@Override
public void run()
{
if(Bukkit.getOnlinePlayers().length > 0)
{
ApiMessenger.fetchPlayerItems(Bukkit.getOnlinePlayers(),true);
}
}
}, 20*60*30, 20*60*30);
}
However the API will accept, at most, 30 users at a time.
So any server using this plugin that has more than 30 users on at a time will not be able to submit all their users at once, because the rest will be ignored.
What I'm trying to figure out is what kind of setup would allow me to store all the users with some form of a timestamp so that the ApiMessenger method shown above can remember which users have been sent and attempt to send the ones who have been waiting the longest for an update first.
I can manage removing/adding users as they join/leave, but my main concern is first creating a sorted data structure that can be updated as the groups of 30 users are sent.
Unfortunately I don't know which data types in Java to use to create such a structure that can be iterated in an ascending fashion.