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

Separate component styling into a ComponentStyle class #3569

Closed
wants to merge 6 commits into from

Conversation

2008Choco
Copy link
Contributor

@2008Choco 2008Choco commented Dec 6, 2023

With the introduction of scoreboard number formats, specifically the minecraft:styled format, Mojang clearly makes a point that component styling can be independent from the contents of a text component. This PR separates all text styling fields into its own ComponentStyle class with its own builder and adds BaseComponent#applyStyle(ComponentStyle) and ComponentBuilder#apply(ComponentStyle) methods to apply these styles.

ComponentStyle instances are mutable but can be cloned or edited into a new instance with ComponentStyle.builder(ComponentStyle).

@md-5
Copy link
Member

md-5 commented Dec 6, 2023

Needs a way to parse a style.

Also throwing out the idea that BaseComponent could extent ComponentStyle instead of having it as a field, but I don't have a preference for either at the moment.

@2008Choco
Copy link
Contributor Author

Needs a way to parse a style.

Yeah, I'll add a way to parse now

BaseComponent could extent ComponentStyle instead of having it as a field

I disagree with this. I think composition vs inheritance decision making applies here. Component doesn't fit the bill for "is a style" but it does fit "has a style", so a field here makes the most sense imo despite the unfortunate need for repetition.

@md-5
Copy link
Member

md-5 commented Dec 12, 2023

I think we still need ComponentSerializer#parseStyle or something for use with scoreboards (and wherever else there is a style)

@2008Choco
Copy link
Contributor Author

I think we still need ComponentSerializer#parseStyle or something for use with scoreboards (and wherever else there is a style)

Oh, yeah, for server internals. Will add that. My bad.

@mrjasonn
Copy link

mrjasonn commented Jan 5, 2024

It seems like this PR is done, probably can be merged?

@md-5
Copy link
Member

md-5 commented Jan 6, 2024

Thanks

@md-5 md-5 closed this Jan 6, 2024
diogotcorreia added a commit to diogotcorreia/BungeeCord that referenced this pull request Feb 1, 2024
diogotcorreia added a commit to diogotcorreia/BungeeCord that referenced this pull request Feb 1, 2024
diogotcorreia added a commit to diogotcorreia/BungeeCord that referenced this pull request Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants