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

ScopedComponent doesn't always respect initial component type #1154

Open
Fusezion opened this issue Jan 10, 2025 · 2 comments · May be fixed by #1161
Open

ScopedComponent doesn't always respect initial component type #1154

Fusezion opened this issue Jan 10, 2025 · 2 comments · May be fixed by #1161

Comments

@Fusezion
Copy link

Fusezion commented Jan 10, 2025

While messing around with some components, an issue arose when using Component#font(Key) on its own outside of builders. It doesn't respect the initial provided component type in it's returned output.

Image

EDIT: after a bit more messing around these are all the effected methods

ScopedComponent#font(Key),
ScopedComponent#style(Consumer<Builder>, Strategy),
ScopedComponent#appendNewLine(),
ScopedComponent#appendSpace(),
ScopedComponent#applyFallbackStyle(StyleBuilderApplicable...),
ScopedComponent#applyFallbackStyle(Style),
ScopedComponent#decorate(TextDecoration....),
ScopedComponent#decorateIfAbsent(TextDecoration, TextDecoration$State),
ScopedComponent#decorations(Set<TextDecoration>, boolean),
ScopedComponent#decorations(Map<TextDecoration, TextDecoration$State>),
ScopedComponent#replaceText(Consumer<Builder>), and
ScopedComponent#replaceText(TextReplacementConfig)

I've left out the #compact method since just like #asComponent it seems more intentional design wise for it to be Component

@zml2008
Copy link
Member

zml2008 commented Jan 10, 2025

see ScopedComponent

@Fusezion Fusezion changed the title Component#font doesn't respect initial component type ScopedComponent doesn't always respect initial component type Jan 10, 2025
@zml2008
Copy link
Member

zml2008 commented Feb 9, 2025

Added a quick test to ensure we don't miss these in the future, the list it gives is:

- interface net.kyori.adventure.text.Component compact()
- interface net.kyori.adventure.text.Component replaceText(Pattern, Function)
- interface net.kyori.adventure.text.Component replaceText(Pattern, Function, int)
- interface net.kyori.adventure.text.Component font(Key)
- interface net.kyori.adventure.text.Component replaceText(Pattern, Function, IntFunction2)
- interface net.kyori.adventure.text.Component replaceFirstText(Pattern, Function)
- interface net.kyori.adventure.text.Component replaceText(TextReplacementConfig)
- interface net.kyori.adventure.text.Component asComponent()
- interface net.kyori.adventure.text.Component decorations(Map)
- interface net.kyori.adventure.text.Component replaceText(Consumer)
- interface net.kyori.adventure.text.Component replaceText(String, ComponentLike)
- interface net.kyori.adventure.text.Component applyFallbackStyle(Style)
- interface net.kyori.adventure.text.Component replaceText(String, ComponentLike, int)
- interface net.kyori.adventure.text.Component appendSpace()
- interface net.kyori.adventure.text.Component replaceFirstText(String, ComponentLike)
- interface net.kyori.adventure.text.Component style(Consumer, Strategy)
- interface net.kyori.adventure.text.Component appendNewline()
- interface net.kyori.adventure.text.Component decorationIfAbsent(TextDecoration, State)
- interface net.kyori.adventure.text.Component applyFallbackStyle(StyleBuilderApplicable[])
- interface net.kyori.adventure.text.Component replaceText(String, ComponentLike, IntFunction2)

I'll filter deprecated methods and give us an exclusion annotation to use, but this gives us an easy list

@zml2008 zml2008 linked a pull request Feb 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants