package com.khorn.terraincontrol.configuration.settingType;

import com.khorn.terraincontrol.exception.InvalidConfigException;
import com.khorn.terraincontrol.util.helpers.StringHelper;

import java.util.Arrays;
import java.util.List;

/**
 * Reads and writes a list of strings. Strings are read using
 * {@link StringHelper#readCommaSeperatedString(String)}, and written with a
 * ", " between each string.
 *
 */
class StringListSetting extends Setting<List<String>>
{
    private String[] defaultValue;

    StringListSetting(String name, String... defaultValue)
    {
        super(name);
        this.defaultValue = defaultValue;
    }

    @Override
    public List<String> getDefaultValue()
    {
        return Arrays.asList(defaultValue);
    }

    @Override
    public List<String> read(String string) throws InvalidConfigException
    {
        String[] split = StringHelper.readCommaSeperatedString(string);
        for (int i = 0; i < split.length; i++)
        {
            // Trimming the values allows "Value1, Value2" instead of
            // "Value1,Value2"
            split[i] = split[i];
        }
        return Arrays.asList(split);
    }

    @Override
    public String write(List<String> value)
    {
        return StringHelper.join(value, ", ");
    }

}

@@ -854,25 +854,29 @@
     
-String%5B%5D split = 
+return Arrays.asList(
 Stri
@@ -920,245 +920,8 @@
 ing)
-;%0A        for (int i = 0; i %3C split.length; i++)%0A        %7B%0A            // Trimming the values allows %22Value1, Value2%22 instead of%0A            // %22Value1,Value2%22%0A            split%5Bi%5D = split%5Bi%5D;%0A        %7D%0A        return Arrays.asList(split
 );%0A 

Remove some unneeded code, as StringHelper.readCommaSeperatedString already trims values