mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 11:26:42 +00:00
Add better control over expression timeouts. (#451)
Add better control over expression timeouts. * //timeout command can be used to change player's current timeout. * Config now also has a max timeout, can be bypassed with permission * Timeout of < 0 will let expressions run indefinitely. * Said expressions won't run on a separate thread, slightly reducing the overhead from context switching. For large //gen commands, for example, this can actually increase speed.
This commit is contained in:
@ -52,6 +52,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.session.SessionOwner;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
@ -541,13 +542,18 @@ public class UtilityCommands {
|
||||
public void calc(Actor actor, @Text String input) throws CommandException {
|
||||
try {
|
||||
Expression expression = Expression.compile(input);
|
||||
actor.print("= " + expression.evaluate());
|
||||
if (actor instanceof SessionOwner) {
|
||||
actor.print("= " + expression.evaluate(
|
||||
new double[]{}, WorldEdit.getInstance().getSessionManager().get((SessionOwner) actor).getTimeout()));
|
||||
} else {
|
||||
actor.print("= " + expression.evaluate());
|
||||
}
|
||||
} catch (EvaluationException e) {
|
||||
actor.printError(String.format(
|
||||
"'%s' could not be parsed as a valid expression", input));
|
||||
"'%s' could not be evaluated (error: %s)", input, e.getMessage()));
|
||||
} catch (ExpressionException e) {
|
||||
actor.printError(String.format(
|
||||
"'%s' could not be evaluated (error: %s)", input, e.getMessage()));
|
||||
"'%s' could not be parsed as a valid expression", input));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user