minecraft - How can I set/get a HashMap in a YAML configuration file? -


i making first bukkit plugin. programmatically create yaml file represents hashmap. how can set , data structure?

the hashmap parameters <signature, location>, signature class stores 4 integers, , location org.bukkit.location

i think yaml file this, not sure if structure best:

myplugin:     listofdata:         - signature: [1,2,3,4]    # unique set of 4 integers           location: [122,64,254]  # non-unique set of 3 integers         - signature: [4,2,1,2]           location: [91,62,101]         - signature: [3,3,1,3]           location: [190,64,321] 

signature can modified necessary, , can create wrapper location if necessary.

thanks!

this suggested solution. don't know if best way...:) may want consider yaml structure:

myplugin:     listofdata:         '[1,2,3,4]': '[122,64,254]'         '[4,2,1,2]': '[91,62,101]'         '[3,3,1,3]': '[190,64,321]'         anothersignature:anotherlocation         ... 

this let read "listofdata" in using normal technique reading hash map yamlconfiguration (see below).

you'll have treat incoming information file hashmap of <string, string> , translation (e.g. turn 122,64,254 location) need there.

for reading hashmap:

this.getconfig().getconfigurationsection("path.to.map").getvalues(false) 

for writing hashmap (saveconfig() still need called write disk):

this.getconfig().createsection("path.to.map", mymap) 

there's details , subtleties here, worth reading these (same page, different non-contiguous sections):

http://wiki.bukkit.org/configuration_api_reference#hashmaps http://wiki.bukkit.org/configuration_api_reference#hashmaps_2


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -