diff options
author | Jake <[email protected]> | 2021-11-23 17:09:49 -0800 |
---|---|---|
committer | MiniDigger | Martin <[email protected]> | 2021-11-30 19:26:33 +0100 |
commit | e481692afdb08c4486866bc856919c585d6d9646 (patch) | |
tree | 66774ecbddc504c3b0fb9460139b6dc8c367d03d /patches/api/0028-Add-sender-name-to-commands.yml-replacement.patch | |
parent | 7665ae86d65b964822b307c085fc86c0fcc442f2 (diff) | |
download | Paper-e481692afdb08c4486866bc856919c585d6d9646.tar.gz Paper-e481692afdb08c4486866bc856919c585d6d9646.zip |
move extra plugins patch up & more work
Diffstat (limited to 'patches/api/0028-Add-sender-name-to-commands.yml-replacement.patch')
-rw-r--r-- | patches/api/0028-Add-sender-name-to-commands.yml-replacement.patch | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/patches/api/0028-Add-sender-name-to-commands.yml-replacement.patch b/patches/api/0028-Add-sender-name-to-commands.yml-replacement.patch new file mode 100644 index 0000000000..7122fed4a2 --- /dev/null +++ b/patches/api/0028-Add-sender-name-to-commands.yml-replacement.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar <[email protected]> +Date: Wed, 22 Jul 2015 18:50:41 -0400 +Subject: [PATCH] Add sender name to commands.yml replacement + +This allows you to use $sender in commands.yml definitions to make +commands that auto target self. + +diff --git a/src/main/java/org/bukkit/command/FormattedCommandAlias.java b/src/main/java/org/bukkit/command/FormattedCommandAlias.java +index a6ad94ef98a1df1d2842635d850bc990b0137849..9d4f553c04784cca63901a56a7aea62a5cae1d72 100644 +--- a/src/main/java/org/bukkit/command/FormattedCommandAlias.java ++++ b/src/main/java/org/bukkit/command/FormattedCommandAlias.java +@@ -1,6 +1,9 @@ + package org.bukkit.command; + + import java.util.ArrayList; ++import java.util.regex.Matcher; // Paper ++import java.util.regex.Pattern; // Paper ++ + import org.bukkit.Bukkit; + import org.jetbrains.annotations.NotNull; + +@@ -19,7 +22,7 @@ public class FormattedCommandAlias extends Command { + ArrayList<String> commands = new ArrayList<String>(); + for (String formatString : formatStrings) { + try { +- commands.add(buildCommand(formatString, args)); ++ commands.add(buildCommand(sender, formatString, args)); // Paper + } catch (Throwable throwable) { + if (throwable instanceof IllegalArgumentException) { + sender.sendMessage(throwable.getMessage()); +@@ -37,7 +40,10 @@ public class FormattedCommandAlias extends Command { + return result; + } + +- private String buildCommand(@NotNull String formatString, @NotNull String[] args) { ++ private String buildCommand(@NotNull CommandSender sender, @NotNull String formatString, @NotNull String[] args) { // Paper ++ if (formatString.contains("$sender")) { // Paper ++ formatString = formatString.replaceAll(Pattern.quote("$sender"), Matcher.quoteReplacement(sender.getName())); // Paper ++ } // Paper + int index = formatString.indexOf('$'); + while (index != -1) { + int start = index; |