SteamWar/BauSystem
Archiviert
13
0

Script Turing Completeness #152

Manuell gemergt
YoyoNow hat 14 Commits von ScriptBranches nach master 2021-01-09 20:40:17 +01:00 zusammengeführt
Nur Änderungen aus Commit 570de88059 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -150,6 +150,12 @@ public class ScriptListener implements Listener {
continue; continue;
} }
// Variable Replaces in commands.
String[] commandArgs = command.split(" ");
String[] args = Arrays.copyOfRange(commandArgs, 1, commandArgs.length);
replaceVariables(this, args);
command = commandArgs[0] + String.join(" ", args);
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command); Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
Bukkit.getServer().dispatchCommand(player, command); Bukkit.getServer().dispatchCommand(player, command);
} }
@ -185,12 +191,16 @@ public class ScriptListener implements Listener {
return scriptExecutor.jumpPoints.getOrDefault(args[0], -1); return scriptExecutor.jumpPoints.getOrDefault(args[0], -1);
} }
private static void infoCommand(ScriptExecutor scriptExecutor, String[] args) { private static void replaceVariables(ScriptExecutor scriptExecutor, String[] args) {
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("$") && isVariable(scriptExecutor, args[i].substring(1))) { if (args[i].startsWith("$") && isVariable(scriptExecutor, args[i].substring(1))) {
args[i] = getValue(scriptExecutor, args[i].substring(1)) + ""; args[i] = getValue(scriptExecutor, args[i].substring(1)) + "";
} }
} }
}
private static void infoCommand(ScriptExecutor scriptExecutor, String[] args) {
replaceVariables(scriptExecutor, args);
scriptExecutor.player.sendMessage("§eInfo§8» §7" + ChatColor.translateAlternateColorCodes('&', String.join(" ", args))); scriptExecutor.player.sendMessage("§eInfo§8» §7" + ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
} }