3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-05 02:50:05 +01:00

fix tabcomplete for biomes and tree types, fixes #457

Dieser Commit ist enthalten in:
wea_ondara 2020-10-10 15:41:34 +02:00 committet von Aurora
Ursprung 8c26c55501
Commit 6d45169d9d

Datei anzeigen

@ -3,17 +3,14 @@ package com.sk89q.worldedit.extension.platform.binding;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Caption;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.image.ImageUtil;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.annotation.Confirm;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.annotation.Selection;
@ -23,20 +20,13 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import org.enginehub.piston.inject.InjectedValueAccess;
import java.util.Collection;
import java.util.UUID;
public class ConsumeBindings extends Bindings {
@ -167,58 +157,4 @@ public class ConsumeBindings extends Bindings {
throw new InputParseException(e.getMessage());
}
}
/**
* Gets an {@link TreeType} from a {@link Binding}.
*
* @param argument the context
* @return a TreeType
* @throws WorldEditException on error
*/
@Binding
public TreeGenerator.TreeType getTreeType(String argument) throws WorldEditException {
if (argument != null) {
TreeGenerator.TreeType type = TreeGenerator.lookup(argument);
if (type != null) {
return type;
} else {
throw new InputParseException(
String.format("Can't recognize tree type '%s' -- choose from: %s", argument,
TreeGenerator.TreeType.getPrimaryAliases()));
}
} else {
return TreeGenerator.TreeType.TREE;
}
}
/**
* Gets an {@link BiomeType} from a {@link Binding}.
*
* @param argument the context
* @return a BiomeType
* @throws WorldEditException on error
*/
@Binding
public BiomeType getBiomeType(String argument) throws WorldEditException {
if (argument != null) {
if (MathMan.isInteger(argument)) {
return BiomeTypes.getLegacy(Integer.parseInt(argument));
}
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
Collection<BiomeType> knownBiomes = BiomeType.REGISTRY.values();
BiomeType biome = Biomes.findBiomeByName(knownBiomes, argument, biomeRegistry);
if (biome != null) {
return biome;
} else {
throw new InputParseException(
String.format("Can't recognize biome type '%s' -- use /biomelist to list available types", argument));
}
} else {
throw new InputParseException(
"This command takes a 'default' biome if one is not set, except there is no particular " +
"biome that should be 'default', so the command should not be taking a default biome");
}
}
}