From 7ee6b1eba56267c85d2a65d795e5cd2f87a33aab Mon Sep 17 00:00:00 2001 From: Riley Park Date: Mon, 15 May 2023 13:24:56 -0700 Subject: [PATCH] a --- .../net/kyori/adventure/text/Component.java | 32 +++++++++---------- .../adventure/text/VirtualComponent.java | 2 +- .../adventure/text/VirtualComponentImpl.java | 26 +++++++-------- .../renderer/AbstractComponentRenderer.java | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/api/src/main/java/net/kyori/adventure/text/Component.java b/api/src/main/java/net/kyori/adventure/text/Component.java index 2a5ee3584..3ad538dd5 100644 --- a/api/src/main/java/net/kyori/adventure/text/Component.java +++ b/api/src/main/java/net/kyori/adventure/text/Component.java @@ -1267,67 +1267,67 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * Creates a virtual component. * * @param the context type - * @param context the context type + * @param contextType the context type * @param renderer the renderer * @return a virtual component * @since 4.14.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull VirtualComponent virtual(final @NotNull Class context, final @NotNull VirtualComponentRenderer renderer) { - requireNonNull(context, "context"); + static @NotNull VirtualComponent virtual(final @NotNull Class contextType, final @NotNull VirtualComponentRenderer renderer) { + requireNonNull(contextType, "context type"); requireNonNull(renderer, "renderer"); - return VirtualComponentImpl.createVirtual(context, renderer); + return VirtualComponentImpl.createVirtual(contextType, renderer); } /** * Creates a virtual component with a value. * * @param the context type - * @param context the context type + * @param contextType the context type * @param renderer the renderer * @param style the style * @return a virtual component * @since 4.14.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull VirtualComponent virtual(final @NotNull Class context, final @NotNull VirtualComponentRenderer renderer, final @NotNull Style style) { - requireNonNull(context, "context"); + static @NotNull VirtualComponent virtual(final @NotNull Class contextType, final @NotNull VirtualComponentRenderer renderer, final @NotNull Style style) { + requireNonNull(contextType, "context type"); requireNonNull(renderer, "renderer"); - return VirtualComponentImpl.createVirtual(context, renderer, Collections.emptyList(), style); + return VirtualComponentImpl.createVirtual(contextType, renderer, Collections.emptyList(), style); } /** * Creates a virtual component with a value. * * @param the context type - * @param context the context type + * @param contextType the context type * @param renderer the renderer * @param style the style elements * @return a virtual component * @since 4.14.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull VirtualComponent virtual(final @NotNull Class context, final @NotNull VirtualComponentRenderer renderer, final @NotNull StyleBuilderApplicable... style) { - requireNonNull(context, "context"); + static @NotNull VirtualComponent virtual(final @NotNull Class contextType, final @NotNull VirtualComponentRenderer renderer, final @NotNull StyleBuilderApplicable... style) { + requireNonNull(contextType, "context type"); requireNonNull(renderer, "renderer"); - return VirtualComponentImpl.createVirtual(context, renderer, Collections.emptyList(), Style.style(style)); + return VirtualComponentImpl.createVirtual(contextType, renderer, Collections.emptyList(), Style.style(style)); } /** * Creates a virtual component with a value. * * @param the context type - * @param context the context type + * @param contextType the context type * @param renderer the renderer * @param style the style elements * @return a virtual component * @since 4.14.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull VirtualComponent virtual(final @NotNull Class context, final @NotNull VirtualComponentRenderer renderer, final @NotNull Iterable style) { - requireNonNull(context, "context"); + static @NotNull VirtualComponent virtual(final @NotNull Class contextType, final @NotNull VirtualComponentRenderer renderer, final @NotNull Iterable style) { + requireNonNull(contextType, "context type"); requireNonNull(renderer, "renderer"); - return VirtualComponentImpl.createVirtual(context, renderer, Collections.emptyList(), Style.style(style)); + return VirtualComponentImpl.createVirtual(contextType, renderer, Collections.emptyList(), Style.style(style)); } /* diff --git a/api/src/main/java/net/kyori/adventure/text/VirtualComponent.java b/api/src/main/java/net/kyori/adventure/text/VirtualComponent.java index d057c051f..f28dda0d5 100644 --- a/api/src/main/java/net/kyori/adventure/text/VirtualComponent.java +++ b/api/src/main/java/net/kyori/adventure/text/VirtualComponent.java @@ -39,7 +39,7 @@ public interface VirtualComponent extends TextComponent { * @return the renderer context type * @since 4.14.0 */ - @NotNull Class context(); + @NotNull Class contextType(); /** * Gets the renderer. diff --git a/api/src/main/java/net/kyori/adventure/text/VirtualComponentImpl.java b/api/src/main/java/net/kyori/adventure/text/VirtualComponentImpl.java index 511ee354b..385c8d0d4 100644 --- a/api/src/main/java/net/kyori/adventure/text/VirtualComponentImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/VirtualComponentImpl.java @@ -29,33 +29,33 @@ import org.jetbrains.annotations.NotNull; final class VirtualComponentImpl extends TextComponentImpl implements VirtualComponent { - static VirtualComponent createVirtual(final @NotNull Class context, final @NotNull VirtualComponentRenderer renderer) { - return createVirtual(context, renderer, Collections.emptyList(), Style.empty()); + static VirtualComponent createVirtual(final @NotNull Class contextType, final @NotNull VirtualComponentRenderer renderer) { + return createVirtual(contextType, renderer, Collections.emptyList(), Style.empty()); } - static VirtualComponent createVirtual(final @NotNull Class context, final @NotNull VirtualComponentRenderer renderer, final List children, final Style style) { + static VirtualComponent createVirtual(final @NotNull Class contextType, final @NotNull VirtualComponentRenderer renderer, final List children, final Style style) { final List filteredChildren = ComponentLike.asComponents(children, IS_NOT_EMPTY); - return new VirtualComponentImpl(filteredChildren, style, "", context, renderer); + return new VirtualComponentImpl(filteredChildren, style, "", contextType, renderer); } - private final Class context; + private final Class contextType; private final VirtualComponentRenderer renderer; - private VirtualComponentImpl(final @NotNull List children, final @NotNull Style style, final @NotNull String content, final @NotNull Class context, final @NotNull VirtualComponentRenderer renderer) { + private VirtualComponentImpl(final @NotNull List children, final @NotNull Style style, final @NotNull String content, final @NotNull Class contextType, final @NotNull VirtualComponentRenderer renderer) { super(children, style, content); - this.context = context; + this.contextType = contextType; this.renderer = renderer; } @Override VirtualComponent create0(final @NotNull List children, final @NotNull Style style, final @NotNull String content) { - return new VirtualComponentImpl(ComponentLike.asComponents(children, IS_NOT_EMPTY), style, content, this.context, this.renderer); + return new VirtualComponentImpl(ComponentLike.asComponents(children, IS_NOT_EMPTY), style, content, this.contextType, this.renderer); } @Override - public @NotNull Class context() { - return this.context; + public @NotNull Class contextType() { + return this.contextType; } @Override @@ -74,18 +74,18 @@ VirtualComponent create0(final @NotNull List children, } static final class BuilderImpl extends TextComponentImpl.BuilderImpl { - private final Class context; + private final Class contextType; private final VirtualComponentRenderer renderer; BuilderImpl(final VirtualComponent other) { super(other); - this.context = other.context(); + this.contextType = other.contextType(); this.renderer = other.renderer(); } @Override public @NotNull TextComponent build() { - return createVirtual(this.context, this.renderer, this.children, this.buildStyle()); + return createVirtual(this.contextType, this.renderer, this.children, this.buildStyle()); } } } diff --git a/api/src/main/java/net/kyori/adventure/text/renderer/AbstractComponentRenderer.java b/api/src/main/java/net/kyori/adventure/text/renderer/AbstractComponentRenderer.java index 4704b9bb7..51aa83d50 100644 --- a/api/src/main/java/net/kyori/adventure/text/renderer/AbstractComponentRenderer.java +++ b/api/src/main/java/net/kyori/adventure/text/renderer/AbstractComponentRenderer.java @@ -144,7 +144,7 @@ public abstract class AbstractComponentRenderer implements ComponentRenderer< */ @SuppressWarnings("unchecked") protected @NotNull Component renderVirtual(final @NotNull VirtualComponent component, final @NotNull C context) { - if (component.context().isInstance(context)) { + if (component.contextType().isInstance(context)) { return ((VirtualComponentRenderer) component.renderer()).apply(context).asComponent(); } return component; // will be processed as a TextComponent instead