i am making a plugin where i need an config file like this: Code: kits: kitname: armor: inventory: but i dont know how to do this can some one help me pleas?
You can take a look at how I make this config : Code:yml worlds: plotworld: PlotAutoLimit: 100 PathWidth: 7 PlotSize: 32 BottomBlockId: 7 WallBlockId: 44 PlotFloorBlockId: 2 PlotFillingBlockId: 3 RoadHeight: 64 DaysToExpiration: 7 ProtectedBlocks: - 54 - 61 - 62 - 120 - 94 - 93 - 84 - 25 - 355 - 118 - 117 PreventedItems: - '351:15' - '321' - '259' - '328' - '343' - '342' - '333'usemySQL: falsemySQLconn: jdbc:mysql://localhost:3306/minecraftmySQLuname: rootmySQLpass: password Using this code : Code:java File configfile = new File(configpath, "config.yml");FileConfiguration config = new YamlConfiguration(); try {config.load(configfile);} catch (FileNotFoundException e) { } catch (IOException e) {logger.severe(PREFIX + " can't read configuration file");e.printStackTrace();} catch (InvalidConfigurationException e) {logger.severe(PREFIX + " invalid configuration format");e.printStackTrace();} usemySQL = config.getBoolean("usemySQL", false);mySQLconn = config.getString("mySQLconn", "jdbc:mysql://localhost:3306/minecraft");mySQLuname = config.getString("mySQLuname", "root");mySQLpass = config.getString("mySQLpass", "password");AutoPlotLimit = config.getInt("AutoPlotLimit", 100); ConfigurationSection worlds; if(!config.contains("worlds")){worlds = config.createSection("worlds"); ConfigurationSection plotworld = worlds.createSection("plotworld"); plotworld.set("PlotAutoLimit", 100);plotworld.set("PathWidth", 7);plotworld.set("PlotSize", 32);plotworld.set("BottomBlockId", 7);plotworld.set("WallBlockId", 44);plotworld.set("PlotFloorBlockId", 2);plotworld.set("PlotFillingBlockId", 3);plotworld.set("RoadHeight", 64);plotworld.set("DaysToExpiration", 7);plotworld.set("ProtectedBlocks", getDefaultProtectedBlocks());plotworld.set("PreventedItems", getDefaultPreventedItems()); worlds.set("plotworld", plotworld);config.set("worlds", worlds);}else{worlds = config.getConfigurationSection("worlds");} plotmaps = new HashMap<String, PlotMapInfo>(); for(String worldname : worlds.getKeys(false)){PlotMapInfo tempPlotInfo = new PlotMapInfo();ConfigurationSection currworld = worlds.getConfigurationSection(worldname); tempPlotInfo.PlotAutoLimit = currworld.getInt("PlotAutoLimit", 100);tempPlotInfo.PathWidth = currworld.getInt("PathWidth", 7);tempPlotInfo.PlotSize = currworld.getInt("PlotSize", 32);tempPlotInfo.BottomBlockId = (byte) currworld.getInt("BottomBlockId", 7);tempPlotInfo.WallBlockId = (byte) currworld.getInt("WallBlockId", 44);tempPlotInfo.PlotFloorBlockId = (byte) currworld.getInt("PlotFloorBlockId", 2);tempPlotInfo.PlotFillingBlockId = (byte) currworld.getInt("PlotFillingBlockId", 3);tempPlotInfo.RoadHeight = currworld.getInt("RoadHeight", currworld.getInt("WorldHeight", 64));tempPlotInfo.DaysToExpiration = currworld.getInt("DaysToExpiration", 7); if(currworld.contains("ProtectedBlocks")){tempPlotInfo.protectedblocks = currworld.getLongList("ProtectedBlocks");}else{tempPlotInfo.protectedblocks = getDefaultProtectedBlocks();} if(currworld.contains("PreventedItems")){tempPlotInfo.preventeditems = currworld.getStringList("PreventedItems");}else{tempPlotInfo.preventeditems = getDefaultPreventedItems();} if(tempPlotInfo.RoadHeight > 250){logger.severe(PREFIX + " RoadHeight above 250 is unsafe. This is the height at which your road is located. Setting it to 64.");tempPlotInfo.RoadHeight = 64;} currworld.set("PlotAutoLimit", tempPlotInfo.PlotAutoLimit);currworld.set("PathWidth", tempPlotInfo.PathWidth);currworld.set("PlotSize", tempPlotInfo.PlotSize);currworld.set("BottomBlockId", tempPlotInfo.BottomBlockId);currworld.set("WallBlockId", tempPlotInfo.WallBlockId);currworld.set("PlotFloorBlockId", tempPlotInfo.PlotFloorBlockId);currworld.set("PlotFillingBlockId", tempPlotInfo.PlotFillingBlockId);currworld.set("RoadHeight", tempPlotInfo.RoadHeight);currworld.set("WorldHeight", null);currworld.set("DaysToExpiration", tempPlotInfo.DaysToExpiration);currworld.set("ProtectedBlocks", tempPlotInfo.protectedblocks);currworld.set("PreventedItems", tempPlotInfo.preventeditems); tempPlotInfo.plots = SqlManager.getPlots(worldname.toLowerCase()); plotmaps.put(worldname.toLowerCase(), tempPlotInfo);} config.set("usemySQL", usemySQL);config.set("mySQLconn", mySQLconn);config.set("mySQLuname", mySQLuname);config.set("mySQLpass", mySQLpass); try { config.save(configfile);} catch (IOException e) { logger.severe(PREFIX + " error writting configurations"); e.printStackTrace();} Adding a new post because if I edit the previous one it'll break the config file indentation. P.S. "configpath" is : configpath = getDataFolder().getAbsolutePath(); EDIT by Moderator: merged posts, please use the edit button instead of double posting.