Fix format parsing in local spy chat format (Fixes #5665)

This commit is contained in:
Josh Roy 2024-02-11 21:36:57 -05:00
parent 1dccfbfcee
commit 82606a7ced
2 changed files with 10 additions and 1 deletions

View File

@ -125,6 +125,13 @@ public final class AdventureUtil {
return COLORS[index];
}
/**
* Convenience method for submodules to escape MiniMessage tags.
*/
public static String escapeTags(final String input) {
return miniMessage().escapeTags(input);
}
/**
* Parameters for a translation message are not parsed for MiniMessage by default to avoid injection. If you want
* a parameter to be parsed for MiniMessage you must wrap it in a ParsedPlaceholder by using this method.

View File

@ -227,8 +227,10 @@ public abstract class AbstractChatHandler {
server.getPluginManager().callEvent(spyEvent);
if (!spyEvent.isCancelled()) {
final String legacyString = AdventureUtil.miniToLegacy(String.format(spyEvent.getFormat(), AdventureUtil.legacyToMini(user.getDisplayName()), AdventureUtil.escapeTags(spyEvent.getMessage())));
for (final Player onlinePlayer : spyEvent.getRecipients()) {
onlinePlayer.sendMessage(String.format(spyEvent.getFormat(), user.getDisplayName(), spyEvent.getMessage()));
onlinePlayer.sendMessage(legacyString);
}
}
}