diff --git a/AdvancedCore/src/main/java/com/bencodez/advancedcore/api/messages/PlaceholderUtils.java b/AdvancedCore/src/main/java/com/bencodez/advancedcore/api/messages/PlaceholderUtils.java index 3f0f3a134..57f062e8d 100644 --- a/AdvancedCore/src/main/java/com/bencodez/advancedcore/api/messages/PlaceholderUtils.java +++ b/AdvancedCore/src/main/java/com/bencodez/advancedcore/api/messages/PlaceholderUtils.java @@ -304,6 +304,14 @@ public static ArrayList replacePlaceHolders(ArrayList list, Play return newList; } + public static ArrayList replacePlaceHolders(OfflinePlayer player, ArrayList list) { + ArrayList newList = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + newList.add(replacePlaceHolders(player, list.get(i))); + } + return newList; + } + public static String replacePlaceHolders(OfflinePlayer player, String text) { if (player == null) { return text; diff --git a/AdvancedCore/src/main/java/com/bencodez/advancedcore/api/misc/MiscUtils.java b/AdvancedCore/src/main/java/com/bencodez/advancedcore/api/misc/MiscUtils.java index 8174a5643..cacd5b93e 100644 --- a/AdvancedCore/src/main/java/com/bencodez/advancedcore/api/misc/MiscUtils.java +++ b/AdvancedCore/src/main/java/com/bencodez/advancedcore/api/misc/MiscUtils.java @@ -174,10 +174,11 @@ public void executeConsoleCommands(final Player player, final ArrayList final HashMap placeholders, boolean stagger) { if (cmds != null && !cmds.isEmpty()) { placeholders.put("player", player.getName()); - final ArrayList commands = PlaceholderUtils.replaceJavascript(player, - PlaceholderUtils.replacePlaceHolder(cmds, placeholders)); + ArrayList commands = PlaceholderUtils.replacePlaceHolder(cmds, placeholders); + commands = PlaceholderUtils.replacePlaceHolders(commands, player); + final ArrayList finalCommands = PlaceholderUtils.replaceJavascript(player, commands); int tick = 0; - for (final String cmd : commands) { + for (final String cmd : finalCommands) { plugin.debug("Executing console command: " + cmd); runConsoleCommand(cmd, tick, stagger); } @@ -187,15 +188,16 @@ public void executeConsoleCommands(final Player player, final ArrayList public void executeConsoleCommands(Player player, String command, HashMap placeholders) { if (command != null && !command.isEmpty()) { - final String cmd = PlaceholderUtils.replaceJavascript(player, - PlaceholderUtils.replacePlaceHolder(command, placeholders)); + String cmd = PlaceholderUtils.replacePlaceHolder(command, placeholders); + cmd = PlaceholderUtils.replacePlaceHolders(player, cmd); + final String finalCommand = PlaceholderUtils.replaceJavascript(player, cmd); plugin.debug("Executing console command: " + command); plugin.getBukkitScheduler().executeOrScheduleSync(plugin, new Runnable() { @Override public void run() { - Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand); } }, player); @@ -209,11 +211,11 @@ public void executeConsoleCommands(final String playerName, final ArrayList commands1 = cmds; + ArrayList commands = PlaceholderUtils.replacePlaceHolder(cmds, placeholders); if (p != null) { - commands1 = PlaceholderUtils.replaceJavascript(p, commands1); + commands = PlaceholderUtils.replacePlaceHolders(p, commands); + commands = PlaceholderUtils.replaceJavascript(p, commands); } - final ArrayList commands = PlaceholderUtils.replacePlaceHolder(commands1, placeholders); int tick = 0; for (final String cmd : commands) { plugin.debug("Executing console command: " + cmd); @@ -224,14 +226,16 @@ public void executeConsoleCommands(final String playerName, final ArrayList placeholders) { if (command != null && !command.isEmpty()) { - Player p = Bukkit.getPlayer(playerName); + OfflinePlayer p = Bukkit.getOfflinePlayer(playerName); + command = PlaceholderUtils.replacePlaceHolder(command, placeholders); if (p != null) { + command = PlaceholderUtils.replacePlaceHolders(p, command); command = PlaceholderUtils.replaceJavascript(p, command); } if (command.startsWith("/")) { command.replaceFirst("/", ""); } - final String cmd = PlaceholderUtils.replacePlaceHolder(command, placeholders); + final String cmd = command; plugin.debug("Executing console command: " + command); plugin.getBukkitScheduler().executeOrScheduleSync(plugin, new Runnable() {