Tuesday, 20 August 2013

Best way to store, sort, and compare data values?

Best way to store, sort, and compare data values?

NOTE: The API I'm dealing with is Bukkit's API, which is for creating
plugins for the game Minecraft.
I'm trying to find the easiest/best way to store a set of data values that
I must sort, then compare. Here is what i'm trying to do:
When a player joins, I need the time the player joined and the players
name (like a key and value), then I need a way to compare the values and
check all of the players time and see if the times are too "old". Then,
i'd delete a region through WorldGuard that they own.
For example, if 'Jim' joined at the system time of '10 milliseconds' (I
know it has been more than 10 milliseconds since January 1, 1970), then
his time was recorded. 'Jim' left, and didn't return for a while. In the
config, it says anyone who is gone for longer than '15 milliseconds' is to
have their region deleted. So, after 'Jim' is gone for '15 milliseconds',
the system time is now '25 milliseconds'. So, I have to run a method that
checks 'Jim's' time, and matches the time he joined with his name. Then
get the name, and delete his region.
I've tried HashMaps, but apparently you cannot sort them. I've tried
TreeMaps, but the sorting and comparing seems very complicated, even after
reading about it for a few days. So far, the raw storage has been in a YML
file, but I have also tried SQLite storage, but I'm still not sure on the
easiest/best way.
If you've read this far, thanks, and thanks for helping, AhellHound

No comments:

Post a Comment