Update upstream

This commit is contained in:
Alexander Brandes 2024-01-06 10:53:53 +01:00
parent a4a11265ec
commit 7b4b384df6
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
7 changed files with 149 additions and 51 deletions

View File

@ -141,20 +141,15 @@ tasks.named<Jar>("jar") {
addJarManifest(WorldEditKind.Plugin, includeClasspath = true) addJarManifest(WorldEditKind.Plugin, includeClasspath = true)
tasks.named<ShadowJar>("shadowJar") { tasks.named<ShadowJar>("shadowJar") {
dependsOn(project.project(":worldedit-bukkit:adapters").subprojects.map { it.tasks.named("assemble") }) configurations.add(adapters)
from(Callable {
adapters.resolve()
.map { f ->
zipTree(f).matching {
exclude("META-INF/")
}
}
})
archiveFileName.set("${rootProject.name}-Bukkit-${project.version}.${archiveExtension.getOrElse("jar")}") archiveFileName.set("${rootProject.name}-Bukkit-${project.version}.${archiveExtension.getOrElse("jar")}")
dependencies { dependencies {
// In tandem with not bundling log4j, we shouldn't relocate base package here. // In tandem with not bundling log4j, we shouldn't relocate base package here.
// relocate("org.apache.logging", "com.sk89q.worldedit.log4j") // relocate("org.apache.logging", "com.sk89q.worldedit.log4j")
relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4") relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4")
exclude(dependency("$group:$name"))
include(dependency(":worldedit-core")) include(dependency(":worldedit-core"))
include(dependency(":worldedit-libs:bukkit")) include(dependency(":worldedit-libs:bukkit"))
// Purposefully not included, we assume (even though no API exposes it) that Log4J will be present at runtime // Purposefully not included, we assume (even though no API exposes it) that Log4J will be present at runtime
@ -192,6 +187,15 @@ tasks.named<ShadowJar>("shadowJar") {
include(dependency("org.anarres:parallelgzip:1.0.5")) include(dependency("org.anarres:parallelgzip:1.0.5"))
} }
} }
project.project(":worldedit-bukkit:adapters").subprojects.forEach {
dependencies {
include(dependency("${it.group}:${it.name}"))
}
minimize {
exclude(dependency("${it.group}:${it.name}"))
}
}
} }
tasks.named("assemble").configure { tasks.named("assemble").configure {

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

@ -19,6 +19,7 @@
package com.sk89q.worldedit.extent.clipboard.io; package com.sk89q.worldedit.extent.clipboard.io;
import com.fastasyncworldedit.core.configuration.Caption;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.sk89q.jnbt.AdventureNBTConverter; import com.sk89q.jnbt.AdventureNBTConverter;
import com.sk89q.jnbt.ByteArrayTag; 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.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; 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.DataFixer;
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;
@ -137,9 +139,8 @@ public class SpongeSchematicReader extends NBTSchematicReader {
BlockArrayClipboard clip = readVersion1(schematicTag); BlockArrayClipboard clip = readVersion1(schematicTag);
return readVersion2(clip, schematicTag); return readVersion2(clip, schematicTag);
} }
throw new IOException("This schematic version is not supported; Version: " + schematicVersion + ", DataVersion: " + dataVersion + "." + throw new SchematicLoadException(Caption.of("worldedit.schematic.load.unsupported-version",
"It's very likely your schematic has an invalid file extension, if the schematic has been created on a version lower than" + TextComponent.of(schematicVersion)));
"1.13.2, the extension MUST be `.schematic`, elsewise the schematic can't be read properly.");
} }
@Override @Override
@ -169,6 +170,13 @@ public class SpongeSchematicReader extends NBTSchematicReader {
// Check // Check
Map<String, Tag> schematic = schematicTag.getValue(); 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(); schematicVersion = requireTag(schematic, "Version", IntTag.class).getValue();
return schematicTag; return schematicTag;
} }

View File

