Hello! I'm making a eggwars plugin and I register all the generators in its map config file. I don't know why It's not working, I did this code many times. When I register the first generator, it Works perfectly but, when It's number 2 or higher, overwrites the other generator. I have this code: Code (Java): List<String> generators = config.getStringList("Generators.list"); if(generators.contains(name)) { sender.sendMessage(chatprefix + ChatAPI.cc("&c¡El generador " + name + " ya existe en el mapa " + args[1] + "!")); } else { generators.add(name); config.set("Generators.list", generators); config.set("Generators.list." + name + ".loc", loc); config.set("Generators.list." + name + ".type", type); config.set("Generators.list." + name + ".level", level); config.set("Generators.list." + name + ".sign", sign); try { config.save(map.getConfig()); } catch (IOException e) { e.printStackTrace(); } } I don't know why it's overwriting the other one, anybody knows how to register 2 or more objects in a config list? Thanks!!
if you want to add a generator into the config, you do not need to load a list. simply check if "Generators.list." + name" exist or not. Code (Java): if(config.contains("Generators.list." + name)) { sender.sendMessage(chatprefix + ChatAPI.cc("&c¡El generador " + name + " ya existe en el mapa " + args[1] + "!")); } else { config.set("Generators.list." + name + ".loc", loc); config.set("Generators.list." + name + ".type", type); config.set("Generators.list." + name + ".level", level); config.set("Generators.list." + name + ".sign", sign); try { config.save(map.getConfig()); } catch (IOException e) { e.printStackTrace(); } }