mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-15 01:08:35 +00:00
Update upstream
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard.io;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.jnbt.AdventureNBTConverter;
|
||||
import com.sk89q.jnbt.ByteArrayTag;
|
||||
@ -46,6 +47,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.world.DataFixer;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
@ -137,9 +139,8 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
BlockArrayClipboard clip = readVersion1(schematicTag);
|
||||
return readVersion2(clip, schematicTag);
|
||||
}
|
||||
throw new IOException("This schematic version is not supported; Version: " + schematicVersion + ", DataVersion: " + dataVersion + "." +
|
||||
"It's very likely your schematic has an invalid file extension, if the schematic has been created on a version lower than" +
|
||||
"1.13.2, the extension MUST be `.schematic`, elsewise the schematic can't be read properly.");
|
||||
throw new SchematicLoadException(Caption.of("worldedit.schematic.load.unsupported-version",
|
||||
TextComponent.of(schematicVersion)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -169,6 +170,13 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
// Check
|
||||
Map<String, Tag> schematic = schematicTag.getValue();
|
||||
|
||||
// Be lenient about the specific nesting level of the Schematic tag
|
||||
// Also allows checking the version from newer versions of the specification
|
||||
if (schematic.size() == 1 && schematic.containsKey("Schematic")) {
|
||||
schematicTag = requireTag(schematic, "Schematic", CompoundTag.class);
|
||||
schematic = schematicTag.getValue();
|
||||
}
|
||||
|
||||
schematicVersion = requireTag(schematic, "Version", IntTag.class).getValue();
|
||||
return schematicTag;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
@ -34,7 +35,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class DataValidatorExtent extends AbstractDelegateExtent {
|
||||
|
||||
private final World world;
|
||||
private final int minY;
|
||||
private final int maxY;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -43,16 +45,27 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
|
||||
* @param world the world
|
||||
*/
|
||||
public DataValidatorExtent(Extent extent, World world) {
|
||||
this(extent, checkNotNull(world).getMinY(), world.getMaxY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent The extent
|
||||
* @param minY The minimum Y height to allow (inclusive)
|
||||
* @param maxY The maximum Y height to allow (inclusive)
|
||||
*/
|
||||
public DataValidatorExtent(Extent extent, int minY, int maxY) {
|
||||
super(extent);
|
||||
checkNotNull(world);
|
||||
this.world = world;
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||
final int y = location.getBlockY();
|
||||
final BlockType type = block.getBlockType();
|
||||
if (y < world.getMinY() || y > world.getMaxY()) {
|
||||
if (y < minY || y > maxY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -64,4 +77,15 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 location, BiomeType biome) {
|
||||
final int y = location.getBlockY();
|
||||
|
||||
if (y < minY || y > maxY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.setBiome(location, biome);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user