Open danthedaniel opened 11 months ago
This seems like a simple bug:
@EventHandler(priority = EventPriority.LOWEST)
This should be EventPriority.HIGHEST
. Or the code can pass through the Component
unmodified.
I see your point if there is a situation where someone wants to use some formatting prior to HexNicks formatting the chat. HexNicks' formatter was really only meant to be used by people who had no other chat formatting tool. So the solution in most cases is to just turn off the formatter in the config.
I had luck with passing through the Component
:
/**
* Format the chat for all server implementations.
*
* @param source the chatter
* @param message the message
* @return formatted chat
*/
private @NotNull Component formatChat(final @NotNull Player source, final @NotNull Component message) {
final MiniMessageWrapper miniMessageWrapper = MiniMessageWrapper.builder()
.advancedTransformations(source.hasPermission("hexnicks.chat.advanced"))
.gradients(source.hasPermission("hexnicks.color.gradient"))
.hexColors(source.hasPermission("hexnicks.color.hex"))
.legacyColors(HexNicks.config().LEGACY_COLORS)
.removeTextDecorations(MiscUtils.blockedDecorations(source))
.removeColors(MiscUtils.blockedColors(source))
.build();
Component ret = miniMessageWrapper
.mmParse(HexNicks.hooks().applyPlaceHolders(source, HexNicks.config().CHAT_FORMAT))
// Replace display name placeholder with HexNicks nick
.replaceText(TextReplacementConfig.builder().matchLiteral("{displayname}")
.replacement(HexNicks.core().getDisplayName(source)).build())
// Replace prefix placeholder with Vault prefix
.replaceText(TextReplacementConfig.builder().matchLiteral("{prefix}")
.replacement(HexNicks.hooks().vaultPrefix(source)).build())
// Replace suffix placeholder with Vault Suffix
.replaceText(TextReplacementConfig.builder().matchLiteral("{suffix}")
.replacement(HexNicks.hooks().vaultSuffix(source)).build())
// Replace message placeholder with the formatted message from the event
.replaceText(TextReplacementConfig.builder().matchLiteral("{message}")
.replacement(message).build());
HexNicks.logging()
.debug("Formatted message: " + PlainTextComponentSerializer.plainText().serialize(ret));
return ret;
}
Would you accept such a patch?
Is your feature request related to a problem? Please describe. When using multiple chat formatters, HexNicks will destroy formatting information
Describe the solution you'd like When one plugin modifies text color/decoration, HexNicks should respect that.