Various minor
tweak help cancellable EditSessionEvent
This commit is contained in:
parent
f0553f80ae
commit
73b7ca941a
@ -547,6 +547,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
event = event.clone(stage);
|
||||
event.setExtent(extent);
|
||||
eventBus.post(event);
|
||||
if (event.isCancelled()) {
|
||||
return new NullExtent(extent, BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
|
||||
}
|
||||
final Extent toReturn = event.getExtent();
|
||||
if (!(toReturn instanceof AbstractDelegateExtent)) {
|
||||
Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.event.extent;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.event.Cancellable;
|
||||
import com.sk89q.worldedit.event.Event;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -59,7 +60,7 @@ import static com.sk89q.worldedit.EditSession.Stage;
|
||||
* and block interceptors intercept at BOTH {@link Stage#BEFORE_CHANGE} and
|
||||
* {@link Stage#BEFORE_HISTORY}.</p>
|
||||
*/
|
||||
public class EditSessionEvent extends Event {
|
||||
public class EditSessionEvent extends Event implements Cancellable {
|
||||
|
||||
private final World world;
|
||||
private final Actor actor;
|
||||
@ -67,6 +68,7 @@ public class EditSessionEvent extends Event {
|
||||
private final Stage stage;
|
||||
private Extent extent;
|
||||
private EditSession session;
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* Create a new event.
|
||||
@ -151,6 +153,16 @@ public class EditSessionEvent extends Event {
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a clone of this event with the given stage.
|
||||
*
|
||||
@ -166,5 +178,4 @@ public class EditSessionEvent extends Event {
|
||||
public static Class<?> inject() {
|
||||
return EditSessionEvent.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import com.boydti.fawe.util.chat.UsageMessage;
|
||||
import com.boydti.fawe.wrappers.FakePlayer;
|
||||
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
@ -77,6 +78,7 @@ import com.sk89q.worldedit.internal.command.WorldEditBinding;
|
||||
import com.sk89q.worldedit.internal.command.WorldEditExceptionConverter;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.util.command.InvalidUsageException;
|
||||
import com.sk89q.worldedit.util.command.composition.ProvidedValue;
|
||||
@ -90,6 +92,7 @@ import com.sk89q.worldedit.util.logging.DynamicStreamHandler;
|
||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -393,8 +396,17 @@ public final class CommandManager {
|
||||
BBC.NO_PERM.send(finalActor, StringMan.join(failedPermissions, " "));
|
||||
} catch (InvalidUsageException e) {
|
||||
if (e.isFullHelpSuggested()) {
|
||||
UsageMessage usage = new UsageMessage(e.getCommand(), e.getCommandUsed((WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/"), ""), locals);
|
||||
usage.send(fp);
|
||||
CommandCallable cmd = e.getCommand();
|
||||
if (cmd instanceof Dispatcher) {
|
||||
try {
|
||||
CommandContext context = new CommandContext(("ignoreThis " + Joiner.on(" ").join(split)).split(" "), new HashSet<>(), false, locals);
|
||||
UtilityCommands.help(context, worldEdit, actor);
|
||||
} catch (CommandException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
new UsageMessage(cmd, e.getCommandUsed((WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/"), ""), locals).send(fp);
|
||||
}
|
||||
String message = e.getMessage();
|
||||
if (message != null) {
|
||||
finalActor.printError(message);
|
||||
|
Loading…
Reference in New Issue
Block a user