mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-04 18:01:17 +01:00
17b58d00d8
This was a useless exception wrapper that ends up making stack traces harder to read as well as the JVM cutting off the important parts Nothing catches this exception, so its safe to just get rid of it and let the REAL exception bubble down
47 lines
1.9 KiB
Diff
47 lines
1.9 KiB
Diff
From 01aa5305d302cfcdfdd2fb0ba3726cf5f3e7f8cd 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 9c80f464..631be1cb 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.logging.Level;
|
|
+import java.util.regex.Matcher;
|
|
+import java.util.regex.Pattern;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
@@ -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(String formatString, String[] args) {
|
|
+ private String buildCommand(CommandSender sender, String formatString, 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.20.1
|
|
|