use of biomesoplenty.api.config.IConfigObj in project BiomesOPlenty by Glitchfiend.
the class GeneratorWeighted method configure.
@Override
public void configure(IConfigObj conf) {
this.amountPerChunk = conf.getFloat("amountPerChunk", this.amountPerChunk);
IConfigObj confGenerators = conf.getObject("generators");
if (confGenerators != null) {
for (String name : confGenerators.getKeys()) {
IConfigObj confCurrentGen = confGenerators.getObject(name);
if (this.generators.containsKey(name)) {
IGenerator generator = this.getGenerator(name);
Integer weight = confCurrentGen.getInt("weight", this.weights.get(generator));
if (weight.intValue() < 1) {
// remove this generator if the weight is zero (or negative)
this.removeGenerator(name);
} else {
// adjust weight
this.weights.put(generator, weight);
// configure the existing generator
generator.configure(confCurrentGen);
}
} else {
// there was previously no generator of this name - attempt to add it
Integer weight = confCurrentGen.getInt("weight", null);
IGenerator generator = GeneratorRegistry.createGenerator(confCurrentGen);
if (weight != null && generator != null) {
this.add(name, weight, generator);
}
}
}
}
}
Aggregations