From 1c911053672ebbad846cc9fe8ab153cd0ef70a1b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 21 Apr 2021 11:42:59 +0200 Subject: [PATCH] Simplify ScriptExecutor --- .../bausystem/features/script/ScriptExecutor.java | 10 +++------- 1 file changed, 3 insertions(+), 7 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 cc85ba3a..9a13e08d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java @@ -68,7 +68,7 @@ public final class ScriptExecutor { return; } - String[] strings = generateStringArray(command); + String[] strings = replaceVariables(command); if (strings.length == 0) { return; } @@ -99,12 +99,8 @@ public final class ScriptExecutor { } } - private String[] generateStringArray(String command) { - return replaceVariables(command.replaceAll(" +", " ").split(" ")); - } - - private String[] replaceVariables(String[] args) { - String s = String.join(" ", args); + private String[] replaceVariables(String s) { + s = s.replaceAll(" +", " "); Set variables = new HashSet<>(localVariables.allVariables()); variables.addAll(Constants.allVariables()); variables.addAll(globalVariables.allVariables());