Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 18:40:05 +01:00
Pass the exception converter through more.
Dieser Commit ist enthalten in:
Ursprung
ea30578781
Commit
8d07877463
@ -112,7 +112,10 @@ public class WorldEditCommands {
|
||||
|
||||
if (args.hasFlag('p')) {
|
||||
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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<URL> future = new EngineHubPaste().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...)");
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren