From 915ab43f6eeece42e5e2ed6c33e6ccac725d94fe Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Thu, 5 Mar 2020 16:07:20 -0500 Subject: [PATCH] Cleanup unused code. --- .../bukkit/BukkitBlockCommandSender.java | 22 +++ .../worldedit/bukkit/BukkitCommandSender.java | 22 ++- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 24 ++- .../src/main/java/com/boydti/fawe/Fawe.java | 6 +- .../main/java/com/boydti/fawe/FaweAPI.java | 1 + .../main/java/com/boydti/fawe/FaweCache.java | 6 +- .../implementation/chunk/FinalizedChunk.java | 33 ----- .../implementation/chunk/ReferenceChunk.java | 29 ---- .../beta/implementation/chunk/SoftChunk.java | 22 --- .../beta/implementation/chunk/WeakChunk.java | 23 --- .../implementation/filter/DistrFilter.java | 5 +- .../queue/SingleThreadQueueExtent.java | 4 - .../com/boydti/fawe/object/RegionWrapper.java | 1 + .../boydti/fawe/object/brush/BlendBall.java | 2 +- .../boydti/fawe/object/brush/ImageBrush.java | 3 - .../object/change/MutableEntityChange.java | 4 - .../fawe/object/collection/BitArray4096.java | 16 +- .../fawe/object/mask/FaweBlockMatcher.java | 138 ------------------ .../selector/PolyhedralRegionSelector.java | 5 +- .../boydti/fawe/util/EditSessionBuilder.java | 4 - .../com/boydti/fawe/util/ReflectionUtils.java | 80 ++++++---- .../com/boydti/fawe/wrappers/AsyncPlayer.java | 30 ++-- .../worldedit/command/BrushCommands.java | 2 +- .../worldedit/command/ChunkCommands.java | 8 +- .../worldedit/command/HistorySubCommands.java | 6 +- .../worldedit/command/RegionCommands.java | 16 +- .../worldedit/command/WorldEditCommands.java | 4 +- .../worldedit/extension/platform/Actor.java | 12 +- .../extension/platform/PlayerProxy.java | 18 ++- .../com/sk89q/worldedit/regions/Region.java | 2 +- .../util/paste/ActorCallbackPaste.java | 2 +- 31 files changed, 192 insertions(+), 358 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/FinalizedChunk.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ReferenceChunk.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/SoftChunk.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/WeakChunk.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/object/mask/FaweBlockMatcher.java diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java index 92fc54fd2..c51a3c17a 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java @@ -28,7 +28,9 @@ import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter; +import com.sk89q.worldedit.util.formatting.text.format.TextColor; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; @@ -72,6 +74,26 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements } } + @Override + public void print(String msg) { + for (String part : msg.split("\n")) { + print(TextComponent.of(part, TextColor.LIGHT_PURPLE)); + } + } + + @Override + public void printDebug(String msg) { + for (String part : msg.split("\n")) { + print(TextComponent.of(part, TextColor.GRAY)); + } + } + + @Override + public void printError(String msg) { + for (String part : msg.split("\n")) { + print(TextComponent.of(part, TextColor.RED)); + } + } @Override public void print(Component component) { TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale())); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java index 8d8303b7c..188b5af66 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java @@ -74,6 +74,26 @@ public class BukkitCommandSender extends AbstractNonPlayerActor { } } + @Override + public void print(String msg) { + for (String part : msg.split("\n")) { + sender.sendMessage("\u00A7d" + part); + } + } + + @Override + public void printDebug(String msg) { + for (String part : msg.split("\n")) { + sender.sendMessage("\u00A77" + part); + } + } + + @Override + public void printError(String msg) { + for (String part : msg.split("\n")) { + sender.sendMessage("\u00A7c" + part); + } + } @Override public void print(Component component) { TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale())); @@ -118,7 +138,7 @@ public class BukkitCommandSender extends AbstractNonPlayerActor { public boolean isActive() { if (sender instanceof Entity) { Entity entity = (Entity) sender; - return (entity.isValid() && !entity.isDead()); + return entity.isValid() && !entity.isDead(); } return true; } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index ff97cf854..3147dd971 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -84,10 +84,6 @@ public class BukkitPlayer extends AbstractPlayerActor { public BukkitPlayer(WorldEditPlugin plugin, Player player) { this.plugin = plugin; this.player = player; - init(); - } - - private void init() { if (Settings.IMP.CLIPBOARD.USE_DISK) { loadClipboardFromDisk(); } @@ -170,6 +166,26 @@ public class BukkitPlayer extends AbstractPlayerActor { } } + @Override + public void print(String msg) { + for (String part : msg.split("\n")) { + player.sendMessage("\u00A7d" + part); + } + } + + @Override + public void printDebug(String msg) { + for (String part : msg.split("\n")) { + player.sendMessage("\u00A77" + part); + } + } + + @Override + public void printError(String msg) { + for (String part : msg.split("\n")) { + player.sendMessage("\u00A7c" + part); + } + } @Override public void print(Component component) { component = Caption.color(TranslatableComponent.of("prefix", component), getLocale()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index 48af96fd3..7695aa49b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -145,13 +145,13 @@ public class Fawe { * * @param s */ - public static void debug(Object s) { + public static void debug(String s) { Actor actor = Request.request().getActor(); if (actor != null && actor.isPlayer()) { - actor.print((String)s); + actor.printInfo(TextComponent.of(s)); return; } - debugPlain((String) s); + debugPlain(s); } /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java index 2d271d472..e11897570 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -399,6 +399,7 @@ public class FaweAPI { * @return */ public static int fixLighting(World world, Region selection, @Nullable IQueueExtent queue) { + //TODO NONE OF THIS CODE WORKS AS OF 2020-03-05 final BlockVector3 bot = selection.getMinimumPoint(); final BlockVector3 top = selection.getMaximumPoint(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java index a8e7ee656..68f15a369 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -227,10 +227,10 @@ public enum FaweCache implements Trimable { long[] blockStates = BLOCK_STATES.get(); int[] blocksCopy = SECTION_BLOCKS.get(); - int blockIndexStart = layerOffset << 12; - int blockIndexEnd = blockIndexStart + 4096; - int num_palette = 0; try { + int num_palette = 0; + int blockIndexStart = layerOffset << 12; + int blockIndexEnd = blockIndexStart + 4096; if (blocksChars != null) { for (int i = blockIndexStart, j = 0; i < blockIndexEnd; i++, j++) { int ordinal = blocksChars[i]; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/FinalizedChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/FinalizedChunk.java deleted file mode 100644 index 8c0211d80..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/FinalizedChunk.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.boydti.fawe.beta.implementation.chunk; - -import com.boydti.fawe.beta.IQueueChunk; -import com.boydti.fawe.beta.IQueueExtent; - -/** - * Used by {@link ReferenceChunk} to allow the chunk to be garbage collected. - When the object is - * finalized, add it to the queue - */ -public class FinalizedChunk extends DelegateChunk { - - private final IQueueExtent queueExtent; - - public FinalizedChunk(T parent, IQueueExtent queueExtent) { - super(parent); - this.queueExtent = queueExtent; - } - - /** - * Submit the chunk to the queue - * - * @throws Throwable - */ - @Override - protected void finalize() throws Throwable { - if (getParent() != null) { - // TODO apply safely -// apply(); - setParent(null); - } - super.finalize(); - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ReferenceChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ReferenceChunk.java deleted file mode 100644 index 5522c49bd..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ReferenceChunk.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.boydti.fawe.beta.implementation.chunk; - -import com.boydti.fawe.beta.IChunk; -import com.boydti.fawe.beta.IDelegateChunk; -import com.boydti.fawe.beta.IQueueChunk; -import com.boydti.fawe.beta.IQueueExtent; -import java.lang.ref.Reference; - -/** - * An {@link IChunk} may be wrapped by a ReferenceChunk if there is low memory. This class stores a - * reference for garbage collection purposes. If it cleaned by garbage collection, the {@link - * FinalizedChunk} logic is run. - */ -public abstract class ReferenceChunk implements IDelegateChunk { - - private final Reference reference; - - public ReferenceChunk(IQueueChunk parent, IQueueExtent queueExtent) { - this.reference = toReference(new FinalizedChunk(parent, queueExtent)); - } - - protected abstract Reference toReference(FinalizedChunk parent); - - @Override - public IQueueChunk getParent() { - final FinalizedChunk finalized = reference.get(); - return finalized != null ? finalized.getParent() : null; - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/SoftChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/SoftChunk.java deleted file mode 100644 index cd58d4c97..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/SoftChunk.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.boydti.fawe.beta.implementation.chunk; - -import com.boydti.fawe.beta.IChunk; -import com.boydti.fawe.beta.IQueueChunk; -import com.boydti.fawe.beta.IQueueExtent; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; - -/** - * Soft reference implementation of {@link ReferenceChunk} - */ -public class SoftChunk extends ReferenceChunk { - - public SoftChunk(IQueueChunk parent, IQueueExtent queueExtent) { - super(parent, queueExtent); - } - - @Override - protected Reference toReference(FinalizedChunk parent) { - return new SoftReference<>(parent); - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/WeakChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/WeakChunk.java deleted file mode 100644 index 4c5e556c3..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/WeakChunk.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.boydti.fawe.beta.implementation.chunk; - -import com.boydti.fawe.beta.IChunk; -import com.boydti.fawe.beta.IQueueChunk; -import com.boydti.fawe.beta.IQueueExtent; - -import java.lang.ref.Reference; -import java.lang.ref.WeakReference; - -/** - * A {@link ReferenceChunk} using {@link WeakReference} to hold the chunk. - */ -public class WeakChunk extends ReferenceChunk { - - public WeakChunk(IQueueChunk parent, IQueueExtent queueExtent) { - super(parent, queueExtent); - } - - @Override - protected Reference toReference(FinalizedChunk parent) { - return new WeakReference<>(parent); - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java index 581a3554a..645e23cd9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java @@ -4,6 +4,7 @@ import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.function.mask.ABlockMask; import com.sk89q.worldedit.util.Countable; +import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -94,10 +95,10 @@ public class DistrFilter extends ForkedFilter { for (Countable c : getDistribution()) { final String name = c.getID().toString(); final String str = String.format("%-7s (%.3f%%) %s", - String.valueOf(c.getAmount()), + c.getAmount(), c.getAmount() / (double) size * 100, name); - actor.print(str); + actor.printInfo(TextComponent.of(str)); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java index 2524d3c40..1f3ed59de 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java @@ -10,7 +10,6 @@ import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.implementation.blocks.CharSetBlocks; import com.boydti.fawe.beta.implementation.chunk.ChunkHolder; import com.boydti.fawe.beta.implementation.chunk.NullChunk; -import com.boydti.fawe.beta.implementation.chunk.ReferenceChunk; import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock; import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor; @@ -210,9 +209,6 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen return NullChunk.INSTANCE; } IQueueChunk chunk = chunks.get(pair); - if (chunk instanceof ReferenceChunk) { - chunk = ((ReferenceChunk) chunk).getParent(); - } if (chunk != null) { lastPair = pair; lastChunk = chunk; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/RegionWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/object/RegionWrapper.java index 3259c0cfc..8513d3ee6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/RegionWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/RegionWrapper.java @@ -49,6 +49,7 @@ public class RegionWrapper extends CuboidRegion { this.maxY = Math.max(pos1.getBlockY(), pos2.getBlockY()); } + @Override public RegionWrapper[] toArray() { return new RegionWrapper[]{this}; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlendBall.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlendBall.java index df6339e29..76460548d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlendBall.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlendBall.java @@ -46,7 +46,7 @@ public class BlendBall implements Brush { continue; } BlockState state = editSession.getBlock(x0 + ox, y0 + oy, z0 + oz); - Integer count = frequency[state.getInternalBlockTypeId()]; + int count = frequency[state.getInternalBlockTypeId()]; count++; if (count > highest) { highest = count; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java index c6d103f23..536828a9c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java @@ -135,7 +135,4 @@ public class ImageBrush implements Brush { Operations.completeBlindly(visitor); } - private void apply(double val) { - - } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java index bfab674e3..49f1a48f5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java @@ -2,7 +2,6 @@ package com.boydti.fawe.object.change; import static org.slf4j.LoggerFactory.getLogger; -import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.util.MathMan; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.DoubleTag; @@ -89,7 +88,4 @@ public class MutableEntityChange implements Change { context.getExtent().createEntity(location, entity); } - public void perform(IQueueExtent queue) { - - } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BitArray4096.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BitArray4096.java index f9e434db3..689c7985f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BitArray4096.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BitArray4096.java @@ -2,17 +2,17 @@ package com.boydti.fawe.object.collection; public final class BitArray4096 { + private final long[] data; private final int bitsPerEntry; private final int maxSeqLocIndex; private final int maxEntryValue; - private final long[] data; private final int longLen; public BitArray4096(long[] buffer, int bitsPerEntry) { this.bitsPerEntry = bitsPerEntry; this.maxSeqLocIndex = 64 - bitsPerEntry; maxEntryValue = (1 << bitsPerEntry) - 1; - this.longLen = (this.bitsPerEntry * 4096) >> 6; + this.longLen = (this.bitsPerEntry << 12) >> 6; if (buffer.length < longLen) { this.data = new long[longLen]; } else { @@ -32,7 +32,7 @@ public final class BitArray4096 { return data; } - public final void setAt(int index, int value) { + public final void set(int index, int value) { if (longLen == 0) return; int bitIndexStart = index * bitsPerEntry; int longIndexStart = bitIndexStart >> 6; @@ -47,7 +47,7 @@ public final class BitArray4096 { } } - public final int getAt(int index) { + public final int get(int index) { if (longLen == 0) return 0; int bitIndexStart = index * bitsPerEntry; @@ -68,7 +68,7 @@ public final class BitArray4096 { public final void fromRawSlow(char[] arr) { for (int i = 0; i < arr.length; i++) { - setAt(i, arr[i]); + set(i, arr[i]); } } @@ -112,7 +112,7 @@ public final class BitArray4096 { public BitArray4096 growSlow(int bitsPerEntry) { BitArray4096 newBitArray = new BitArray4096(bitsPerEntry); for (int i = 0; i < 4096; i++) { - newBitArray.setAt(i, getAt(i)); + newBitArray.set(i, get(i)); } return newBitArray; } @@ -120,7 +120,7 @@ public final class BitArray4096 { public final char[] toRawSlow() { char[] arr = new char[4096]; for (int i = 0; i < arr.length; i++) { - arr[i] = (char) getAt(i); + arr[i] = (char) get(i); } return arr; } @@ -196,4 +196,4 @@ public final class BitArray4096 { } return buffer; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/FaweBlockMatcher.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/FaweBlockMatcher.java deleted file mode 100644 index 84f3e7aca..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/FaweBlockMatcher.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.boydti.fawe.object.mask; - -import com.sk89q.worldedit.world.block.BaseBlock; -import java.util.Set; - -// TODO FIXME -public abstract class FaweBlockMatcher { - public abstract boolean apply(BaseBlock block); - - public static FaweBlockMatcher ALWAYS_TRUE = new FaweBlockMatcher() { - @Override - public boolean apply(BaseBlock block) { - return true; - } - }; - - public static FaweBlockMatcher NOT_AIR = new FaweBlockMatcher() { - @Override - public boolean apply(BaseBlock block) { - return !block.getBlockType().getMaterial().isAir(); - } - }; - - public static FaweBlockMatcher setBlock(BaseBlock block) { - return null; -// final int id = block.getId(); -// final int data = block.getData(); -// if (data == 0) { -// return new FaweBlockMatcher() { -// @Override -// public boolean apply(BaseBlock oldBlock) { -// int currentId = oldBlock.getId(); -// oldBlock.setId(id); -// if (FaweCache.IMP.hasData(currentId)) { -// oldBlock.setData(0); -// } -// if (FaweCache.IMP.hasNBT(currentId)) { -// oldBlock.setNbtData(null); -// } -// return true; -// } -// }; -// } -// return new FaweBlockMatcher() { -// @Override -// public boolean apply(BaseBlock oldBlock) { -// int currentId = oldBlock.getId(); -// oldBlock.setId(id); -// oldBlock.setData(data); -// if (FaweCache.IMP.hasNBT(currentId)) { -// oldBlock.setNbtData(null); -// } -// return true; -// } -// }; - } - - public static FaweBlockMatcher setBlocks(Set blocks) { -// if (blocks.size() == 1) { -// return setBlock(blocks.iterator().next()); -// } -// final BaseBlock[] array = blocks.toArray(new BaseBlock[blocks.size()]); -// final int size = array.length; -// return new FaweBlockMatcher() { -// @Override -// public boolean apply(BaseBlock block) { -// BaseBlock replace = array[random.random(size)]; -// int currentId = block.getId(); -// block.setId(replace.getId()); -// if (FaweCache.IMP.hasNBT(currentId)) { -// block.setNbtData(null); -// } -// if (FaweCache.IMP.hasData(currentId) || replace.getData() != 0) { -// block.setData(replace.getData()); -// } -// return true; -// } -// }; - return null; - } - - public static FaweBlockMatcher fromBlock(BaseBlock block, boolean checkData) { -// final int id = block.getId(); -// final int data = block.getData(); -// if (checkData && FaweCache.IMP.hasData(id)) { -// return new FaweBlockMatcher() { -// @Override -// public boolean apply(BaseBlock block) { -// return (block.getId() == id && block.getData() == data); -// } -// }; -// } else { -// return new FaweBlockMatcher() { -// @Override -// public boolean apply(BaseBlock block) { -// return (block.getId() == id); -// } -// }; -// } - return null; - } - - public static FaweBlockMatcher fromBlocks(Set searchBlocks, boolean checkData) { -// if (searchBlocks.size() == 1) { -// return fromBlock(searchBlocks.iterator().next(), checkData); -// } -// final boolean[] allowedId = new boolean[FaweCache.IMP.getId(Character.MAX_VALUE)]; -// for (BaseBlock block : searchBlocks) { -// allowedId[block.getId()] = true; -// } -// final boolean[] allowed = new boolean[Character.MAX_VALUE]; -// for (BaseBlock block : searchBlocks) { -// allowed[FaweCache.IMP.getCombined(block)] = true; -// } -// if (checkData) { -// return new FaweBlockMatcher() { -// @Override -// public boolean apply(BaseBlock block) { -// int id = block.getId(); -// if (allowedId[id]) { -// if (FaweCache.IMP.hasData(id)) { -// return allowed[(id << 4) + block.getData()]; -// } -// return true; -// } -// return false; -// } -// }; -// } -// return new FaweBlockMatcher() { -// @Override -// public boolean apply(BaseBlock block) { -// return allowedId[block.getId()]; -// } -// }; - return null; - } -} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java index 8ecb65138..6c94049c3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java @@ -33,6 +33,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.limit.SelectorLimits; +import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.world.World; import java.util.ArrayList; import java.util.Collection; @@ -161,7 +162,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion { session.describeCUI(player); - player.print("Started new selection with vertex " + pos + "."); + player.print(TextComponent.of("Started new selection with vertex " + pos + ".")); } @Override @@ -172,7 +173,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion { session.describeCUI(player); - player.print("Added vertex " + pos + " to the selection."); + player.print(TextComponent.of("Added vertex " + pos + " to the selection.")); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java index b791bbcd6..ff54bcf16 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java @@ -237,10 +237,6 @@ public class EditSessionBuilder { if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) { return new NullExtent(toReturn, FaweCache.MANUAL); } -// if (!(toReturn instanceof AbstractDelegateExtent)) { -// Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent"); -// return extent; -// } if (toReturn != extent) { String className = toReturn.getClass().getName().toLowerCase(); for (String allowed : Settings.IMP.EXTENT.ALLOWED_PLUGINS) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java b/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java index 8b46cbe3f..74640b513 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java @@ -1,5 +1,6 @@ package com.boydti.fawe.util; +import com.boydti.fawe.Fawe; import java.lang.invoke.MethodHandles; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Constructor; @@ -13,8 +14,10 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; +import org.jetbrains.annotations.NotNull; public class ReflectionUtils { + public static T as(Class t, Object o) { return t.isInstance(o) ? t.cast(o) : null; } @@ -24,7 +27,7 @@ public class ReflectionUtils { } public static void setAccessibleNonFinal(Field field) - throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { + throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { // let's make the field accessible field.setAccessible(true); @@ -38,7 +41,7 @@ public class ReflectionUtils { // blank out the final bit in the modifiers int ((MethodHandles.Lookup) lookupField.get(null)) - .findSetter(Field.class, "modifiers", int.class) + .findSetter(Field.class, "modifiers", int.class) .invokeExact(field, field.getModifiers() & ~Modifier.FINAL); } catch (Throwable e) { e.printStackTrace(); @@ -47,14 +50,14 @@ public class ReflectionUtils { } public static void setFailsafeFieldValue(Field field, Object target, Object value) - throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { + throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { setAccessibleNonFinal(field); - field.set(target,value); + field.set(target, value); } private static void blankField(Class enumClass, String fieldName) - throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { + throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { for (Field field : Class.class.getDeclaredFields()) { if (field.getName().contains(fieldName)) { AccessibleObject.setAccessible(new Field[]{field}, true); @@ -65,17 +68,21 @@ public class ReflectionUtils { } static void cleanEnumCache(Class enumClass) - throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { + throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { blankField(enumClass, "enumConstantDirectory"); // Sun (Oracle?!?) JDK 1.5/6 blankField(enumClass, "enumConstants"); // IBM JDK } - private static Class UNMODIFIABLE_MAP = Collections.unmodifiableMap(Collections.emptyMap()).getClass(); + private static Class UNMODIFIABLE_MAP = Collections.unmodifiableMap(Collections.emptyMap()) + .getClass(); public static Map getMap(Map map) { try { Class clazz = map.getClass(); - if (clazz != UNMODIFIABLE_MAP) return map; + if (clazz != UNMODIFIABLE_MAP) { + Fawe.debug("getMap is unused. Please report this to MattBDev on Github or Discord"); + return map; + } Field m = clazz.getDeclaredField("m"); m.setAccessible(true); return (Map) m.get(map); @@ -87,8 +94,11 @@ public class ReflectionUtils { public static List getList(List list) { try { - Class> clazz = (Class>) Class.forName("java.util.Collections$UnmodifiableList"); - if (!clazz.isInstance(list)) return list; + Class> clazz = (Class>) Class + .forName("java.util.Collections$UnmodifiableList"); + if (!clazz.isInstance(list)) { + return list; + } Field m = clazz.getDeclaredField("list"); m.setAccessible(true); return (List) m.get(list); @@ -189,25 +199,32 @@ public class ReflectionUtils { return findMethod(clazz, 0, returnType, params); } - public static Method findMethod(Class clazz, int index, int hasMods, int noMods, Class returnType, Class... params) { + public static Method findMethod(Class clazz, int index, int hasMods, int noMods, + Class returnType, Class... params) { outer: for (Method method : sortMethods(clazz.getDeclaredMethods())) { if (returnType == null || method.getReturnType() == returnType) { Class[] mp = method.getParameterTypes(); int mods = method.getModifiers(); - if ((mods & hasMods) != hasMods || (mods & noMods) != 0) continue; + if ((mods & hasMods) != hasMods || (mods & noMods) != 0) { + continue; + } if (params == null) { - if (index-- == 0) return setAccessible(method); - else { + if (index-- == 0) { + return setAccessible(method); + } else { continue; } } if (mp.length == params.length) { for (int i = 0; i < mp.length; i++) { - if (mp[i] != params[i]) continue outer; + if (mp[i] != params[i]) { + continue outer; + } } - if (index-- == 0) return setAccessible(method); - else { + if (index-- == 0) { + return setAccessible(method); + } else { continue; } } @@ -226,7 +243,8 @@ public class ReflectionUtils { return fields; } - public static Method findMethod(Class clazz, int index, Class returnType, Class... params) { + public static Method findMethod(Class clazz, int index, Class returnType, + Class... params) { return findMethod(clazz, index, 0, 0, returnType, params); } @@ -236,10 +254,7 @@ public class ReflectionUtils { } @SuppressWarnings("unchecked") - public static T getField(Field field, Object instance) { - if (field == null) { - throw new RuntimeException("No such field"); - } + public static T getField(@NotNull Field field, Object instance) { field.setAccessible(true); try { return (T) field.get(instance); @@ -248,10 +263,7 @@ public class ReflectionUtils { } } - public static void setField(Field field, Object instance, Object value) { - if (field == null) { - throw new RuntimeException("No such field"); - } + public static void setField(@NotNull Field field, Object instance, Object value) { field.setAccessible(true); try { field.set(instance, value); @@ -283,7 +295,7 @@ public class ReflectionUtils { * @param clazz class * @return RefClass based on passed class */ - public static RefClass getRefClass(Class clazz) { + public static RefClass getRefClass(Class clazz) { return new RefClass(clazz); } @@ -291,6 +303,7 @@ public class ReflectionUtils { * RefClass - utility to simplify work with reflections. */ public static class RefClass { + private final Class clazz; private RefClass(Class clazz) { @@ -319,7 +332,7 @@ public class ReflectionUtils { /** * get existing method by name and types * - * @param name name + * @param name name * @param types method parameters. can be Class or RefClass * @return RefMethod object * @throws RuntimeException if method not found @@ -454,9 +467,9 @@ public class ReflectionUtils { * @return RefMethod * @throws RuntimeException if method not found */ - public RefMethod findMethodByReturnType(Class type) { + public RefMethod findMethodByReturnType(Class type) { if (type == null) { - type = void.class; + type = void.class.getComponentType(); } final List methods = new ArrayList<>(); Collections.addAll(methods, this.clazz.getMethods()); @@ -525,7 +538,7 @@ public class ReflectionUtils { * @return RefField * @throws RuntimeException if field not found */ - public RefField findField(Class type) { + public RefField findField(Class type) { if (type == null) { type = void.class; } @@ -545,6 +558,7 @@ public class ReflectionUtils { * Method wrapper */ public static class RefMethod { + private final Method method; private RefMethod(Method method) { @@ -598,6 +612,7 @@ public class ReflectionUtils { } public class RefExecutor { + final Object e; public RefExecutor(Object e) { @@ -625,6 +640,7 @@ public class ReflectionUtils { * Constructor wrapper */ public static class RefConstructor { + private final Constructor constructor; private RefConstructor(Constructor constructor) { @@ -663,6 +679,7 @@ public class ReflectionUtils { } public static class RefField { + private final Field field; private RefField(Field field) { @@ -702,6 +719,7 @@ public class ReflectionUtils { } public class RefExecutor { + final Object e; public RefExecutor(Object e) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/AsyncPlayer.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/AsyncPlayer.java index 899a25353..baca0fa1f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/AsyncPlayer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/AsyncPlayer.java @@ -18,6 +18,7 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockTypes; public class AsyncPlayer extends PlayerProxy { + public AsyncPlayer(Player parent) { super(parent); } @@ -81,7 +82,7 @@ public class AsyncPlayer extends PlayerProxy { @Override public boolean ascendToCeiling(int clearance, boolean alwaysGlass) { - Location pos = getBlockIn(); + Location pos = getBlockLocation(); int x = pos.getBlockX(); int initialY = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY() + 2); @@ -95,7 +96,8 @@ public class AsyncPlayer extends PlayerProxy { while (y <= world.getMaximumPoint().getY()) { // Found a ceiling! - if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial() + .isMovementBlocker()) { int platformY = Math.max(initialY, y - 3 - clearance); floatAt(x, platformY + 1, z, alwaysGlass); return true; @@ -114,7 +116,7 @@ public class AsyncPlayer extends PlayerProxy { @Override public boolean ascendUpwards(int distance, boolean alwaysGlass) { - final Location pos = getBlockIn(); + final Location pos = getBlockLocation(); final int x = pos.getBlockX(); final int initialY = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY() + 1); @@ -123,7 +125,8 @@ public class AsyncPlayer extends PlayerProxy { final Extent world = getLocation().getExtent(); while (y <= world.getMaximumPoint().getY() + 2) { - if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial() + .isMovementBlocker()) { break; // Hit something } else if (y > maxY + 1) { break; @@ -142,7 +145,8 @@ public class AsyncPlayer extends PlayerProxy { public void floatAt(int x, int y, int z, boolean alwaysGlass) { RuntimeException caught = null; try { - EditSession edit = new EditSessionBuilder(WorldWrapper.unwrap(getWorld())).player(unwrap(getBasePlayer())).build(); + EditSession edit = new EditSessionBuilder(WorldWrapper.unwrap(getWorld())) + .player(unwrap(getBasePlayer())).build(); edit.setBlock(BlockVector3.at(x, y - 1, z), BlockTypes.GLASS); edit.flushQueue(); LocalSession session = Fawe.get().getWorldEdit().getSessionManager().get(this); @@ -166,17 +170,17 @@ public class AsyncPlayer extends PlayerProxy { @Override public Location getBlockTrace(int range, boolean useLastBlock) { return TaskManager.IMP.sync(() -> { - TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D); - return useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock(); - }); + TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D); + return useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock(); + }); } @Override public Location getBlockTraceFace(int range, boolean useLastBlock) { return TaskManager.IMP.sync(() -> { - TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D); - return useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace(); - }); + TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D); + return useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace(); + }); } @Override @@ -204,7 +208,9 @@ public class AsyncPlayer extends PlayerProxy { boolean inFree = false; while ((block = hitBlox.getNextBlock()) != null) { - boolean free = !world.getBlock(BlockVector3.at(block.getBlockX(), block.getBlockY(), block.getBlockZ())).getBlockType().getMaterial().isMovementBlocker(); + boolean free = !world.getBlock( + BlockVector3.at(block.getBlockX(), block.getBlockY(), block.getBlockZ())) + .getBlockType().getMaterial().isMovementBlocker(); if (firstBlock) { firstBlock = false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 28371d41b..3d190d3f7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -1052,7 +1052,7 @@ public class BrushCommands { tool.setFill(null); tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission); - player.print("Set brush to " + factory); + player.print(TextComponent.of("Set brush to " + factory)); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java index 1653bf1ae..bce0ecc39 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java @@ -161,11 +161,11 @@ public class ChunkCommands { throw new StopExecutionException(TextComponent.of("Failed to write chunk list: " + e.getMessage())); } - actor.print(String.format("%d chunk(s) have been marked for deletion the next time the server starts.", - newBatch.getChunkCount())); + actor.print(TextComponent.of(String.format("%d chunk(s) have been marked for deletion the next time the server starts.", + newBatch.getChunkCount()))); if (currentInfo.batches.size() > 1) { - actor.printDebug(String.format("%d chunks total marked for deletion. (May have overlaps).", - currentInfo.batches.stream().mapToInt(ChunkDeletionInfo.ChunkBatch::getChunkCount).sum())); + actor.printDebug(TextComponent.of(String.format("%d chunks total marked for deletion. (May have overlaps).", + currentInfo.batches.stream().mapToInt(ChunkDeletionInfo.ChunkBatch::getChunkCount).sum()))); } actor.print(TextComponent.of("You can mark more chunks for deletion, or to stop now, run: ", TextColor.LIGHT_PURPLE) .append(TextComponent.of("/stop", TextColor.AQUA) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java index e632ac1c5..1e27040f9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java @@ -182,7 +182,7 @@ public class HistorySubCommands { RollbackDatabase db = DBHandler.IMP .getDatabase(world); db.logEdit(rollback); - actor.print("Logging: " + historyFile); + actor.print(TextComponent.of("Logging: " + historyFile)); } } } catch (IllegalArgumentException e) { @@ -192,7 +192,7 @@ public class HistorySubCommands { } } } - actor.print("Done import!"); + actor.print(TextComponent.of("Done import!")); } } @@ -289,7 +289,7 @@ public class HistorySubCommands { return elem; } else { // TODO - return TextComponent.of(""); + return TextComponent.empty(); } } }); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index d820bd4ee..77df15796 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -27,7 +27,6 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion; import static com.sk89q.worldedit.regions.Regions.maximumBlockY; import static com.sk89q.worldedit.regions.Regions.minimumBlockY; -import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweCache; import com.boydti.fawe.config.Caption; import com.boydti.fawe.object.FaweLimit; @@ -71,7 +70,6 @@ import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; 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.BlockTypes; import java.util.ArrayList; @@ -132,7 +130,7 @@ public class RegionCommands { @CommandPermissions("worldedit.region.test") @Logging(REGION) public void test(Player player, EditSession editSession, @Arg(desc = "test") double testValue) throws WorldEditException { - player.print("" + testValue); + player.print(TextComponent.of(testValue)); } @Command( @@ -141,7 +139,7 @@ public class RegionCommands { ) @CommandPermissions("worldedit.light.fix") public void fixLighting(Player player) throws WorldEditException { - player.print("Temporarily not working"); + player.print(TextComponent.of("Temporarily not working")); // final Location loc = player.getLocation(); // Region selection = player.getSelection(); // if (selection == null) { @@ -162,7 +160,7 @@ public class RegionCommands { final Location loc = player.getLocation(); int block = editSession.getBlockLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); int sky = editSession.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); - player.print("Light: " + block + " | " + sky); + player.print(TextComponent.of("Light: " + block + " | " + sky)); } @Command( @@ -171,7 +169,7 @@ public class RegionCommands { ) @CommandPermissions("worldedit.light.remove") public void removeLighting(Player player) { - player.print("Temporarily not working"); + player.print(TextComponent.of("Temporarily not working")); // Region selection = player.getSelection(); // if (selection == null) { // final int cx = player.getLocation().getBlockX() >> 4; @@ -196,7 +194,7 @@ public class RegionCommands { } CompoundTag nbt = editSession.getFullBlock(pos.toBlockPoint()).getNbtData(); if (nbt != null) { - player.print(nbt.getValue().toString()); + player.print(TextComponent.of(nbt.getValue().toString())); } else { player.printError(TranslatableComponent.of("fawe.navigation.no.block")); } @@ -208,7 +206,7 @@ public class RegionCommands { ) @CommandPermissions("worldedit.light.set") public void setlighting(Player player, EditSession editSession, @Selection Region region, @Range(from = 0, to = 15) int value) { - player.print("Temporarily not working"); + player.print(TextComponent.of("Temporarily not working")); } @Command( @@ -217,7 +215,7 @@ public class RegionCommands { ) @CommandPermissions("worldedit.light.set") public void setskylighting(Player player, @Selection Region region, @Range(from = 0, to= 15) int value) { - player.print("Temporarily not working"); + player.printInfo(TextComponent.of("Temporarily not working")); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index e7ff23ad5..615677488 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -76,7 +76,7 @@ public class WorldEditCommands { public void version(Actor actor) { FaweVersion fVer = Fawe.get().getVersion(); String fVerStr = fVer == null ? "unknown" : "-" + fVer.build; - actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92"); + actor.print(TextComponent.of("FastAsyncWorldEdit" + fVerStr + " created by Empire92")); if (fVer != null) { FaweVersion version = Fawe.get().getVersion(); @@ -170,7 +170,7 @@ public class WorldEditCommands { name = "cui", desc = "Complete CUI handshake (internal usage)" ) - @CommandPermissions({}) + @CommandPermissions() public void cui(Player player, LocalSession session) { session.setCUISupport(true); session.dispatchCUISetup(player); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java index 244832e23..e72fb2d1a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java @@ -78,9 +78,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab * @deprecated Use component-based functions (printDebug) */ @Deprecated - default void printDebug(String msg) { - printDebug(TextComponent.of(msg)); - } + void printDebug(String msg); /** * Print a WorldEdit message. @@ -89,9 +87,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab * @deprecated Use component-based functions (printInfo) */ @Deprecated - default void print(String msg) { - printInfo(TextComponent.of(msg)); - } + void print(String msg); /** * Print a WorldEdit error. @@ -100,9 +96,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab * @deprecated Use component-based functions (printError) */ @Deprecated - default void printError(String msg) { - printError(TextComponent.of(msg)); - } + void printError(String msg); /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java index f43203df0..6cd5dfa5f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java @@ -33,6 +33,7 @@ import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -141,7 +142,22 @@ public class PlayerProxy extends AbstractPlayerActor { @Override public void printRaw(String msg) { - basePlayer.printRaw(msg); + basePlayer.print(TextComponent.of(msg)); + } + + @Override + public void printDebug(String msg) { + basePlayer.printDebug(TextComponent.of(msg)); + } + + @Override + public void print(String msg) { + basePlayer.printInfo(TextComponent.of(msg)); + } + + @Override + public void printError(String msg) { + basePlayer.printError(TextComponent.of(msg)); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index e61ed68cf..b2880913d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -280,9 +280,9 @@ public interface Region extends Iterable, Cloneable, IBatchProcess BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - boolean processExtra = false; if (tx >= min.getX() && bx <= max.getX() && tz >= min.getZ() && bz <= max.getZ()) { // contains some + boolean processExtra = false; for (int layer = 0; layer < 16; layer++) { int by = layer << 4; int ty = by + 15; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java index 09f05ef4e..0cdd7c43d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java @@ -54,7 +54,7 @@ public final class ActorCallbackPaste { AsyncCommandBuilder.wrap(task, sender) .registerWithSupervisor(supervisor, "Submitting content to a pastebin service.") .sendMessageAfterDelay("(Please wait... sending output to pastebin...)") - .onSuccess((String) null, url -> sender.print(String.format(successMessage, url))) + .onSuccess((String) null, url -> sender.print(TextComponent.of(String.format(successMessage, url)))) .onFailure("Failed to submit paste", null) .buildAndExec(Pasters.getExecutor()); }