diff --git a/src/main/java/biomesoplenty/api/biome/BOPBiome.java b/src/main/java/biomesoplenty/api/biome/BOPBiome.java index 8b3c359c0..498ce0b13 100644 --- a/src/main/java/biomesoplenty/api/biome/BOPBiome.java +++ b/src/main/java/biomesoplenty/api/biome/BOPBiome.java @@ -16,8 +16,7 @@ import net.minecraftforge.common.BiomeManager.BiomeType; import biomesoplenty.api.biome.generation.GenerationManager; import biomesoplenty.api.biome.generation.GeneratorStage; import biomesoplenty.api.biome.generation.IGenerator; -import biomesoplenty.common.util.config.ConfigHelper; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; public class BOPBiome extends BiomeGenBase implements IExtendedBiome { @@ -36,7 +35,7 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome this.theBiomeDecorator.clayPerChunk = -999; } - public void configure(ConfigHelper conf) + public void configure(IConfigObj conf) { // Allow name to be overridden @@ -52,7 +51,7 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome this.waterColorMultiplier = conf.getInt("waterColorMultiplier", this.waterColorMultiplier); // Allow weights to be overridden - WrappedJsonObject confWeights = conf.getObject("weights"); + IConfigObj confWeights = conf.getObject("weights"); if (confWeights != null) { for (BiomeType type : BiomeType.values()) @@ -71,7 +70,7 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome } // Allow generators to be configured - WrappedJsonObject confGenerators = conf.getObject("generators"); + IConfigObj confGenerators = conf.getObject("generators"); if (confGenerators != null) { for (String name : confGenerators.getKeys()) diff --git a/src/main/java/biomesoplenty/api/biome/generation/GenerationManager.java b/src/main/java/biomesoplenty/api/biome/generation/GenerationManager.java index 0023fdeb5..3faebeb65 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/GenerationManager.java +++ b/src/main/java/biomesoplenty/api/biome/generation/GenerationManager.java @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import biomesoplenty.common.world.feature.*; import biomesoplenty.common.world.feature.tree.*; @@ -57,7 +57,7 @@ public class GenerationManager return this.generators.get(name); } - public void configureWith(String name, WrappedJsonObject conf) + public void configureWith(String name, IConfigObj conf) { if (this.generators.containsKey(name)) { @@ -88,10 +88,10 @@ public class GenerationManager { FLORA, DOUBLE_FLORA, GRASS, ORE_CLUSTER, ORE_SINGLE, WATERSIDE, BASIC_TREE, BIG_TREE, BUSH; - public static IGenerator create(WrappedJsonObject conf) + public static IGenerator create(IConfigObj conf) { - GeneratorStage stage = conf.getEnum("stage", null, GeneratorStage.class); - GeneratorFactory factory = conf.getEnum("type", null, GeneratorFactory.class); + GeneratorStage stage = conf.getEnum("stage", GeneratorStage.class); + GeneratorFactory factory = conf.getEnum("type", GeneratorFactory.class); if (stage == null || factory == null) {return null;} IGenerator generator = factory.create(); generator.setStage(stage); diff --git a/src/main/java/biomesoplenty/api/biome/generation/GeneratorCustomizable.java b/src/main/java/biomesoplenty/api/biome/generation/GeneratorCustomizable.java index c15d862f6..2f7306b10 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/GeneratorCustomizable.java +++ b/src/main/java/biomesoplenty/api/biome/generation/GeneratorCustomizable.java @@ -8,8 +8,9 @@ package biomesoplenty.api.biome.generation; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; +// TODO - scrap this? public abstract class GeneratorCustomizable implements IGenerator { private final String identifier; @@ -57,7 +58,7 @@ public abstract class GeneratorCustomizable implements IGenerator } @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { ; } diff --git a/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeighted.java b/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeighted.java index 49236f01c..b14909eeb 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeighted.java +++ b/src/main/java/biomesoplenty/api/biome/generation/GeneratorWeighted.java @@ -15,7 +15,7 @@ import java.util.Random; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import biomesoplenty.api.biome.generation.GenerationManager.GeneratorFactory; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; public class GeneratorWeighted extends GeneratorCustomizable { @@ -104,10 +104,10 @@ public class GeneratorWeighted extends GeneratorCustomizable @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { this.amountPerChunk = conf.getInt("amountPerChunk", this.amountPerChunk); - WrappedJsonObject confGenerators = conf.getObject("generators"); + IConfigObj confGenerators = conf.getObject("generators"); if (confGenerators != null) { for (String name : confGenerators.getKeys()) diff --git a/src/main/java/biomesoplenty/api/biome/generation/IGenerator.java b/src/main/java/biomesoplenty/api/biome/generation/IGenerator.java index cb0b23b74..321d13d56 100644 --- a/src/main/java/biomesoplenty/api/biome/generation/IGenerator.java +++ b/src/main/java/biomesoplenty/api/biome/generation/IGenerator.java @@ -10,9 +10,9 @@ package biomesoplenty.api.biome.generation; import java.util.Random; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; public interface IGenerator { @@ -30,5 +30,5 @@ public interface IGenerator public String getIdentifier(); public GeneratorStage getStage(); - public void configure(WrappedJsonObject conf); + public void configure(IConfigObj conf); } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenDenseForest.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenDenseForest.java index c51389a0a..044719e8b 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenDenseForest.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenDenseForest.java @@ -18,7 +18,7 @@ import biomesoplenty.common.block.BlockBOPPlant; import biomesoplenty.common.block.BlockGem; import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPPlants; -import biomesoplenty.common.util.config.ConfigHelper; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorOreSingle; @@ -74,7 +74,7 @@ public class BiomeGenDenseForest extends BOPBiome } @Override - public void configure(ConfigHelper conf) + public void configure(IConfigObj conf) { super.configure(conf); diff --git a/src/main/java/biomesoplenty/common/init/ModBiomes.java b/src/main/java/biomesoplenty/common/init/ModBiomes.java index bfc8a57f3..257a5e22e 100644 --- a/src/main/java/biomesoplenty/common/init/ModBiomes.java +++ b/src/main/java/biomesoplenty/common/init/ModBiomes.java @@ -18,7 +18,6 @@ import java.util.Map.Entry; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeManager.BiomeEntry; import net.minecraftforge.common.BiomeManager.BiomeType; - import biomesoplenty.api.biome.BOPBiome; import biomesoplenty.api.biome.IExtendedBiome; import biomesoplenty.common.biome.BOPBiomeManager; @@ -33,7 +32,7 @@ import biomesoplenty.common.biome.overworld.BiomeGenShrubland; import biomesoplenty.common.biome.overworld.BiomeGenSteppe; import biomesoplenty.common.biome.overworld.BiomeGenThicket; import biomesoplenty.common.command.BOPCommand; -import biomesoplenty.common.util.config.ConfigHelper; +import biomesoplenty.common.util.config.BOPConfig; import biomesoplenty.common.world.WorldTypeBOP; import biomesoplenty.core.BiomesOPlenty; @@ -45,7 +44,7 @@ public class ModBiomes private static int nextBiomeId = 40; private static File biomeIdMapFile; - private static ConfigHelper biomeIdMapConf; + private static BOPConfig.IConfigObj biomeIdMapConf; private static Map biomeIdMap; public static void init() @@ -54,14 +53,14 @@ public class ModBiomes // get BOP biome ids from the config file (if it exists) biomeIdMapFile = new File(BiomesOPlenty.configDirectory, "biome_ids.json"); - biomeIdMapConf = new ConfigHelper(biomeIdMapFile); + biomeIdMapConf = new BOPConfig.ConfigFileObj(biomeIdMapFile); biomeIdMap = new HashMap(); registerBiomes(); registerExternalBiomes(); // save the biome ids to the config file (creating it if it doesn't exist) - ConfigHelper.writeFile(biomeIdMapFile, biomeIdMap); + BOPConfig.writeFile(biomeIdMapFile, biomeIdMap); } @@ -90,15 +89,15 @@ public class ModBiomes if (id > -1) { File configFile = new File(new File(BiomesOPlenty.configDirectory, "biomes"), idName + ".json"); - ConfigHelper conf = new ConfigHelper(configFile); + BOPConfig.IConfigObj conf = new BOPConfig.ConfigFileObj(configFile); BOPCommand.biomeCount++; biome.biomeID = id; biome.setBiomeName(name); // If there was a valid config file, then use it to configure the biome - if (!conf.isNull()) {biome.configure(conf);} + if (!conf.isEmpty()) {biome.configure(conf);} // log any warnings from parsing the config file - for (String msg : conf.messages) {BiomesOPlenty.logger.warn(idName+" config "+msg);} + for (String msg : conf.flushMessages()) {BiomesOPlenty.logger.warn(idName+" config "+msg);} BiomeGenBase.getBiomeGenArray()[id] = biome; diff --git a/src/main/java/biomesoplenty/common/util/config/BOPConfig.java b/src/main/java/biomesoplenty/common/util/config/BOPConfig.java new file mode 100644 index 000000000..2290000c2 --- /dev/null +++ b/src/main/java/biomesoplenty/common/util/config/BOPConfig.java @@ -0,0 +1,577 @@ +/******************************************************************************* + * Copyright 2014, the Biomes O' Plenty Team + * + * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License. + * + * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. + ******************************************************************************/ + +package biomesoplenty.common.util.config; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.IBlockState; + +import org.apache.commons.io.FileUtils; + +import biomesoplenty.common.util.block.BlockStateUtils; +import biomesoplenty.core.BiomesOPlenty; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +public class BOPConfig +{ + + public static Gson serializer = new GsonBuilder().setPrettyPrinting().create(); + public static JsonParser parser = new JsonParser(); + private static enum Types {BOOLEAN, STRING, INTEGER, FLOAT, BLOCKSTATE} + + public static boolean writeFile(File outputFile, Object obj) + { + try { + FileUtils.write(outputFile, serializer.toJson(obj)); + return true; + } catch (Exception e) { + BiomesOPlenty.logger.error("Error writing config file " + outputFile.getAbsolutePath() + ": " + e.getMessage()); + return false; + } + } + + public static interface IConfigObj + { + public void addMessage(String message); + public void addMessage(String extraPrefix, String message); + public List flushMessages(); + public boolean isEmpty(); + public boolean has(String name); + public Set getKeys(); + + public IConfigObj getObject(String name); + public ArrayList getObjectArray(String name); + public IConfigObj getObject(String name, boolean warnIfMissing); + public ArrayList getObjectArray(String name, boolean warnIfMissing); + + // Use the methods below when you want to obtain a value from a config file, if it is present, but you have a default value to use if it isn't + // No warning messages will be logged using these methods if the value is missing + public Boolean getBool(String name, Boolean defaultVal); + public String getString(String name, String defaultVal); + public Integer getInt(String name, Integer defaultVal); + public Float getFloat(String name, Float defaultVal); + public IBlockState getBlockState(String name, IBlockState defaultVal); + public E getEnum(String name, E defaultVal, Class clazz); + + // Use the methods below when you want to obtain a value from a config file which SHOULD be present + // If the value is missing, a warning message is logged, and null is returned + public Boolean getBool(String name); + public String getString(String name); + public Integer getInt(String name); + public Float getFloat(String name); + public IBlockState getBlockState(String name); + public E getEnum(String name, Class clazz); + + // Use the methods below when you want to obtain an array of values from a config file, if it is present, but you have a default value to use if it isn't + // No warning messages will be logged using these methods if the value is missing + public ArrayList getBoolArray(String name, ArrayList defaultVal); + public ArrayList getStringArray(String name, ArrayList defaultVal); + public ArrayList getIntArray(String name, ArrayList defaultVal); + public ArrayList getFloatArray(String name, ArrayList defaultVal); + public ArrayList getBlockStateArray(String name, ArrayList defaultVal); + public ArrayList getEnumArray(String name, ArrayList defaultVal, Class clazz); + + // Use the methods below when you want to obtain an array of values from a config file which SHOULD be present + // If the value is missing, a warning message is logged, and null is returned + public ArrayList getBoolArray(String name); + public ArrayList getStringArray(String name); + public ArrayList getIntArray(String name); + public ArrayList getFloatArray(String name); + public ArrayList getBlockStateArray(String name); + public ArrayList getEnumArray(String name, Class clazz); + + + } + + + // Abstract base class for a config object + public static abstract class ConfigObjBase implements IConfigObj + { + protected Map members; + protected List messages = new ArrayList(); + protected String prefix = ""; + + public void parse(String jsonString) + { + this.members = new HashMap(); + if (jsonString != null) {return;} + JsonElement rootElement = null; + try + { + rootElement = parser.parse(jsonString); + if (rootElement != null) + { + if (rootElement.isJsonObject()) + { + for (Entry entry : rootElement.getAsJsonObject().entrySet()) + { + this.members.put(entry.getKey(), entry.getValue()); + } + } else { + this.addMessage("Error parsing config: not a JSON object"); + } + } + } catch (Exception e) { + this.addMessage("Error parsing config: "+e.getMessage()); + } + } + + + @Override + public void addMessage(String message) + { + this.messages.add(this.prefix + ": " + message); + } + @Override + public void addMessage(String extraPrefix, String message) + { + this.messages.add(this.prefix + "." + extraPrefix + ": " + message); + } + @Override + public List flushMessages() + { + ArrayList out = new ArrayList(this.messages); + this.messages.clear(); + return out; + } + @Override + public boolean isEmpty() + { + return this.members == null || this.members.isEmpty(); + } + @Override + public boolean has(String name) + { + return this.members != null && this.members.containsKey(name); + } + @Override + public Set getKeys() + { + return this.members.keySet(); + } + + @Override + public IConfigObj getObject(String name) + { + return this.getObject(name, false); + } + @Override + public IConfigObj getObject(String name, boolean warnIfMissing) + { + if (!this.has(name)) + { + if (warnIfMissing) + { + this.addMessage(name, "Error - missing value"); + } + return null; + } + try + { + JsonObject obj = this.members.get(name).getAsJsonObject(); + return new ConfigChildObj(this.prefix + "." + name, obj); + } catch (Exception e) { + this.addMessage("Error fetching object " + name + ": " + e.getMessage()); + return null; + } + } + + @Override + public ArrayList getObjectArray(String name) + { + return this.getObjectArray(name, false); + } + @Override + public ArrayList getObjectArray(String name, boolean warnIfMissing) + { + if (!this.has(name)) + { + if (warnIfMissing) + { + this.addMessage(name, "Error - missing value"); + } + return null; + } + ArrayList list = new ArrayList(); + try + { + JsonArray arr = this.members.get(name).getAsJsonArray(); + for (int i = 0; i < arr.size(); i++) + { + try + { + JsonObject obj = arr.get(i).getAsJsonObject(); + if (obj != null) {list.add( new ConfigChildObj(this.prefix + "." + name + "." + i, obj) );} + } catch (Exception e) { + this.addMessage("Error fetching object from array " + name + " at index " + i + ": " + e.getMessage()); + } + } + } catch (Exception e) { + this.addMessage("Error fetching object array " + name + ": " + e.getMessage()); + return null; + } + return list; + } + + + // Implement the simple getter methods + + @Override + public Boolean getBool(String name, Boolean defaultVal) {return this.get(name, defaultVal, false, Types.BOOLEAN);} + @Override + public String getString(String name, String defaultVal) {return this.get(name, defaultVal, false, Types.STRING);} + @Override + public Integer getInt(String name, Integer defaultVal) {return this.get(name, defaultVal, false, Types.INTEGER);} + @Override + public Float getFloat(String name, Float defaultVal) {return this.get(name, defaultVal, false, Types.FLOAT);} + @Override + public IBlockState getBlockState(String name, IBlockState defaultVal) {return this.get(name, defaultVal, false, Types.BLOCKSTATE);} + @Override + public E getEnum(String name, E defaultVal, Class clazz) {return this.getEnum(name, defaultVal, false, clazz);} + + @Override + public Boolean getBool(String name) {return this.get(name, null, true, Types.BOOLEAN);} + @Override + public String getString(String name) {return this.get(name, null, true, Types.STRING);} + @Override + public Integer getInt(String name) {return this.get(name, null, true, Types.INTEGER);} + @Override + public Float getFloat(String name) {return this.get(name, null, true, Types.FLOAT);} + @Override + public IBlockState getBlockState(String name) {return this.get(name, null, true, Types.BLOCKSTATE);} + @Override + public E getEnum(String name, Class clazz) {return this.getEnum(name, null, true, clazz);} + + @Override + public ArrayList getBoolArray(String name, ArrayList defaultVal) {return this.getArray(name, defaultVal, false, Types.BOOLEAN);} + @Override + public ArrayList getStringArray(String name, ArrayList defaultVal) {return this.getArray(name, defaultVal, false, Types.STRING);} + @Override + public ArrayList getIntArray(String name, ArrayList defaultVal) {return this.getArray(name, defaultVal, false, Types.INTEGER);} + @Override + public ArrayList getFloatArray(String name, ArrayList defaultVal) {return this.getArray(name, defaultVal, false, Types.FLOAT);} + @Override + public ArrayList getBlockStateArray(String name, ArrayList defaultVal) {return this.getArray(name, defaultVal, false, Types.BLOCKSTATE);} + @Override + public ArrayList getEnumArray(String name, ArrayList defaultVal, Class clazz) {return this.getEnumArray(name, defaultVal, false, clazz);} + + @Override + public ArrayList getBoolArray(String name) {return this.getArray(name, null, true, Types.BOOLEAN);} + @Override + public ArrayList getStringArray(String name) {return this.getArray(name, null, true, Types.STRING);} + @Override + public ArrayList getIntArray(String name) {return this.getArray(name, null, true, Types.INTEGER);} + @Override + public ArrayList getFloatArray(String name) {return this.getArray(name, null, true, Types.FLOAT);} + @Override + public ArrayList getBlockStateArray(String name) {return this.getArray(name, null, true, Types.BLOCKSTATE);} + @Override + public ArrayList getEnumArray(String name, Class clazz) {return this.getEnumArray(name, null, true, clazz);} + + + + + protected ArrayList getEnumArray(String name, ArrayList defaultVal, boolean warnIfMissing, Class clazz) + { + if (!this.has(name)) + { + if (warnIfMissing) + { + this.addMessage(name, "Error - missing value"); + } + return defaultVal; + } + ArrayList list = new ArrayList(); + try + { + JsonArray arr = this.members.get(name).getAsJsonArray(); + for (int i = 0; i < arr.size(); i++) + { + E ele = this.asEnum(arr.get(i), clazz, name + "." + i); + if (ele != null) {list.add(ele);} + } + } catch (Exception e) { + this.addMessage(name, "Error fetching " + clazz.getName() + " array: " + e.getMessage()); + } + return list; + } + + protected E getEnum(String name, E defaultVal, boolean warnIfMissing, Class clazz) + { + if (!this.has(name)) + { + if (warnIfMissing) + { + this.addMessage(name, "Error - missing value"); + } + return defaultVal; + } + E out = this.asEnum(this.members.get(name), clazz, name); + return out == null ? defaultVal : out; + } + + private T get(String name, T defaultVal, boolean warnIfMissing, Types type) + { + if (!this.has(name)) + { + if (warnIfMissing) + { + this.addMessage(name, "Error - missing value"); + } + return defaultVal; + } + T out = this.as(this.members.get(name), type, name); + return out == null ? defaultVal : out; + } + + private ArrayList getArray(String name, ArrayList defaultVal, boolean warnIfMissing, Types type) + { + if (!this.has(name)) + { + if (warnIfMissing) + { + this.addMessage(name, "Error - missing value"); + } + return defaultVal; + } + ArrayList list = new ArrayList(); + try + { + JsonArray arr = this.members.get(name).getAsJsonArray(); + for (int i = 0; i < arr.size(); i++) + { + T ele = this.as(arr.get(i), type, name + "." + i); + if (ele != null) {list.add(ele);} + } + } catch (Exception e) { + this.addMessage(name, "Error fetching " + type.toString().toLowerCase() + " array: " + e.getMessage()); + } + return list; + } + + private T as(JsonElement ele, Types type, String extraPrefix) + { + switch (type) { + case BOOLEAN: + return (T)this.asBool(ele, extraPrefix); + case STRING: + return (T)this.asString(ele, extraPrefix); + case INTEGER: + return (T)this.asInt(ele, extraPrefix); + case FLOAT: + return (T)this.asFloat(ele, extraPrefix); + case BLOCKSTATE: + return (T)this.asBlockState(ele, extraPrefix); + default: + return null; + } + } + + + protected E asEnum(JsonElement ele, Classclazz, String extraPrefix) + { + try + { + String val = ele.getAsString(); + E[] enums = clazz.getEnumConstants(); + if (enums == null) + { + this.addMessage(extraPrefix, "Class " + clazz.getName() + " contains no enum constants"); + return null; + } + for (E enumVal : enums) + { + if (enumVal.name().equalsIgnoreCase(val)) + { + return enumVal; + } + } + this.addMessage(extraPrefix, "Value " + val + " does not exist in enum " + clazz); + return null; + } catch (Exception e) { + this.addMessage(extraPrefix, "Error fetching string: " + e.getMessage()); + return null; + } + } + + protected Boolean asBool(JsonElement ele, String extraPrefix) + { + try + { + return ele.getAsBoolean(); + } catch (Exception e) { + this.addMessage(extraPrefix, "Error fetching boolean: " + e.getMessage()); + return null; + } + } + + protected String asString(JsonElement ele, String extraPrefix) + { + try + { + return ele.getAsString(); + } catch (Exception e) { + this.addMessage(extraPrefix, "Error fetching string: " + e.getMessage()); + return null; + } + } + + protected Integer asInt(JsonElement ele, String extraPrefix) + { + try + { + return ele.getAsInt(); + } catch (Exception e) { + this.addMessage(extraPrefix, "Error fetching integer: " + e.getMessage()); + return null; + } + } + + protected Float asFloat(JsonElement ele, String extraPrefix) + { + try + { + return ele.getAsFloat(); + } catch (Exception e) { + this.addMessage(extraPrefix, "Error fetching float: " + e.getMessage()); + return null; + } + } + + protected IBlockState asBlockState(JsonElement ele, String extraPrefix) + { + try { + + JsonObject obj = ele.getAsJsonObject(); + + // attempt to load the specified block + if (!obj.has("block")) + { + this.addMessage(extraPrefix, "Block name missing"); + return null; + } + JsonElement blockName = obj.get("block"); + if (!blockName.isJsonPrimitive()) + { + this.addMessage(extraPrefix, "Invalid block name - must be a string"); + return null; + } + Block block = Block.getBlockFromName(blockName.getAsString()); + if (block == null) + { + this.addMessage(extraPrefix, "Unrecognised block name " + blockName.getAsString()); + return null; + } + + IBlockState state = block.getDefaultState(); + + // attempt to add properties + if (obj.has("properties")) { + + JsonElement properties = obj.get("properties"); + if (!properties.isJsonObject()) + { + this.addMessage(extraPrefix, "Invalid properties list - must be a JSON object"); + return state; + } + + for (Entry entry : properties.getAsJsonObject().entrySet()) + { + IProperty property = BlockStateUtils.getPropertyByName(state, entry.getKey()); + if (property != null) + { + Comparable propertyValue = BlockStateUtils.getPropertyValueByName(state, property, entry.getValue().getAsString()); + if (propertyValue != null) + { + state = state.withProperty(property, propertyValue); + } + else + { + this.addMessage(extraPrefix, "Invalid value " + entry.getValue().getAsString() + " for property " + entry.getKey()); + } + } + else + { + this.addMessage(extraPrefix, "Invalid property name: " + entry.getKey()); + } + } + } + + return state; + + } catch (Exception e) { + this.addMessage(extraPrefix, "Error fetching blockstate: " + e.getMessage()); + return null; + } + } + + + + } + + // Concrete class for a config object created by supplying the JSON in a string + public static class ConfigObj extends ConfigObjBase + { + public ConfigObj(String jsonString) + { + this.parse(jsonString); + } + } + + // Concrete class for a config object created from a file + public static class ConfigFileObj extends ConfigObjBase + { + public ConfigFileObj(File configFile) + { + this.prefix = configFile.getAbsolutePath(); + String jsonString = null; + if (configFile.exists()) + { + try + { + jsonString = FileUtils.readFileToString(configFile); + } catch (IOException e) { + this.addMessage("Error reading config file "+e.getMessage()); + } + } + this.parse(jsonString); + } + } + + // Concrete class for a config object which is a child of another config object + public static class ConfigChildObj extends ConfigObjBase + { + protected ConfigChildObj(String prefix, JsonObject obj) + { + this.prefix = prefix; + this.members = new HashMap(); + for (Entry entry : obj.entrySet()) + { + this.members.put(entry.getKey(), entry.getValue()); + } + } + } + + +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/util/config/ConfigHelper.java b/src/main/java/biomesoplenty/common/util/config/ConfigHelper.java deleted file mode 100644 index a87a2c7d2..000000000 --- a/src/main/java/biomesoplenty/common/util/config/ConfigHelper.java +++ /dev/null @@ -1,443 +0,0 @@ -/******************************************************************************* - * Copyright 2014, the Biomes O' Plenty Team - * - * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License. - * - * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. - ******************************************************************************/ - -package biomesoplenty.common.util.config; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Map.Entry; - -import net.minecraft.block.Block; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.state.IBlockState; - -import org.apache.commons.io.FileUtils; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import biomesoplenty.common.util.block.BlockStateUtils; -import biomesoplenty.core.BiomesOPlenty; - -public class ConfigHelper -{ - - public static Gson serializer = new GsonBuilder().setPrettyPrinting().create(); - public static JsonParser parser = new JsonParser(); - public WrappedJsonObject root = null; - public ArrayList messages = new ArrayList(); - - - public ConfigHelper(String jsonString) - { - this.parse(jsonString); - } - - public ConfigHelper(File configFile) - { - String jsonString = null; - if (configFile.exists()) - { - try - { - jsonString = FileUtils.readFileToString(configFile); - } catch (IOException e) { - BiomesOPlenty.logger.error("Error reading config file "+e.getMessage()); - } - } - this.parse(jsonString); - } - - public boolean isNull() - { - return this.root == null; - } - - public void parse(String jsonString) - { - this.root = null; - JsonElement rootElement = null; - if (jsonString != null) - { - try - { - rootElement = parser.parse(jsonString); - if (rootElement != null) - { - if (rootElement.isJsonObject()) - { - this.root = new WrappedJsonObject(this, rootElement.getAsJsonObject()); - } else { - BiomesOPlenty.logger.error("Error parsing config: not a JSON object"); - } - } - } catch (Exception e) { - BiomesOPlenty.logger.error("Error parsing config: "+e.getMessage()); - } - } - } - - - public void addMessage(String message) - { - this.messages.add(message); - } - - public static boolean writeFile(File outputFile, Object obj) - { - try { - FileUtils.write(outputFile, serializer.toJson(obj)); - return true; - } catch (Exception e) { - BiomesOPlenty.logger.error("Error writing config file " + outputFile.getAbsolutePath() + ": " + e.getMessage()); - return false; - } - } - - - public WrappedJsonObject getObject(String name) - { - return this.root == null ? null : this.root.getObject(name); - } - public ArrayList getObjectArray(String name) - { - return this.root == null ? new ArrayList() : this.root.getObjectArray(name); - } - public ArrayList getBoolArray(String name, ArrayList defaultVal) - { - return this.root == null ? new ArrayList() : this.root.getBoolArray(name, defaultVal); - } - public Boolean getBool(String name, Boolean defaultVal) - { - return this.root == null ? defaultVal : this.root.getBool(name, defaultVal); - } - public ArrayList getStringArray(String name, ArrayList defaultVal) - { - return this.root == null ? new ArrayList() : this.root.getStringArray(name, defaultVal); - } - public String getString(String name, String defaultVal) - { - return this.root == null ? defaultVal : this.root.getString(name, defaultVal); - } - public ArrayList getIntArray(String name, ArrayList defaultVal) - { - return this.root == null ? new ArrayList() : this.root.getIntArray(name, defaultVal); - } - public Integer getInt(String name, Integer defaultVal) - { - return this.root == null ? defaultVal : this.root.getInt(name, defaultVal); - } - public ArrayList getFloatArray(String name, ArrayList defaultVal) - { - return this.root == null ? new ArrayList() : this.root.getFloatArray(name, defaultVal); - } - public Float getFloat(String name, Float defaultVal) - { - return this.root == null ? defaultVal : this.root.getFloat(name, defaultVal); - } - public ArrayList getBlockStateArray(String name, ArrayList defaultVal) - { - return this.root == null ? new ArrayList() : this.root.getBlockStateArray(name, defaultVal); - } - public IBlockState getBlockState(String name, IBlockState defaultVal) - { - return this.root == null ? defaultVal : this.root.getBlockState(name, defaultVal); - } - - - - - - private static enum Types {BOOLEAN, STRING, INTEGER, FLOAT, BLOCKSTATE} - - public class WrappedJsonObject - { - - private JsonObject obj; - private ConfigHelper conf; - - public WrappedJsonObject(ConfigHelper conf, JsonObject obj) - { - this.obj = obj; - this.conf = conf; - } - - public ArrayList getKeys() - { - ArrayList out = new ArrayList(); - for (Entry entry : this.obj.entrySet()) - { - out.add(entry.getKey()); - } - return out; - } - - public WrappedJsonObject getObject(String name) - { - if (this.obj == null || !this.obj.has(name)) {return null;} - try - { - JsonObject obj = this.obj.getAsJsonObject(name); - if (obj == null) {return null;} - return new WrappedJsonObject(this.conf, obj); - } catch (Exception e) { - this.conf.addMessage("Error fetching object " + name + ": " + e.getMessage()); - return null; - } - } - - public ArrayList getObjectArray(String name) - { - ArrayList list = new ArrayList(); - if (this.obj != null && this.obj.has(name)) { - try - { - JsonArray arr = this.obj.getAsJsonArray(name); - for (int i = 0; i < arr.size(); i++) - { - try - { - JsonObject obj = arr.get(i).getAsJsonObject(); - if (obj != null) {list.add( new WrappedJsonObject(this.conf, obj) );} - } catch (Exception e) { - this.conf.addMessage("Error fetching object from array " + name + " at index " + i + ": " + e.getMessage()); - } - } - - } catch (Exception e) { - this.conf.addMessage("Error fetching object array " + name + ": " + e.getMessage()); - return null; - } - } - return list; - } - - public ArrayList getBoolArray(String name, ArrayList defaultVal) {return this.getArray(name, defaultVal, Types.BOOLEAN);} - public Boolean getBool(String name, Boolean defaultVal) {return this.get(name, defaultVal, Types.BOOLEAN);} - public ArrayList getStringArray(String name, ArrayList defaultVal) {return this.getArray(name, defaultVal, Types.STRING);} - public String getString(String name, String defaultVal) {return this.get(name, defaultVal, Types.STRING);} - public ArrayList getIntArray(String name, ArrayList defaultVal) {return this.getArray(name, defaultVal, Types.INTEGER);} - public Integer getInt(String name, Integer defaultVal) {return this.get(name, defaultVal, Types.INTEGER);} - public ArrayList getFloatArray(String name, ArrayList defaultVal) {return this.getArray(name, defaultVal, Types.FLOAT);} - public Float getFloat(String name, Float defaultVal) {return this.get(name, defaultVal, Types.FLOAT);} - public ArrayList getBlockStateArray(String name, ArrayList defaultVal) {return this.getArray(name, defaultVal, Types.BLOCKSTATE);} - public IBlockState getBlockState(String name, IBlockState defaultVal) {return this.get(name, defaultVal, Types.BLOCKSTATE);} - - public ArrayList getEnumArray(String name, ArrayList defaultVal, Class clazz) - { - if (this.obj == null || !this.obj.has(name)) {return defaultVal;} - ArrayList list = new ArrayList(); - try - { - JsonArray arr = this.obj.getAsJsonArray(name); - for (int i = 0; i < arr.size(); i++) - { - E ele = this.asEnum(arr.get(i), clazz); - if (ele != null) {list.add(ele);} - } - } catch (Exception e) { - this.conf.addMessage("Error fetching " + clazz.getName() + " array: " + e.getMessage()); - } - return list; - } - public E getEnum(String name, E defaultVal, Class clazz) - { - if (this.obj == null || !this.obj.has(name)) {return defaultVal;} - E out = this.asEnum(this.obj.get(name), clazz); - return out == null ? defaultVal : out; - } - - private T get(String name, T defaultVal, Types type) - { - if (this.obj == null || !this.obj.has(name)) {return defaultVal;} - T out = this.as(this.obj.get(name), type); - return out == null ? defaultVal : out; - } - - private ArrayList getArray(String name, ArrayList defaultVal, Types type) - { - if (this.obj == null || !this.obj.has(name)) {return defaultVal;} - ArrayList list = new ArrayList(); - try - { - JsonArray arr = this.obj.getAsJsonArray(name); - for (int i = 0; i < arr.size(); i++) - { - T ele = this.as(arr.get(i), type); - if (ele != null) {list.add(ele);} - } - } catch (Exception e) { - this.conf.addMessage("Error fetching " + type.toString().toLowerCase() + " array: " + e.getMessage()); - } - return list; - } - - private T as(JsonElement ele, Types type) - { - switch (type) { - case BOOLEAN: - return (T)this.asBool(ele); - case STRING: - return (T)this.asString(ele); - case INTEGER: - return (T)this.asInt(ele); - case FLOAT: - return (T)this.asFloat(ele); - case BLOCKSTATE: - return (T)this.asBlockState(ele); - default: - return null; - } - } - - public E asEnum(JsonElement ele, Classclazz) - { - try - { - String val = ele.getAsString(); - E[] enums = clazz.getEnumConstants(); - if (enums == null) - { - this.conf.addMessage("Class " + clazz.getName() + " contains no enum constants"); - return null; - } - for (E enumVal : enums) - { - if (enumVal.name().equalsIgnoreCase(val)) - { - return enumVal; - } - } - this.conf.addMessage("Value " + val + " does not exist in enum " + clazz); - return null; - } catch (Exception e) { - this.conf.addMessage("Error fetching string: " + e.getMessage()); - return null; - } - } - - public Boolean asBool(JsonElement ele) - { - try - { - return ele.getAsBoolean(); - } catch (Exception e) { - this.conf.addMessage("Error fetching boolean: " + e.getMessage()); - return null; - } - } - - public String asString(JsonElement ele) - { - try - { - return ele.getAsString(); - } catch (Exception e) { - this.conf.addMessage("Error fetching string: " + e.getMessage()); - return null; - } - } - - public Integer asInt(JsonElement ele) - { - try - { - return ele.getAsInt(); - } catch (Exception e) { - this.conf.addMessage("Error fetching integer: " + e.getMessage()); - return null; - } - } - - public Float asFloat(JsonElement ele) - { - try - { - return ele.getAsFloat(); - } catch (Exception e) { - this.conf.addMessage("Error fetching float: " + e.getMessage()); - return null; - } - } - - public IBlockState asBlockState(JsonElement arse) - { - try { - - JsonObject ele = arse.getAsJsonObject(); - - // attempt to load the specified block - if (!ele.has("block")) - { - this.conf.addMessage("Block name missing"); - return null; - } - JsonElement blockName = ele.get("block"); - if (!blockName.isJsonPrimitive()) - { - this.conf.addMessage("Invalid block name - must be a string"); - return null; - } - Block block = Block.getBlockFromName(blockName.getAsString()); - if (block == null) - { - this.conf.addMessage("Unrecognised block name " + blockName.getAsString()); - return null; - } - - IBlockState state = block.getDefaultState(); - - // attempt to add properties - if (ele.has("properties")) { - - JsonElement properties = ele.get("properties"); - if (!properties.isJsonObject()) - { - this.conf.addMessage("Invalid properties list - must be a JSON object"); - return state; - } - - for (Entry entry : properties.getAsJsonObject().entrySet()) - { - IProperty property = BlockStateUtils.getPropertyByName(state, entry.getKey()); - if (property != null) - { - Comparable propertyValue = BlockStateUtils.getPropertyValueByName(state, property, entry.getValue().getAsString()); - if (propertyValue != null) - { - state = state.withProperty(property, propertyValue); - } - else - { - this.conf.addMessage("Invalid value " + entry.getValue().getAsString() + " for property " + entry.getKey()); - } - } - else - { - this.conf.addMessage("Invalid property name: " + entry.getKey()); - } - } - } - - return state; - - } catch (Exception e) { - this.conf.addMessage("Error fetching blockstate: " + e.getMessage()); - return null; - } - } - } - - - -} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/feature/GeneratorDoubleFlora.java b/src/main/java/biomesoplenty/common/world/feature/GeneratorDoubleFlora.java index 554e7033e..88297493a 100644 --- a/src/main/java/biomesoplenty/common/world/feature/GeneratorDoubleFlora.java +++ b/src/main/java/biomesoplenty/common/world/feature/GeneratorDoubleFlora.java @@ -16,7 +16,7 @@ import biomesoplenty.common.block.BlockBOPDoublePlant; import biomesoplenty.common.block.BlockDecoration; import biomesoplenty.common.block.BlockDoubleDecoration; import biomesoplenty.common.util.biome.GeneratorUtils; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.util.BlockPos; @@ -91,7 +91,7 @@ public class GeneratorDoubleFlora extends GeneratorCustomizable } @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { this.amountPerChunk = conf.getInt("amountPerChunk", this.amountPerChunk); this.bottomState = conf.getBlockState("bottomState", this.bottomState); diff --git a/src/main/java/biomesoplenty/common/world/feature/GeneratorFlora.java b/src/main/java/biomesoplenty/common/world/feature/GeneratorFlora.java index dcb8c5ca4..1b9c911d0 100644 --- a/src/main/java/biomesoplenty/common/world/feature/GeneratorFlora.java +++ b/src/main/java/biomesoplenty/common/world/feature/GeneratorFlora.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; import biomesoplenty.api.biome.generation.GeneratorCustomizable; import biomesoplenty.common.block.BlockDecoration; import biomesoplenty.common.util.biome.GeneratorUtils; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; public class GeneratorFlora extends GeneratorCustomizable { @@ -80,7 +80,7 @@ public class GeneratorFlora extends GeneratorCustomizable } @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { this.amountPerChunk = conf.getInt("amountPerChunk", this.amountPerChunk); this.state = conf.getBlockState("state", this.state); diff --git a/src/main/java/biomesoplenty/common/world/feature/GeneratorOreBase.java b/src/main/java/biomesoplenty/common/world/feature/GeneratorOreBase.java index 1e998c37f..4cde26e51 100644 --- a/src/main/java/biomesoplenty/common/world/feature/GeneratorOreBase.java +++ b/src/main/java/biomesoplenty/common/world/feature/GeneratorOreBase.java @@ -17,7 +17,7 @@ import org.apache.commons.lang3.tuple.Pair; import biomesoplenty.api.biome.generation.GeneratorCustomizable; import biomesoplenty.common.util.biome.GeneratorUtils; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; public abstract class GeneratorOreBase extends GeneratorCustomizable { @@ -46,7 +46,7 @@ public abstract class GeneratorOreBase extends GeneratorCustomizable } @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { this.amountPerChunk = conf.getInt("amountPerChunk", this.amountPerChunk); int minHeight = conf.getInt("minHeight", this.minHeight).intValue(); diff --git a/src/main/java/biomesoplenty/common/world/feature/GeneratorOreCluster.java b/src/main/java/biomesoplenty/common/world/feature/GeneratorOreCluster.java index 1b32e18db..70a5fb34e 100644 --- a/src/main/java/biomesoplenty/common/world/feature/GeneratorOreCluster.java +++ b/src/main/java/biomesoplenty/common/world/feature/GeneratorOreCluster.java @@ -10,12 +10,12 @@ package biomesoplenty.common.world.feature; import java.util.Random; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenMinable; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; public class GeneratorOreCluster extends GeneratorOreBase { @@ -41,7 +41,7 @@ public class GeneratorOreCluster extends GeneratorOreBase } @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { super.configure(conf); diff --git a/src/main/java/biomesoplenty/common/world/feature/GeneratorOreSingle.java b/src/main/java/biomesoplenty/common/world/feature/GeneratorOreSingle.java index b2d4d9b90..164aaba65 100644 --- a/src/main/java/biomesoplenty/common/world/feature/GeneratorOreSingle.java +++ b/src/main/java/biomesoplenty/common/world/feature/GeneratorOreSingle.java @@ -15,7 +15,7 @@ import net.minecraft.block.state.pattern.BlockHelper; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import com.google.common.base.Predicate; @@ -50,7 +50,7 @@ public class GeneratorOreSingle extends GeneratorOreBase } @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { super.configure(conf); diff --git a/src/main/java/biomesoplenty/common/world/feature/GeneratorWaterside.java b/src/main/java/biomesoplenty/common/world/feature/GeneratorWaterside.java index ecb687a61..1598ee48f 100644 --- a/src/main/java/biomesoplenty/common/world/feature/GeneratorWaterside.java +++ b/src/main/java/biomesoplenty/common/world/feature/GeneratorWaterside.java @@ -19,7 +19,7 @@ import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import biomesoplenty.api.biome.generation.GeneratorCustomizable; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; public class GeneratorWaterside extends GeneratorCustomizable { @@ -106,7 +106,7 @@ public class GeneratorWaterside extends GeneratorCustomizable } @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { this.amountPerChunk = conf.getInt("amountPerChunk", this.amountPerChunk); this.maxRadius = conf.getInt("maxRadius", this.maxRadius); diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java index 2e4a4a75f..7f936c585 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java @@ -24,7 +24,7 @@ import org.apache.commons.lang3.tuple.Pair; import biomesoplenty.api.biome.generation.GeneratorCustomizable; import biomesoplenty.common.util.biome.GeneratorUtils; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; public class GeneratorBasicTree extends GeneratorCustomizable { @@ -302,7 +302,7 @@ public class GeneratorBasicTree extends GeneratorCustomizable } @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { this.amountPerChunk = conf.getInt("amountPerChunk", this.amountPerChunk); this.updateNeighbours = conf.getBool("updateNeighbours", this.updateNeighbours); diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBigTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBigTree.java index 81484fe55..836fa8a21 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBigTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBigTree.java @@ -23,7 +23,7 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import biomesoplenty.api.biome.generation.GeneratorCustomizable; import biomesoplenty.common.util.biome.GeneratorUtils; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import com.google.common.collect.Lists; @@ -535,7 +535,7 @@ public class GeneratorBigTree extends GeneratorCustomizable } @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { this.amountPerChunk = conf.getInt("amountPerChunk", this.amountPerChunk); this.updateNeighbours = conf.getBool("updateNeighbours", this.updateNeighbours); diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBush.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBush.java index 163044abc..c5114360a 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBush.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBush.java @@ -17,9 +17,8 @@ import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; - import biomesoplenty.api.biome.generation.GeneratorCustomizable; -import biomesoplenty.common.util.config.ConfigHelper.WrappedJsonObject; +import biomesoplenty.common.util.config.BOPConfig.IConfigObj; public class GeneratorBush extends GeneratorCustomizable { @@ -110,7 +109,7 @@ public class GeneratorBush extends GeneratorCustomizable } @Override - public void configure(WrappedJsonObject conf) + public void configure(IConfigObj conf) { this.amountPerChunk = conf.getInt("amountPerChunk", this.amountPerChunk); this.log = conf.getBlockState("logState", this.log);