From 1058a49f1fa6ec3c5ae3fe9191a5cf71617eb85f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 23 Dec 2022 22:52:11 +0100 Subject: [PATCH] Fix variable resolution order --- .../features/script/ScriptExecutor.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java index 1ce3c6eb..a5eb755e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java @@ -5,8 +5,6 @@ import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.function.operation.Operations; -import com.sk89q.worldedit.session.SessionKey; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.expression.Expression; import de.steamwar.bausystem.features.script.expression.UnknownOperatorException; @@ -251,24 +249,24 @@ public final class ScriptExecutor { return Value.parse(variable); } - if (Constants.isConstant(variable)) { - return Constants.getConstant(variable, player); + if (localVariables.hasValue(variable)) { + return localVariables.getValue(variable); } if (globalVariables.hasValue(variable)) { return globalVariables.getValue(variable); } - return localVariables.getValue(variable); + return Constants.getConstant(variable, player); } public Value getValueOrNull(String variable) { - if (Constants.isConstant(variable)) { - return Constants.getConstant(variable, player); + if (localVariables.hasValue(variable)) { + return localVariables.getValue(variable); } if (globalVariables.hasValue(variable)) { return globalVariables.getValue(variable); } - if (localVariables.hasValue(variable)) { - return localVariables.getValue(variable); + if (Constants.isConstant(variable)) { + return Constants.getConstant(variable, player); } return null; } @@ -285,14 +283,14 @@ public final class ScriptExecutor { } public String getValue(String variable) { - if (Constants.isConstant(variable)) { - return Constants.getConstant(variable, player).asString(); + if (localVariables.hasValue(variable)) { + return localVariables.getValue(variable).asString(); } if (globalVariables.hasValue(variable)) { return globalVariables.getValue(variable).asString(); } - if (localVariables.hasValue(variable)) { - return localVariables.getValue(variable).asString(); + if (Constants.isConstant(variable)) { + return Constants.getConstant(variable, player).asString(); } return ""; }