From 385fea359b2be6b4edc3b171c6aa66c05ef32691 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Fri, 12 Aug 2022 19:58:11 +0200 Subject: [PATCH] chore: make snow set more future-proof --- .../bukkit/listener/BlockEventListener.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index 24749e8fd..7347b724d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -109,6 +109,8 @@ import java.util.List; import java.util.Objects; import java.util.Set; import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.Stream; @SuppressWarnings("unused") public class BlockEventListener implements Listener { @@ -121,22 +123,10 @@ public class BlockEventListener implements Listener { Material.TURTLE_EGG, Material.TURTLE_SPAWN_EGG ); - private static final Set SNOW; // needed as Tag.SNOW isn't present in 1.16.5 - - static { - if (PlotSquared.platform().serverVersion()[1] < 17) { - SNOW = Set.of( - Material.SNOW, - Material.SNOW_BLOCK - ); - } else { - SNOW = Set.of( - Material.SNOW, - Material.SNOW_BLOCK, - Material.POWDER_SNOW // only since 1.17 - ); - } - } + private static final Set SNOW = Stream.of(Material.values()) // needed as Tag.SNOW isn't present in 1.16.5 + .filter(material -> material.name().contains("SNOW")) + .filter(Material::isBlock) + .collect(Collectors.toUnmodifiableSet()); private final PlotAreaManager plotAreaManager; private final WorldEdit worldEdit;