How can I load the hashMap? Note: The saving those work HashMap and List: Code (Text): public HashMap<String, ClanManager> Clans = new HashMap<String, ClanManager>(); List<String> ClansData = new ArrayList<String>(); Saving the HashMap: Code (Text): for (Entry<String, ClanManager> clanName : Clan.Clans.entrySet()) { String data = clanName.toString(); ClansData.add(data); }
Loop through the keys in the config, insert the key (as the key) to the hashmap and the value in the config (as the value) to the hashmap
I'm using this method But when I use your's or mine I still need the class in it... Code (Text): for(String Clans : getConfig().getStringList("Clans.yml")) { }
You're using .getStringList() wrong. You don't put the file name in the arguments, you put the name of the list. Code (Java): config.getStringList("Example Path"); Code (Text): Example Path: - Value 1 - Value 2 - Value 3
@C10sp The path I can fix but I still don't understand how I will add the values from the config to the current hashMap
Code (Java): // your map Map<UUID, GamePlayer> dataMap = new HashMap<>(); // a GSON instance final Gson gson = new Gson(); // save getConfig().set("my.map", gson.toJson(dataMap)); // load Map<UUID, GamePlayer> loadedData = gson.fromJson(getConfig().getString("my.map"), HashMap.class); Not getting simpler than this. Explanation: uses GSON (included JSON library from google in Spigot) to serialize the map and it content's and then read and map them back.
Please provide some actual useful information, like, what you tried and what isn't working. If you want us to look with you, for you, please at least give us the chance.