From c6e36fd70e1c7c1f6f5fdaf8ae0945ad173a0447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Fri, 20 Dec 2019 17:37:48 +0100 Subject: [PATCH] Fix plot biomes. When migrating to the WorldEdit Biome types, code was not altered to account for these changes. This lead to configuration parsing breaking, and the `/plot setbiome` command no longer functioning. This fixes #2599. --- .../plotsquared/plot/commands/Biome.java | 28 ++++++++++--------- .../plot/config/Configuration.java | 6 +--- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Biome.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Biome.java index d377acd15..df48c1aed 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Biome.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Biome.java @@ -15,20 +15,11 @@ import com.sk89q.worldedit.world.biome.BiomeTypes; requiredType = RequiredType.NONE) public class Biome extends SetCommand { @Override public boolean set(final PlotPlayer player, final Plot plot, final String value) { + BiomeType biome = null; try { - BiomeType biome = BiomeTypes.get(value); - if (plot.getRunning() > 0) { - MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER); - return false; - } - plot.addRunning(); - plot.setBiome(biome, () -> { - plot.removeRunning(); - MainUtil - .sendMessage(player, Captions.BIOME_SET_TO.getTranslated() + value.toLowerCase()); - }); - return true; - } catch (IllegalStateException ignore) { + biome = BiomeTypes.get(value.toLowerCase()); + } catch (final Exception ignore) {} + if (biome == null) { String biomes = StringMan .join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated()); Captions.NEED_BIOME.send(player); @@ -36,5 +27,16 @@ import com.sk89q.worldedit.world.biome.BiomeTypes; Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + biomes); return false; } + if (plot.getRunning() > 0) { + MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER); + return false; + } + plot.addRunning(); + plot.setBiome(biome, () -> { + plot.removeRunning(); + MainUtil + .sendMessage(player, Captions.BIOME_SET_TO.getTranslated() + value.toLowerCase()); + }); + return true; } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Configuration.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Configuration.java index aba85f3f8..1fa167177 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Configuration.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Configuration.java @@ -1,8 +1,6 @@ package com.github.intellectualsites.plotsquared.plot.config; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; -import com.github.intellectualsites.plotsquared.plot.util.StringComparison; -import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeTypes; @@ -10,8 +8,6 @@ import com.sk89q.worldedit.world.block.BlockState; import lombok.Getter; import lombok.NonNull; -import java.util.regex.Matcher; - /** * Main Configuration Utility */ @@ -53,7 +49,7 @@ public class Configuration { @Override public BiomeType parseString(String string) { if (validateValue(string)) { - return BiomeTypes.get(string.toUpperCase()); + return BiomeTypes.get(string.toLowerCase()); } return BiomeTypes.FOREST; }