Alternative to ArrayLists for storing player data?

Discussion in 'Plugin Development' started by bbq, Jun 9, 2012.

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

    bbq

    I'm writing a plugin for protecting stuff. Basically it will have three main arrays:
    Players - used to store player data like claim points and the group they belong to (could I maybe integrate this into the existing player data?)
    Chunklets - This would be an array of protected chunklets along with information like permissions.
    Groups - This would be an array of groups, it would contain information about the group.

    Right now when an action occurs I loop through the array list in question. So for example when a player tries to create a group I loop through the groups arraylist, calling the "getName()" function for each one (and comparing the returned string to the new faction's name).

    Is there a better more CPU/RAM effective way of doing this. I noticed after I've added a couple of groups it takes a while to run through the ArrayList (only a second or so, but on a larger scale this would become noticeable).
     
  2. Offline

    Waterflames

  3. Yes, use a hashmap to store those stuff and use whatever you're searching for as the key and you can just use hashmap.get(key)... like players.get(playerName).

    And no I don't belive you can integrate anything in the existing Player stuff... there's something with metadata but that's complicated and has alot of stuff that can go wrong from what I've seen...
     
  4. Offline

    messageofdeath

Thread Status:
Not open for further replies.

Share This Page