Slight changes

This commit is contained in:
Jesse Boyd 2017-03-06 14:00:34 +11:00
parent e555c24618
commit 119a332d83
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 7 additions and 17 deletions

View File

@ -28,7 +28,7 @@ ext {
date = git.head().date.format("yy.MM.dd") date = git.head().date.format("yy.MM.dd")
revision = "-${git.head().abbreviatedId}" revision = "-${git.head().abbreviatedId}"
parents = git.head().parentIds; parents = git.head().parentIds;
index = -81; // Offset to mach CI index = -82; // Offset to mach CI
int major, minor, patch; int major, minor, patch;
major = minor = patch = 0; major = minor = patch = 0;
for (;parents != null && !parents.isEmpty();index++) { for (;parents != null && !parents.isEmpty();index++) {

View File

@ -108,7 +108,7 @@ public class Settings extends Config {
}) })
public int MAX_HISTORY_MB = -1; public int MAX_HISTORY_MB = -1;
@Comment("Maximum time in milliseconds //calc can execute") @Comment("Maximum time in milliseconds //calc can execute")
public int MAX_CALC_MS = 50; public int MAX_EXPRESSION_MS = 50;
@Comment({ @Comment({
"Cinematic block placement:", "Cinematic block placement:",
" - Adds a delay to block placement (ms/block)", " - Adds a delay to block placement (ms/block)",
@ -367,7 +367,7 @@ public class Settings extends Config {
limit.MAX_FAILS = Math.max(limit.MAX_FAILS, newLimit.MAX_FAILS != -1 ? newLimit.MAX_FAILS : Integer.MAX_VALUE); limit.MAX_FAILS = Math.max(limit.MAX_FAILS, newLimit.MAX_FAILS != -1 ? newLimit.MAX_FAILS : Integer.MAX_VALUE);
limit.MAX_ITERATIONS = Math.max(limit.MAX_ITERATIONS, newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE); limit.MAX_ITERATIONS = Math.max(limit.MAX_ITERATIONS, newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE);
limit.MAX_HISTORY = Math.max(limit.MAX_HISTORY, newLimit.MAX_HISTORY_MB != -1 ? newLimit.MAX_HISTORY_MB : Integer.MAX_VALUE); limit.MAX_HISTORY = Math.max(limit.MAX_HISTORY, newLimit.MAX_HISTORY_MB != -1 ? newLimit.MAX_HISTORY_MB : Integer.MAX_VALUE);
limit.MAX_CALC_MS = Math.max(limit.MAX_CALC_MS, newLimit.MAX_CALC_MS != -1 ? newLimit.MAX_CALC_MS : Integer.MAX_VALUE); limit.MAX_EXPRESSION_MS = Math.max(limit.MAX_EXPRESSION_MS, newLimit.MAX_EXPRESSION_MS != -1 ? newLimit.MAX_EXPRESSION_MS : Integer.MAX_VALUE);
limit.INVENTORY_MODE = Math.min(limit.INVENTORY_MODE, newLimit.INVENTORY_MODE); limit.INVENTORY_MODE = Math.min(limit.INVENTORY_MODE, newLimit.INVENTORY_MODE);
limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION); limit.SPEED_REDUCTION = Math.min(limit.SPEED_REDUCTION, newLimit.SPEED_REDUCTION);
limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT; limit.FAST_PLACEMENT |= newLimit.FAST_PLACEMENT;

View File

@ -12,7 +12,7 @@ public class FaweLimit {
public int MAX_BLOCKSTATES = 0; public int MAX_BLOCKSTATES = 0;
public int MAX_ENTITIES = 0; public int MAX_ENTITIES = 0;
public int MAX_HISTORY = 0; public int MAX_HISTORY = 0;
public int MAX_CALC_MS = 0; public int MAX_EXPRESSION_MS = 0;
public int INVENTORY_MODE = Integer.MAX_VALUE; public int INVENTORY_MODE = Integer.MAX_VALUE;
public int SPEED_REDUCTION = Integer.MAX_VALUE; public int SPEED_REDUCTION = Integer.MAX_VALUE;
public boolean FAST_PLACEMENT = false; public boolean FAST_PLACEMENT = false;
@ -56,7 +56,7 @@ public class FaweLimit {
MAX.MAX_BLOCKSTATES = Integer.MAX_VALUE; MAX.MAX_BLOCKSTATES = Integer.MAX_VALUE;
MAX.MAX_ENTITIES = Integer.MAX_VALUE; MAX.MAX_ENTITIES = Integer.MAX_VALUE;
MAX.MAX_HISTORY = Integer.MAX_VALUE; MAX.MAX_HISTORY = Integer.MAX_VALUE;
MAX.MAX_CALC_MS = 50; MAX.MAX_EXPRESSION_MS = 50;
MAX.FAST_PLACEMENT = true; MAX.FAST_PLACEMENT = true;
} }

View File

@ -514,17 +514,7 @@ public class UtilityCommands {
@CommandPermissions("worldedit.calc") @CommandPermissions("worldedit.calc")
public void calc(final Actor actor, @Text String input) throws CommandException { public void calc(final Actor actor, @Text String input) throws CommandException {
try { try {
FaweLimit limit; FaweLimit limit = FawePlayer.wrap(actor).getLimit();
FawePlayer player = null;
if (actor != null) {
player = FawePlayer.wrap(actor);
}
if (player == null) {
limit = FaweLimit.MAX;
} else {
limit = player.getLimit();
}
final Expression expression = Expression.compile(input); final Expression expression = Expression.compile(input);
final AtomicDouble result = new AtomicDouble(Double.NaN); final AtomicDouble result = new AtomicDouble(Double.NaN);
ExecutorService executor = Executors.newSingleThreadExecutor(); ExecutorService executor = Executors.newSingleThreadExecutor();
@ -535,7 +525,7 @@ public class UtilityCommands {
result.set(expression.evaluate()); result.set(expression.evaluate());
return null; return null;
} }
}), limit.MAX_CALC_MS, TimeUnit.MILLISECONDS); // Default timeout of 50 milliseconds to prevent abuse. }), limit.MAX_EXPRESSION_MS, TimeUnit.MILLISECONDS); // Default timeout of 50 milliseconds to prevent abuse.
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }