Skip to content
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

Add support for Adventure components #59

Open
Tracked by #54
checkcast opened this issue Jul 16, 2024 · 4 comments
Open
Tracked by #54

Add support for Adventure components #59

checkcast opened this issue Jul 16, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@checkcast
Copy link

Hi,
I think it would be a great idea to be able to use Adventure components and/or minimessages in Holoeasy.

@unldenis unldenis added the enhancement New feature or request label Jul 23, 2024
@unldenis
Copy link
Owner

I don't quite understand, can you try to give me some examples?

@bivashy
Copy link

bivashy commented Jul 26, 2024

I don't quite understand, can you try to give me some examples?

Adventure API

Currently, each line could be represented as a String, but we could (optionally) support Adventure Component which represents rich text (clickable, hoverable, HEX colors). In most cases users only need HEX colors and nothing more.
Very simple example to create a component:

Component component = MiniMessage.miniMessage().deserialize("<yellow><bold>Hello <reset>world!");

Which will result in:
hello-world-minimessage-example


Adventure API in holoeasy

It could be great if we could provide such component as line in holoeasy like:

Component component = MiniMessage.miniMessage().deserialize("<yellow><bold>Hello <reset>world!");

hologramPool.registerHolograms(() -> {
            hologram(location, () -> {
                textline("test");
                componentline(component);
            });
        });

Alternative solutions

Currently we only have a workaround by using dirty hack LegacyComponentSerializer:

private static final LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder()
            .character(LegacyComponentSerializer.SECTION_CHAR)
            .useUnusualXRepeatedCharacterHexFormat()
            .hexColors()
            .build();
            
hologramPool.registerHolograms(() -> {
            hologram(location, () -> {
                textline("test");
                textline(SERIALIZER.serialize(MiniMessage.miniMessage().deserialize(("<rainbow>||||||||||||||||||||||||</rainbow>"))));
            });
        });

Result is:
rainbow-hologram-example
But in my opinion this doesn't look good and might be an unreliable solution.

@checkcast
Copy link
Author

@unldenis Hello, I can try to work on that by myself, will fork & PR if you need!

@unldenis
Copy link
Owner

unldenis commented Feb 1, 2025

Hi @checkcast ,
update me when you have any updates.

However at this moment with packetevents you could pass a Component.
With protocol lib I don't know how you could serialize it.

Then there would be something to change in the hologram api, or add a new component text line type.

I'm open to any solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants