Jump to content

[1.7.10]How to use arrayList in configuration?


TheCreepySheep

Recommended Posts

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.