Fixes bug where island world settings in config were not used

https://github.com/BentoBoxWorld/Level/issues/80
This commit is contained in:
tastybento 2019-08-16 19:07:13 -07:00
parent 378a855bde
commit 8e2f4a4b5e
2 changed files with 10 additions and 7 deletions

View File

@ -191,12 +191,8 @@ public class CalcIslandLevel {
result.ofCount.add(md);
return 0;
}
} else if (addon.getSettings().getBlockValues().containsKey(md)) {
return getValue(md);
} else {
result.ncCount.add(md);
return 0;
}
return getValue(md);
}
/**
@ -206,10 +202,17 @@ public class CalcIslandLevel {
* @return value of a material
*/
private int getValue(Material md) {
// Check world settings
if (addon.getSettings().getWorldBlockValues().containsKey(world) && addon.getSettings().getWorldBlockValues().get(world).containsKey(md)) {
return addon.getSettings().getWorldBlockValues().get(world).get(md);
}
return addon.getSettings().getBlockValues().getOrDefault(md, 0);
// Check baseline
if (addon.getSettings().getBlockValues().containsKey(md)) {
return addon.getSettings().getBlockValues().get(md);
}
// Not in config
result.ncCount.add(md);
return 0;
}
/**

View File

@ -109,7 +109,7 @@ public class Settings {
for (String material : worldValues.getKeys(false)) {
Material mat = Material.valueOf(material);
Map<Material, Integer> values = worldBlockValues.getOrDefault(bWorld, new HashMap<>());
values.put(mat, worldValues.getInt("blocks." + material, 0));
values.put(mat, worldValues.getInt(material));
worldBlockValues.put(bWorld, values);
}
} else {