Solved Saving hashmaps to config?

Discussion in 'Plugin Development' started by webbhead, Jul 3, 2015.

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

    webbhead

    My problem is that the plugin won't save the HashMap onDisable, here is my code.
    Code:
        public void onDisable() {
            FileConfiguration fc = YamlConfiguration.loadConfiguration(f);
            fc.set("players", hs);
            try {
                fc.save(f);
            } catch (IOException e) {
                e.printStackTrace();
            }
            plugin = null;
        }
    
    I want it to save like:

    Code:
    players:
      <name>: <num>
      <name>: <num>
    The names and numbers being what is in the hashmap.

    Note: It doesn't throw any errors in console.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  2. Offline

    mythbusterma

    @webbhead

    Those meaningless variable names.....makes that extremely hard to read.

    HashMaps aren't automatically serialized. You have to iterate through the Map and set the values yourself.
     
  3. Offline

    webbhead

    Well, I already figured out it was: My QuitEvent but I don't know what it is in my QuitEvent.

    http://pastebin.com/1WgLA4dg
     
Thread Status:
Not open for further replies.

Share This Page