From cbb284b0fd16bb4b2753a7be4c9a9595c5a3299e Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Wed, 14 Jun 2023 15:12:34 +0200 Subject: [PATCH] Properly drop unsupported biomes from biome list (#4074) * Drop CUSTOM from biome list * Drop cherry_grove if present on pre 1.20 versions --- .../bukkit/generator/BukkitPlotGenerator.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index da97ac621..08c669f66 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -37,6 +37,7 @@ import com.sk89q.worldedit.math.BlockVector2; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.bukkit.HeightMap; +import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.World; import org.bukkit.block.Biome; @@ -50,10 +51,12 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Arrays; +import java.util.EnumSet; import java.util.List; import java.util.Random; import java.util.Set; -import java.util.stream.Collectors; + +import static java.util.function.Predicate.not; public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper { @@ -437,9 +440,16 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap private static final List BIOMES; static { + Set disabledBiomes = EnumSet.of(Biome.CUSTOM); + if (PlotSquared.platform().serverVersion()[1] <= 19) { + final Biome cherryGrove = Registry.BIOME.get(NamespacedKey.minecraft("cherry_grove")); + if (cherryGrove != null) { + disabledBiomes.add(cherryGrove); + } + } BIOMES = Arrays.stream(Biome.values()) - .filter(b -> Registry.BIOME.get(b.getKey()) != null) - .collect(Collectors.toList()); + .filter(not(disabledBiomes::contains)) + .toList(); } @Override