Per Player YAML

Discussion in 'Plugin Development' started by rocket138, Dec 20, 2013.

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

    rocket138

    So, I'm trying to create a points system on my minigames server, where players get points for winning and can spend them and stuff.

    Basically, I want to save a yaml per player, so like: /MyPlugin/PlayersName/PlayersName.YML

    I have this HashMap:
    Code:java
    1. HashMap<OfflinePlayer, Integer> scores = new HashMap<OfflinePlayer, Integer>();

    (I'm aware that OfflinePlayer is a resource heavy thing to use as a key)

    And I want to have my plugin read the file of a player when they join (if it exists) and set their integer in the hashmap to their score, and I want it to save the YAML whenever they log off or when the plugin is disabled. I have read https://forums.bukkit.org/threads/bukkits-yaml-configuration-tutorial.42770/ but I just can't seem to soak it in at all, can somebody just give me a method or two that will point me in the right direction?
     
  2. Offline

    cfil360

    there is no point in creating a yaml file for every single player to only store points. Just create a list and have the players name and their score in 1 yaml file. Something like this.
    Code:
    Scores:
      Player1: 10
      Player2: 20
      Player3: 40
      Player4: 50
     
  3. Offline

    rocket138

    But if I had like 20,000 players get on the server over like 2 years, that YAML would take forever to load...
     
  4. Offline

    The_Doctor_123

    rocket138
    You should have a quarterly cleaning up. Meaning, go through all the contents of the YML. If the player hasn't logged in for 3 months, get rid of the entry.
     
  5. Offline

    cfil360

    rocket138 The_Doctor_123 is right just remove players from the file if they are inactive. Also do you know how much space 20,000 different yaml files would take up.
     
  6. Offline

    The_Doctor_123

    cfil360
    4 KB, minimum. So 256 players would be 1 MB.
     
  7. Offline

    rocket138

    Fair points, but should I have it save a players last login aswell? because it would be rather difficult to pay attention to every single player.
     
Thread Status:
Not open for further replies.

Share This Page