Fixed a bug with configuring weighted generators

This commit is contained in:
Adubbz 2016-02-12 20:53:01 +11:00
parent ee8dbb44f1
commit c73f73e1dd

View file

@ -130,10 +130,12 @@ public class GeneratorWeighted extends BOPGeneratorBase
{ {
for (String name : confGenerators.getKeys()) for (String name : confGenerators.getKeys())
{ {
IConfigObj confCurrentGen = confGenerators.getObject(name);
if (this.generators.containsKey(name)) if (this.generators.containsKey(name))
{ {
IGenerator generator = this.getGenerator(name); IGenerator generator = this.getGenerator(name);
Integer weight = conf.getInt("weight", this.weights.get(generator)); Integer weight = confCurrentGen.getInt("weight", this.weights.get(generator));
if (weight.intValue() < 1) if (weight.intValue() < 1)
{ {
// remove this generator if the weight is zero (or negative) // remove this generator if the weight is zero (or negative)
@ -144,14 +146,14 @@ public class GeneratorWeighted extends BOPGeneratorBase
// adjust weight // adjust weight
this.weights.put(generator, weight); this.weights.put(generator, weight);
// configure the existing generator // configure the existing generator
generator.configure(conf); generator.configure(confCurrentGen);
} }
} }
else else
{ {
// there was previously no generator of this name - attempt to add it // there was previously no generator of this name - attempt to add it
Integer weight = conf.getInt("weight", null); Integer weight = confCurrentGen.getInt("weight", null);
IGenerator generator = GeneratorRegistry.createGenerator(conf); IGenerator generator = GeneratorRegistry.createGenerator(confCurrentGen);
if (weight != null && generator != null) if (weight != null && generator != null)
{ {
this.add(name, weight, generator); this.add(name, weight, generator);