Script Turing Completeness #152
@ -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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren