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.
This commit is contained in:
Alexander Söderberg 2019-12-20 17:37:48 +01:00
parent ccc7b0ec65
commit c6e36fd70e
2 changed files with 16 additions and 18 deletions

View File

@ -15,8 +15,18 @@ import com.sk89q.worldedit.world.biome.BiomeTypes;
requiredType = RequiredType.NONE) public class Biome extends SetCommand { requiredType = RequiredType.NONE) public class Biome extends SetCommand {
@Override public boolean set(final PlotPlayer player, final Plot plot, final String value) { @Override public boolean set(final PlotPlayer player, final Plot plot, final String value) {
BiomeType biome = null;
try { try {
BiomeType biome = BiomeTypes.get(value); 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);
MainUtil.sendMessage(player,
Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + biomes);
return false;
}
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER); MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
return false; return false;
@ -28,13 +38,5 @@ import com.sk89q.worldedit.world.biome.BiomeTypes;
.sendMessage(player, Captions.BIOME_SET_TO.getTranslated() + value.toLowerCase()); .sendMessage(player, Captions.BIOME_SET_TO.getTranslated() + value.toLowerCase());
}); });
return true; return true;
} catch (IllegalStateException ignore) {
String biomes = StringMan
.join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated());
Captions.NEED_BIOME.send(player);
MainUtil.sendMessage(player,
Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + biomes);
return false;
}
} }
} }

View File

@ -1,8 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.config; package com.github.intellectualsites.plotsquared.plot.config;
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; 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.function.pattern.Pattern;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
@ -10,8 +8,6 @@ import com.sk89q.worldedit.world.block.BlockState;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import java.util.regex.Matcher;
/** /**
* Main Configuration Utility * Main Configuration Utility
*/ */
@ -53,7 +49,7 @@ public class Configuration {
@Override public BiomeType parseString(String string) { @Override public BiomeType parseString(String string) {
if (validateValue(string)) { if (validateValue(string)) {
return BiomeTypes.get(string.toUpperCase()); return BiomeTypes.get(string.toLowerCase());
} }
return BiomeTypes.FOREST; return BiomeTypes.FOREST;
} }