mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 20:16:41 +00:00
Finish up transition to captions
This commit is contained in:
@ -48,6 +48,8 @@ import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||
@ -80,12 +82,15 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
try {
|
||||
return ((Player) actor).getBlockInHand(handSide);
|
||||
} catch (NotABlockException e) {
|
||||
throw new InputParseException("You're not holding a block!");
|
||||
throw new InputParseException(e.getRichMessage());
|
||||
} catch (WorldEditException e) {
|
||||
throw new InputParseException("Unknown error occurred: " + e.getMessage(), e);
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.unknown", e.getRichMessage()), e);
|
||||
}
|
||||
} else {
|
||||
throw new InputParseException("The user is not a player!");
|
||||
throw new InputParseException(TranslatableComponent.of(
|
||||
"worldedit.error.parser.player-only",
|
||||
TextComponent.of(handSide == HandSide.MAIN_HAND ? "hand" : "offhand")
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,35 +180,51 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
try {
|
||||
String[] parts = parseableData.split("=");
|
||||
if (parts.length != 2) {
|
||||
throw new NoMatchException("Bad state format in " + parseableData);
|
||||
throw new InputParseException(
|
||||
TranslatableComponent.of("worldedit.error.parser.bad-state-format",
|
||||
TextComponent.of(parseableData))
|
||||
);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Property<Object> propertyKey = (Property<Object>) type.getPropertyMap().get(parts[0]);
|
||||
if (propertyKey == null) {
|
||||
if (context.getActor() != null) {
|
||||
throw new NoMatchException("Unknown property " + parts[0] + " for block " + type.getId());
|
||||
throw new NoMatchException(TranslatableComponent.of(
|
||||
"worldedit.error.parser.unknown-property",
|
||||
TextComponent.of(parts[0]),
|
||||
TextComponent.of(type.getId())
|
||||
));
|
||||
} else {
|
||||
WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.getId());
|
||||
}
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
if (blockStates.containsKey(propertyKey)) {
|
||||
throw new NoMatchException("Duplicate property " + parts[0]);
|
||||
throw new InputParseException(TranslatableComponent.of(
|
||||
"worldedit.error.parser.duplicate-property",
|
||||
TextComponent.of(parts[0])
|
||||
));
|
||||
}
|
||||
Object value;
|
||||
try {
|
||||
value = propertyKey.getValueFor(parts[1]);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new NoMatchException("Unknown value " + parts[1] + " for state " + parts[0]);
|
||||
throw new NoMatchException(TranslatableComponent.of(
|
||||
"worldedit.error.parser.unknown-value",
|
||||
TextComponent.of(parts[1]),
|
||||
TextComponent.of(propertyKey.getName())
|
||||
));
|
||||
}
|
||||
|
||||
blockStates.put(propertyKey, value);
|
||||
} catch (NoMatchException e) {
|
||||
throw e; // Pass-through
|
||||
} catch (Exception e) {
|
||||
WorldEdit.logger.warn("Unknown state '" + parseableData + "'", e);
|
||||
throw new NoMatchException("Unknown state '" + parseableData + "'");
|
||||
throw new InputParseException(TranslatableComponent.of(
|
||||
"worldedit.error.parser.bad-state-format",
|
||||
TextComponent.of(parseableData)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -243,14 +264,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
try {
|
||||
String[] split = blockAndExtraData[0].split(":", 2);
|
||||
if (split.length == 0) {
|
||||
throw new InputParseException("Invalid colon.");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.invalid-colon"));
|
||||
} else if (split.length == 1) {
|
||||
state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]));
|
||||
} else if (MathMan.isInteger(split[0])) {
|
||||
int id = Integer.parseInt(split[0]);
|
||||
int data = Integer.parseInt(split[1]);
|
||||
if (data < 0 || data >= 16) {
|
||||
throw new InputParseException("Invalid data " + data);
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.parser.invalid-data", TextComponent.of(data)));
|
||||
}
|
||||
state = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
|
||||
} else {
|
||||
@ -258,7 +279,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
if (type != null) {
|
||||
int data = Integer.parseInt(split[1]);
|
||||
if (data < 0 || data >= 16) {
|
||||
throw new InputParseException("Invalid data " + data);
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.parser.invalid-data", TextComponent.of(data)));
|
||||
}
|
||||
state = LegacyMapper.getInstance().getBlockFromLegacy(type.getLegacyCombinedId() >> 4, data);
|
||||
}
|
||||
@ -277,11 +298,11 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
} else {
|
||||
typeString = blockAndExtraData[0].substring(0, stateStart);
|
||||
if (stateStart + 1 >= blockAndExtraData[0].length()) {
|
||||
throw new InputParseException("Invalid format. Hanging bracket @ " + stateStart + ".");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.hanging-lbracket", TextComponent.of(stateStart)));
|
||||
}
|
||||
int stateEnd = blockAndExtraData[0].lastIndexOf(']');
|
||||
if (stateEnd < 0) {
|
||||
throw new InputParseException("Invalid format. Unclosed property.");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.missing-rbracket"));
|
||||
}
|
||||
stateString = blockAndExtraData[0].substring(stateStart + 1, blockAndExtraData[0].length() - 1);
|
||||
}
|
||||
@ -290,7 +311,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
stateProperties = stateString.split(",");
|
||||
}
|
||||
if (typeString.isEmpty()) {
|
||||
throw new InputParseException("Invalid format");
|
||||
throw new InputParseException(TranslatableComponent.of(
|
||||
"worldedit.error.parser.bad-state-format",
|
||||
TextComponent.of(blockAndExtraData[0])
|
||||
));
|
||||
}
|
||||
if ("hand".equalsIgnoreCase(typeString)) {
|
||||
// Get the block type from the item in the user's hand.
|
||||
@ -310,25 +334,25 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
try {
|
||||
primaryPosition = context.requireSession().getRegionSelector(world).getVertices().get(index - 1);
|
||||
} catch (IncompleteRegionException e) {
|
||||
throw new InputParseException("Your selection is not complete.");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.incomplete-region"));
|
||||
}
|
||||
state = world.getBlock(primaryPosition);
|
||||
} else if (typeString.matches("slot[0-9]+")) {
|
||||
int slot = Integer.parseInt(typeString.substring(4)) - 1;
|
||||
Actor actor = context.requireActor();
|
||||
if (!(actor instanceof Player)) {
|
||||
throw new InputParseException("The user is not a player!");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.command.player-only"));
|
||||
}
|
||||
Player player = (Player) actor;
|
||||
BlockBag bag = player.getInventoryBlockBag();
|
||||
if (!(bag instanceof SlottableBlockBag)) {
|
||||
throw new InputParseException("Unsupported!");
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.unsupported"));
|
||||
}
|
||||
SlottableBlockBag slottable = (SlottableBlockBag) bag;
|
||||
BaseItem item = slottable.getItem(slot);
|
||||
|
||||
if (!item.getType().hasBlockType()) {
|
||||
throw new InputParseException("You're not holding a block!");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.not-a-block"));
|
||||
}
|
||||
state = item.getType().getBlockType().getDefaultState();
|
||||
nbt = item.getNbtData();
|
||||
@ -339,8 +363,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
state = type.getDefaultState();
|
||||
}
|
||||
if (state == null) {
|
||||
throw new NoMatchException(
|
||||
"Does not match a valid block type: '" + input + "'");
|
||||
throw new NoMatchException(TranslatableComponent.of("fawe.error.invalid-block-type", TextComponent.of(input)));
|
||||
}
|
||||
}
|
||||
if (nbt == null) {
|
||||
@ -371,7 +394,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
// this should be impossible but IntelliJ isn't that smart
|
||||
if (state == null) {
|
||||
throw new NoMatchException("Does not match a valid block type: '" + input + "'");
|
||||
throw new NoMatchException(TranslatableComponent.of("fawe.error.invalid-block-type", TextComponent.of(input)));
|
||||
}
|
||||
|
||||
if (blockAndExtraData.length > 1 && blockAndExtraData[1].startsWith("{")) {
|
||||
@ -379,7 +402,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
try {
|
||||
nbt = JSON2NBT.getTagFromJson(joined);
|
||||
} catch (NBTException e) {
|
||||
throw new NoMatchException(e.getMessage());
|
||||
throw new NoMatchException(TranslatableComponent.of(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,7 +413,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
Actor actor = context.requireActor();
|
||||
if (actor != null && !actor.hasPermission("worldedit.anyblock")
|
||||
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.getId())) {
|
||||
throw new DisallowedUsageException("You are not allowed to use '" + input + "'");
|
||||
throw new DisallowedUsageException(TranslatableComponent.of("fawe.error.block.not.allowed", TextComponent.of(input)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -413,11 +436,11 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
String mobName = blockAndExtraData[1];
|
||||
EntityType ent = EntityTypes.get(mobName.toLowerCase(Locale.ROOT));
|
||||
if (ent == null) {
|
||||
throw new NoMatchException("Unknown entity type '" + mobName + "'");
|
||||
throw new NoMatchException(TranslatableComponent.of("worldedit.error.unknown-entity", TextComponent.of(mobName)));
|
||||
}
|
||||
mobName = ent.getId();
|
||||
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
|
||||
throw new NoMatchException("Unknown mob type '" + mobName + "'");
|
||||
throw new NoMatchException(TranslatableComponent.of("worldedit.error.unknown-mob", TextComponent.of(mobName)));
|
||||
}
|
||||
return validate(context, new MobSpawnerBlock(state, mobName));
|
||||
} else {
|
||||
@ -442,12 +465,12 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
if (context.isRestricted()) {
|
||||
Actor actor = context.requireActor();
|
||||
if (!actor.hasPermission("worldedit.anyblock") && worldEdit.getConfiguration().checkDisallowedBlocks(holder)) {
|
||||
throw new DisallowedUsageException(Caption.toString(Caption.of("fawe.error.block.not.allowed", holder)));
|
||||
throw new DisallowedUsageException(TranslatableComponent.of("fawe.error.block.not.allowed", TextComponent.of(String.valueOf(holder))));
|
||||
}
|
||||
CompoundTag nbt = holder.getNbtData();
|
||||
if (nbt != null) {
|
||||
if (!actor.hasPermission("worldedit.anyblock")) {
|
||||
throw new DisallowedUsageException("You are not allowed to use nbt'");
|
||||
throw new DisallowedUsageException(TranslatableComponent.of("fawe.error.nbt.forbidden"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
@ -56,7 +58,7 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
String[] split = input.split(":");
|
||||
ItemType type;
|
||||
if (split.length == 0) {
|
||||
throw new InputParseException("Invalid colon.");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.invalid-colon"));
|
||||
} else if (split.length == 1) {
|
||||
type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]));
|
||||
} else {
|
||||
@ -83,7 +85,7 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
}
|
||||
|
||||
if (item == null) {
|
||||
throw new InputParseException("'" + input + "' did not match any item");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.unknown-item", TextComponent.of(input)));
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
@ -93,7 +95,10 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
if (actor instanceof Player) {
|
||||
return ((Player) actor).getItemInHand(handSide);
|
||||
} else {
|
||||
throw new InputParseException("The user is not a player!");
|
||||
throw new InputParseException(TranslatableComponent.of(
|
||||
"worldedit.error.parser.player-only",
|
||||
TextComponent.of(handSide == HandSide.MAIN_HAND ? "hand" : "offhand")
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -141,7 +143,7 @@ public abstract class RichParser<E> extends InputParser<E> {
|
||||
arguments.add(input.substring(openIndex + 1));
|
||||
}
|
||||
if (requireClosing && open != 0) {
|
||||
throw new InputParseException("Invalid bracketing, are you missing a '[' or ']'?");
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.invalid-bracketing", TextComponent.of("'[' or ']'?")));
|
||||
}
|
||||
return arguments.toArray(new String[0]);
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.BlockCategoryMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
|
||||
import java.util.Locale;
|
||||
@ -51,7 +53,7 @@ public class BlockCategoryMaskParser extends InputParser<Mask> {
|
||||
// This means it's a tag mask.
|
||||
BlockCategory category = BlockCategory.REGISTRY.get(input.substring(2).toLowerCase(Locale.ROOT));
|
||||
if (category == null) {
|
||||
throw new InputParseException("Unrecognised tag '" + input.substring(2) + '\'');
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.unrecognised-tag", TextComponent.of(input.substring(2)), TextComponent.of("\\")));
|
||||
} else {
|
||||
return new BlockCategoryMask(context.requireExtent(), category);
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.BlockStateMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -56,7 +58,7 @@ public class BlockStateMaskParser extends InputParser<Mask> {
|
||||
Splitter.on(',').omitEmptyStrings().trimResults().withKeyValueSeparator('=').split(states),
|
||||
strict);
|
||||
} catch (Exception e) {
|
||||
throw new InputParseException("Invalid states.", e);
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.invalid-states", TextComponent.of(String.valueOf(e))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
import com.sk89q.worldedit.session.SessionOwner;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.stream.Stream;
|
||||
@ -66,7 +68,7 @@ public class ExpressionMaskParser extends InputParser<Mask> {
|
||||
}
|
||||
return new ExpressionMask(exp);
|
||||
} catch (ExpressionException e) {
|
||||
throw new InputParseException("Invalid expression: " + e.getMessage());
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.invalid-expression", TextComponent.of(e.getMessage())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -54,7 +55,7 @@ public class NegateMaskParser extends InputParser<Mask> {
|
||||
if (input.length() > 1) {
|
||||
return Masks.negate(worldEdit.getMaskFactory().parseFromInput(input.substring(1), context));
|
||||
} else {
|
||||
throw new InputParseException("Can't negate nothing!");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.negate-nothing"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -48,7 +49,7 @@ public class RegionMaskParser extends SimpleInputParser<Mask> {
|
||||
try {
|
||||
return new RegionMask(context.requireSession().getSelection(context.requireWorld()).clone());
|
||||
} catch (IncompleteRegionException e) {
|
||||
throw new InputParseException("Please make a selection first.");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.incomplete-region"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class BiomePatternParser extends RichParser<Pattern> {
|
||||
@Override
|
||||
protected Pattern parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException {
|
||||
if (arguments.length != 1) {
|
||||
throw new InputParseException("Invalid amount of arguments. Expected: #biome[<biome>]");
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.invalid-arguments", TextComponent.of("#biome[<biome>]")));
|
||||
}
|
||||
BiomeType biomeType = BiomeTypes.get(arguments[0]);
|
||||
if (biomeType == null) {
|
||||
|
@ -26,6 +26,8 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
@ -58,13 +60,13 @@ public class BlockCategoryPatternParser extends InputParser<Pattern> {
|
||||
|
||||
BlockCategory category = BlockCategory.REGISTRY.get(tag);
|
||||
if (category == null) {
|
||||
throw new InputParseException("Unknown block tag: " + tag);
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.unknown-block-tag", TextComponent.of(tag)));
|
||||
}
|
||||
RandomPattern randomPattern = new RandomPattern();
|
||||
|
||||
Set<BlockType> blocks = category.getAll();
|
||||
if (blocks.isEmpty()) {
|
||||
throw new InputParseException("Block tag " + category.getId() + " had no blocks!");
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.block-tag-no-blocks", TextComponent.of(category.getId())));
|
||||
}
|
||||
|
||||
if (anyState) {
|
||||
|
@ -30,6 +30,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
@ -78,11 +80,11 @@ public class ClipboardPatternParser extends InputParser<Pattern> {
|
||||
String coords = offsetParts[1];
|
||||
if (coords.length() < 7 // min length of `[x,y,z]`
|
||||
|| coords.charAt(0) != '[' || coords.charAt(coords.length() - 1) != ']') {
|
||||
throw new InputParseException("Offset specified with @ but no offset given. Use '#copy@[x,y,z]'.");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.clipboard.missing-offset"));
|
||||
}
|
||||
String[] offsetSplit = coords.substring(1, coords.length() - 1).split(",");
|
||||
if (offsetSplit.length != 3) {
|
||||
throw new InputParseException("Clipboard offset needs x,y,z coordinates.");
|
||||
throw new InputParseException(TranslatableComponent.of("worldedit.error.parser.clipboard.missing-coordinates"));
|
||||
}
|
||||
offset = BlockVector3.at(
|
||||
Integer.valueOf(offsetSplit[0]),
|
||||
@ -97,10 +99,10 @@ public class ClipboardPatternParser extends InputParser<Pattern> {
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
return new ClipboardPattern(clipboard, offset);
|
||||
} catch (EmptyClipboardException e) {
|
||||
throw new InputParseException("To use #clipboard, please first copy something to your clipboard");
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.empty-clipboard", TextComponent.of("#clipboard")));
|
||||
}
|
||||
} else {
|
||||
throw new InputParseException("No session is available, so no clipboard is available");
|
||||
throw new InputParseException(TranslatableComponent.of("fawe.error.no-session"));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user