Merge branch 'version/7.2.x'

This commit is contained in:
Madeline Miller 2024-01-06 21:59:18 +10:00
commit 64bcf66eb4
No known key found for this signature in database
GPG Key ID: B8EA2E5693115D81
4 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,43 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent.clipboard.io;
import com.sk89q.worldedit.util.formatting.text.Component;
/**
* Raised when a known exception occurs during schematic load.
*/
public final class SchematicLoadException extends RuntimeException {
private final Component message;
public SchematicLoadException(Component message) {
this.message = message;
}
/**
* Get the message of this exception as a rich text component.
*
* @return The rich message
*/
public Component getRichMessage() {
return this.message;
}
}

View File

@ -28,6 +28,8 @@ import com.sk89q.worldedit.extent.clipboard.io.sponge.ReaderUtil;
import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader;
import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV2Reader;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import java.io.IOException;
import java.util.OptionalInt;
@ -56,7 +58,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
return switch (version) {
case 1 -> SpongeSchematicV1Reader.doRead(schematicTag.toLinTag());
case 2 -> SpongeSchematicV2Reader.doRead(schematicTag.toLinTag());
default -> throw new IllegalStateException("Unsupported schematic version: " + version);
default -> throw new SchematicLoadException(TranslatableComponent.of("worldedit.schematic.load.unsupported-version", TextComponent.of(version)));
};
}

View File

@ -34,6 +34,7 @@ import com.sk89q.worldedit.command.InsufficientArgumentsException;
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extent.clipboard.io.SchematicLoadException;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.util.formatting.text.Component;
@ -183,6 +184,11 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
throw newCommandException(TranslatableComponent.of("worldedit.error.file-aborted"), e);
}
@ExceptionMatch
public void convert(SchematicLoadException e) throws CommandException {
throw newCommandException(e.getRichMessage(), e);
}
@ExceptionMatch
public void convert(WorldEditException e) throws CommandException {
throw newCommandException(e.getRichMessage(), e);

View File

@ -125,6 +125,7 @@
"worldedit.schematic.load.does-not-exist": "Schematic {0} does not exist!",
"worldedit.schematic.load.loading": "(Please wait... loading schematic.)",
"worldedit.schematic.load.still-loading": "(Please wait... still loading schematic.)",
"worldedit.schematic.load.unsupported-version": "This schematic version is currently not supported. Version: {0}.",
"worldedit.schematic.save.already-exists": "That schematic already exists. Use the -f flag to overwrite it.",
"worldedit.schematic.save.failed-directory": "Could not create folder for schematics!",
"worldedit.schematic.save.saving": "(Please wait... saving schematic.)",