@ -24,6 +24,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.World; 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.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
@ -34,7 +35,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/ */
public class DataValidatorExtent extends AbstractDelegateExtent { public class DataValidatorExtent extends AbstractDelegateExtent {
private final World world; private final int minY;
private final int maxY;
/** /**
* Create a new instance. * Create a new instance.
@ -43,16 +45,27 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
* @param world the world * @param world the world
*/ */
public DataValidatorExtent(Extent extent, World 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); super(extent);
checkNotNull(world); this.minY = minY;
this.world = world; this.maxY = maxY;
} }
@Override @Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException { public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
final int y = location.getBlockY(); final int y = location.getBlockY();
final BlockType type = block.getBlockType(); final BlockType type = block.getBlockType();
if (y < world.getMinY() || y > world.getMaxY()) { if (y < minY || y > maxY) {
return false; return false;
} }
@ -64,4 +77,15 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
return super.setBlock(location, block); 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);
}
} }

View File

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

View File

@ -195,6 +195,33 @@ public class AffineTransform implements Transform, Serializable {
// =================================================================== // ===================================================================
// general methods // general methods
/**
* Returns the affine transform created by applying first the affine
* transform given by the parameters, then this affine transform.
*
* @return the composition this * that
*/
public AffineTransform concatenate(double o00, double o01, double o02, double o03,
double o10, double o11, double o12, double o13,
double o20, double o21, double o22, double o23) {
double n00 = m00 * o00 + m01 * o10 + m02 * o20;
double n01 = m00 * o01 + m01 * o11 + m02 * o21;
double n02 = m00 * o02 + m01 * o12 + m02 * o22;
double n03 = m00 * o03 + m01 * o13 + m02 * o23 + m03;
double n10 = m10 * o00 + m11 * o10 + m12 * o20;
double n11 = m10 * o01 + m11 * o11 + m12 * o21;
double n12 = m10 * o02 + m11 * o12 + m12 * o22;
double n13 = m10 * o03 + m11 * o13 + m12 * o23 + m13;
double n20 = m20 * o00 + m21 * o10 + m22 * o20;
double n21 = m20 * o01 + m21 * o11 + m22 * o21;
double n22 = m20 * o02 + m21 * o12 + m22 * o22;
double n23 = m20 * o03 + m21 * o13 + m22 * o23 + m23;
return new AffineTransform(
n00, n01, n02, n03,
n10, n11, n12, n13,
n20, n21, n22, n23);
}
/** /**
* Returns the affine transform created by applying first the affine * Returns the affine transform created by applying first the affine
* transform given by {@code that}, then this affine transform. * transform given by {@code that}, then this affine transform.
@ -203,22 +230,10 @@ public class AffineTransform implements Transform, Serializable {
* @return the composition this * that * @return the composition this * that
*/ */
public AffineTransform concatenate(AffineTransform that) { public AffineTransform concatenate(AffineTransform that) {
double n00 = m00 * that.m00 + m01 * that.m10 + m02 * that.m20; return concatenate(
double n01 = m00 * that.m01 + m01 * that.m11 + m02 * that.m21; that.m00, that.m01, that.m02, that.m03,
double n02 = m00 * that.m02 + m01 * that.m12 + m02 * that.m22; that.m10, that.m11, that.m12, that.m13,
double n03 = m00 * that.m03 + m01 * that.m13 + m02 * that.m23 + m03; that.m20, that.m21, that.m22, that.m23
double n10 = m10 * that.m00 + m11 * that.m10 + m12 * that.m20;
double n11 = m10 * that.m01 + m11 * that.m11 + m12 * that.m21;
double n12 = m10 * that.m02 + m11 * that.m12 + m12 * that.m22;
double n13 = m10 * that.m03 + m11 * that.m13 + m12 * that.m23 + m13;
double n20 = m20 * that.m00 + m21 * that.m10 + m22 * that.m20;
double n21 = m20 * that.m01 + m21 * that.m11 + m22 * that.m21;
double n22 = m20 * that.m02 + m21 * that.m12 + m22 * that.m22;
double n23 = m20 * that.m03 + m21 * that.m13 + m22 * that.m23 + m23;
return new AffineTransform(
n00, n01, n02, n03,
n10, n11, n12, n13,
n20, n21, n22, n23
); );
} }
@ -258,40 +273,37 @@ public class AffineTransform implements Transform, Serializable {
} }
public AffineTransform translate(double x, double y, double z) { public AffineTransform translate(double x, double y, double z) {
return concatenate(new AffineTransform(1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z)); return concatenate(1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z);
} }
public AffineTransform rotateX(double theta) { public AffineTransform rotateX(double theta) {
double cot = MathUtils.dCos(theta); double cot = MathUtils.dCos(theta);
double sit = MathUtils.dSin(theta); double sit = MathUtils.dSin(theta);
return concatenate( return concatenate(
new AffineTransform(
1, 0, 0, 0, 1, 0, 0, 0,
0, cot, -sit, 0, 0, cot, -sit, 0,
0, sit, cot, 0 0, sit, cot, 0
)); );
} }
public AffineTransform rotateY(double theta) { public AffineTransform rotateY(double theta) {
double cot = MathUtils.dCos(theta); double cot = MathUtils.dCos(theta);
double sit = MathUtils.dSin(theta); double sit = MathUtils.dSin(theta);
return concatenate( return concatenate(
new AffineTransform(
cot, 0, sit, 0, cot, 0, sit, 0,
0, 1, 0, 0, 0, 1, 0, 0,
-sit, 0, cot, 0 -sit, 0, cot, 0
)); );
} }
public AffineTransform rotateZ(double theta) { public AffineTransform rotateZ(double theta) {
double cot = MathUtils.dCos(theta); double cot = MathUtils.dCos(theta);
double sit = MathUtils.dSin(theta); double sit = MathUtils.dSin(theta);
return concatenate( return concatenate(
new AffineTransform(
cot, -sit, 0, 0, cot, -sit, 0, 0,
sit, cot, 0, 0, sit, cot, 0, 0,
0, 0, 1, 0 0, 0, 1, 0
)); );
} }
public AffineTransform scale(double s) { public AffineTransform scale(double s) {
@ -299,7 +311,7 @@ public class AffineTransform implements Transform, Serializable {
} }
public AffineTransform scale(double sx, double sy, double sz) { public AffineTransform scale(double sx, double sy, double sz) {
return concatenate(new AffineTransform(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0)); return concatenate(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0);
} }
public AffineTransform scale(Vector3 vec) { public AffineTransform scale(Vector3 vec) {
@ -352,9 +364,9 @@ public class AffineTransform implements Transform, Serializable {
//FAWE start - check other identity //FAWE start - check other identity
if (other instanceof Identity || other.isIdentity()) { if (other instanceof Identity || other.isIdentity()) {
return this; return this;
} else if (other instanceof AffineTransform) { } else if (other instanceof AffineTransform otherTransform) {
//FAWE end //FAWE end
return concatenate((AffineTransform) other); return concatenate(otherTransform);
} else { } else {
return new CombinedTransform(this, other); return new CombinedTransform(this, other);
} }

View File

@ -354,6 +354,7 @@
"worldedit.schematic.unknown-format": "Unknown schematic format: {0}.", "worldedit.schematic.unknown-format": "Unknown schematic format: {0}.",
"worldedit.schematic.load.does-not-exist": "Schematic {0} does not exist!", "worldedit.schematic.load.does-not-exist": "Schematic {0} does not exist!",
"worldedit.schematic.load.loading": "(Please wait... loading schematic.)", "worldedit.schematic.load.loading": "(Please wait... loading schematic.)",
"worldedit.schematic.load.unsupported-version": "This schematic is not supported. Version: {0}.",
"worldedit.schematic.save.already-exists": "That schematic already exists. Use the -f flag to overwrite it.", "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.failed-directory": "Could not create folder for schematics!",
"worldedit.schematic.save.saving": "(Please wait... saving schematic.)", "worldedit.schematic.save.saving": "(Please wait... saving schematic.)",