Skip to content

[Feature] Respect and use message component from Paper ChatRenderer #113

@Cinnazeyy

Description

@Cinnazeyy

Currently, FairyChat doesnt seem to respect any ChatRenderer formatting, that other plugins might have applied before it reaches FairyChat, effectively circumventing the intended usecase of components entirely.
The plugin seems to just serialise the component before formatting, therefore losing all previous formatting or other component behaviour such as hover events or click events.

Example:

Suppose we have the following FairyChat chat format

chatFormat: <#5E548E><sender_displayname></#5E548E> <dark_gray>»</dark_gray> <message>

if another plugin wanted to highlight some keyword, add some hover text to part of the message or edit the message component in any way using the Paper ChatRenderer like such

@EventHandler(priority = EventPriority.LOW)
public void onChat(AsyncChatEvent event) {
    // some logic

    ChatRenderer renderer = event.renderer();
    event.renderer((source, sourceDisplayName, message, viewer) -> {
        Component modifiedMessage = modifyComponent(message);
        return renderer.render(source, sourceDisplayName, modifiedMessage, viewer);
    });
}

all of those changes unfortunately get thrown out the window by FairyChat.

Expected Behaviour:

I would expect FairyChat to keep the initial "message" component and have that be the <message> keyword in your config and only apply your own formatting onto that component instead of serialising the text and creating a new component.
This way you preserve all component behaviour and formatting.

if another plugin would modify a message to effectively look like this:
Hello this a <red>formatted<red> message

the result with the above mentioned chatFormat would be:
<#5E548E>Player</#5E548E> <dark_gray>»</dark_gray> Hello this a <red>formatted<red> message

if the word "formatted" were to for example be given some hover text as well, this should also be preserved

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions