Solved HashMap Load And Save

Discussion in 'Plugin Development' started by MrFrozen, Mar 2, 2015.

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

    MrFrozen

    Hey Bukkit,

    When the plugin disable I want to save my HashMap to a YML or a other file.
    And when the plugin will be enabled load the YML file or other file back into the HashMap.

    These are my HashMap,

    Code:
    public static HashMap<UUID, Boolean> PLAYER_IN_PB = new HashMap<UUID, Boolean>(); // PlayerBlock User Bind
        public static HashMap<UUID, Location> PLAYER_LO_PB = new HashMap<UUID, Location>(); // PlayerBlock location
     
  2. Offline

    teej107

  3. Offline

    mine-care

  4. Offline

    MrFrozen

    Oke Im gonna play around or search a other way cause it seems a bit difficult or I can find a alternative to HashMap that is easy to use and also work after restart.
     
  5. Offline

    mine-care

    @MrFrozen serialisation ibelive is the simplest way.
     
  6. Offline

    MajorSkillage

    for(Entry<UUID, Boolean> e : PLAYER_IN_PB.entrySet()){
    yourfile.set(e.getKey(), e.getValue());
    }
    Is how you would onEnable();
    not too sure how you would with onDisable(); using another file rather then config.yml :/
    And can't you just make a method
    public boolean isInPB(Location loc){
    if(the location is in a certain range from the location of the PB){
    return true;
    } else {
    return false
    }
    }
    Just a guess by your variable name.
     
  7. .toString()
     
  8. Offline

    mine-care

  9. Offline

    PreFiXAUT

  10. Code:java
    1.  
    2. config.set(uuid, value); //This wont work
    3. config.set(uuid.toString(), value);
    4.  
     
  11. Offline

    mine-care

    @MaTaMoR_ oh i see, you where refering to that :3
     
  12. Offline

    MrFrozen

    Problem Sovled!
     
Thread Status:
Not open for further replies.

Share This Page