3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 02:50:06 +01:00

Pass the exception converter through more.

Dieser Commit ist enthalten in:
Matthew Miller 2018-12-21 17:31:27 +10:00
Ursprung ea30578781
Commit 8d07877463
3 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -112,7 +112,10 @@ public class WorldEditCommands {
if (args.hasFlag('p')) { if (args.hasFlag('p')) {
actor.checkPermission("worldedit.report.pastebin"); actor.checkPermission("worldedit.report.pastebin");
ActorCallbackPaste.pastebin(we.getSupervisor(), actor, result, "WorldEdit report: %s.report"); ActorCallbackPaste.pastebin(
we.getSupervisor(), actor, result, "WorldEdit report: %s.report",
WorldEdit.getInstance().getPlatformManager().getCommandManager().getExceptionConverter()
);
} }
} }

Datei anzeigen

@ -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.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.sk89q.worldedit.extension.platform.Actor; 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.FutureForwardingTask;
import com.sk89q.worldedit.util.task.Supervisor; import com.sk89q.worldedit.util.task.Supervisor;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -35,17 +36,20 @@ public class AsyncCommandHelper {
private final ListenableFuture<?> future; private final ListenableFuture<?> future;
private final Supervisor supervisor; private final Supervisor supervisor;
private final Actor sender; private final Actor sender;
private final ExceptionConverter exceptionConverter;
@Nullable @Nullable
private Object[] formatArgs; private Object[] formatArgs;
private AsyncCommandHelper(ListenableFuture<?> future, Supervisor supervisor, Actor sender) { private AsyncCommandHelper(ListenableFuture<?> future, Supervisor supervisor, Actor sender, ExceptionConverter exceptionConverter) {
checkNotNull(future); checkNotNull(future);
checkNotNull(supervisor); checkNotNull(supervisor);
checkNotNull(sender); checkNotNull(sender);
checkNotNull(exceptionConverter);
this.future = future; this.future = future;
this.supervisor = supervisor; this.supervisor = supervisor;
this.sender = sender; this.sender = sender;
this.exceptionConverter = exceptionConverter;
} }
public AsyncCommandHelper formatUsing(Object... args) { public AsyncCommandHelper formatUsing(Object... args) {
@ -78,6 +82,7 @@ public class AsyncCommandHelper {
Futures.addCallback( Futures.addCallback(
future, future,
new MessageFutureCallback.Builder(sender) new MessageFutureCallback.Builder(sender)
.exceptionConverter(exceptionConverter)
.onSuccess(format(success)) .onSuccess(format(success))
.onFailure(format(failure)) .onFailure(format(failure))
.build()); .build());
@ -89,6 +94,7 @@ public class AsyncCommandHelper {
Futures.addCallback( Futures.addCallback(
future, future,
new MessageFutureCallback.Builder(sender) new MessageFutureCallback.Builder(sender)
.exceptionConverter(exceptionConverter)
.onFailure(format(failure)) .onFailure(format(failure))
.build()); .build());
return this; return this;
@ -128,8 +134,8 @@ public class AsyncCommandHelper {
return this; return this;
} }
public static AsyncCommandHelper wrap(ListenableFuture<?> future, Supervisor supervisor, Actor sender) { public static AsyncCommandHelper wrap(ListenableFuture<?> future, Supervisor supervisor, Actor sender, ExceptionConverter exceptionConverter) {
return new AsyncCommandHelper(future, supervisor, sender); return new AsyncCommandHelper(future, supervisor, sender, exceptionConverter);
} }
} }

Datei anzeigen

@ -24,6 +24,7 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.sk89q.worldedit.command.util.AsyncCommandHelper; import com.sk89q.worldedit.command.util.AsyncCommandHelper;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
import com.sk89q.worldedit.util.task.Supervisor; import com.sk89q.worldedit.util.task.Supervisor;
import java.net.URL; import java.net.URL;
@ -46,10 +47,10 @@ public class ActorCallbackPaste {
* @param content The content * @param content The content
* @param successMessage The message, formatted with {@link String#format(String, Object...)} on success * @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<URL> future = new EngineHubPaste().paste(content); ListenableFuture<URL> future = new EngineHubPaste().paste(content);
AsyncCommandHelper.wrap(future, supervisor, sender) AsyncCommandHelper.wrap(future, supervisor, sender, exceptionConverter)
.registerWithSupervisor("Submitting content to a pastebin service...") .registerWithSupervisor("Submitting content to a pastebin service...")
.sendMessageAfterDelay("(Please wait... sending output to pastebin...)"); .sendMessageAfterDelay("(Please wait... sending output to pastebin...)");