mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
*
A tribute to Jesse
This commit is contained in:
@ -46,7 +46,7 @@ public class CommandRegistrationHandler {
|
||||
.listeners(callListeners);
|
||||
if (registration instanceof CommandPermissionsConditionGenerator.Registration) {
|
||||
((CommandPermissionsConditionGenerator.Registration) registration).commandPermissionsConditionGenerator(
|
||||
PERM_GEN
|
||||
PERM_GEN
|
||||
);
|
||||
}
|
||||
if (registration instanceof CommandQueuedConditionGenerator.Registration) {
|
||||
|
@ -85,6 +85,7 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
|
||||
public void convert(MissingWorldException e) throws CommandException {
|
||||
throw newCommandException("You need to provide a world (Try //world)", e);
|
||||
}
|
||||
|
||||
@ExceptionMatch
|
||||
public void convert(UnknownItemException e) throws CommandException {
|
||||
throw newCommandException("Block name '" + e.getID() + "' was not recognized.", e);
|
||||
|
@ -86,7 +86,6 @@ public class Expression {
|
||||
.build());
|
||||
|
||||
private final Map<String, RValue> variables = new HashMap<>();
|
||||
private final String[] variableNames;
|
||||
private Variable[] variableArray;
|
||||
private RValue root;
|
||||
private final Functions functions = new Functions();
|
||||
@ -97,7 +96,6 @@ public class Expression {
|
||||
}
|
||||
|
||||
public Expression(double constant) {
|
||||
variableNames = null;
|
||||
root = new Constant(0, constant);
|
||||
}
|
||||
|
||||
@ -106,7 +104,6 @@ public class Expression {
|
||||
}
|
||||
|
||||
private Expression(List<Token> tokens, String... variableNames) throws ExpressionException {
|
||||
this.variableNames = variableNames;
|
||||
|
||||
variables.put("e", new Constant(-1, Math.E));
|
||||
variables.put("pi", new Constant(-1, Math.PI));
|
||||
@ -115,12 +112,11 @@ public class Expression {
|
||||
|
||||
variableArray = new Variable[variableNames.length];
|
||||
for (int i = 0; i < variableNames.length; i++) {
|
||||
String variableName = variableNames[i];
|
||||
if (variables.containsKey(variableName)) {
|
||||
throw new ExpressionException(-1, "Tried to overwrite identifier '" + variableName + "'");
|
||||
if (variables.containsKey(variableNames[i])) {
|
||||
throw new ExpressionException(-1, "Tried to overwrite identifier '" + variableNames[i] + "'");
|
||||
}
|
||||
Variable var = new Variable(0);
|
||||
variables.put(variableName, var);
|
||||
variables.put(variableNames[i], var);
|
||||
variableArray[i] = var;
|
||||
}
|
||||
|
||||
@ -139,14 +135,7 @@ public class Expression {
|
||||
return evaluateTimeout(WorldEdit.getInstance().getConfiguration().calculationTimeout, values);
|
||||
}
|
||||
|
||||
public double evaluateTimeout(int timeout, double x, double y) throws EvaluationException {
|
||||
if (root instanceof Constant) return root.getValue();
|
||||
variableArray[0].value = x;
|
||||
variableArray[1].value = y;
|
||||
return evaluateFinal(timeout);
|
||||
}
|
||||
|
||||
public double evaluateTimeout(int timeout, double x, double y, double z) throws EvaluationException {
|
||||
private double evaluateTimeout(int timeout, double x, double y, double z) throws EvaluationException {
|
||||
if (root instanceof Constant) return root.getValue();
|
||||
variableArray[0].value = x;
|
||||
variableArray[1].value = y;
|
||||
@ -156,8 +145,8 @@ public class Expression {
|
||||
|
||||
public double evaluateTimeout(int timeout, double... values) throws EvaluationException {
|
||||
if (root instanceof Constant) return root.getValue();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
Variable var = variableArray[i];
|
||||
for (int i = 0; i < values.length; ++i) {
|
||||
final Variable var = variableArray[i];
|
||||
var.value = values[i];
|
||||
}
|
||||
return evaluateFinal(timeout);
|
||||
@ -167,7 +156,7 @@ public class Expression {
|
||||
if (root instanceof Constant) {
|
||||
return root.getValue();
|
||||
}
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
for (int i = 0; i < values.length; ++i) {
|
||||
Variable var = variableArray[i];
|
||||
var.value = values[i];
|
||||
}
|
||||
|
@ -38,4 +38,4 @@ public class ReturnException extends EvaluationException {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.util;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -31,7 +33,7 @@ public final class Substring {
|
||||
* a Substring.
|
||||
*/
|
||||
public static Substring from(String original, int start) {
|
||||
return wrap(original.substring(start), start, original.length());
|
||||
return new Substring(original.substring(start), start, original.length());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,13 +41,15 @@ public final class Substring {
|
||||
* a Substring.
|
||||
*/
|
||||
public static Substring from(String original, int start, int end) {
|
||||
return wrap(original.substring(start, end), start, end);
|
||||
return new Substring(original.substring(start, end), start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the given parameters into a Substring instance.
|
||||
*/
|
||||
public static Substring wrap(String substring, int start, int end) {
|
||||
checkArgument(0 <= start, "Start must be greater than or equal to zero");
|
||||
checkArgument(start <= end, "End must be greater than or equal to start");
|
||||
return new Substring(substring, start, end);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user