1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

[CI skip] Added failsafe for misconfigured addons

This commit is contained in:
TheBusyBiscuit 2020-05-02 10:40:53 +02:00
parent 085d10be0a
commit e69cdff244

View File

@ -80,7 +80,13 @@ public class ResourceManager {
int value = resource.getDefaultSupply(world.getEnvironment(), block.getBiome()); int value = resource.getDefaultSupply(world.getEnvironment(), block.getBiome());
if (value > 0) { if (value > 0) {
value += ThreadLocalRandom.current().nextInt(resource.getMaxDeviation()); int bound = resource.getMaxDeviation();
if (bound <= 0) {
throw new IllegalStateException("GEO Resource \"" + resource.getKey() + "\" was misconfigured! getMaxDeviation() must return a value higher than zero!");
}
value += ThreadLocalRandom.current().nextInt(bound);
} }
GEOResourceGenerationEvent event = new GEOResourceGenerationEvent(world, block.getBiome(), x, z, resource, value); GEOResourceGenerationEvent event = new GEOResourceGenerationEvent(world, block.getBiome(), x, z, resource, value);