[SOLVED] Saving Hashmaps

Discussion in 'Plugin Development' started by ThatBox, Dec 14, 2011.

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

    ThatBox

    How would i save a hashmap?
    How would i load a hashmap?

    I've seen the HUGE plugin tutorial but i hear there is a way to do it with Bukkit's FileConfiguration object. How would i do so? Sorry i'm kind of a n00b at this.
     
  2. Offline

    wwsean08

    it depends, what is your hashmap going to contain?
     
  3. Offline

    ThatBox

    Got 2.
    <String, String>
    and <Integer,String>
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    @ThatBox
    You can store Hash Maps parameterized <String, Object>
    by using the createSection(Hashmap<String,Object> map) method for your favorite YamlConfiguration object
     
  5. Offline

    halley

    What kinds of integers are put into your Map<Integer,String>? If the integers are all in a tight range like 0-50, you should just use a plain old array. No need to do myMap.get(Integer.valueOf(5)) when myArray[5] is right there in front of your nose. (If you just say myMap.get(5), then Java's compiler will turn that into the cumbersome myMap.get(Integer.valueOf(5)) for you.)
     
    ThatBox likes this.
  6. Offline

    ThatBox

    Thanks.
    I still don't undrstand. Sorry i'm not good at this file-saving stuff.
     
  7. Offline

    Sagacious_Zed Bukkit Docs

    @ThatBox
    Instead of normally invoking the set method of FileConfiguration, you have to invoke the createSection method
     
  8. Offline

    ThatBox

    Ahhhh i see.
    so like:
    Code:java
    1. getConfig().createSection(HashMap<String,Object> myHashMap);

    And anothere question how would i load it?
     
  9. Offline

    Sagacious_Zed Bukkit Docs

    @ThatBox
    There is a getSection Method, but it does not give you back a hashMap. you will need to read the key value pairs off yourself.
     
  10. Offline

    ThatBox

    Well i think thats good enough thanks for all the help. :)
     
Thread Status:
Not open for further replies.

Share This Page