From fce0e819a428ea2eabe004cb72d9acd9bffa5b4f Mon Sep 17 00:00:00 2001 From: BlitzOffline <52609756+BlitzOffline@users.noreply.github.com> Date: Sat, 25 May 2024 23:38:15 +0300 Subject: [PATCH] Target set with `-p:` argument in `/dm open` command ignored in action placeholders --- .../deluxemenus/action/ClickActionTask.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/extendedclip/deluxemenus/action/ClickActionTask.java b/src/main/java/com/extendedclip/deluxemenus/action/ClickActionTask.java index b2aef50..4d32fa0 100644 --- a/src/main/java/com/extendedclip/deluxemenus/action/ClickActionTask.java +++ b/src/main/java/com/extendedclip/deluxemenus/action/ClickActionTask.java @@ -58,8 +58,12 @@ public void run() { } final Optional holder = Menu.getMenuHolder(player); - final String executable = StringUtils.replacePlaceholdersAndArguments(this.exec, this.arguments, player, this.parsePlaceholdersInArguments); + final Player target = holder.isPresent() && holder.get().getPlaceholderPlayer() != null + ? holder.get().getPlaceholderPlayer() + : player; + + final String executable = StringUtils.replacePlaceholdersAndArguments(this.exec, this.arguments, target, this.parsePlaceholdersInArguments); switch (actionType) { case META: @@ -405,14 +409,14 @@ public void run() { switch (actionType) { case BROADCAST_SOUND: - for (final Player target : Bukkit.getOnlinePlayers()) { - target.playSound(target.getLocation(), sound, volume, pitch); + for (final Player broadcastTarget : Bukkit.getOnlinePlayers()) { + broadcastTarget.playSound(broadcastTarget.getLocation(), sound, volume, pitch); } break; case BROADCAST_WORLD_SOUND: - for (final Player target : player.getWorld().getPlayers()) { - target.playSound(target.getLocation(), sound, volume, pitch); + for (final Player broadcastTarget : player.getWorld().getPlayers()) { + broadcastTarget.playSound(broadcastTarget.getLocation(), sound, volume, pitch); } break;