mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Refactor confirmation
This commit is contained in:
@ -23,13 +23,18 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||
import com.boydti.fawe.util.task.InterruptableCondition;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.entity.MapMetadatable;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.session.SessionOwner;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import com.sk89q.worldedit.util.Identifiable;
|
||||
import com.sk89q.worldedit.util.auth.Subject;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
@ -37,7 +42,9 @@ import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
|
||||
/**
|
||||
* An object that can perform actions in WorldEdit.
|
||||
@ -134,100 +141,30 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
|
||||
|
||||
boolean runAction(Runnable ifFree, boolean checkFree, boolean async);
|
||||
|
||||
default void checkConfirmationStack(@NotNull Runnable task, @NotNull String command,
|
||||
Region region, int times, InjectedValueAccess context) throws RegionOperationException {
|
||||
if (!getMeta("cmdConfirmRunning", false)) {
|
||||
if (region != null) {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long area =
|
||||
(long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
|
||||
if (area > 2 << 18) {
|
||||
setConfirmTask(task, context, command);
|
||||
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
|
||||
long volume = (long) base.getX() * base.getZ() * base.getY() * times;
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM
|
||||
.format(min, max, command,
|
||||
NumberFormat.getNumberInstance().format(volume)));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Decline any pending actions
|
||||
* @return true if an action was pending
|
||||
*/
|
||||
default boolean decline() {
|
||||
InterruptableCondition confirm = deleteMeta("cmdConfirm");
|
||||
if (confirm != null) {
|
||||
confirm.interrupt();
|
||||
return true;
|
||||
}
|
||||
task.run();
|
||||
}
|
||||
|
||||
default void checkConfirmationRegion(@NotNull Runnable task, @NotNull String command,
|
||||
Region region, InjectedValueAccess context) throws RegionOperationException {
|
||||
if (!getMeta("cmdConfirmRunning", false)) {
|
||||
if (region != null) {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long area = (max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1);
|
||||
if (area > 2 << 18) {
|
||||
setConfirmTask(task, context, command);
|
||||
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
|
||||
long volume = (long) base.getX() * base.getZ() * base.getY();
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM
|
||||
.format(min, max, command,
|
||||
NumberFormat.getNumberInstance().format(volume)));
|
||||
}
|
||||
}
|
||||
}
|
||||
task.run();
|
||||
}
|
||||
|
||||
default void setConfirmTask(@NotNull Runnable task, InjectedValueAccess context,
|
||||
@NotNull String command) {
|
||||
CommandEvent event = new CommandEvent(this, command);
|
||||
Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> {
|
||||
task.run();
|
||||
return null;
|
||||
}, context, getSession(), event);
|
||||
setMeta("cmdConfirm", newTask);
|
||||
}
|
||||
|
||||
default void checkConfirmation(@NotNull Runnable task, @NotNull String command, int times,
|
||||
int limit, InjectedValueAccess context) throws RegionOperationException {
|
||||
if (!getMeta("cmdConfirmRunning", false)) {
|
||||
if (times > limit) {
|
||||
setConfirmTask(task, context, command);
|
||||
String volume = "<unspecified>";
|
||||
throw new RegionOperationException(
|
||||
BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.format(0, times, command, volume));
|
||||
}
|
||||
}
|
||||
task.run();
|
||||
}
|
||||
|
||||
default void checkConfirmationRadius(@NotNull Runnable task, String command, int radius,
|
||||
InjectedValueAccess context) throws RegionOperationException {
|
||||
if (command != null && !getMeta("cmdConfirmRunning", false)) {
|
||||
if (radius > 0) {
|
||||
if (radius > 448) {
|
||||
setConfirmTask(task, context, command);
|
||||
long volume = (long) (Math.PI * ((double) radius * radius));
|
||||
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM
|
||||
.format(0, radius, command,
|
||||
NumberFormat.getNumberInstance().format(volume)));
|
||||
}
|
||||
}
|
||||
}
|
||||
task.run();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm any pending actions
|
||||
* @return true if an action was pending
|
||||
*/
|
||||
default boolean confirm() {
|
||||
Runnable confirm = deleteMeta("cmdConfirm");
|
||||
if (confirm == null) {
|
||||
return false;
|
||||
InterruptableCondition confirm = deleteMeta("cmdConfirm");
|
||||
if (confirm != null) {
|
||||
confirm.signal();;
|
||||
return true;
|
||||
}
|
||||
queueAction(() -> {
|
||||
setMeta("cmdConfirmRunning", true);
|
||||
try {
|
||||
confirm.run();
|
||||
} finally {
|
||||
setMeta("cmdConfirmRunning", false);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,4 +194,42 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
|
||||
default boolean runIfFree(Runnable r) {
|
||||
return runAction(r, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to cancel all pending and running actions
|
||||
* @param close if Extents are closed
|
||||
* @return number of cancelled actions
|
||||
*/
|
||||
default int cancel(boolean close) {
|
||||
int cancelled = decline() ? 1 : 0;
|
||||
|
||||
for (Request request : Request.getAll()) {
|
||||
EditSession editSession = request.getEditSession();
|
||||
if (editSession != null) {
|
||||
Player player = editSession.getPlayer();
|
||||
if (equals(player)) {
|
||||
editSession.cancel();
|
||||
cancelled++;
|
||||
}
|
||||
}
|
||||
}
|
||||
VirtualWorld world = getSession().getVirtualWorld();
|
||||
if (world != null) {
|
||||
if (close) {
|
||||
try {
|
||||
world.close(false);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
world.close(false);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return cancelled;
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +111,7 @@ import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
||||
import com.sk89q.worldedit.command.util.SubCommandPermissionCondition;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.Event;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
||||
import com.sk89q.worldedit.extension.platform.binding.Bindings;
|
||||
@ -122,6 +123,8 @@ import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.command.CommandArgParser;
|
||||
import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
|
||||
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||
import com.sk89q.worldedit.internal.command.ConfirmHandler;
|
||||
import com.sk89q.worldedit.internal.command.MethodInjector;
|
||||
import com.sk89q.worldedit.internal.command.exception.ExceptionConverter;
|
||||
import com.sk89q.worldedit.internal.command.exception.WorldEditExceptionConverter;
|
||||
import com.sk89q.worldedit.internal.util.Substring;
|
||||
@ -130,6 +133,7 @@ import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
@ -138,12 +142,12 @@ import com.sk89q.worldedit.util.logging.LogFormat;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.config.TextConfig;
|
||||
import org.enginehub.piston.converter.ArgumentConverter;
|
||||
import org.enginehub.piston.converter.ArgumentConverters;
|
||||
import org.enginehub.piston.converter.ConversionResult;
|
||||
import org.enginehub.piston.exception.CommandException;
|
||||
import org.enginehub.piston.exception.CommandExecutionException;
|
||||
import org.enginehub.piston.exception.ConditionFailedException;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
import org.enginehub.piston.exception.UsageException;
|
||||
import org.enginehub.piston.gen.CommandRegistration;
|
||||
import org.enginehub.piston.impl.CommandManagerServiceImpl;
|
||||
@ -165,6 +169,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -221,7 +227,10 @@ public final class PlatformCommandManager {
|
||||
this.globalInjectedValues = MapBackedValueStore.create();
|
||||
this.registration = new CommandRegistrationHandler(
|
||||
ImmutableList.of(
|
||||
new CommandLoggingHandler(worldEdit, COMMAND_LOG)
|
||||
new CommandLoggingHandler(worldEdit, COMMAND_LOG),
|
||||
new MethodInjector(),
|
||||
new ConfirmHandler()
|
||||
|
||||
));
|
||||
// setup separate from main constructor
|
||||
// ensures that everything is definitely assigned
|
||||
@ -262,7 +271,7 @@ public final class PlatformCommandManager {
|
||||
WorldConverter.register(commandManager);
|
||||
ExpressionConverter.register(commandManager);
|
||||
|
||||
registerBindings(new ConsumeBindings(worldEdit));
|
||||
registerBindings(new ConsumeBindings(worldEdit, this));
|
||||
registerBindings(new PrimitiveBindings(worldEdit));
|
||||
registerBindings(new ProvideBindings(worldEdit));
|
||||
}
|
||||
@ -611,17 +620,29 @@ public final class PlatformCommandManager {
|
||||
return CommandArgParser.forArgString(input).parseArgs();
|
||||
}
|
||||
|
||||
public <T> T parse(String args, Actor actor) {
|
||||
public <T> T parseCommand(String args, Actor actor) {
|
||||
InjectedValueAccess context;
|
||||
if (actor == null) {
|
||||
context = globalInjectedValues;
|
||||
} else {
|
||||
context = initializeInjectedValues(args::toString, actor);
|
||||
context = initializeInjectedValues(args::toString, actor, null);
|
||||
}
|
||||
return parse(args, context);
|
||||
return parseCommand(args, context);
|
||||
}
|
||||
|
||||
public <T> T parse(String args, InjectedValueAccess access) {
|
||||
public <T> T parseConverter(String args, InjectedValueAccess access, Class<T> clazz) {
|
||||
ArgumentConverter<T> converter = commandManager.getConverter(Key.of(clazz)).orElse(null);
|
||||
if (converter != null) {
|
||||
ConversionResult<T> result = converter.convert(args, access);
|
||||
Collection<T> values = result.orElse(Collections.emptyList());
|
||||
if (!values.isEmpty()) {
|
||||
return values.iterator().next();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T> T parseCommand(String args, InjectedValueAccess access) {
|
||||
if (args.isEmpty()) return null;
|
||||
String[] split = parseArgs(args)
|
||||
.map(Substring::getSubstring)
|
||||
@ -639,8 +660,6 @@ public final class PlatformCommandManager {
|
||||
String arg0 = space0 == -1 ? args : args.substring(0, space0);
|
||||
Optional<Command> optional = commandManager.getCommand(arg0);
|
||||
if (!optional.isPresent()) {
|
||||
System.out.println("No command for '" + arg0 + "' " + StringMan.getString(commandManager.getAllCommands().map(
|
||||
Command::getName).collect(Collectors.toList())));
|
||||
return;
|
||||
}
|
||||
Command cmd = optional.get();
|
||||
@ -648,6 +667,8 @@ public final class PlatformCommandManager {
|
||||
if (queued != null && !queued.isQueued()) {
|
||||
handleCommandOnCurrentThread(event);
|
||||
return;
|
||||
} else {
|
||||
actor.decline();
|
||||
}
|
||||
LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||
synchronized (session) {
|
||||
@ -679,7 +700,7 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
}
|
||||
|
||||
MemoizingValueAccess context = initializeInjectedValues(event::getArguments, actor);
|
||||
MemoizingValueAccess context = initializeInjectedValues(event::getArguments, actor, event);
|
||||
|
||||
ThrowableSupplier<Throwable> task = () -> commandManager.execute(context, ImmutableList.copyOf(split));
|
||||
|
||||
@ -717,10 +738,6 @@ public final class PlatformCommandManager {
|
||||
} catch (FaweException e) {
|
||||
actor.printError("Edit cancelled: " + e.getMessage());
|
||||
} catch (UsageException e) {
|
||||
actor.print(TextComponent.builder("")
|
||||
.color(TextColor.RED)
|
||||
.append(e.getRichMessage())
|
||||
.build());
|
||||
ImmutableList<Command> cmd = e.getCommands();
|
||||
if (!cmd.isEmpty()) {
|
||||
actor.print(TextComponent.builder("Usage: ")
|
||||
@ -728,22 +745,27 @@ public final class PlatformCommandManager {
|
||||
.append(HelpGenerator.create(e.getCommandParseResult()).getUsage())
|
||||
.build());
|
||||
}
|
||||
} catch (CommandExecutionException e) {
|
||||
handleUnknownException(actor, e.getCause());
|
||||
} catch (CommandException e) {
|
||||
actor.print(TextComponent.builder("")
|
||||
.color(TextColor.RED)
|
||||
.append(e.getRichMessage())
|
||||
.build());
|
||||
List<String> argList = parseArgs(event.getArguments()).map(Substring::getSubstring).collect(Collectors.toList());
|
||||
printUsage(actor, argList);
|
||||
} catch (CommandExecutionException e) {
|
||||
handleUnknownException(actor, e.getCause());
|
||||
} catch (CommandException e) {
|
||||
Component msg = e.getRichMessage();
|
||||
if (msg != TextComponent.empty()) {
|
||||
actor.print(TextComponent.builder("")
|
||||
.color(TextColor.RED)
|
||||
.append(msg)
|
||||
.build());
|
||||
List<String> argList = parseArgs(event.getArguments()).map(Substring::getSubstring).collect(Collectors.toList());
|
||||
printUsage(actor, argList);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
handleUnknownException(actor, t);
|
||||
} finally {
|
||||
if (context instanceof MemoizingValueAccess) {
|
||||
context = ((MemoizingValueAccess) context).snapshotMemory();
|
||||
} else {
|
||||
System.out.println("Invalid context " + context);
|
||||
}
|
||||
Optional<EditSession> editSessionOpt = context.injectedValue(Key.of(EditSession.class));
|
||||
|
||||
@ -783,7 +805,7 @@ public final class PlatformCommandManager {
|
||||
getCommandManager(), actor, "//help");
|
||||
}
|
||||
|
||||
private MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor tmp) {
|
||||
private MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor tmp, Event event) {
|
||||
InjectedValueStore store = MapBackedValueStore.create();
|
||||
Actor actor = wrapActor(tmp, store);
|
||||
store.injectValue(Key.of(Actor.class), ValueProvider.constant(actor));
|
||||
@ -801,9 +823,10 @@ public final class PlatformCommandManager {
|
||||
localSession.tellVersion(actor);
|
||||
return Optional.of(localSession);
|
||||
});
|
||||
|
||||
store.injectValue(Key.of(InjectedValueStore.class), ValueProvider.constant(store));
|
||||
store.injectValue(Key.of(Event.class), ValueProvider.constant(event));
|
||||
return MemoizingValueAccess.wrap(
|
||||
MergedValueAccess.of(store, globalInjectedValues)
|
||||
MergedValueAccess.of(store, globalInjectedValues)
|
||||
);
|
||||
}
|
||||
|
||||
@ -821,7 +844,7 @@ public final class PlatformCommandManager {
|
||||
List<String> argStrings = split.stream()
|
||||
.map(Substring::getSubstring)
|
||||
.collect(Collectors.toList());
|
||||
MemoizingValueAccess access = initializeInjectedValues(() -> arguments, event.getActor());
|
||||
MemoizingValueAccess access = initializeInjectedValues(() -> arguments, event.getActor(), event);
|
||||
ImmutableSet<Suggestion> suggestions;
|
||||
try {
|
||||
suggestions = commandManager.getSuggestions(access, argStrings);
|
||||
@ -832,7 +855,6 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
throw t;
|
||||
}
|
||||
|
||||
event.setSuggestions(suggestions.stream()
|
||||
.map(suggestion -> {
|
||||
int noSlashLength = arguments.length() - 1;
|
||||
|
@ -2,20 +2,24 @@ package com.sk89q.worldedit.extension.platform.binding;
|
||||
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
import com.sk89q.worldedit.UnknownDirectionException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
@ -26,14 +30,73 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.inject.InjectedValueStore;
|
||||
import org.enginehub.piston.converter.ConversionResult;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class ConsumeBindings extends Bindings {
|
||||
public ConsumeBindings(WorldEdit worldEdit) {
|
||||
private final PlatformCommandManager manager;
|
||||
|
||||
public ConsumeBindings(WorldEdit worldEdit, PlatformCommandManager manager) {
|
||||
super(worldEdit);
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Binding
|
||||
@Confirm
|
||||
@Selection
|
||||
public int regionMultiple(Actor actor, InjectedValueAccess context, @Selection Region region, String argument) {
|
||||
int times = (int) Expression.compile(argument).evaluate();
|
||||
return Confirm.Processor.REGION.check(actor, context, times);
|
||||
}
|
||||
|
||||
@Binding
|
||||
@Confirm(Confirm.Processor.RADIUS)
|
||||
public Integer radiusInteger(Actor actor, InjectedValueAccess context, String argument) {
|
||||
int times = (int) Expression.compile(argument).evaluate();
|
||||
return Confirm.Processor.RADIUS.check(actor, context, times);
|
||||
}
|
||||
|
||||
@Binding
|
||||
@Confirm(Confirm.Processor.LIMIT)
|
||||
public Integer limitInteger(Actor actor, InjectedValueAccess context, String argument) {
|
||||
int times = (int) Expression.compile(argument).evaluate();
|
||||
return Confirm.Processor.LIMIT.check(actor, context, times);
|
||||
}
|
||||
|
||||
@Binding
|
||||
@Confirm(Confirm.Processor.RADIUS)
|
||||
public Double radiusDouble(Actor actor, InjectedValueAccess context, String argument) {
|
||||
double times = Expression.compile(argument).evaluate();
|
||||
return Confirm.Processor.RADIUS.check(actor, context, times);
|
||||
}
|
||||
|
||||
@Binding
|
||||
@Confirm(Confirm.Processor.LIMIT)
|
||||
public Double limitDouble(Actor actor, InjectedValueAccess context, String argument) {
|
||||
double times = Expression.compile(argument).evaluate();
|
||||
return Confirm.Processor.LIMIT.check(actor, context, times);
|
||||
}
|
||||
|
||||
@Binding
|
||||
@Confirm(Confirm.Processor.RADIUS)
|
||||
public BlockVector2 radiusVec2(Actor actor, InjectedValueAccess context, String argument) {
|
||||
BlockVector2 radius = manager.parseConverter(argument, context, BlockVector2.class);
|
||||
double length = radius.length();
|
||||
Confirm.Processor.RADIUS.check(actor, context, length);
|
||||
return radius;
|
||||
}
|
||||
|
||||
@Binding
|
||||
@Confirm(Confirm.Processor.RADIUS)
|
||||
public BlockVector3 radiusVec3(Actor actor, InjectedValueAccess context, String argument) {
|
||||
BlockVector3 radius = manager.parseConverter(argument, context, BlockVector3.class);
|
||||
double length = radius.length();
|
||||
Confirm.Processor.RADIUS.check(actor, context, length);
|
||||
return radius;
|
||||
}
|
||||
|
||||
@Binding
|
||||
|
Reference in New Issue
Block a user