From fd2f073520520657b9a8f6efdea25e7c48388321 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 26 Mar 2021 22:25:49 +0100 Subject: [PATCH] Fix CommandScriptVars Fix ScriptListener.generateArgumentArray --- .../de/steamwar/bausystem/commands/CommandScriptVars.java | 5 +++-- .../src/de/steamwar/bausystem/world/ScriptListener.java | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java index 7c32e91..946e07b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandScriptVars.java @@ -44,8 +44,9 @@ public class CommandScriptVars implements CommandExecutor { return false; } player.sendMessage(BauSystem.PREFIX + varName + "=" + globalVariables.get(varName)); + return false; } - switch (args[2].toLowerCase()) { + switch (args[1].toLowerCase()) { case "delete": case "clear": case "remove": @@ -57,7 +58,7 @@ public class CommandScriptVars implements CommandExecutor { player.sendMessage(BauSystem.PREFIX + "Variable " + varName + " gelöscht"); break; default: - int value = ScriptListener.parseValue(args[2]); + int value = ScriptListener.parseValue(args[1]); ScriptListener.GLOBAL_VARIABLES.computeIfAbsent(player, p -> new HashMap<>()).put(varName, value); player.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt"); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java index 4a87884..6b897a0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java @@ -278,6 +278,9 @@ public class ScriptListener implements Listener { String s = String.join(" ", args); Set variables = new HashSet<>(scriptExecutor.variables.keySet()); variables.addAll(CONSTANTS.keySet()); + if (GLOBAL_VARIABLES.containsKey(scriptExecutor.player)) { + variables.addAll(GLOBAL_VARIABLES.get(scriptExecutor.player).keySet()); + } for (String variable : variables) { s = s.replace("<" + variable + ">", getValue(scriptExecutor, variable) + ""); }