So I'm trying to create a list that looks like this: homes: hashmap key 1 hashmap key 2 hashmap key 3 hashmap key 3 hashmap key 3 This will be in a config file, but I went through a lot of the options for it and they all give NPE when trying to call/use it: Code:java FileConfiguration.createPath(HomesConfig, "homes"); for (Entry<String, Location> e:homes.entrySet()) { HomesConfig.set("homes."+e.getKey(), e.getValue()); }
You can't save locations like that since they are not serializable. You will have to write your own location class or save a String representation of a location so you can just create a new location with what you saved. Other than that, I offered a piece of code in the Resources section that can save HashMaps to configuration files. --> http://forums.bukkit.org/threads/res-intermediate-method-to-store-hash-maps-in-configurations.49347/ An example of your own location class would be like the following class: https://github.com/Pandemoneus/MobT...r/pandemoneus/mobTrigger/util/MTLocation.java
This is what I got actually: Code:java public FileConfiguration getHomesConfig() {if (HomesConfig == null) {File CMBhomesFile = new File(getDataFolder(), "homes.csv");Boolean cmb = this.getConfig().getBoolean("Commandbookhomes");if(cmb) {BufferedReader r = null;try {r = new BufferedReader(new FileReader(CMBhomesFile));} catch (FileNotFoundException e1) {logger.info("FileNotFoundExeption:");logger.info(e1.toString());e1.printStackTrace();}String q;try {while((q = r.readLine()) != null) {String[] info = q.split(",");Location l = new Location(null, 0, 0, 0, 0, 0); l.setWorld(Bukkit.getWorld(info[1].replaceAll("\"", "").trim()));l.setX(Double.parseDouble(info[3].replaceAll("\"", "").trim()));l.setY(Double.parseDouble(info[4].replaceAll("\"", "").trim()));l.setZ(Double.parseDouble(info[5].replaceAll("\"", "").trim()));l.setYaw(Float.parseFloat(info[6].replaceAll("\"", "").trim()));l.setPitch(Float.parseFloat(info[7].replaceAll("\"", "").trim())); homes.put(info[0].replaceAll("\"", "").trim(), l);//HomesConfig.set("homes", homes);FileConfiguration.createPath(HomesConfig, "homes");for (Entry<String, Location> e:homes.entrySet()) {HomesConfig.set("homes."+e.getKey(), e.getValue());}}} catch (NumberFormatException e) {logger.info("NumberFormatException: ");logger.info(e.toString());e.printStackTrace();} catch (IOException e) {logger.info("IOException: ");logger.info(e.toString());e.printStackTrace();}}reloadHomesConfig();}return HomesConfig;} So I have to create the Hashmapwriter like you and then call it?