Merge remote-tracking branch 'upstream/main' into upstream
This commit is contained in:
@@ -12,7 +12,7 @@ applyPlatformAndCoreConfiguration()
|
||||
dependencies {
|
||||
constraints {
|
||||
implementation("org.yaml:snakeyaml") {
|
||||
version { strictly("1.30") }
|
||||
version { strictly("1.33") }
|
||||
because("Bukkit provides SnakeYaml")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,8 +391,8 @@ public class Settings extends Config {
|
||||
public boolean UNIVERSAL_DISALLOWED_BLOCKS = true;
|
||||
@Comment({
|
||||
"List of blocks to deny use of. Can be either an entire block type or a block with a specific property value.",
|
||||
"Where block properties are specified, any blockstate with the property will be disallowed (i.g. all directions",
|
||||
"of a waterlogged fence). For blocking/remapping of all occurence of a property like waterlogged, see",
|
||||
"Where block properties are specified, any blockstate with the property will be disallowed (e.g. all directions",
|
||||
"of a waterlogged fence). For blocking/remapping of all occurrences of a property like waterlogged, see",
|
||||
"remap-properties below.",
|
||||
"Example block property blocking:",
|
||||
" - \"minecraft:conduit[waterlogged=true]\"",
|
||||
|
||||
@@ -111,8 +111,9 @@ public class RollbackDatabase extends AsyncNotifyQueue {
|
||||
int index = result.getInt("id");
|
||||
int x1 = result.getInt("x1");
|
||||
int x2 = result.getInt("x2");
|
||||
int y1 = result.getByte("y1") + 128;
|
||||
int y2 = result.getByte("y2") + 128;
|
||||
// Keep 128 offset for backwards-compatibility
|
||||
int y1 = result.getInt("y1") + 128;
|
||||
int y2 = result.getInt("y2") + 128;
|
||||
int z1 = result.getInt("z1");
|
||||
int z2 = result.getInt("z2");
|
||||
CuboidRegion region = new CuboidRegion(BlockVector3.at(x1, y1, z1), BlockVector3.at(x2, y2, z2));
|
||||
@@ -172,8 +173,9 @@ public class RollbackDatabase extends AsyncNotifyQueue {
|
||||
stmt.setInt(3, pos2.getBlockX());
|
||||
stmt.setInt(4, pos1.getBlockZ());
|
||||
stmt.setInt(5, pos2.getBlockZ());
|
||||
stmt.setByte(6, (byte) (pos1.getBlockY() - 128));
|
||||
stmt.setByte(7, (byte) (pos2.getBlockY() - 128));
|
||||
// Keep 128 offset for backwards-compatibility
|
||||
stmt.setInt(6, pos1.getBlockY() - 128);
|
||||
stmt.setInt(7, pos2.getBlockY() - 128);
|
||||
if (uuid != null) {
|
||||
byte[] uuidBytes = toBytes(uuid);
|
||||
stmt.setBytes(8, uuidBytes);
|
||||
@@ -196,8 +198,9 @@ public class RollbackDatabase extends AsyncNotifyQueue {
|
||||
stmt.setInt(3, pos2.getBlockX());
|
||||
stmt.setInt(4, pos1.getBlockZ());
|
||||
stmt.setInt(5, pos2.getBlockZ());
|
||||
stmt.setByte(6, (byte) (pos1.getBlockY() - 128));
|
||||
stmt.setByte(7, (byte) (pos2.getBlockY() - 128));
|
||||
// Keep 128 offset for backwards-compatibility
|
||||
stmt.setInt(6, pos1.getBlockY() - 128);
|
||||
stmt.setInt(7, pos2.getBlockY() - 128);
|
||||
byte[] uuidBytes = ByteBuffer
|
||||
.allocate(16)
|
||||
.putLong(uuid.getMostSignificantBits())
|
||||
@@ -253,8 +256,9 @@ public class RollbackDatabase extends AsyncNotifyQueue {
|
||||
stmt.setInt(5, pos2.getX());
|
||||
stmt.setInt(6, pos1.getZ());
|
||||
stmt.setInt(7, pos2.getZ());
|
||||
stmt.setByte(8, (byte) (pos1.getY() - 128));
|
||||
stmt.setByte(9, (byte) (pos2.getY() - 128));
|
||||
// Keep 128 offset for backwards-compatibility
|
||||
stmt.setInt(8, pos1.getY() - 128);
|
||||
stmt.setInt(9, pos2.getY() - 128);
|
||||
stmt.setString(10, change.getCommand());
|
||||
stmt.setInt(11, change.size());
|
||||
stmt.executeUpdate();
|
||||
|
||||
@@ -18,6 +18,7 @@ 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.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -26,12 +27,8 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.sk89q.worldedit.world.block.BlockTypesCache.states;
|
||||
|
||||
public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IBatchProcessor {
|
||||
|
||||
private static final BlockState RESERVED = BlockTypes.__RESERVED__.getDefaultState();
|
||||
@@ -56,7 +53,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
|
||||
this.blockedBlocks = new HashSet<>();
|
||||
for (String block : blockedBlocks) {
|
||||
if (block.indexOf('[') == -1 || block.indexOf(']') == -1) {
|
||||
blockedBlocks.add(block);
|
||||
this.blockedBlocks.add(block);
|
||||
continue;
|
||||
}
|
||||
String[] properties = block.substring(block.indexOf('[') + 1, block.indexOf(']')).split(",");
|
||||
@@ -138,7 +135,10 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
|
||||
it:
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
char block = blocks[i];
|
||||
BlockState state = states[block];
|
||||
if (block == BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||
continue;
|
||||
}
|
||||
BlockState state = BlockTypesCache.states[block];
|
||||
if (blockedBlocks != null) {
|
||||
if (blockedBlocks.contains(state.getBlockType().getId())) {
|
||||
blocks[i] = 0;
|
||||
|
||||
@@ -96,13 +96,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
if (!contains(position)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return super.getBiome(position);
|
||||
return getBiomeType(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,24 +112,34 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
if (!contains(position)) {
|
||||
return getFullBlock(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
}
|
||||
return super.getFullBlock(position);
|
||||
return super.getFullBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
if (!contains(position)) {
|
||||
return getBlock(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
return super.getBlock(position);
|
||||
return super.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -55,7 +55,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getEntities(region);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
@@ -68,7 +68,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getEntities();
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
@@ -83,7 +83,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.createEntity(location, entity);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return null;
|
||||
@@ -98,7 +98,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.createEntity(location, entity, uuid);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return null;
|
||||
@@ -112,7 +112,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
super.removeEntity(x, y, z, uuid);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.regenerateChunk(x, z, type, seed);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return false;
|
||||
@@ -137,7 +137,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getHighestTerrainBlock(x, z, minY, maxY);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return minY;
|
||||
@@ -150,7 +150,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getHighestTerrainBlock(x, z, minY, maxY, filter);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return minY;
|
||||
@@ -163,7 +163,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getNearestSurfaceLayer(x, z, y, minY, maxY);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return minY;
|
||||
@@ -176,7 +176,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return minY;
|
||||
@@ -189,7 +189,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return minY;
|
||||
@@ -202,7 +202,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return minY;
|
||||
@@ -215,7 +215,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return minY;
|
||||
@@ -237,7 +237,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return minY;
|
||||
@@ -386,7 +386,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
filter.applyBlock(block.init(pos));
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -404,7 +404,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getBlock(position);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
@@ -417,7 +417,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getBlock(x, y, z);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
@@ -430,7 +430,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getFullBlock(position);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
@@ -443,7 +443,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getFullBlock(x, y, z);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
@@ -456,7 +456,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getBiome(position);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return BiomeTypes.FOREST;
|
||||
@@ -469,7 +469,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.getBiomeType(x, y, z);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return BiomeTypes.FOREST;
|
||||
@@ -486,7 +486,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.setBlock(position, block);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return false;
|
||||
@@ -502,7 +502,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.setBlock(x, y, z, block);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return false;
|
||||
@@ -516,7 +516,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.setTile(x, y, z, tile);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return false;
|
||||
@@ -529,7 +529,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.setBiome(position, biome);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return false;
|
||||
@@ -542,7 +542,7 @@ public class LimitExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
return super.setBiome(x, y, z, biome);
|
||||
} catch (FaweException e) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
if (e.getType() == FaweException.Type.MANUAL || !limit.MAX_FAILS()) {
|
||||
throw e;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
import static java.lang.Math.floorDiv;
|
||||
|
||||
public class Linear2DBlockPattern extends AbstractPattern {
|
||||
|
||||
private final Pattern[] patternsArray;
|
||||
@@ -37,7 +39,8 @@ public class Linear2DBlockPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
int index = (get.getBlockX() / this.xScale + get.getBlockZ() / this.zScale) % patternsArray.length;
|
||||
int index = (floorDiv(get.getBlockX(), this.xScale)
|
||||
+ floorDiv(get.getBlockZ(), this.zScale)) % patternsArray.length;
|
||||
if (index < 0) {
|
||||
index += patternsArray.length;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
import static java.lang.Math.floorDiv;
|
||||
|
||||
public class Linear3DBlockPattern extends AbstractPattern {
|
||||
|
||||
private final Pattern[] patternsArray;
|
||||
@@ -41,8 +43,8 @@ public class Linear3DBlockPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
int index = (get.getBlockX() / this.xScale
|
||||
+ get.getBlockY() / this.yScale + get.getBlockZ() / this.zScale) % patternsArray.length;
|
||||
int index = (floorDiv(get.getBlockX(), this.xScale)
|
||||
+ floorDiv(get.getBlockY(), this.yScale) + floorDiv(get.getBlockZ(), this.zScale)) % patternsArray.length;
|
||||
if (index < 0) {
|
||||
index += patternsArray.length;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
private final World world;
|
||||
private final AtomicInteger lastException = new AtomicInteger();
|
||||
protected AtomicInteger waitingCombined = new AtomicInteger(0);
|
||||
protected AtomicInteger waitingAsync = new AtomicInteger(0);
|
||||
|
||||
@@ -369,7 +370,10 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
if (completeNow) {
|
||||
throw t;
|
||||
} else {
|
||||
t.printStackTrace();
|
||||
int hash = t.getMessage().hashCode();
|
||||
if (lastException.getAndSet(hash) != hash) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (AbstractChangeSet.this.waitingCombined.decrementAndGet() <= 0) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.fastasyncworldedit.core.history.change.MutableBlockChange;
|
||||
import com.fastasyncworldedit.core.history.change.MutableEntityChange;
|
||||
import com.fastasyncworldedit.core.history.change.MutableFullBlockChange;
|
||||
import com.fastasyncworldedit.core.history.change.MutableTileChange;
|
||||
import com.fastasyncworldedit.core.internal.exception.FaweSmallEditUnsupportedException;
|
||||
import com.fastasyncworldedit.core.internal.io.FaweInputStream;
|
||||
import com.fastasyncworldedit.core.internal.io.FaweOutputStream;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
@@ -146,8 +147,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
@Override
|
||||
public void write(OutputStream out, int x, int y, int z) throws IOException {
|
||||
if (y < 0 || y > 255) {
|
||||
throw new UnsupportedOperationException("y cannot be outside range 0-255 for " +
|
||||
"small-edits=true");
|
||||
throw new FaweSmallEditUnsupportedException();
|
||||
}
|
||||
int rx = -lx + (lx = x);
|
||||
int ry = -ly + (ly = y);
|
||||
@@ -332,7 +332,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
//x
|
||||
posDel.write(stream, x - originX, y, z - originZ);
|
||||
idDel.writeChange(stream, combinedFrom, combinedTo);
|
||||
} catch (Throwable e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
os.write((byte) (y + 128));
|
||||
os.writeVarInt(from.getInternalId());
|
||||
os.writeVarInt(to.getInternalId());
|
||||
} catch (Throwable e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -699,7 +699,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
|
||||
final Iterator<MutableBiomeChange> biomeChange = getBiomeIterator(dir);
|
||||
|
||||
return new Iterator<Change>() {
|
||||
return new Iterator<>() {
|
||||
final Iterator<Change>[] iterators = new Iterator[]{tileCreate, tileRemove, entityCreate, entityRemove, blockChange, biomeChange};
|
||||
int i = 0;
|
||||
Iterator<Change> current = iterators[0];
|
||||
|
||||
@@ -91,6 +91,7 @@ public class FaweException extends RuntimeException {
|
||||
PLAYER_ONLY,
|
||||
ACTOR_REQUIRED,
|
||||
CLIPBOARD,
|
||||
HISTORY,
|
||||
OTHER
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.fastasyncworldedit.core.internal.exception;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
public class FaweSmallEditUnsupportedException extends FaweException {
|
||||
|
||||
private static final Component message = TextComponent.of(
|
||||
"y cannot be outside range 0-255 for small-edits=true. History will NOT work on edits outside this range.");
|
||||
|
||||
public FaweSmallEditUnsupportedException() {
|
||||
super(message, Type.HISTORY);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.fastasyncworldedit.core.util;
|
||||
|
||||
/**
|
||||
* @deprecated Unused, will be removed in the future. Use String concatenation instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2.5.1")
|
||||
public class JoinedCharSequence implements CharSequence {
|
||||
|
||||
private char join;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class WEManager {
|
||||
* @return array of allowed regions if whitelist, else of disallowed regions.
|
||||
*/
|
||||
public Region[] getMask(Player player, FaweMaskManager.MaskType type, final boolean isWhitelist) {
|
||||
if (!Settings.settings().REGION_RESTRICTIONS || player.hasPermission("fawe.bypass") || player.hasPermission("fawe.bypass.regions")) {
|
||||
if (!Settings.settings().REGION_RESTRICTIONS || player.hasPermission("fawe.bypass.regions")) {
|
||||
return new Region[]{RegionWrapper.GLOBAL()};
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
|
||||
@@ -320,12 +320,12 @@ public class WorldWrapper extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
return TaskManager.taskManager().sync(() -> parent.getEntities(region));
|
||||
return parent.getEntities(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities() {
|
||||
return TaskManager.taskManager().sync(parent::getEntities);
|
||||
return parent.getEntities();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.sk89q.util.yaml;
|
||||
|
||||
import com.sk89q.util.StringUtil;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
import org.yaml.snakeyaml.nodes.Tag;
|
||||
@@ -89,13 +90,22 @@ public class YAMLProcessor extends YAMLNode {
|
||||
super(new LinkedHashMap<>(), writeDefaults);
|
||||
this.format = format;
|
||||
|
||||
DumperOptions options = new DumperOptions();
|
||||
options.setIndent(4);
|
||||
options.setDefaultFlowStyle(format.getStyle());
|
||||
DumperOptions dumperOptions = new DumperOptions();
|
||||
dumperOptions.setIndent(4);
|
||||
dumperOptions.setDefaultFlowStyle(format.getStyle());
|
||||
Representer representer = new FancyRepresenter();
|
||||
representer.setDefaultFlowStyle(format.getStyle());
|
||||
|
||||
yaml = new Yaml(new SafeConstructor(), representer, options);
|
||||
LoaderOptions loaderOptions = new LoaderOptions();
|
||||
try {
|
||||
// 64 MB default
|
||||
int yamlCodePointLimit = Integer.getInteger("worldedit.yaml.codePointLimit", 64 * 1024 * 1024);
|
||||
loaderOptions.setCodePointLimit(yamlCodePointLimit);
|
||||
} catch (NoSuchMethodError ignored) {
|
||||
// pre-1.32 snakeyaml
|
||||
}
|
||||
|
||||
yaml = new Yaml(new SafeConstructor(), representer, dumperOptions, loaderOptions);
|
||||
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ public final class EditSessionBuilder {
|
||||
}
|
||||
}
|
||||
if (allowedRegions == null && Settings.settings().REGION_RESTRICTIONS) {
|
||||
if (actor != null && !actor.hasPermission("fawe.bypass") && !actor.hasPermission("fawe.bypass.regions")) {
|
||||
if (actor != null && !actor.hasPermission("fawe.bypass.regions")) {
|
||||
if (actor instanceof Player) {
|
||||
Player player = (Player) actor;
|
||||
allowedRegions = player.getAllowedRegions();
|
||||
@@ -538,7 +538,7 @@ public final class EditSessionBuilder {
|
||||
}
|
||||
}
|
||||
if (disallowedRegions == null && Settings.settings().REGION_RESTRICTIONS && Settings.settings().REGION_RESTRICTIONS_OPTIONS.ALLOW_BLACKLISTS) {
|
||||
if (actor != null && !actor.hasPermission("fawe.bypass") && !actor.hasPermission("fawe.bypass.regions")) {
|
||||
if (actor != null && !actor.hasPermission("fawe.bypass.regions")) {
|
||||
if (actor instanceof Player) {
|
||||
Player player = (Player) actor;
|
||||
disallowedRegions = player.getDisallowedRegions();
|
||||
@@ -605,7 +605,7 @@ public final class EditSessionBuilder {
|
||||
}
|
||||
if (this.limit != null && !this.limit.isUnlimited()) {
|
||||
Set<String> limitBlocks = new HashSet<>();
|
||||
if ((getActor() == null || getActor().hasPermission("worldedit.anyblock") && this.limit.UNIVERSAL_DISALLOWED_BLOCKS)) {
|
||||
if ((getActor() == null || getActor().hasPermission("worldedit.anyblock")) && this.limit.UNIVERSAL_DISALLOWED_BLOCKS) {
|
||||
limitBlocks.addAll(WorldEdit.getInstance().getConfiguration().disallowedBlocks);
|
||||
}
|
||||
if (this.limit.DISALLOWED_BLOCKS != null && !this.limit.DISALLOWED_BLOCKS.isEmpty()) {
|
||||
|
||||
@@ -420,7 +420,7 @@ public final class WorldEdit {
|
||||
}
|
||||
|
||||
private boolean checkFilename(String filename) {
|
||||
return filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$");
|
||||
return filename.matches("^[A-Za-z0-9_\\-./'$@~!%()\\[\\]+{},]+\\.[A-Za-z0-9]+$");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -408,14 +408,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
TextComponent.of(blockAndExtraData[0])
|
||||
));
|
||||
}
|
||||
if ("hand".equalsIgnoreCase(typeString)) {
|
||||
if ("hand".equalsIgnoreCase(typeString) || "h".equalsIgnoreCase(typeString)) {
|
||||
// Get the block type from the item in the user's hand.
|
||||
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
|
||||
//FAWE start
|
||||
state = blockInHand.toBlockState();
|
||||
nbt = blockInHand.getNbtData();
|
||||
//FAWE end
|
||||
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
||||
} else if ("offhand".equalsIgnoreCase(typeString) || "oh".equalsIgnoreCase(typeString)) {
|
||||
// Get the block type from the item in the user's off hand.
|
||||
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
|
||||
//FAWE start
|
||||
|
||||
@@ -106,13 +106,13 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
nbtString = input.substring(nbtStart);
|
||||
}
|
||||
|
||||
if ("hand".equalsIgnoreCase(typeString)) {
|
||||
if ("hand".equalsIgnoreCase(typeString) || "h".equalsIgnoreCase(typeString)) {
|
||||
BaseItemStack heldItem = getItemInHand(context.requireActor(), HandSide.MAIN_HAND);
|
||||
//FAWE start
|
||||
itemType = heldItem.getType();
|
||||
itemNbtData = heldItem.getNbt();
|
||||
//FAWE end
|
||||
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
||||
} else if ("offhand".equalsIgnoreCase(typeString) || "oh".equalsIgnoreCase(typeString)) {
|
||||
BaseItemStack heldItem = getItemInHand(context.requireActor(), HandSide.OFF_HAND);
|
||||
//FAWE start
|
||||
itemType = heldItem.getType();
|
||||
|
||||
@@ -223,23 +223,11 @@ public abstract class AbstractRegion extends AbstractSet<BlockVector3> implement
|
||||
// Sub-class utilities
|
||||
|
||||
protected final int getWorldMinY() {
|
||||
//FAWE start > Server default based on version
|
||||
return world == null ? WorldEdit
|
||||
.getInstance()
|
||||
.getPlatformManager()
|
||||
.queryCapability(Capability.WORLD_EDITING)
|
||||
.versionMinY() : world.getMinY();
|
||||
//FAWE end
|
||||
return world == null ? Integer.MIN_VALUE : world.getMinY();
|
||||
}
|
||||
|
||||
protected final int getWorldMaxY() {
|
||||
//FAWE start > Server default based on version
|
||||
return world == null ? WorldEdit
|
||||
.getInstance()
|
||||
.getPlatformManager()
|
||||
.queryCapability(Capability.WORLD_EDITING)
|
||||
.versionMaxY() : world.getMaxY();
|
||||
//FAWE end
|
||||
return world == null ? Integer.MAX_VALUE : world.getMaxY();
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
||||
@@ -150,7 +150,11 @@ public final class TreeGenerator {
|
||||
public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
|
||||
//FAWE start - ensure canGenerateOn is called.
|
||||
// chorus plants have to generate starting in the end stone itself, not the air above the ground
|
||||
return super.generate(editSession, pos.subtract(0, 1, 0));
|
||||
BlockVector3 down = pos.subtract(0, 1, 0);
|
||||
if (!canGenerateOn(editSession.getBlockType(down.getX(), down.getY(), down.getZ()))) {
|
||||
return false;
|
||||
}
|
||||
return editSession.getWorld().generateTree(this, editSession, down);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.fastasyncworldedit.core.command.SuggestInputParseException;
|
||||
import com.fastasyncworldedit.core.util.JoinedCharSequence;
|
||||
import com.fastasyncworldedit.core.util.StringMan;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
@@ -1923,23 +1922,19 @@ public final class BlockTypes {
|
||||
public static final BlockType ZOMBIE_WALL_HEAD = init();
|
||||
|
||||
private static Field[] fieldsTmp;
|
||||
private static JoinedCharSequence joined;
|
||||
private static int initIndex = 0;
|
||||
|
||||
public static BlockType init() {
|
||||
if (fieldsTmp == null) {
|
||||
fieldsTmp = BlockTypes.class.getDeclaredFields();
|
||||
BlockTypesCache.$NAMESPACES.isEmpty(); // initialize cache
|
||||
joined = new JoinedCharSequence();
|
||||
}
|
||||
String name = fieldsTmp[initIndex++].getName().toLowerCase(Locale.ROOT);
|
||||
CharSequence fullName = joined.init(BlockType.REGISTRY.getDefaultNamespace(), ':', name);
|
||||
return BlockType.REGISTRY.getMap().get(fullName);
|
||||
return BlockType.REGISTRY.get(name);
|
||||
}
|
||||
|
||||
static {
|
||||
fieldsTmp = null;
|
||||
joined = null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.world.item;
|
||||
|
||||
import com.fastasyncworldedit.core.util.JoinedCharSequence;
|
||||
import com.fastasyncworldedit.core.world.block.ItemTypesCache;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
@@ -2362,7 +2361,6 @@ public final class ItemTypes {
|
||||
}
|
||||
|
||||
private static Field[] fieldsTmp;
|
||||
private static JoinedCharSequence joined;
|
||||
private static int initIndex = 0;
|
||||
|
||||
private static ItemType init() {
|
||||
@@ -2370,11 +2368,9 @@ public final class ItemTypes {
|
||||
if (fieldsTmp == null) {
|
||||
fieldsTmp = ItemTypes.class.getDeclaredFields();
|
||||
ItemTypesCache.init(); // force class to load
|
||||
joined = new JoinedCharSequence();
|
||||
}
|
||||
String name = fieldsTmp[initIndex++].getName().toLowerCase(Locale.ROOT);
|
||||
CharSequence fullName = joined.init(ItemType.REGISTRY.getDefaultNamespace(), ':', name);
|
||||
return ItemType.REGISTRY.getMap().get(fullName);
|
||||
return ItemType.REGISTRY.get(name);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
@@ -2383,7 +2379,6 @@ public final class ItemTypes {
|
||||
|
||||
static {
|
||||
fieldsTmp = null;
|
||||
joined = null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user