Posted December 28, 201410 yr Hello! Could someone please explain me how to use (add/remove strings) arraylist<string> in configurations? This is my current ConfigurationHandler class: package com.creepysheep.magnet.handler; import com.creepysheep.magnet.reference.Reference; import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.common.config.Configuration; import java.io.File; import java.util.ArrayList; public class ConfigurationHandler { public static Configuration configuration; public static boolean isEnabled; public static ArrayList<String> itemsDisabled = new ArrayList<String>(); public static void init(File configFile) { // Create the configuration object from the given configuration file if (configuration == null) { configuration = new Configuration(configFile); loadConfiguration(); } } @SubscribeEvent public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) { if (event.modID.equalsIgnoreCase(Reference.MOD_ID)) { loadConfiguration(); } } private static void loadConfiguration() { isEnabled = configuration.getBoolean("isEnabled", Configuration.CATEGORY_GENERAL, true, null); //itemsDisabled = configuration.getStringList("itemsDisabled", Configuration.CATEGORY_GENERAL, [{"test1"}], null; if (configuration.hasChanged()) { configuration.save(); } } } Also, is there a way to change the config entry with Gui Button? Thanks in advance, TheCreepySheep
December 28, 201410 yr Author getStringList will work fine, it will give you a String[]. Could you please specify how to provide the String[] string parameter?
December 28, 201410 yr Author String[] values = config.getStringList("name", "category", new String[] { "these", "are", "the", "default", "values" }, "comment"); Basic Java. Thank you. I've been coding all day. Sorry about that simple mistake.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.