Add variable replacing for every command
Dieser Commit ist enthalten in:
Ursprung
a8e6edefb8
Commit
570de88059
@ -150,6 +150,12 @@ public class ScriptListener implements Listener {
|
||||
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.getServer().dispatchCommand(player, command);
|
||||
}
|
||||
@ -185,12 +191,16 @@ public class ScriptListener implements Listener {
|
||||
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++) {
|
||||
if (args[i].startsWith("$") && isVariable(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)));
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren