-
Notifications
You must be signed in to change notification settings - Fork 17
AsyncChatEvent listener should maintain formatting #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This seems like a simple bug: @EventHandler(priority = EventPriority.LOWEST) This should be |
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 /**
* 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.
The text was updated successfully, but these errors were encountered: