mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
4d6f73449f
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 CraftBukkit Changes:17543ecf
SPIGOT-5035: Error Using Virtual Merchant GUI0fc6922b
SPIGOT-5028: Villager#setVillagerExperience() doesn't workbdbdbe44
SPIGOT-5024: Fox error - Unknown target reason
44 lines
No EOL
2 KiB
Diff
44 lines
No EOL
2 KiB
Diff
From 0000000000000000000000000000000000000000 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 a6ad94ef9..9d4f553c0 100644
|
|
--- a/src/main/java/org/bukkit/command/FormattedCommandAlias.java
|
|
+++ b/src/main/java/org/bukkit/command/FormattedCommandAlias.java
|
|
@@ -0,0 +0,0 @@
|
|
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;
|
|
|
|
@@ -0,0 +0,0 @@ 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());
|
|
@@ -0,0 +0,0 @@ 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;
|
|
--
|