From e69cdff2440574fbc6ac54366416805d4cf79739 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 2 May 2020 10:40:53 +0200 Subject: [PATCH] [CI skip] Added failsafe for misconfigured addons --- .../thebusybiscuit/slimefun4/api/geo/ResourceManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java index 1dee05289..9fc120dcc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java @@ -80,7 +80,13 @@ public class ResourceManager { int value = resource.getDefaultSupply(world.getEnvironment(), block.getBiome()); 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);