mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 17:31:06 +01:00
0976d52bbd
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Please note that this build includes changes to meet upstreams requirements for nullability annotations. While we aim for a level of accuracy, these might not be 100% correct, if there are any issues, please speak to us on discord, or open an issue on the tracker to discuss. Bukkit Changes: 9a6a1de3 Remove nullability annotations from enum constructors 3f0591ea SPIGOT-2540: Add nullability annotations to entire Bukkit API CraftBukkit Changes:8d8475fc
SPIGOT-4666: Force parameter in HumanEntity#sleep8b1588e2
Fix ExplosionPrimeEvent#setFire not working with EnderCrystals39a287b7
Don't ignore newlines in PlayerListHeader/Footer Spigot Changes: cf694d87 Add nullability annotations
45 lines
2 KiB
Diff
45 lines
2 KiB
Diff
From 897b248eb3ad7bb683e285b8c144942bc9e8e951 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
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 982f0fb4..3276879d 100644
|
|
--- a/src/main/java/org/bukkit/command/FormattedCommandAlias.java
|
|
+++ b/src/main/java/org/bukkit/command/FormattedCommandAlias.java
|
|
@@ -1,6 +1,8 @@
|
|
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;
|
|
@@ -20,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());
|
|
@@ -38,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;
|
|
--
|
|
2.21.0
|
|
|