From d80ac24c63c92e2fa58850f5682b2698b40d41cc Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Fri, 21 Dec 2018 17:31:27 +1000 Subject: [PATCH] Pass the exception converter through more. --- .../com/sk89q/worldedit/bukkit/DelegateEntity.java | 5 +++++ .../fawe/jnbt/anvil/HeightMapMCAGenerator.java | 6 ++++++ .../java/com/boydti/fawe/jnbt/anvil/MCAWorld.java | 5 +++++ .../java/com/boydti/fawe/object/HistoryExtent.java | 5 +++++ .../boydti/fawe/object/clipboard/FaweClipboard.java | 6 ++++++ .../fawe/object/schematic/visualizer/SchemVis.java | 6 ++++++ .../java/com/boydti/fawe/wrappers/FakePlayer.java | 6 ++++++ .../java/com/boydti/fawe/wrappers/PlayerWrapper.java | 5 +++++ .../java/com/boydti/fawe/wrappers/WorldWrapper.java | 5 +++++ .../main/java/com/sk89q/worldedit/EditSession.java | 5 +++++ .../sk89q/worldedit/command/WorldEditCommands.java | 2 +- .../worldedit/command/util/AsyncCommandHelper.java | 12 +++++++++--- .../worldedit/util/paste/ActorCallbackPaste.java | 5 +++-- 13 files changed, 67 insertions(+), 6 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/DelegateEntity.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/DelegateEntity.java index 26cb9847e..86a978f92 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/DelegateEntity.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/DelegateEntity.java @@ -44,4 +44,9 @@ public class DelegateEntity implements Entity { public T getFacet(Class cls) { return parent.getFacet(cls); } + + @Override + public boolean setLocation(Location location) { + return parent.setLocation(location); + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java index e6709bb2e..2315269c3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java @@ -2286,4 +2286,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr // TODO Auto-generated method stub return false; } + + @Override + public BlockVector3 getSpawnPosition() { + // TODO Auto-generated method stub + return null; + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java index 8a4cad8e5..3c6d0c7a3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java @@ -127,4 +127,9 @@ public class MCAWorld implements SimpleWorld { // TODO Auto-generated method stub return false; } + + @Override + public BlockVector3 getSpawnPosition() { + return queue.getWEWorld().getSpawnPosition(); + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java index e6f8398aa..334565487 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java @@ -163,5 +163,10 @@ public class HistoryExtent extends AbstractDelegateExtent { public T getFacet(final Class cls) { return this.entity.getFacet(cls); } + + @Override + public boolean setLocation(Location location) { + return this.entity.setLocation(location); + } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/FaweClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/FaweClipboard.java index 5388dbbaa..7267432fd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/FaweClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/FaweClipboard.java @@ -161,5 +161,11 @@ public abstract class FaweClipboard { public Extent getExtent() { return world; } + + @Override + public boolean setLocation(Location location) { + //Should not be teleporting this entity + return false; + } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java index 69d9b464a..c6469ce39 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java @@ -640,4 +640,10 @@ public class SchemVis extends ImmutableVirtualWorld { // TODO Auto-generated method stub return false; } + + @Override + public BlockVector3 getSpawnPosition() { + // TODO Auto-generated method stub + return null; + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java index e7eaf0026..44ba6cc34 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/FakePlayer.java @@ -304,4 +304,10 @@ public class FakePlayer extends AbstractPlayerActor { return true; } } + + @Override + public boolean setLocation(Location location) { + this.pos = location; + return true; + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java index ef40faff3..6e6711650 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java @@ -420,4 +420,9 @@ public class PlayerWrapper extends AbstractPlayerActor { public File openFileSaveDialog(String[] extensions) { return parent.openFileSaveDialog(extensions); } + + @Override + public boolean setLocation(Location location) { + return parent.setLocation(location); + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java index b8055c129..d9b134a9d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java @@ -259,4 +259,9 @@ public class WorldWrapper extends AbstractWorld { public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException { return parent.notifyAndLightBlock(position, previousType); } + + @Override + public BlockVector3 getSpawnPosition() { + return parent.getSpawnPosition(); + } } 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 aa1b9a174..920c62dab 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -3604,4 +3604,9 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, return world.notifyAndLightBlock(position, previousType); } + @Override + public BlockVector3 getSpawnPosition() { + return world.getSpawnPosition(); + } + } 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 c4e957bab..019047786 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 @@ -203,7 +203,7 @@ public class WorldEditCommands { @CommandPermissions("worldedit.debugpaste") public void debugpaste(Actor actor) throws WorldEditException, IOException { // BBC.DOWNLOAD_LINK.send(actor, HastebinUtility.debugPaste()); - ActorCallbackPaste.pastebin(we.getSupervisor(), actor, null, "FastAsyncWorldEdit report: " + BBC.DOWNLOAD_LINK); + ActorCallbackPaste.pastebin(we.getSupervisor(), actor, null, "FastAsyncWorldEdit report: " + BBC.DOWNLOAD_LINK, WorldEdit.getInstance().getPlatformManager().getCommandManager().getExceptionConverter()); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandHelper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandHelper.java index 0f521336d..f3b707435 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandHelper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandHelper.java @@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.util.command.parametric.ExceptionConverter; import com.sk89q.worldedit.util.task.FutureForwardingTask; import com.sk89q.worldedit.util.task.Supervisor; import com.sk89q.worldedit.world.World; @@ -35,17 +36,20 @@ public class AsyncCommandHelper { private final ListenableFuture future; private final Supervisor supervisor; private final Actor sender; + private final ExceptionConverter exceptionConverter; @Nullable private Object[] formatArgs; - private AsyncCommandHelper(ListenableFuture future, Supervisor supervisor, Actor sender) { + private AsyncCommandHelper(ListenableFuture future, Supervisor supervisor, Actor sender, ExceptionConverter exceptionConverter) { checkNotNull(future); checkNotNull(supervisor); checkNotNull(sender); + checkNotNull(exceptionConverter); this.future = future; this.supervisor = supervisor; this.sender = sender; + this.exceptionConverter = exceptionConverter; } public AsyncCommandHelper formatUsing(Object... args) { @@ -78,6 +82,7 @@ public class AsyncCommandHelper { Futures.addCallback( future, new MessageFutureCallback.Builder(sender) + .exceptionConverter(exceptionConverter) .onSuccess(format(success)) .onFailure(format(failure)) .build()); @@ -89,6 +94,7 @@ public class AsyncCommandHelper { Futures.addCallback( future, new MessageFutureCallback.Builder(sender) + .exceptionConverter(exceptionConverter) .onFailure(format(failure)) .build()); return this; @@ -128,8 +134,8 @@ public class AsyncCommandHelper { return this; } - public static AsyncCommandHelper wrap(ListenableFuture future, Supervisor supervisor, Actor sender) { - return new AsyncCommandHelper(future, supervisor, sender); + public static AsyncCommandHelper wrap(ListenableFuture future, Supervisor supervisor, Actor sender, ExceptionConverter exceptionConverter) { + return new AsyncCommandHelper(future, supervisor, sender, exceptionConverter); } } 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 ee98c4364..e87e440bf 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 @@ -24,6 +24,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.sk89q.worldedit.command.util.AsyncCommandHelper; import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.util.command.parametric.ExceptionConverter; import com.sk89q.worldedit.util.task.Supervisor; import java.net.URL; @@ -46,10 +47,10 @@ public class ActorCallbackPaste { * @param content The content * @param successMessage The message, formatted with {@link String#format(String, Object...)} on success */ - public static void pastebin(Supervisor supervisor, final Actor sender, String content, final String successMessage) { +public static void pastebin(Supervisor supervisor, final Actor sender, String content, final String successMessage, final ExceptionConverter exceptionConverter) { ListenableFuture future = new IncendoPaste("fastasyncworldedit").paste(content); - AsyncCommandHelper.wrap(future, supervisor, sender) + AsyncCommandHelper.wrap(future, supervisor, sender, exceptionConverter) .registerWithSupervisor("Submitting content to a pastebin service...") .sendMessageAfterDelay("(Please wait... sending output to pastebin...)");