mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Prevented overwriting built-in constants.
This commit is contained in:
parent
5ef9df7feb
commit
efc2209c0f
@ -26,7 +26,6 @@ import java.util.Map;
|
||||
import com.sk89q.worldedit.expression.lexer.Lexer;
|
||||
import com.sk89q.worldedit.expression.lexer.tokens.Token;
|
||||
import com.sk89q.worldedit.expression.parser.Parser;
|
||||
import com.sk89q.worldedit.expression.parser.ParserException;
|
||||
import com.sk89q.worldedit.expression.runtime.Constant;
|
||||
import com.sk89q.worldedit.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.expression.runtime.RValue;
|
||||
@ -69,13 +68,18 @@ public class Expression {
|
||||
this(Lexer.tokenize(expression), variableNames);
|
||||
}
|
||||
|
||||
private Expression(List<Token> tokens, String... variableNames) throws ParserException {
|
||||
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));
|
||||
variables.put("true", new Constant(-1, 1));
|
||||
variables.put("false", new Constant(-1, 0));
|
||||
|
||||
for (String variableName : variableNames) {
|
||||
if (variables.containsKey(variableName)) {
|
||||
throw new ExpressionException(-1, "Tried to overwrite identifier '" + variableName + "'");
|
||||
}
|
||||
variables.put(variableName, new Variable(0));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user