From 5a67363a78dfbf7d0b6bab962bd10db7fecabddb Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 29 Jun 2019 02:24:57 +1000 Subject: [PATCH] 031332081612c8bb648a60a213fca96627a92801 --- .../fawe/bukkit/wrapper/AsyncBlock.java | 10 +++++-- .../java/com/boydti/fawe/util/MainUtil.java | 29 +++++++++++++++++++ .../java/com/sk89q/worldedit/EditSession.java | 2 +- .../worldedit/function/mask/BlockMask.java | 5 ++++ .../sk89q/worldedit/regions/CuboidRegion.java | 7 ++++- 5 files changed, 48 insertions(+), 5 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java index 1cbde61a4..4d0b949cb 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java @@ -6,6 +6,7 @@ import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import org.bukkit.FluidCollisionMode; @@ -219,10 +220,13 @@ public class AsyncBlock implements Block { public AsyncBlockState getState() { int combined = queue.getCombinedId4Data(x, y, z, 0); BlockType type = BlockTypes.getFromStateId(combined); - if (type == BlockTypes.SIGN || type == BlockTypes.WALL_SIGN) { - return new AsyncSign(this, combined); + switch (type.getInternalId()) { + case BlockID.SIGN: + case BlockID.WALL_SIGN: + return new AsyncSign(this, combined); + default: + return new AsyncBlockState(this, combined); } - return new AsyncBlockState(this, combined); } @NotNull @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java index 4b140c617..84b1d975f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java @@ -853,4 +853,33 @@ public class MainUtil { } } + public static void warnDeprecated(Class... alternatives) { + StackTraceElement[] stacktrace = new RuntimeException().getStackTrace(); + if (stacktrace.length > 1) { + for (int i = 1; i < stacktrace.length; i++) { + StackTraceElement stack = stacktrace[i]; + String s = stack.toString(); + if (s.startsWith("com.sk89q")) { + continue; + } + try { + StackTraceElement creatorElement = stacktrace[1]; + String className = creatorElement.getClassName(); + Class clazz = Class.forName(className); + String creator = clazz.getSimpleName(); + String packageName = clazz.getPackage().getName(); + + StackTraceElement deprecatedElement = stack; + String myName = Class.forName(deprecatedElement.getClassName()).getSimpleName(); + Fawe.debug("@" + creator + " used by " + myName + "." + deprecatedElement.getMethodName() + "():" + deprecatedElement.getLineNumber() + " is deprecated."); + Fawe.debug(" - Alternatives: " + StringMan.getString(alternatives)); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } finally { + break; + } + } + } + } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index e4eed01bb..8f15a9f47 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1833,7 +1833,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @throws MaxChangedBlocksException thrown if too many blocks are changed */ public int replaceBlocks(Region region, Set filter, Pattern pattern) throws MaxChangedBlocksException { - Mask mask = filter == null ? new ExistingBlockMask(this) : new BlockMask(this, filter); + Mask mask = filter == null ? new ExistingBlockMask(this) : new BlockMaskBuilder().addBlocks(filter).build(this); return replaceBlocks(region, mask, pattern); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index ddc92cec0..e17ea0b14 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.function.mask; import com.boydti.fawe.object.collection.FastBitSet; +import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.StringMan; import static com.google.common.base.Preconditions.checkNotNull; @@ -47,7 +48,9 @@ import java.util.Map; * *

This mask checks for both an exact block type and state value match, * respecting fuzzy status of the BlockState.

+ * @deprecated use BlockMaskBuilder */ +@Deprecated public class BlockMask extends AbstractExtentMask { private final long[][] bitSets; @@ -62,6 +65,7 @@ public class BlockMask extends AbstractExtentMask { */ public BlockMask(Extent extent, Collection blocks) { super(extent); + MainUtil.warnDeprecated(BlockMaskBuilder.class); checkNotNull(blocks); this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits(); } @@ -74,6 +78,7 @@ public class BlockMask extends AbstractExtentMask { */ public BlockMask(Extent extent, BaseBlock... block) { super(extent); + MainUtil.warnDeprecated(BlockMaskBuilder.class); checkNotNull(block); this.bitSets = new BlockMaskBuilder().addBlocks(block).optimize().getBits(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 334542a26..e78422cd8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -546,7 +546,12 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public BlockVector2 next() { - if (!hasNext()) throw new NoSuchElementException(); + if (!hasNext()) throw new NoSuchElementException() { + @Override + public synchronized Throwable fillInStackTrace() { + return this; + } + }; BlockVector2 answer = BlockVector2.at(nextX, nextZ); if (++nextX > max.getBlockX()) { nextX = min.getBlockX();