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

Native support for Adventure API Component #29

Open
zvyap opened this issue Jan 29, 2024 · 2 comments
Open

Native support for Adventure API Component #29

zvyap opened this issue Jan 29, 2024 · 2 comments
Assignees

Comments

@zvyap
Copy link

zvyap commented Jan 29, 2024

It would be beneficial for this library to include native support for commonly used Adventure API objects such as TextComponent, Sound, and Key.

In my experience, I've used this library in two different projects, and the first task I always undertake is copying the ComponentSerializer, SoundSerializer, and KeySerializer modules.

The Adventure API also provides support, some of which is even native on other platforms. It would be advantageous to integrate similar support into this library. You can find more information about Adventure API support on other platforms here: https://docs.advntr.dev/platform/native.html

@Exlll Exlll self-assigned this Jan 30, 2024
@Exlll
Copy link
Owner

Exlll commented Jan 30, 2024

Hi, thanks for your suggestion!

To get support for these additional serializers, you'll probably have to use a custom ConfigurationProperties object (similar to what you already have to do currently to get support for Bukkit's ConfigurationSerializable), i.e.:

YamlConfigurationProperties properties = ConfigLib.PAPER_DEFAULT_PROPERTIES.toBuilder()
     // ...further configure the builder...
    .build();

 // ...use builder to save/load configurations

What do you think about this approach? Perhaps you have a different idea in mind?

I've used this library in two different projects, and the first task I always undertake is copying the ComponentSerializer, SoundSerializer, and KeySerializer modules.

Could you perhaps share the relevant parts of your code/config to give me an idea of how you currently do it?

@zvyap
Copy link
Author

zvyap commented Jan 30, 2024

Hi, thanks for your suggestion!

To get support for these additional serializers, you'll probably have to use a custom ConfigurationProperties object (similar to what you already have to do currently to get support for Bukkit's ConfigurationSerializable), i.e.:

YamlConfigurationProperties properties = ConfigLib.PAPER_DEFAULT_PROPERTIES.toBuilder()
     // ...further configure the builder...
    .build();

 // ...use builder to save/load configurations

What do you think about this approach? Perhaps you have a different idea in mind?

I think you should change the way that add support to a platform. Currently, we are using ConfigLib.PAPER_DEFAULT_PROPERTIES to add support to paper/bukkit stuff, but Adventure API is supported in various platform.

How about using this way to add specify support to a platform

ConfigLib.newBuilder()
      .addBundle(ConfigLibBundles.PAPER)
      .addBundle(ConfigLibBundles.ADVENTURE_API)

I've used this library in two different projects, and the first task I always undertake is copying the ComponentSerializer, SoundSerializer, and KeySerializer modules.

Could you perhaps share your the relevant parts of your code/config do give me an idea of how you currently do it?

I just make my own class that implements Serializer<Component, String>, nothing special
For sound, I deserialize string format "<sound_id>:[pitch]:[volume]:[source]"
For component, I just deserialize String with https://docs.advntr.dev/serializer/index.html.
For Key, just deserialize string to Key object, nothing special.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants