Solved Save hashmap on plugin disable and load hashmap on plugin enable?

Discussion in 'Plugin Development' started by MasterDoctor, Oct 23, 2014.

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


    The title pretty much sums it up...
  2. Offline


  3. Offline


    Not much, My eclipse has screwed up and no longer suggests the next bit. like if you type "config." normally a box pops up with what you can type. But that doesn't work

    The box doesn't pop up! mythbusterma

    mythbusterma I fixed that problem, let me see if I can guess the code

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


    Hash maps already save..
  5. Offline


  6. Offline


    Who wants a cluttry file?
  7. Offline


    You could serialize and encode the HashMap.

    Take a look at this for making Locations Serializable.
    And then look at ObjectOutputStream to see how you can Serialize.
    I believe that Serialization makes a messy String so to be safe encode it with Base64..

    That's what i would do at least.
  8. Offline


    MasterDoctor Bukkit API provides implementation for this. Bukkit Configuration API. Check out the sections on HashMaps: #1 and especially #2.

    Please remember that a lot of us are hesitant and/or reluctant to help out if it looks like you have done little work to solve your own problem. Try adding code or things you've already tried in your next post.
  9. MasterDoctor do you have always the same classes for key and value? Because if you have, you can create a .cfg file, write your content int it like key | value and seperate the single entrys with linebreaks. This is how you save it, how to read and split it you should know :) Also you could create 2 files like value.cfg and key.cfg and seperate them like this, but thats your decision. If the classes in your hashmap are changing, you are able to do this, but you've to save the different types in different files or mark them with an annotation in the file. this could become much work. The only situation in which this wont work is if you got a HashMap<?, ?> with unknown types. Then you could cast to object but this wont do very much :D

    Did i help you?
  10. Offline


Thread Status:
Not open for further replies.

Share This Page