From 7b230fc67927bf967ee78ce7f7428bc9cd90b3cf Mon Sep 17 00:00:00 2001 From: Andre601 Date: Mon, 6 May 2024 16:42:24 +0200 Subject: [PATCH] Fix output for parse command + "me" support in parserel --- .../commands/impl/local/CommandParse.java | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java index 8eccc95..7313f65 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java @@ -87,7 +87,8 @@ public final class CommandParse extends PlaceholderCommand { final boolean command) { if (params.size() < 2) { Msg.msg(sender, - "&cYou must supply a target, and a message: &b/papi " + (broadcast ? "bcparse" : "parse") + "&cYou must provide a target and message: &b/papi " + + (command ? "cmdparse" : (broadcast ? "bcparse" : "parse")) + " &7{target} &a{message}"); return; } @@ -132,24 +133,49 @@ public final class CommandParse extends PlaceholderCommand { @NotNull @Unmodifiable final List params) { if (params.size() < 3) { Msg.msg(sender, - "&cYou must supply two targets, and a message: &b/papi parserel &7{target one} {target two} &a{message}"); + "&cYou must supply two targets, and a message: &b/papi parserel &7{target one} " + + "{target two} &a{message}"); return; } - - final OfflinePlayer targetOne = resolvePlayer(params.get(0)); - if (targetOne == null || !targetOne.isOnline()) { + + OfflinePlayer playerOne; + + if ("me".equalsIgnoreCase(params.get(0))) { + if (!(sender instanceof Player)) { + Msg.msg(sender, "&cYou must be a player to use &7me&c as a target!"); + return; + } + + playerOne = ((Player) sender); + } else { + playerOne = resolvePlayer(params.get(0)); + } + + if (playerOne == null || !playerOne.isOnline()) { Msg.msg(sender, "&cFailed to find player: &f" + params.get(0)); return; } - - final OfflinePlayer targetTwo = resolvePlayer(params.get(1)); - if (targetTwo == null || !targetTwo.isOnline()) { + + OfflinePlayer playerTwo; + + if ("me".equalsIgnoreCase(params.get(1))) { + if (!(sender instanceof Player)) { + Msg.msg(sender, "&cYou must be a player to use &7me&c as a target!"); + return; + } + + playerTwo = ((Player) sender); + } else { + playerTwo = resolvePlayer(params.get(1)); + } + + if (playerTwo == null || !playerTwo.isOnline()) { Msg.msg(sender, "&cFailed to find player: &f" + params.get(1)); return; } final String message = PlaceholderAPI - .setRelationalPlaceholders(((Player) targetOne), ((Player) targetTwo), + .setRelationalPlaceholders(playerOne.getPlayer(), playerTwo.getPlayer(), String.join(" ", params.subList(2, params.size()))); sender.sendMessage(message);