diff --git a/api/build.gradle.kts b/api/build.gradle.kts index b6eeac9a03..e55a39deb3 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -14,6 +14,7 @@ dependencies { api(libs.examination.api) api(libs.examination.string) compileOnlyApi(libs.jetbrainsAnnotations) + compileOnlyApi(libs.jspecify) testImplementation(libs.guava) annotationProcessor(projects.adventureAnnotationProcessors) } diff --git a/api/src/main/java/net/kyori/adventure/audience/Audience.java b/api/src/main/java/net/kyori/adventure/audience/Audience.java index 3911b9837b..35e036f1f7 100644 --- a/api/src/main/java/net/kyori/adventure/audience/Audience.java +++ b/api/src/main/java/net/kyori/adventure/audience/Audience.java @@ -43,7 +43,7 @@ import net.kyori.adventure.title.Title; import net.kyori.adventure.title.TitlePart; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * A receiver of Minecraft media. @@ -87,6 +87,7 @@ * @see BossBarViewer * @since 4.0.0 */ +@NullMarked public interface Audience extends Pointered { /** * Gets an audience that does nothing. @@ -94,7 +95,7 @@ public interface Audience extends Pointered { * @return a do-nothing audience * @since 4.0.0 */ - static @NotNull Audience empty() { + static Audience empty() { return EmptyAudience.INSTANCE; } @@ -106,7 +107,7 @@ public interface Audience extends Pointered { * @see ForwardingAudience * @since 4.0.0 */ - static @NotNull Audience audience(final @NotNull Audience@NotNull... audiences) { + static Audience audience(final Audience... audiences) { final int length = audiences.length; if (length == 0) { return empty(); @@ -127,7 +128,7 @@ public interface Audience extends Pointered { * @see ForwardingAudience * @since 4.0.0 */ - static @NotNull ForwardingAudience audience(final @NotNull Iterable audiences) { + static ForwardingAudience audience(final Iterable audiences) { return () -> audiences; } @@ -139,7 +140,7 @@ public interface Audience extends Pointered { * @return a collector to create a forwarding audience * @since 4.0.0 */ - static @NotNull Collector toAudience() { + static Collector toAudience() { return Audiences.COLLECTOR; } @@ -156,7 +157,7 @@ public interface Audience extends Pointered { * @return an audience providing a snapshot of all audiences that match the predicate when this method is invoked * @since 4.9.0 */ - default @NotNull Audience filterAudience(final @NotNull Predicate filter) { + default Audience filterAudience(final Predicate filter) { return filter.test(this) ? this : empty(); @@ -175,7 +176,7 @@ public interface Audience extends Pointered { * @param action the action * @since 4.9.0 */ - default void forEachAudience(final @NotNull Consumer action) { + default void forEachAudience(final Consumer action) { action.accept(this); } @@ -190,7 +191,7 @@ default void forEachAudience(final @NotNull Consumer action) { * @since 4.1.0 */ @ForwardingAudienceOverrideNotRequired - default void sendMessage(final @NotNull ComponentLike message) { + default void sendMessage(final ComponentLike message) { this.sendMessage(message.asComponent()); } @@ -204,7 +205,7 @@ default void sendMessage(final @NotNull ComponentLike message) { * @since 4.1.0 */ @SuppressWarnings("deprecation") - default void sendMessage(final @NotNull Component message) { + default void sendMessage(final Component message) { this.sendMessage(message, MessageType.SYSTEM); } @@ -222,7 +223,7 @@ default void sendMessage(final @NotNull Component message) { @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Deprecated @ForwardingAudienceOverrideNotRequired - default void sendMessage(final @NotNull ComponentLike message, final @NotNull MessageType type) { + default void sendMessage(final ComponentLike message, final MessageType type) { this.sendMessage(message.asComponent(), type); } @@ -240,7 +241,7 @@ default void sendMessage(final @NotNull ComponentLike message, final @NotNull Me @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Deprecated @ForwardingAudienceOverrideNotRequired - default void sendMessage(final @NotNull Component message, final @NotNull MessageType type) { + default void sendMessage(final Component message, final MessageType type) { this.sendMessage(Identity.nil(), message, type); } /* End: system messages */ @@ -257,7 +258,7 @@ default void sendMessage(final @NotNull Component message, final @NotNull Messag */ @Deprecated @ForwardingAudienceOverrideNotRequired - default void sendMessage(final @NotNull Identified source, final @NotNull ComponentLike message) { + default void sendMessage(final Identified source, final ComponentLike message) { this.sendMessage(source, message.asComponent()); } @@ -272,7 +273,7 @@ default void sendMessage(final @NotNull Identified source, final @NotNull Compon */ @Deprecated @ForwardingAudienceOverrideNotRequired - default void sendMessage(final @NotNull Identity source, final @NotNull ComponentLike message) { + default void sendMessage(final Identity source, final ComponentLike message) { this.sendMessage(source, message.asComponent()); } @@ -287,7 +288,7 @@ default void sendMessage(final @NotNull Identity source, final @NotNull Componen */ @Deprecated @ForwardingAudienceOverrideNotRequired - default void sendMessage(final @NotNull Identified source, final @NotNull Component message) { + default void sendMessage(final Identified source, final Component message) { this.sendMessage(source, message, MessageType.CHAT); } @@ -302,7 +303,7 @@ default void sendMessage(final @NotNull Identified source, final @NotNull Compon */ @Deprecated @ForwardingAudienceOverrideNotRequired - default void sendMessage(final @NotNull Identity source, final @NotNull Component message) { + default void sendMessage(final Identity source, final Component message) { this.sendMessage(source, message, MessageType.CHAT); } @@ -319,7 +320,7 @@ default void sendMessage(final @NotNull Identity source, final @NotNull Componen @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Deprecated @ForwardingAudienceOverrideNotRequired - default void sendMessage(final @NotNull Identified source, final @NotNull ComponentLike message, final @NotNull MessageType type) { + default void sendMessage(final Identified source, final ComponentLike message, final MessageType type) { this.sendMessage(source, message.asComponent(), type); } @@ -336,7 +337,7 @@ default void sendMessage(final @NotNull Identified source, final @NotNull Compon @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Deprecated @ForwardingAudienceOverrideNotRequired - default void sendMessage(final @NotNull Identity source, final @NotNull ComponentLike message, final @NotNull MessageType type) { + default void sendMessage(final Identity source, final ComponentLike message, final MessageType type) { this.sendMessage(source, message.asComponent(), type); } @@ -352,7 +353,7 @@ default void sendMessage(final @NotNull Identity source, final @NotNull Componen */ @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Deprecated - default void sendMessage(final @NotNull Identified source, final @NotNull Component message, final @NotNull MessageType type) { + default void sendMessage(final Identified source, final Component message, final MessageType type) { this.sendMessage(source.identity(), message, type); } @@ -368,7 +369,7 @@ default void sendMessage(final @NotNull Identified source, final @NotNull Compon */ @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Deprecated - default void sendMessage(final @NotNull Identity source, final @NotNull Component message, final @NotNull MessageType type) { + default void sendMessage(final Identity source, final Component message, final MessageType type) { // implementation required } /* End: unsigned player messages */ @@ -383,7 +384,7 @@ default void sendMessage(final @NotNull Identity source, final @NotNull Componen * @sinceMinecraft 1.19 */ @SuppressWarnings("deprecation") - default void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) { + default void sendMessage(final Component message, final ChatType.Bound boundChatType) { this.sendMessage(message, MessageType.CHAT); } @@ -396,7 +397,7 @@ default void sendMessage(final @NotNull Component message, final ChatType.@NotNu * @sinceMinecraft 1.19 */ @ForwardingAudienceOverrideNotRequired - default void sendMessage(final @NotNull ComponentLike message, final ChatType.@NotNull Bound boundChatType) { + default void sendMessage(final ComponentLike message, final ChatType.Bound boundChatType) { this.sendMessage(message.asComponent(), boundChatType); } /* End: disguised player messages @@ -411,7 +412,7 @@ default void sendMessage(final @NotNull ComponentLike message, final ChatType.@N * @sinceMinecraft 1.19 */ @SuppressWarnings("deprecation") - default void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) { + default void sendMessage(final SignedMessage signedMessage, final ChatType.Bound boundChatType) { final Component content = signedMessage.unsignedContent() != null ? signedMessage.unsignedContent() : Component.text(signedMessage.message()); if (signedMessage.isSystem()) { this.sendMessage(content); @@ -429,7 +430,7 @@ default void sendMessage(final @NotNull SignedMessage signedMessage, final ChatT * @sinceMinecraft 1.19 */ @ForwardingAudienceOverrideNotRequired - default void deleteMessage(final @NotNull SignedMessage signedMessage) { + default void deleteMessage(final SignedMessage signedMessage) { if (signedMessage.canDelete()) { this.deleteMessage(Objects.requireNonNull(signedMessage.signature())); } @@ -442,7 +443,7 @@ default void deleteMessage(final @NotNull SignedMessage signedMessage) { * @since 4.12.0 * @sinceMinecraft 1.19 */ - default void deleteMessage(final SignedMessage.@NotNull Signature signature) { + default void deleteMessage(final SignedMessage.Signature signature) { } /* End: signed player messages */ @@ -454,7 +455,7 @@ default void deleteMessage(final SignedMessage.@NotNull Signature signature) { * @since 4.0.0 */ @ForwardingAudienceOverrideNotRequired - default void sendActionBar(final @NotNull ComponentLike message) { + default void sendActionBar(final ComponentLike message) { this.sendActionBar(message.asComponent()); } @@ -465,7 +466,7 @@ default void sendActionBar(final @NotNull ComponentLike message) { * @see Component * @since 4.0.0 */ - default void sendActionBar(final @NotNull Component message) { + default void sendActionBar(final Component message) { } /** @@ -478,7 +479,7 @@ default void sendActionBar(final @NotNull Component message) { * @since 4.3.0 */ @ForwardingAudienceOverrideNotRequired - default void sendPlayerListHeader(final @NotNull ComponentLike header) { + default void sendPlayerListHeader(final ComponentLike header) { this.sendPlayerListHeader(header.asComponent()); } @@ -491,7 +492,7 @@ default void sendPlayerListHeader(final @NotNull ComponentLike header) { * @param header the header * @since 4.3.0 */ - default void sendPlayerListHeader(final @NotNull Component header) { + default void sendPlayerListHeader(final Component header) { this.sendPlayerListHeaderAndFooter(header, Component.empty()); } @@ -505,7 +506,7 @@ default void sendPlayerListHeader(final @NotNull Component header) { * @since 4.3.0 */ @ForwardingAudienceOverrideNotRequired - default void sendPlayerListFooter(final @NotNull ComponentLike footer) { + default void sendPlayerListFooter(final ComponentLike footer) { this.sendPlayerListFooter(footer.asComponent()); } @@ -518,7 +519,7 @@ default void sendPlayerListFooter(final @NotNull ComponentLike footer) { * @param footer the footer * @since 4.3.0 */ - default void sendPlayerListFooter(final @NotNull Component footer) { + default void sendPlayerListFooter(final Component footer) { this.sendPlayerListHeaderAndFooter(Component.empty(), footer); } @@ -530,7 +531,7 @@ default void sendPlayerListFooter(final @NotNull Component footer) { * @since 4.3.0 */ @ForwardingAudienceOverrideNotRequired - default void sendPlayerListHeaderAndFooter(final @NotNull ComponentLike header, final @NotNull ComponentLike footer) { + default void sendPlayerListHeaderAndFooter(final ComponentLike header, final ComponentLike footer) { this.sendPlayerListHeaderAndFooter(header.asComponent(), footer.asComponent()); } @@ -541,7 +542,7 @@ default void sendPlayerListHeaderAndFooter(final @NotNull ComponentLike header, * @param footer the footer * @since 4.3.0 */ - default void sendPlayerListHeaderAndFooter(final @NotNull Component header, final @NotNull Component footer) { + default void sendPlayerListHeaderAndFooter(final Component header, final Component footer) { } /** @@ -552,7 +553,7 @@ default void sendPlayerListHeaderAndFooter(final @NotNull Component header, fina * @since 4.0.0 */ @ForwardingAudienceOverrideNotRequired - default void showTitle(final @NotNull Title title) { + default void showTitle(final Title title) { final Title.Times times = title.times(); if (times != null) this.sendTitlePart(TitlePart.TIMES, times); @@ -569,7 +570,7 @@ default void showTitle(final @NotNull Title title) { * @throws IllegalArgumentException if a title part that is not in {@link TitlePart} is used * @since 4.9.0 */ - default void sendTitlePart(final @NotNull TitlePart part, final @NotNull T value) { + default void sendTitlePart(final TitlePart part, final T value) { } /** @@ -597,7 +598,7 @@ default void resetTitle() { * @see BossBar * @since 4.0.0 */ - default void showBossBar(final @NotNull BossBar bar) { + default void showBossBar(final BossBar bar) { } /** @@ -607,7 +608,7 @@ default void showBossBar(final @NotNull BossBar bar) { * @see BossBar * @since 4.0.0 */ - default void hideBossBar(final @NotNull BossBar bar) { + default void hideBossBar(final BossBar bar) { } /** @@ -619,7 +620,7 @@ default void hideBossBar(final @NotNull BossBar bar) { * @see Sound * @since 4.0.0 */ - default void playSound(final @NotNull Sound sound) { + default void playSound(final Sound sound) { } /** @@ -632,7 +633,7 @@ default void playSound(final @NotNull Sound sound) { * @see Sound * @since 4.0.0 */ - default void playSound(final @NotNull Sound sound, final double x, final double y, final double z) { + default void playSound(final Sound sound, final double x, final double y, final double z) { } /** @@ -651,7 +652,7 @@ default void playSound(final @NotNull Sound sound, final double x, final double * @param emitter an emitter * @since 4.8.0 */ - default void playSound(final @NotNull Sound sound, final Sound.@NotNull Emitter emitter) { + default void playSound(final Sound sound, final Sound.Emitter emitter) { } /** @@ -661,7 +662,7 @@ default void playSound(final @NotNull Sound sound, final Sound.@NotNull Emitter * @since 4.8.0 */ @ForwardingAudienceOverrideNotRequired - default void stopSound(final @NotNull Sound sound) { + default void stopSound(final Sound sound) { this.stopSound(Objects.requireNonNull(sound, "sound").asStop()); } @@ -672,7 +673,7 @@ default void stopSound(final @NotNull Sound sound) { * @see SoundStop * @since 4.0.0 */ - default void stopSound(final @NotNull SoundStop stop) { + default void stopSound(final SoundStop stop) { } /** @@ -685,7 +686,7 @@ default void stopSound(final @NotNull SoundStop stop) { * @since 4.0.0 */ @ForwardingAudienceOverrideNotRequired - default void openBook(final Book.@NotNull Builder book) { + default void openBook(final Book.Builder book) { this.openBook(book.build()); } @@ -698,6 +699,6 @@ default void openBook(final Book.@NotNull Builder book) { * @see Book * @since 4.0.0 */ - default void openBook(final @NotNull Book book) { + default void openBook(final Book book) { } } diff --git a/api/src/main/java/net/kyori/adventure/audience/Audiences.java b/api/src/main/java/net/kyori/adventure/audience/Audiences.java index ae560eef85..289a53c837 100644 --- a/api/src/main/java/net/kyori/adventure/audience/Audiences.java +++ b/api/src/main/java/net/kyori/adventure/audience/Audiences.java @@ -29,13 +29,14 @@ import java.util.stream.Collector; import java.util.stream.Collectors; import net.kyori.adventure.text.ComponentLike; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * {@link Audience}-related utilities. * * @since 4.13.0 */ +@NullMarked public final class Audiences { static final Collector COLLECTOR = Collectors.collectingAndThen( Collectors.toCollection(ArrayList::new), @@ -52,7 +53,7 @@ private Audiences() { * @return an action to send a message * @since 4.13.0 */ - public static @NotNull Consumer sendingMessage(final @NotNull ComponentLike message) { + public static Consumer sendingMessage(final ComponentLike message) { return audience -> audience.sendMessage(message); } } diff --git a/api/src/main/java/net/kyori/adventure/audience/EmptyAudience.java b/api/src/main/java/net/kyori/adventure/audience/EmptyAudience.java index 0c95a1c9fa..aa0d1fdf6f 100644 --- a/api/src/main/java/net/kyori/adventure/audience/EmptyAudience.java +++ b/api/src/main/java/net/kyori/adventure/audience/EmptyAudience.java @@ -36,86 +36,86 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.UnknownNullability; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class EmptyAudience implements Audience { static final EmptyAudience INSTANCE = new EmptyAudience(); @Override - public @NotNull Optional get(final @NotNull Pointer pointer) { + public Optional get(final Pointer pointer) { return Optional.empty(); } @Contract("_, null -> null; _, !null -> !null") @Override - public @Nullable T getOrDefault(final @NotNull Pointer pointer, final @Nullable T defaultValue) { + public @Nullable T getOrDefault(final Pointer pointer, final @Nullable T defaultValue) { return defaultValue; } @Override - public @UnknownNullability T getOrDefaultFrom(final @NotNull Pointer pointer, final @NotNull Supplier defaultValue) { + public @Nullable T getOrDefaultFrom(final Pointer pointer, final Supplier defaultValue) { return defaultValue.get(); } @Override - public @NotNull Audience filterAudience(final @NotNull Predicate filter) { + public Audience filterAudience(final Predicate filter) { return this; } @Override - public void forEachAudience(final @NotNull Consumer action) { + public void forEachAudience(final Consumer action) { } @Override - public void sendMessage(final @NotNull ComponentLike message) { + public void sendMessage(final ComponentLike message) { } @Override - public void sendMessage(final @NotNull Component message) { + public void sendMessage(final Component message) { } @Override @Deprecated - public void sendMessage(final @NotNull Identified source, final @NotNull Component message, final @NotNull MessageType type) { + public void sendMessage(final Identified source, final Component message, final MessageType type) { } @Override @Deprecated - public void sendMessage(final @NotNull Identity source, final @NotNull Component message, final @NotNull MessageType type) { + public void sendMessage(final Identity source, final Component message, final MessageType type) { } @Override - public void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) { + public void sendMessage(final Component message, final ChatType.Bound boundChatType) { } @Override - public void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) { + public void sendMessage(final SignedMessage signedMessage, final ChatType.Bound boundChatType) { } @Override - public void deleteMessage(final SignedMessage.@NotNull Signature signature) { + public void deleteMessage(final SignedMessage.Signature signature) { } @Override - public void sendActionBar(final @NotNull ComponentLike message) { + public void sendActionBar(final ComponentLike message) { } @Override - public void sendPlayerListHeader(final @NotNull ComponentLike header) { + public void sendPlayerListHeader(final ComponentLike header) { } @Override - public void sendPlayerListFooter(final @NotNull ComponentLike footer) { + public void sendPlayerListFooter(final ComponentLike footer) { } @Override - public void sendPlayerListHeaderAndFooter(final @NotNull ComponentLike header, final @NotNull ComponentLike footer) { + public void sendPlayerListHeaderAndFooter(final ComponentLike header, final ComponentLike footer) { } @Override - public void openBook(final Book.@NotNull Builder book) { + public void openBook(final Book.Builder book) { } @Override diff --git a/api/src/main/java/net/kyori/adventure/audience/ForwardingAudience.java b/api/src/main/java/net/kyori/adventure/audience/ForwardingAudience.java index 8ba6135193..c02fe81768 100644 --- a/api/src/main/java/net/kyori/adventure/audience/ForwardingAudience.java +++ b/api/src/main/java/net/kyori/adventure/audience/ForwardingAudience.java @@ -44,9 +44,8 @@ import net.kyori.adventure.title.TitlePart; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.UnknownNullability; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A receiver that wraps one or more receivers. @@ -58,6 +57,7 @@ * @since 4.0.0 */ @FunctionalInterface +@NullMarked public interface ForwardingAudience extends Audience { /** * Gets the audiences. @@ -66,15 +66,15 @@ public interface ForwardingAudience extends Audience { * @since 4.0.0 */ @ApiStatus.OverrideOnly - @NotNull Iterable audiences(); + Iterable audiences(); @Override - default @NotNull Pointers pointers() { + default Pointers pointers() { return Pointers.empty(); // unsupported } @Override - default @NotNull Audience filterAudience(final @NotNull Predicate filter) { + default Audience filterAudience(final Predicate filter) { @Nullable List audiences = null; for (final Audience audience : this.audiences()) { if (filter.test(audience)) { @@ -93,64 +93,64 @@ public interface ForwardingAudience extends Audience { } @Override - default void forEachAudience(final @NotNull Consumer action) { + default void forEachAudience(final Consumer action) { for (final Audience audience : this.audiences()) audience.forEachAudience(action); } @Override - default void sendMessage(final @NotNull Component message) { + default void sendMessage(final Component message) { for (final Audience audience : this.audiences()) audience.sendMessage(message); } @Override - default void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) { + default void sendMessage(final Component message, final ChatType.Bound boundChatType) { for (final Audience audience : this.audiences()) audience.sendMessage(message, boundChatType); } @Override - default void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) { + default void sendMessage(final SignedMessage signedMessage, final ChatType.Bound boundChatType) { for (final Audience audience : this.audiences()) audience.sendMessage(signedMessage, boundChatType); } @Override - default void deleteMessage(final SignedMessage.@NotNull Signature signature) { + default void deleteMessage(final SignedMessage.Signature signature) { for (final Audience audience : this.audiences()) audience.deleteMessage(signature); } @Override @Deprecated - default void sendMessage(final @NotNull Identified source, final @NotNull Component message, final @NotNull MessageType type) { + default void sendMessage(final Identified source, final Component message, final MessageType type) { for (final Audience audience : this.audiences()) audience.sendMessage(source, message, type); } @Override @Deprecated - default void sendMessage(final @NotNull Identity source, final @NotNull Component message, final @NotNull MessageType type) { + default void sendMessage(final Identity source, final Component message, final MessageType type) { for (final Audience audience : this.audiences()) audience.sendMessage(source, message, type); } @Override - default void sendActionBar(final @NotNull Component message) { + default void sendActionBar(final Component message) { for (final Audience audience : this.audiences()) audience.sendActionBar(message); } @Override - default void sendPlayerListHeader(final @NotNull Component header) { + default void sendPlayerListHeader(final Component header) { for (final Audience audience : this.audiences()) audience.sendPlayerListHeader(header); } @Override - default void sendPlayerListFooter(final @NotNull Component footer) { + default void sendPlayerListFooter(final Component footer) { for (final Audience audience : this.audiences()) audience.sendPlayerListFooter(footer); } @Override - default void sendPlayerListHeaderAndFooter(final @NotNull Component header, final @NotNull Component footer) { + default void sendPlayerListHeaderAndFooter(final Component header, final Component footer) { for (final Audience audience : this.audiences()) audience.sendPlayerListHeaderAndFooter(header, footer); } @Override - default void sendTitlePart(final @NotNull TitlePart part, final @NotNull T value) { + default void sendTitlePart(final TitlePart part, final T value) { for (final Audience audience : this.audiences()) audience.sendTitlePart(part, value); } @@ -165,37 +165,37 @@ default void resetTitle() { } @Override - default void showBossBar(final @NotNull BossBar bar) { + default void showBossBar(final BossBar bar) { for (final Audience audience : this.audiences()) audience.showBossBar(bar); } @Override - default void hideBossBar(final @NotNull BossBar bar) { + default void hideBossBar(final BossBar bar) { for (final Audience audience : this.audiences()) audience.hideBossBar(bar); } @Override - default void playSound(final @NotNull Sound sound) { + default void playSound(final Sound sound) { for (final Audience audience : this.audiences()) audience.playSound(sound); } @Override - default void playSound(final @NotNull Sound sound, final double x, final double y, final double z) { + default void playSound(final Sound sound, final double x, final double y, final double z) { for (final Audience audience : this.audiences()) audience.playSound(sound, x, y, z); } @Override - default void playSound(final @NotNull Sound sound, final Sound.@NotNull Emitter emitter) { + default void playSound(final Sound sound, final Sound.Emitter emitter) { for (final Audience audience : this.audiences()) audience.playSound(sound, emitter); } @Override - default void stopSound(final @NotNull SoundStop stop) { + default void stopSound(final SoundStop stop) { for (final Audience audience : this.audiences()) audience.stopSound(stop); } @Override - default void openBook(final @NotNull Book book) { + default void openBook(final Book book) { for (final Audience audience : this.audiences()) audience.openBook(book); } @@ -212,7 +212,7 @@ interface Single extends ForwardingAudience { * @since 4.0.0 */ @ApiStatus.OverrideOnly - @NotNull Audience audience(); + Audience audience(); /** * {@inheritDoc} @@ -222,28 +222,28 @@ interface Single extends ForwardingAudience { */ @Deprecated(/* forRemoval = false */) @Override - default @NotNull Iterable audiences() { + default Iterable audiences() { return Collections.singleton(this.audience()); } @Override - default @NotNull Optional get(final @NotNull Pointer pointer) { + default Optional get(final Pointer pointer) { return this.audience().get(pointer); } @Contract("_, null -> null; _, !null -> !null") @Override - default @Nullable T getOrDefault(final @NotNull Pointer pointer, final @Nullable T defaultValue) { + default @Nullable T getOrDefault(final Pointer pointer, final @Nullable T defaultValue) { return this.audience().getOrDefault(pointer, defaultValue); } @Override - default @UnknownNullability T getOrDefaultFrom(final @NotNull Pointer pointer, final @NotNull Supplier defaultValue) { + default @Nullable T getOrDefaultFrom(final Pointer pointer, final Supplier defaultValue) { return this.audience().getOrDefaultFrom(pointer, defaultValue); } @Override - default @NotNull Audience filterAudience(final @NotNull Predicate filter) { + default Audience filterAudience(final Predicate filter) { final Audience audience = this.audience(); return filter.test(audience) ? this @@ -251,69 +251,69 @@ interface Single extends ForwardingAudience { } @Override - default void forEachAudience(final @NotNull Consumer action) { + default void forEachAudience(final Consumer action) { this.audience().forEachAudience(action); } @Override - default @NotNull Pointers pointers() { + default Pointers pointers() { return this.audience().pointers(); } @Override - default void sendMessage(final @NotNull Component message) { + default void sendMessage(final Component message) { this.audience().sendMessage(message); } @Override - default void sendMessage(final @NotNull Component message, final ChatType.@NotNull Bound boundChatType) { + default void sendMessage(final Component message, final ChatType.Bound boundChatType) { this.audience().sendMessage(message, boundChatType); } @Override - default void sendMessage(final @NotNull SignedMessage signedMessage, final ChatType.@NotNull Bound boundChatType) { + default void sendMessage(final SignedMessage signedMessage, final ChatType.Bound boundChatType) { this.audience().sendMessage(signedMessage, boundChatType); } @Override - default void deleteMessage(final SignedMessage.@NotNull Signature signature) { + default void deleteMessage(final SignedMessage.Signature signature) { this.audience().deleteMessage(signature); } @Override @Deprecated - default void sendMessage(final @NotNull Identified source, final @NotNull Component message, final @NotNull MessageType type) { + default void sendMessage(final Identified source, final Component message, final MessageType type) { this.audience().sendMessage(source, message, type); } @Override @Deprecated - default void sendMessage(final @NotNull Identity source, final @NotNull Component message, final @NotNull MessageType type) { + default void sendMessage(final Identity source, final Component message, final MessageType type) { this.audience().sendMessage(source, message, type); } @Override - default void sendActionBar(final @NotNull Component message) { + default void sendActionBar(final Component message) { this.audience().sendActionBar(message); } @Override - default void sendPlayerListHeader(final @NotNull Component header) { + default void sendPlayerListHeader(final Component header) { this.audience().sendPlayerListHeader(header); } @Override - default void sendPlayerListFooter(final @NotNull Component footer) { + default void sendPlayerListFooter(final Component footer) { this.audience().sendPlayerListFooter(footer); } @Override - default void sendPlayerListHeaderAndFooter(final @NotNull Component header, final @NotNull Component footer) { + default void sendPlayerListHeaderAndFooter(final Component header, final Component footer) { this.audience().sendPlayerListHeaderAndFooter(header, footer); } @Override - default void sendTitlePart(final @NotNull TitlePart part, final @NotNull T value) { + default void sendTitlePart(final TitlePart part, final T value) { this.audience().sendTitlePart(part, value); } @@ -328,37 +328,37 @@ default void resetTitle() { } @Override - default void showBossBar(final @NotNull BossBar bar) { + default void showBossBar(final BossBar bar) { this.audience().showBossBar(bar); } @Override - default void hideBossBar(final @NotNull BossBar bar) { + default void hideBossBar(final BossBar bar) { this.audience().hideBossBar(bar); } @Override - default void playSound(final @NotNull Sound sound) { + default void playSound(final Sound sound) { this.audience().playSound(sound); } @Override - default void playSound(final @NotNull Sound sound, final double x, final double y, final double z) { + default void playSound(final Sound sound, final double x, final double y, final double z) { this.audience().playSound(sound, x, y, z); } @Override - default void playSound(final @NotNull Sound sound, final Sound.@NotNull Emitter emitter) { + default void playSound(final Sound sound, final Sound.Emitter emitter) { this.audience().playSound(sound, emitter); } @Override - default void stopSound(final @NotNull SoundStop stop) { + default void stopSound(final SoundStop stop) { this.audience().stopSound(stop); } @Override - default void openBook(final @NotNull Book book) { + default void openBook(final Book book) { this.audience().openBook(book); } } diff --git a/api/src/main/java/net/kyori/adventure/bossbar/BossBar.java b/api/src/main/java/net/kyori/adventure/bossbar/BossBar.java index 506c71bf69..cb204d22a0 100644 --- a/api/src/main/java/net/kyori/adventure/bossbar/BossBar.java +++ b/api/src/main/java/net/kyori/adventure/bossbar/BossBar.java @@ -31,8 +31,8 @@ import net.kyori.examination.Examinable; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.UnmodifiableView; +import org.jspecify.annotations.NullMarked; /** * Represents an in-game bossbar which can be shown to the client. @@ -53,6 +53,7 @@ * @since 4.0.0 */ @ApiStatus.NonExtendable +@NullMarked public interface BossBar extends Examinable { /** * The minimum value the progress can be. @@ -96,7 +97,7 @@ public interface BossBar extends Examinable { * @throws IllegalArgumentException if progress is less than 0 or greater than 1 * @since 4.3.0 */ - static @NotNull BossBar bossBar(final @NotNull ComponentLike name, final float progress, final @NotNull Color color, final @NotNull Overlay overlay) { + static BossBar bossBar(final ComponentLike name, final float progress, final Color color, final Overlay overlay) { BossBarImpl.checkProgress(progress); return bossBar(name.asComponent(), progress, color, overlay); } @@ -112,7 +113,7 @@ public interface BossBar extends Examinable { * @throws IllegalArgumentException if progress is less than 0 or greater than 1 * @since 4.0.0 */ - static @NotNull BossBar bossBar(final @NotNull Component name, final float progress, final @NotNull Color color, final @NotNull Overlay overlay) { + static BossBar bossBar(final Component name, final float progress, final Color color, final Overlay overlay) { BossBarImpl.checkProgress(progress); return new BossBarImpl(name, progress, color, overlay); } @@ -129,7 +130,7 @@ public interface BossBar extends Examinable { * @throws IllegalArgumentException if progress is less than 0 or greater than 1 * @since 4.3.0 */ - static @NotNull BossBar bossBar(final @NotNull ComponentLike name, final float progress, final @NotNull Color color, final @NotNull Overlay overlay, final @NotNull Set flags) { + static BossBar bossBar(final ComponentLike name, final float progress, final Color color, final Overlay overlay, final Set flags) { BossBarImpl.checkProgress(progress); return bossBar(name.asComponent(), progress, color, overlay, flags); } @@ -146,7 +147,7 @@ public interface BossBar extends Examinable { * @throws IllegalArgumentException if progress is less than 0 or greater than 1 * @since 4.0.0 */ - static @NotNull BossBar bossBar(final @NotNull Component name, final float progress, final @NotNull Color color, final @NotNull Overlay overlay, final @NotNull Set flags) { + static BossBar bossBar(final Component name, final float progress, final Color color, final Overlay overlay, final Set flags) { BossBarImpl.checkProgress(progress); return new BossBarImpl(name, progress, color, overlay, flags); } @@ -157,7 +158,7 @@ public interface BossBar extends Examinable { * @return the name * @since 4.0.0 */ - @NotNull Component name(); + Component name(); /** * Sets the name. @@ -167,7 +168,7 @@ public interface BossBar extends Examinable { * @since 4.3.0 */ @Contract("_ -> this") - default @NotNull BossBar name(final @NotNull ComponentLike name) { + default BossBar name(final ComponentLike name) { return this.name(name.asComponent()); } @@ -179,7 +180,7 @@ public interface BossBar extends Examinable { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar name(final @NotNull Component name); + BossBar name(final Component name); /** * Gets the progress. @@ -202,7 +203,7 @@ public interface BossBar extends Examinable { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar progress(final float progress); + BossBar progress(final float progress); /** * Gets the progress. @@ -233,7 +234,7 @@ default float percent() { @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Contract("_ -> this") @Deprecated - default @NotNull BossBar percent(final float progress) { + default BossBar percent(final float progress) { return this.progress(progress); } @@ -243,7 +244,7 @@ default float percent() { * @return the color * @since 4.0.0 */ - @NotNull Color color(); + Color color(); /** * Sets the color. @@ -253,7 +254,7 @@ default float percent() { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar color(final @NotNull Color color); + BossBar color(final Color color); /** * Gets the overlay. @@ -261,7 +262,7 @@ default float percent() { * @return the overlay * @since 4.0.0 */ - @NotNull Overlay overlay(); + Overlay overlay(); /** * Sets the overlay. @@ -271,7 +272,7 @@ default float percent() { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar overlay(final @NotNull Overlay overlay); + BossBar overlay(final Overlay overlay); /** * Gets the flags. @@ -279,7 +280,7 @@ default float percent() { * @return the flags * @since 4.0.0 */ - @UnmodifiableView @NotNull Set flags(); + @UnmodifiableView Set flags(); /** * Sets the flags. @@ -289,7 +290,7 @@ default float percent() { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar flags(final @NotNull Set flags); + BossBar flags(final Set flags); /** * Checks if this bossbar has a flag. @@ -298,7 +299,7 @@ default float percent() { * @return {@code true} if this bossbar has the flag, {@code false} otherwise * @since 4.0.0 */ - boolean hasFlag(final @NotNull Flag flag); + boolean hasFlag(final Flag flag); /** * Adds a flag to this bossbar. @@ -308,7 +309,7 @@ default float percent() { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar addFlag(final @NotNull Flag flag); + BossBar addFlag(final Flag flag); /** * Removes a flag from this bossbar. @@ -318,7 +319,7 @@ default float percent() { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar removeFlag(final @NotNull Flag flag); + BossBar removeFlag(final Flag flag); /** * Adds flags to this bossbar. @@ -328,7 +329,7 @@ default float percent() { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar addFlags(final @NotNull Flag@NotNull... flags); + BossBar addFlags(final Flag... flags); /** * Removes flags from this bossbar. @@ -338,7 +339,7 @@ default float percent() { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar removeFlags(final @NotNull Flag@NotNull... flags); + BossBar removeFlags(final Flag... flags); /** * Adds flags to this bossbar. @@ -348,7 +349,7 @@ default float percent() { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar addFlags(final @NotNull Iterable flags); + BossBar addFlags(final Iterable flags); /** * Removes flags from this bossbar. @@ -358,7 +359,7 @@ default float percent() { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar removeFlags(final @NotNull Iterable flags); + BossBar removeFlags(final Iterable flags); /** * Adds a listener. @@ -368,7 +369,7 @@ default float percent() { * @since 4.0.0 */ @Contract(value = "_ -> this") - @NotNull BossBar addListener(final @NotNull Listener listener); + BossBar addListener(final Listener listener); /** * Removes a listener. @@ -378,7 +379,7 @@ default float percent() { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull BossBar removeListener(final @NotNull Listener listener); + BossBar removeListener(final Listener listener); /** * Gets an unmodifiable view of the viewers of this bossbar. @@ -389,7 +390,7 @@ default float percent() { * @since 4.14.0 */ @UnmodifiableView - @NotNull Iterable viewers(); + Iterable viewers(); /** * Show this bossbar to {@code viewer}. @@ -399,7 +400,7 @@ default float percent() { * @see Audience#showBossBar(BossBar) * @since 4.14.0 */ - default @NotNull BossBar addViewer(final @NotNull Audience viewer) { + default BossBar addViewer(final Audience viewer) { viewer.showBossBar(this); return this; } @@ -412,7 +413,7 @@ default float percent() { * @see Audience#hideBossBar(BossBar) * @since 4.14.0 */ - default @NotNull BossBar removeViewer(final @NotNull Audience viewer) { + default BossBar removeViewer(final Audience viewer) { viewer.hideBossBar(this); return this; } @@ -432,7 +433,7 @@ interface Listener { * @param newName the new name * @since 4.0.0 */ - default void bossBarNameChanged(final @NotNull BossBar bar, final @NotNull Component oldName, final @NotNull Component newName) { + default void bossBarNameChanged(final BossBar bar, final Component oldName, final Component newName) { } /** @@ -443,7 +444,7 @@ default void bossBarNameChanged(final @NotNull BossBar bar, final @NotNull Compo * @param newProgress the new progress * @since 4.0.0 */ - default void bossBarProgressChanged(final @NotNull BossBar bar, final float oldProgress, final float newProgress) { + default void bossBarProgressChanged(final BossBar bar, final float oldProgress, final float newProgress) { this.bossBarPercentChanged(bar, oldProgress, newProgress); } @@ -459,7 +460,7 @@ default void bossBarProgressChanged(final @NotNull BossBar bar, final float oldP @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Deprecated @SuppressWarnings("DeprecatedIsStillUsed") - default void bossBarPercentChanged(final @NotNull BossBar bar, final float oldProgress, final float newProgress) { + default void bossBarPercentChanged(final BossBar bar, final float oldProgress, final float newProgress) { } /** @@ -470,7 +471,7 @@ default void bossBarPercentChanged(final @NotNull BossBar bar, final float oldPr * @param newColor the new color * @since 4.0.0 */ - default void bossBarColorChanged(final @NotNull BossBar bar, final @NotNull Color oldColor, final @NotNull Color newColor) { + default void bossBarColorChanged(final BossBar bar, final Color oldColor, final Color newColor) { } /** @@ -481,7 +482,7 @@ default void bossBarColorChanged(final @NotNull BossBar bar, final @NotNull Colo * @param newOverlay the new overlay * @since 4.0.0 */ - default void bossBarOverlayChanged(final @NotNull BossBar bar, final @NotNull Overlay oldOverlay, final @NotNull Overlay newOverlay) { + default void bossBarOverlayChanged(final BossBar bar, final Overlay oldOverlay, final Overlay newOverlay) { } /** @@ -492,7 +493,7 @@ default void bossBarOverlayChanged(final @NotNull BossBar bar, final @NotNull Ov * @param flagsRemoved the flags removed from the bossbar * @since 4.0.0 */ - default void bossBarFlagsChanged(final @NotNull BossBar bar, final @NotNull Set flagsAdded, final @NotNull Set flagsRemoved) { + default void bossBarFlagsChanged(final BossBar bar, final Set flagsAdded, final Set flagsRemoved) { } } diff --git a/api/src/main/java/net/kyori/adventure/bossbar/BossBarImpl.java b/api/src/main/java/net/kyori/adventure/bossbar/BossBarImpl.java index f460d4c576..649e685cd7 100644 --- a/api/src/main/java/net/kyori/adventure/bossbar/BossBarImpl.java +++ b/api/src/main/java/net/kyori/adventure/bossbar/BossBarImpl.java @@ -39,12 +39,13 @@ import net.kyori.adventure.util.Services; import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; @SuppressWarnings("deprecation") +@NullMarked final class BossBarImpl extends HackyBossBarPlatformBridge implements BossBar { private final List listeners = new CopyOnWriteArrayList<>(); private Component name; @@ -63,7 +64,7 @@ private ImplementationAccessor() { } @SuppressWarnings("OptionalGetWithoutIsPresent") - static @NotNull I get(final @NotNull BossBar bar, final @NotNull Class type) { + static I get(final BossBar bar, final Class type) { @Nullable BossBarImplementation implementation = ((BossBarImpl) bar).implementation; if (implementation == null) { implementation = SERVICE.get().create(bar); @@ -73,25 +74,25 @@ private ImplementationAccessor() { } } - BossBarImpl(final @NotNull Component name, final float progress, final @NotNull Color color, final @NotNull Overlay overlay) { + BossBarImpl(final Component name, final float progress, final Color color, final Overlay overlay) { this.name = requireNonNull(name, "name"); this.progress = progress; this.color = requireNonNull(color, "color"); this.overlay = requireNonNull(overlay, "overlay"); } - BossBarImpl(final @NotNull Component name, final float progress, final @NotNull Color color, final @NotNull Overlay overlay, final @NotNull Set flags) { + BossBarImpl(final Component name, final float progress, final Color color, final Overlay overlay, final Set flags) { this(name, progress, color, overlay); this.flags.addAll(flags); } @Override - public @NotNull Component name() { + public Component name() { return this.name; } @Override - public @NotNull BossBar name(final @NotNull Component newName) { + public BossBar name(final Component newName) { requireNonNull(newName, "name"); final Component oldName = this.name; if (!Objects.equals(newName, oldName)) { @@ -107,7 +108,7 @@ public float progress() { } @Override - public @NotNull BossBar progress(final float newProgress) { + public BossBar progress(final float newProgress) { checkProgress(newProgress); final float oldProgress = this.progress; if (newProgress != oldProgress) { @@ -124,12 +125,12 @@ static void checkProgress(final float progress) { } @Override - public @NotNull Color color() { + public Color color() { return this.color; } @Override - public @NotNull BossBar color(final @NotNull Color newColor) { + public BossBar color(final Color newColor) { requireNonNull(newColor, "color"); final Color oldColor = this.color; if (newColor != oldColor) { @@ -140,12 +141,12 @@ static void checkProgress(final float progress) { } @Override - public @NotNull Overlay overlay() { + public Overlay overlay() { return this.overlay; } @Override - public @NotNull BossBar overlay(final @NotNull Overlay newOverlay) { + public BossBar overlay(final Overlay newOverlay) { requireNonNull(newOverlay, "overlay"); final Overlay oldOverlay = this.overlay; if (newOverlay != oldOverlay) { @@ -156,12 +157,12 @@ static void checkProgress(final float progress) { } @Override - public @NotNull Set flags() { + public Set flags() { return Collections.unmodifiableSet(this.flags); } @Override - public @NotNull BossBar flags(final @NotNull Set newFlags) { + public BossBar flags(final Set newFlags) { if (newFlags.isEmpty()) { final Set oldFlags = EnumSet.copyOf(this.flags); this.flags.clear(); @@ -180,21 +181,21 @@ static void checkProgress(final float progress) { } @Override - public boolean hasFlag(final @NotNull Flag flag) { + public boolean hasFlag(final Flag flag) { return this.flags.contains(flag); } @Override - public @NotNull BossBar addFlag(final @NotNull Flag flag) { + public BossBar addFlag(final Flag flag) { return this.editFlags(flag, Set::add, BossBarImpl::onFlagsAdded); } @Override - public @NotNull BossBar removeFlag(final @NotNull Flag flag) { + public BossBar removeFlag(final Flag flag) { return this.editFlags(flag, Set::remove, BossBarImpl::onFlagsRemoved); } - private @NotNull BossBar editFlags(final @NotNull Flag flag, final @NotNull BiPredicate, Flag> predicate, final BiConsumer> onChange) { + private BossBar editFlags(final Flag flag, final BiPredicate, Flag> predicate, final BiConsumer> onChange) { if (predicate.test(this.flags, flag)) { onChange.accept(this, Collections.singleton(flag)); } @@ -202,16 +203,16 @@ public boolean hasFlag(final @NotNull Flag flag) { } @Override - public @NotNull BossBar addFlags(final @NotNull Flag@NotNull... flags) { + public BossBar addFlags(final Flag... flags) { return this.editFlags(flags, Set::add, BossBarImpl::onFlagsAdded); } @Override - public @NotNull BossBar removeFlags(final @NotNull Flag@NotNull... flags) { + public BossBar removeFlags(final Flag... flags) { return this.editFlags(flags, Set::remove, BossBarImpl::onFlagsRemoved); } - private @NotNull BossBar editFlags(final Flag[] flags, final BiPredicate, Flag> predicate, final BiConsumer> onChange) { + private BossBar editFlags(final Flag[] flags, final BiPredicate, Flag> predicate, final BiConsumer> onChange) { if (flags.length == 0) return this; Set changes = null; for (int i = 0, length = flags.length; i < length; i++) { @@ -229,16 +230,16 @@ public boolean hasFlag(final @NotNull Flag flag) { } @Override - public @NotNull BossBar addFlags(final @NotNull Iterable flags) { + public BossBar addFlags(final Iterable flags) { return this.editFlags(flags, Set::add, BossBarImpl::onFlagsAdded); } @Override - public @NotNull BossBar removeFlags(final @NotNull Iterable flags) { + public BossBar removeFlags(final Iterable flags) { return this.editFlags(flags, Set::remove, BossBarImpl::onFlagsRemoved); } - private @NotNull BossBar editFlags(final Iterable flags, final BiPredicate, Flag> predicate, final BiConsumer> onChange) { + private BossBar editFlags(final Iterable flags, final BiPredicate, Flag> predicate, final BiConsumer> onChange) { Set changes = null; for (final Flag flag : flags) { if (predicate.test(this.flags, flag)) { @@ -255,26 +256,26 @@ public boolean hasFlag(final @NotNull Flag flag) { } @Override - public @NotNull BossBar addListener(final @NotNull Listener listener) { + public BossBar addListener(final Listener listener) { this.listeners.add(listener); return this; } @Override - public @NotNull BossBar removeListener(final @NotNull Listener listener) { + public BossBar removeListener(final Listener listener) { this.listeners.remove(listener); return this; } @Override - public @NotNull Iterable viewers() { + public Iterable viewers() { if (this.implementation != null) { return this.implementation.viewers(); } return Collections.emptyList(); } - private void forEachListener(final @NotNull Consumer consumer) { + private void forEachListener(final Consumer consumer) { for (final Listener listener : this.listeners) { consumer.accept(listener); } @@ -289,7 +290,7 @@ private static void onFlagsRemoved(final BossBarImpl bar, final Set flagsR } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("name", this.name), ExaminableProperty.of("progress", this.progress), diff --git a/api/src/main/java/net/kyori/adventure/bossbar/BossBarImplementation.java b/api/src/main/java/net/kyori/adventure/bossbar/BossBarImplementation.java index 3a3428ba75..d9113a9f06 100644 --- a/api/src/main/java/net/kyori/adventure/bossbar/BossBarImplementation.java +++ b/api/src/main/java/net/kyori/adventure/bossbar/BossBarImplementation.java @@ -25,7 +25,7 @@ import java.util.Collections; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * {@link BossBar} internal implementation. @@ -33,6 +33,7 @@ * @since 4.12.0 */ @ApiStatus.Internal +@NullMarked public interface BossBarImplementation { /** * Gets an implementation, and casts it to {@code type}. @@ -44,7 +45,7 @@ public interface BossBarImplementation { * @since 4.12.0 */ @ApiStatus.Internal - static @NotNull I get(final @NotNull BossBar bar, final @NotNull Class type) { + static I get(final BossBar bar, final Class type) { return BossBarImpl.ImplementationAccessor.get(bar, type); } @@ -55,7 +56,7 @@ public interface BossBarImplementation { * @since 4.14.0 */ @ApiStatus.Internal - default @NotNull Iterable viewers() { + default Iterable viewers() { return Collections.emptyList(); } @@ -74,6 +75,6 @@ interface Provider { * @since 4.12.0 */ @ApiStatus.Internal - @NotNull BossBarImplementation create(final @NotNull BossBar bar); + BossBarImplementation create(final BossBar bar); } } diff --git a/api/src/main/java/net/kyori/adventure/bossbar/BossBarViewer.java b/api/src/main/java/net/kyori/adventure/bossbar/BossBarViewer.java index ffb5a98d53..0382f22629 100644 --- a/api/src/main/java/net/kyori/adventure/bossbar/BossBarViewer.java +++ b/api/src/main/java/net/kyori/adventure/bossbar/BossBarViewer.java @@ -23,14 +23,15 @@ */ package net.kyori.adventure.bossbar; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.UnmodifiableView; +import org.jspecify.annotations.NullMarked; /** * Something that can view a {@link BossBar}. * * @since 4.14.0 */ +@NullMarked public interface BossBarViewer { /** * Gets an unmodifiable view of all known currently active bossbars. @@ -39,5 +40,5 @@ public interface BossBarViewer { * @since 4.14.0 */ @UnmodifiableView - @NotNull Iterable activeBossBars(); + Iterable activeBossBars(); } diff --git a/api/src/main/java/net/kyori/adventure/builder/AbstractBuilder.java b/api/src/main/java/net/kyori/adventure/builder/AbstractBuilder.java index cecf2e7259..7d4d9fee05 100644 --- a/api/src/main/java/net/kyori/adventure/builder/AbstractBuilder.java +++ b/api/src/main/java/net/kyori/adventure/builder/AbstractBuilder.java @@ -25,8 +25,8 @@ import java.util.function.Consumer; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A builder. @@ -35,6 +35,7 @@ * @since 4.10.0 */ @FunctionalInterface +@NullMarked public interface AbstractBuilder { /** * Configures {@code builder} using {@code consumer} and then builds. @@ -47,7 +48,7 @@ public interface AbstractBuilder { * @since 4.10.0 */ @Contract(mutates = "param1") - static > @NotNull R configureAndBuild(final @NotNull B builder, final @Nullable Consumer consumer) { + static > R configureAndBuild(final B builder, final @Nullable Consumer consumer) { if (consumer != null) { consumer.accept(builder); } @@ -61,5 +62,5 @@ public interface AbstractBuilder { * @since 4.10.0 */ @Contract(value = "-> new", pure = true) - @NotNull R build(); + R build(); } diff --git a/api/src/main/java/net/kyori/adventure/chat/ChatType.java b/api/src/main/java/net/kyori/adventure/chat/ChatType.java index 8d93477373..fe37224ea3 100644 --- a/api/src/main/java/net/kyori/adventure/chat/ChatType.java +++ b/api/src/main/java/net/kyori/adventure/chat/ChatType.java @@ -31,8 +31,8 @@ import net.kyori.examination.Examinable; import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; @@ -42,6 +42,7 @@ * @since 4.12.0 * @sinceMinecraft 1.19 */ +@NullMarked public interface ChatType extends Examinable, Keyed { /** * A chat message from a player. @@ -106,7 +107,7 @@ public interface ChatType extends Examinable, Keyed { * @return the chat type * @since 4.12.0 */ - static @NotNull ChatType chatType(final @NotNull Keyed key) { + static ChatType chatType(final Keyed key) { return key instanceof ChatType ? (ChatType) key : new ChatTypeImpl(requireNonNull(key, "key").key()); } @@ -119,7 +120,7 @@ public interface ChatType extends Examinable, Keyed { * @sinceMinecraft 1.19 */ @Contract(value = "_ -> new", pure = true) - default ChatType.@NotNull Bound bind(final @NotNull ComponentLike name) { + default ChatType.Bound bind(final ComponentLike name) { return this.bind(name, null); } @@ -133,12 +134,12 @@ public interface ChatType extends Examinable, Keyed { * @sinceMinecraft 1.19 */ @Contract(value = "_, _ -> new", pure = true) - default ChatType.@NotNull Bound bind(final @NotNull ComponentLike name, final @Nullable ComponentLike target) { + default ChatType.Bound bind(final ComponentLike name, final @Nullable ComponentLike target) { return new ChatTypeImpl.BoundImpl(this, requireNonNull(name.asComponent(), "name"), ComponentLike.unbox(target)); } @Override - default @NotNull Stream examinableProperties() { + default Stream examinableProperties() { return Stream.of(ExaminableProperty.of("key", this.key())); } @@ -158,7 +159,7 @@ interface Bound extends Examinable { * @sinceMinecraft 1.19 */ @Contract(pure = true) - @NotNull ChatType type(); + ChatType type(); /** * Get the name component. @@ -168,7 +169,7 @@ interface Bound extends Examinable { * @sinceMinecraft 1.19 */ @Contract(pure = true) - @NotNull Component name(); + Component name(); /** * Get the target component. @@ -181,7 +182,7 @@ interface Bound extends Examinable { @Nullable Component target(); @Override - default @NotNull Stream examinableProperties() { + default Stream examinableProperties() { return Stream.of( ExaminableProperty.of("type", this.type()), ExaminableProperty.of("name", this.name()), diff --git a/api/src/main/java/net/kyori/adventure/chat/ChatTypeImpl.java b/api/src/main/java/net/kyori/adventure/chat/ChatTypeImpl.java index bed3c2dde8..9605525b45 100644 --- a/api/src/main/java/net/kyori/adventure/chat/ChatTypeImpl.java +++ b/api/src/main/java/net/kyori/adventure/chat/ChatTypeImpl.java @@ -26,18 +26,19 @@ import net.kyori.adventure.internal.Internals; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class ChatTypeImpl implements ChatType { private final Key key; - ChatTypeImpl(final @NotNull Key key) { + ChatTypeImpl(final Key key) { this.key = key; } @Override - public @NotNull Key key() { + public Key key() { return this.key; } @@ -58,12 +59,12 @@ static final class BoundImpl implements ChatType.Bound { } @Override - public @NotNull ChatType type() { + public ChatType type() { return this.chatType; } @Override - public @NotNull Component name() { + public Component name() { return this.name; } diff --git a/api/src/main/java/net/kyori/adventure/chat/SignedMessage.java b/api/src/main/java/net/kyori/adventure/chat/SignedMessage.java index 96d9316920..7bc6a2e5f4 100644 --- a/api/src/main/java/net/kyori/adventure/chat/SignedMessage.java +++ b/api/src/main/java/net/kyori/adventure/chat/SignedMessage.java @@ -33,8 +33,8 @@ import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A signed chat message. @@ -43,6 +43,7 @@ * @sinceMinecraft 1.19 */ @ApiStatus.NonExtendable +@NullMarked public interface SignedMessage extends Identified, Examinable { /** @@ -54,7 +55,7 @@ public interface SignedMessage extends Identified, Examinable { * @sinceMinecraft 1.19 */ @Contract(value = "_ -> new", pure = true) - static @NotNull Signature signature(final byte[] signature) { + static Signature signature(final byte[] signature) { return new SignedMessageImpl.SignatureImpl(signature); } @@ -68,7 +69,7 @@ public interface SignedMessage extends Identified, Examinable { * @sinceMinecraft 1.19 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull SignedMessage system(final @NotNull String message, final @Nullable ComponentLike unsignedContent) { + static SignedMessage system(final String message, final @Nullable ComponentLike unsignedContent) { return new SignedMessageImpl(message, ComponentLike.unbox(unsignedContent)); } @@ -80,7 +81,7 @@ public interface SignedMessage extends Identified, Examinable { * @sinceMinecraft 1.19 */ @Contract(pure = true) - @NotNull Instant timestamp(); + Instant timestamp(); /** * The salt. @@ -120,7 +121,7 @@ public interface SignedMessage extends Identified, Examinable { * @sinceMinecraft 1.19 */ @Contract(pure = true) - @NotNull String message(); + String message(); /** * Checks if this message is a system message. @@ -147,7 +148,7 @@ default boolean canDelete() { } @Override - default @NotNull Stream examinableProperties() { + default Stream examinableProperties() { return Stream.of( ExaminableProperty.of("timestamp", this.timestamp()), ExaminableProperty.of("salt", this.salt()), @@ -177,7 +178,7 @@ interface Signature extends Examinable { byte[] bytes(); @Override - default @NotNull Stream examinableProperties() { + default Stream examinableProperties() { return Stream.of(ExaminableProperty.of("bytes", this.bytes())); } } diff --git a/api/src/main/java/net/kyori/adventure/chat/SignedMessageImpl.java b/api/src/main/java/net/kyori/adventure/chat/SignedMessageImpl.java index 98e1b87648..73f6f20b94 100644 --- a/api/src/main/java/net/kyori/adventure/chat/SignedMessageImpl.java +++ b/api/src/main/java/net/kyori/adventure/chat/SignedMessageImpl.java @@ -27,10 +27,11 @@ import java.time.Instant; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; // Used for system messages ONLY +@NullMarked final class SignedMessageImpl implements SignedMessage { static final SecureRandom RANDOM = new SecureRandom(); @@ -47,7 +48,7 @@ final class SignedMessageImpl implements SignedMessage { } @Override - public @NotNull Instant timestamp() { + public Instant timestamp() { return this.instant; } @@ -67,12 +68,12 @@ public Signature signature() { } @Override - public @NotNull String message() { + public String message() { return this.message; } @Override - public @NotNull Identity identity() { + public Identity identity() { return Identity.nil(); } diff --git a/api/src/main/java/net/kyori/adventure/identity/Identified.java b/api/src/main/java/net/kyori/adventure/identity/Identified.java index 5f2f186fbb..8efeeba2e1 100644 --- a/api/src/main/java/net/kyori/adventure/identity/Identified.java +++ b/api/src/main/java/net/kyori/adventure/identity/Identified.java @@ -23,13 +23,14 @@ */ package net.kyori.adventure.identity; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Something that can be identified by an {@link Identity}. * * @since 4.0.0 */ +@NullMarked public interface Identified { /** * Gets the identity. @@ -37,5 +38,5 @@ public interface Identified { * @return the identity * @since 4.0.0 */ - @NotNull Identity identity(); + Identity identity(); } diff --git a/api/src/main/java/net/kyori/adventure/identity/Identity.java b/api/src/main/java/net/kyori/adventure/identity/Identity.java index 433eb10ce8..7cc1239f25 100644 --- a/api/src/main/java/net/kyori/adventure/identity/Identity.java +++ b/api/src/main/java/net/kyori/adventure/identity/Identity.java @@ -32,7 +32,7 @@ import net.kyori.adventure.text.Component; import net.kyori.examination.Examinable; import net.kyori.examination.ExaminableProperty; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * An identity used to track the sender of messages for the social interaction features @@ -41,6 +41,7 @@ * @since 4.0.0 * @sinceMinecraft 1.16 */ +@NullMarked public interface Identity extends Examinable, Identified { /** * A pointer to a name. @@ -75,7 +76,7 @@ public interface Identity extends Examinable, Identified { * @return the {@code null} identity * @since 4.0.0 */ - static @NotNull Identity nil() { + static Identity nil() { return NilIdentity.INSTANCE; } @@ -86,7 +87,7 @@ public interface Identity extends Examinable, Identified { * @return an identity * @since 4.0.0 */ - static @NotNull Identity identity(final @NotNull UUID uuid) { + static Identity identity(final UUID uuid) { if (uuid.equals(NilIdentity.NIL_UUID)) return NilIdentity.INSTANCE; return new IdentityImpl(uuid); } @@ -97,15 +98,15 @@ public interface Identity extends Examinable, Identified { * @return the uuid * @since 4.0.0 */ - @NotNull UUID uuid(); + UUID uuid(); @Override - default @NotNull Identity identity() { + default Identity identity() { return this; } @Override - default @NotNull Stream examinableProperties() { + default Stream examinableProperties() { return Stream.of(ExaminableProperty.of("uuid", this.uuid())); } } diff --git a/api/src/main/java/net/kyori/adventure/identity/IdentityImpl.java b/api/src/main/java/net/kyori/adventure/identity/IdentityImpl.java index a7a10d969e..f110a13db5 100644 --- a/api/src/main/java/net/kyori/adventure/identity/IdentityImpl.java +++ b/api/src/main/java/net/kyori/adventure/identity/IdentityImpl.java @@ -26,9 +26,10 @@ import java.util.UUID; import net.kyori.adventure.internal.Internals; import net.kyori.examination.Examinable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class IdentityImpl implements Examinable, Identity { private final UUID uuid; @@ -37,7 +38,7 @@ final class IdentityImpl implements Examinable, Identity { } @Override - public @NotNull UUID uuid() { + public UUID uuid() { return this.uuid; } diff --git a/api/src/main/java/net/kyori/adventure/identity/NilIdentity.java b/api/src/main/java/net/kyori/adventure/identity/NilIdentity.java index 1fe26b3550..887209d5ea 100644 --- a/api/src/main/java/net/kyori/adventure/identity/NilIdentity.java +++ b/api/src/main/java/net/kyori/adventure/identity/NilIdentity.java @@ -24,15 +24,16 @@ package net.kyori.adventure.identity; import java.util.UUID; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class NilIdentity implements Identity { static final UUID NIL_UUID = new UUID(0, 0); static final Identity INSTANCE = new NilIdentity(); @Override - public @NotNull UUID uuid() { + public UUID uuid() { return NIL_UUID; } diff --git a/api/src/main/java/net/kyori/adventure/internal/Internals.java b/api/src/main/java/net/kyori/adventure/internal/Internals.java index 9dc0246191..69bf600757 100644 --- a/api/src/main/java/net/kyori/adventure/internal/Internals.java +++ b/api/src/main/java/net/kyori/adventure/internal/Internals.java @@ -26,12 +26,13 @@ import net.kyori.examination.Examinable; import net.kyori.examination.string.StringExaminer; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Utilities internal to Adventure. */ @ApiStatus.Internal +@NullMarked public final class Internals { private Internals() { } @@ -43,7 +44,7 @@ private Internals() { * @return the result from examining * @since 4.10.0 */ - public static @NotNull String toString(final @NotNull Examinable examinable) { + public static String toString(final Examinable examinable) { return examinable.examine(StringExaminer.simpleEscaping()); } } diff --git a/api/src/main/java/net/kyori/adventure/internal/properties/AdventureProperties.java b/api/src/main/java/net/kyori/adventure/internal/properties/AdventureProperties.java index fb27ab9115..32307701fd 100644 --- a/api/src/main/java/net/kyori/adventure/internal/properties/AdventureProperties.java +++ b/api/src/main/java/net/kyori/adventure/internal/properties/AdventureProperties.java @@ -25,8 +25,8 @@ import java.util.function.Function; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Adventure properties. @@ -34,6 +34,7 @@ * @since 4.10.0 */ @ApiStatus.Internal +@NullMarked public final class AdventureProperties { /** * Property for specifying whether debug mode is enabled. @@ -73,7 +74,7 @@ private AdventureProperties() { * @return a property * @since 4.10.0 */ - public static @NotNull Property property(final @NotNull String name, final @NotNull Function parser, final @Nullable T defaultValue) { + public static Property property(final String name, final Function parser, final @Nullable T defaultValue) { return AdventurePropertiesImpl.property(name, parser, defaultValue); } diff --git a/api/src/main/java/net/kyori/adventure/internal/properties/AdventurePropertiesImpl.java b/api/src/main/java/net/kyori/adventure/internal/properties/AdventurePropertiesImpl.java index a279efcac9..6006e2a8ff 100644 --- a/api/src/main/java/net/kyori/adventure/internal/properties/AdventurePropertiesImpl.java +++ b/api/src/main/java/net/kyori/adventure/internal/properties/AdventurePropertiesImpl.java @@ -31,10 +31,11 @@ import java.util.Optional; import java.util.Properties; import java.util.function.Function; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class AdventurePropertiesImpl { private static final String FILESYSTEM_DIRECTORY_NAME = "config"; private static final String FILESYSTEM_FILE_NAME = "adventure.properties"; @@ -63,11 +64,11 @@ private AdventurePropertiesImpl() { } @VisibleForTesting - static @NotNull String systemPropertyName(final String name) { + static String systemPropertyName(final String name) { return String.join(".", "net", "kyori", "adventure", name); } - static AdventureProperties.@NotNull Property property(final @NotNull String name, final @NotNull Function parser, final @Nullable T defaultValue) { + static AdventureProperties.Property property(final String name, final Function parser, final @Nullable T defaultValue) { return new PropertyImpl<>(name, parser, defaultValue); } @@ -78,7 +79,7 @@ private static final class PropertyImpl implements AdventureProperties.Proper private boolean valueCalculated; private @Nullable T value; - PropertyImpl(final @NotNull String name, final @NotNull Function parser, final @Nullable T defaultValue) { + PropertyImpl(final String name, final Function parser, final @Nullable T defaultValue) { this.name = name; this.parser = parser; this.defaultValue = defaultValue; diff --git a/api/src/main/java/net/kyori/adventure/inventory/Book.java b/api/src/main/java/net/kyori/adventure/inventory/Book.java index 98c60fd7b1..096c0ad0fc 100644 --- a/api/src/main/java/net/kyori/adventure/inventory/Book.java +++ b/api/src/main/java/net/kyori/adventure/inventory/Book.java @@ -34,8 +34,8 @@ import net.kyori.examination.Examinable; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; +import org.jspecify.annotations.NullMarked; /** * Represents the in-game interface of a book. @@ -48,6 +48,7 @@ * @since 4.0.0 */ @ApiStatus.NonExtendable +@NullMarked public interface Book extends Buildable, Examinable { /** * Creates a book. @@ -58,7 +59,7 @@ public interface Book extends Buildable, Examinable { * @return a book * @since 4.0.0 */ - static @NotNull Book book(final @NotNull Component title, final @NotNull Component author, final @NotNull Collection pages) { + static Book book(final Component title, final Component author, final Collection pages) { return new BookImpl(title, author, new ArrayList<>(pages)); } @@ -71,7 +72,7 @@ public interface Book extends Buildable, Examinable { * @return a book * @since 4.0.0 */ - static @NotNull Book book(final @NotNull Component title, final @NotNull Component author, final @NotNull Component@NotNull... pages) { + static Book book(final Component title, final Component author, final Component... pages) { return book(title, author, Arrays.asList(pages)); } @@ -81,7 +82,7 @@ public interface Book extends Buildable, Examinable { * @return a builder * @since 4.0.0 */ - static @NotNull Builder builder() { + static Builder builder() { return new BookImpl.BuilderImpl(); } @@ -91,7 +92,7 @@ public interface Book extends Buildable, Examinable { * @return the title * @since 4.0.0 */ - @NotNull Component title(); + Component title(); /** * Changes the book's title. @@ -101,7 +102,7 @@ public interface Book extends Buildable, Examinable { * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - @NotNull Book title(final @NotNull Component title); + Book title(final Component title); /** * Gets the author. @@ -109,7 +110,7 @@ public interface Book extends Buildable, Examinable { * @return the author * @since 4.0.0 */ - @NotNull Component author(); + Component author(); /** * Changes the book's author. @@ -119,7 +120,7 @@ public interface Book extends Buildable, Examinable { * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - @NotNull Book author(final @NotNull Component author); + Book author(final Component author); /** * Gets the list of pages. @@ -129,7 +130,7 @@ public interface Book extends Buildable, Examinable { * @return the list of pages * @since 4.0.0 */ - @Unmodifiable @NotNull List pages(); + @Unmodifiable List pages(); /** * Returns an updated book with the provided pages. @@ -139,7 +140,7 @@ public interface Book extends Buildable, Examinable { * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - default @NotNull Book pages(final @NotNull Component@NotNull... pages) { + default Book pages(final Component... pages) { return this.pages(Arrays.asList(pages)); } @@ -151,7 +152,7 @@ public interface Book extends Buildable, Examinable { * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - @NotNull Book pages(final @NotNull List pages); + Book pages(final List pages); /** * Create a new builder initialized with the attributes of this book. @@ -159,7 +160,7 @@ public interface Book extends Buildable, Examinable { * @return the builder */ @Override - default @NotNull Builder toBuilder() { + default Builder toBuilder() { return builder() .title(this.title()) .author(this.author()) @@ -180,7 +181,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder title(final @NotNull Component title); + Builder title(final Component title); /** * Set the author. @@ -190,7 +191,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder author(final @NotNull Component author); + Builder author(final Component author); /** * Add a page to the book. @@ -203,7 +204,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder addPage(final @NotNull Component page); + Builder addPage(final Component page); /** * Add pages to the book. @@ -214,7 +215,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder pages(final @NotNull Component@NotNull... pages); + Builder pages(final Component... pages); /** * Add pages to the book. @@ -225,7 +226,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder pages(final @NotNull Collection pages); + Builder pages(final Collection pages); /** * Builds. @@ -233,6 +234,6 @@ interface Builder extends AbstractBuilder, Buildable.Builder { * @return a new book */ @Override - @NotNull Book build(); + Book build(); } } diff --git a/api/src/main/java/net/kyori/adventure/inventory/BookImpl.java b/api/src/main/java/net/kyori/adventure/inventory/BookImpl.java index a8650cb2a4..ec62637ca7 100644 --- a/api/src/main/java/net/kyori/adventure/inventory/BookImpl.java +++ b/api/src/main/java/net/kyori/adventure/inventory/BookImpl.java @@ -31,53 +31,54 @@ import net.kyori.adventure.internal.Internals; import net.kyori.adventure.text.Component; import net.kyori.examination.ExaminableProperty; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import static java.util.Objects.requireNonNull; +@NullMarked final class BookImpl implements Book { private final Component title; private final Component author; private final List pages; - BookImpl(final @NotNull Component title, final @NotNull Component author, final @NotNull List pages) { + BookImpl(final Component title, final Component author, final List pages) { this.title = requireNonNull(title, "title"); this.author = requireNonNull(author, "author"); this.pages = Collections.unmodifiableList(requireNonNull(pages, "pages")); } @Override - public @NotNull Component title() { + public Component title() { return this.title; } @Override - public @NotNull Book title(final @NotNull Component title) { + public Book title(final Component title) { return new BookImpl(requireNonNull(title, "title"), this.author, this.pages); } @Override - public @NotNull Component author() { + public Component author() { return this.author; } @Override - public @NotNull Book author(final @NotNull Component author) { + public Book author(final Component author) { return new BookImpl(this.title, requireNonNull(author, "author"), this.pages); } @Override - public @NotNull List pages() { + public List pages() { return this.pages; } @Override - public @NotNull Book pages(final @NotNull List pages) { + public Book pages(final List pages) { return new BookImpl(this.title, this.author, new ArrayList<>(requireNonNull(pages, "pages"))); } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("title", this.title), ExaminableProperty.of("author", this.author), @@ -114,37 +115,37 @@ static final class BuilderImpl implements Book.Builder { private final List pages = new ArrayList<>(); @Override - public @NotNull Builder title(final @NotNull Component title) { + public Builder title(final Component title) { this.title = requireNonNull(title, "title"); return this; } @Override - public @NotNull Builder author(final @NotNull Component author) { + public Builder author(final Component author) { this.author = requireNonNull(author, "author"); return this; } @Override - public @NotNull Builder addPage(final @NotNull Component page) { + public Builder addPage(final Component page) { this.pages.add(requireNonNull(page, "page")); return this; } @Override - public @NotNull Builder pages(final @NotNull Collection pages) { + public Builder pages(final Collection pages) { this.pages.addAll(requireNonNull(pages, "pages")); return this; } @Override - public @NotNull Builder pages(final @NotNull Component@NotNull... pages) { + public Builder pages(final Component... pages) { Collections.addAll(this.pages, pages); return this; } @Override - public @NotNull Book build() { + public Book build() { return new BookImpl(this.title, this.author, new ArrayList<>(this.pages)); } } diff --git a/api/src/main/java/net/kyori/adventure/nbt/api/BinaryTagHolder.java b/api/src/main/java/net/kyori/adventure/nbt/api/BinaryTagHolder.java index 798943eabc..25b79a3b91 100644 --- a/api/src/main/java/net/kyori/adventure/nbt/api/BinaryTagHolder.java +++ b/api/src/main/java/net/kyori/adventure/nbt/api/BinaryTagHolder.java @@ -25,7 +25,7 @@ import net.kyori.adventure.util.Codec; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Holds a compound binary tag. @@ -37,6 +37,7 @@ * * @since 4.0.0 */ +@NullMarked public interface BinaryTagHolder { /** * Encodes {@code nbt} using {@code codec}. @@ -49,7 +50,7 @@ public interface BinaryTagHolder { * @throws EX if an error occurred while encoding the binary tag * @since 4.0.0 */ - static @NotNull BinaryTagHolder encode(final @NotNull T nbt, final @NotNull Codec codec) throws EX { + static BinaryTagHolder encode(final T nbt, final Codec codec) throws EX { return new BinaryTagHolderImpl(codec.encode(nbt)); } @@ -60,7 +61,7 @@ public interface BinaryTagHolder { * @return the encoded binary tag * @since 4.10.0 */ - static @NotNull BinaryTagHolder binaryTagHolder(final @NotNull String string) { + static BinaryTagHolder binaryTagHolder(final String string) { return new BinaryTagHolderImpl(string); } @@ -74,7 +75,7 @@ public interface BinaryTagHolder { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - static @NotNull BinaryTagHolder of(final @NotNull String string) { + static BinaryTagHolder of(final String string) { return new BinaryTagHolderImpl(string); } @@ -84,7 +85,7 @@ public interface BinaryTagHolder { * @return the raw string value * @since 4.0.0 */ - @NotNull String string(); + String string(); /** * Gets the held value as a binary tag. @@ -96,5 +97,5 @@ public interface BinaryTagHolder { * @throws DX if an error occurred while retrieving the binary tag * @since 4.0.0 */ - @NotNull T get(final @NotNull Codec codec) throws DX; + T get(final Codec codec) throws DX; } diff --git a/api/src/main/java/net/kyori/adventure/nbt/api/BinaryTagHolderImpl.java b/api/src/main/java/net/kyori/adventure/nbt/api/BinaryTagHolderImpl.java index 7223cdc87a..f7443e16e6 100644 --- a/api/src/main/java/net/kyori/adventure/nbt/api/BinaryTagHolderImpl.java +++ b/api/src/main/java/net/kyori/adventure/nbt/api/BinaryTagHolderImpl.java @@ -24,10 +24,11 @@ package net.kyori.adventure.nbt.api; import net.kyori.adventure.util.Codec; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import static java.util.Objects.requireNonNull; +@NullMarked final class BinaryTagHolderImpl implements BinaryTagHolder { private final String string; @@ -36,12 +37,12 @@ final class BinaryTagHolderImpl implements BinaryTagHolder { } @Override - public @NotNull String string() { + public String string() { return this.string; } @Override - public @NotNull T get(final @NotNull Codec codec) throws DX { + public T get(final Codec codec) throws DX { return codec.decode(this.string); } diff --git a/api/src/main/java/net/kyori/adventure/permission/PermissionChecker.java b/api/src/main/java/net/kyori/adventure/permission/PermissionChecker.java index 58338bf750..20eed2ee5c 100644 --- a/api/src/main/java/net/kyori/adventure/permission/PermissionChecker.java +++ b/api/src/main/java/net/kyori/adventure/permission/PermissionChecker.java @@ -28,7 +28,7 @@ import net.kyori.adventure.key.Key; import net.kyori.adventure.pointer.Pointer; import net.kyori.adventure.util.TriState; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import static java.util.Objects.requireNonNull; @@ -37,6 +37,7 @@ * * @since 4.8.0 */ +@NullMarked public interface PermissionChecker extends Predicate { /** * A pointer to a permission predicate. @@ -52,7 +53,7 @@ public interface PermissionChecker extends Predicate { * @return a {@link PermissionChecker} * @since 4.8.0 */ - static @NotNull PermissionChecker always(final @NotNull TriState state) { + static PermissionChecker always(final TriState state) { requireNonNull(state); if (state == TriState.TRUE) return PermissionCheckers.TRUE; if (state == TriState.FALSE) return PermissionCheckers.FALSE; @@ -66,10 +67,10 @@ public interface PermissionChecker extends Predicate { * @return a tri-state result * @since 4.8.0 */ - @NotNull TriState value(final @NotNull String permission); + TriState value(final String permission); @Override - default boolean test(final @NotNull String permission) { + default boolean test(final String permission) { return this.value(permission) == TriState.TRUE; } } diff --git a/api/src/main/java/net/kyori/adventure/permission/PermissionCheckers.java b/api/src/main/java/net/kyori/adventure/permission/PermissionCheckers.java index 8bfc6fbe57..d9920f5594 100644 --- a/api/src/main/java/net/kyori/adventure/permission/PermissionCheckers.java +++ b/api/src/main/java/net/kyori/adventure/permission/PermissionCheckers.java @@ -24,9 +24,10 @@ package net.kyori.adventure.permission; import net.kyori.adventure.util.TriState; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class PermissionCheckers { static final PermissionChecker NOT_SET = new Always(TriState.NOT_SET); static final PermissionChecker FALSE = new Always(TriState.FALSE); @@ -43,7 +44,7 @@ private Always(final TriState value) { } @Override - public @NotNull TriState value(final @NotNull String permission) { + public TriState value(final String permission) { return this.value; } diff --git a/api/src/main/java/net/kyori/adventure/pointer/Pointer.java b/api/src/main/java/net/kyori/adventure/pointer/Pointer.java index 51ccd7c29c..b493c53249 100644 --- a/api/src/main/java/net/kyori/adventure/pointer/Pointer.java +++ b/api/src/main/java/net/kyori/adventure/pointer/Pointer.java @@ -27,7 +27,7 @@ import net.kyori.adventure.key.Key; import net.kyori.examination.Examinable; import net.kyori.examination.ExaminableProperty; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * A pointer to a resource. @@ -35,6 +35,7 @@ * @param the value type * @since 4.8.0 */ +@NullMarked public interface Pointer extends Examinable { /** * Creates a pointer. @@ -45,7 +46,7 @@ public interface Pointer extends Examinable { * @return the pointer * @since 4.8.0 */ - static @NotNull Pointer pointer(final @NotNull Class type, final @NotNull Key key) { + static Pointer pointer(final Class type, final Key key) { return new PointerImpl<>(type, key); } @@ -55,7 +56,7 @@ public interface Pointer extends Examinable { * @return the value type * @since 4.8.0 */ - @NotNull Class type(); + Class type(); /** * Gets the key. @@ -63,10 +64,10 @@ public interface Pointer extends Examinable { * @return the key * @since 4.8.0 */ - @NotNull Key key(); + Key key(); @Override - default @NotNull Stream examinableProperties() { + default Stream examinableProperties() { return Stream.of( ExaminableProperty.of("type", this.type()), ExaminableProperty.of("key", this.key()) diff --git a/api/src/main/java/net/kyori/adventure/pointer/PointerImpl.java b/api/src/main/java/net/kyori/adventure/pointer/PointerImpl.java index 61197c34b2..cb35a3a44a 100644 --- a/api/src/main/java/net/kyori/adventure/pointer/PointerImpl.java +++ b/api/src/main/java/net/kyori/adventure/pointer/PointerImpl.java @@ -25,9 +25,10 @@ import net.kyori.adventure.internal.Internals; import net.kyori.adventure.key.Key; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class PointerImpl implements Pointer { private final Class type; private final Key key; @@ -38,12 +39,12 @@ final class PointerImpl implements Pointer { } @Override - public @NotNull Class type() { + public Class type() { return this.type; } @Override - public @NotNull Key key() { + public Key key() { return this.key; } diff --git a/api/src/main/java/net/kyori/adventure/pointer/Pointered.java b/api/src/main/java/net/kyori/adventure/pointer/Pointered.java index ea9f7c4a6e..0d0d6ee6f0 100644 --- a/api/src/main/java/net/kyori/adventure/pointer/Pointered.java +++ b/api/src/main/java/net/kyori/adventure/pointer/Pointered.java @@ -26,15 +26,15 @@ import java.util.Optional; import java.util.function.Supplier; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.UnknownNullability; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Something that can retrieve values based on a given {@link Pointer}. * * @since 4.8.0 */ +@NullMarked public interface Pointered { /** * Gets the value of {@code pointer}. @@ -44,7 +44,7 @@ public interface Pointered { * @return the value * @since 4.8.0 */ - default @NotNull Optional get(final @NotNull Pointer pointer) { + default Optional get(final Pointer pointer) { return this.pointers().get(pointer); } @@ -61,7 +61,7 @@ public interface Pointered { */ @Contract("_, null -> _; _, !null -> !null") @SuppressWarnings("checkstyle:MethodName") - default @Nullable T getOrDefault(final @NotNull Pointer pointer, final @Nullable T defaultValue) { + default @Nullable T getOrDefault(final Pointer pointer, final @Nullable T defaultValue) { return this.pointers().getOrDefault(pointer, defaultValue); } @@ -77,7 +77,7 @@ public interface Pointered { * @since 4.8.0 */ @SuppressWarnings("checkstyle:MethodName") - default @UnknownNullability T getOrDefaultFrom(final @NotNull Pointer pointer, final @NotNull Supplier defaultValue) { + default @Nullable T getOrDefaultFrom(final Pointer pointer, final Supplier defaultValue) { return this.pointers().getOrDefaultFrom(pointer, defaultValue); } @@ -87,7 +87,7 @@ public interface Pointered { * @return the pointers * @since 4.8.0 */ - default @NotNull Pointers pointers() { + default Pointers pointers() { return Pointers.empty(); } } diff --git a/api/src/main/java/net/kyori/adventure/pointer/Pointers.java b/api/src/main/java/net/kyori/adventure/pointer/Pointers.java index c022fd1022..38e615015f 100644 --- a/api/src/main/java/net/kyori/adventure/pointer/Pointers.java +++ b/api/src/main/java/net/kyori/adventure/pointer/Pointers.java @@ -28,15 +28,15 @@ import net.kyori.adventure.builder.AbstractBuilder; import net.kyori.adventure.util.Buildable; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.UnknownNullability; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A collection of {@link Pointer pointers}. * * @since 4.8.0 */ +@NullMarked public interface Pointers extends Buildable { /** * Gets an empty pointers collection. @@ -45,7 +45,7 @@ public interface Pointers extends Buildable { * @since 4.8.0 */ @Contract(pure = true) - static @NotNull Pointers empty() { + static Pointers empty() { return PointersImpl.EMPTY; } @@ -57,7 +57,7 @@ public interface Pointers extends Buildable { * @since 4.8.0 */ @Contract(pure = true) - static @NotNull Builder builder() { + static Builder builder() { return new PointersImpl.BuilderImpl(); } @@ -69,7 +69,7 @@ public interface Pointers extends Buildable { * @return the value * @since 4.8.0 */ - @NotNull Optional get(final @NotNull Pointer pointer); + Optional get(final Pointer pointer); /** * Gets the value of {@code pointer}. @@ -84,7 +84,7 @@ public interface Pointers extends Buildable { */ @Contract("_, null -> _; _, !null -> !null") @SuppressWarnings("checkstyle:MethodName") - default @Nullable T getOrDefault(final @NotNull Pointer pointer, final @Nullable T defaultValue) { + default @Nullable T getOrDefault(final Pointer pointer, final @Nullable T defaultValue) { return this.get(pointer).orElse(defaultValue); } @@ -100,7 +100,7 @@ public interface Pointers extends Buildable { * @since 4.8.0 */ @SuppressWarnings("checkstyle:MethodName") - default @UnknownNullability T getOrDefaultFrom(final @NotNull Pointer pointer, final @NotNull Supplier defaultValue) { + default @Nullable T getOrDefaultFrom(final Pointer pointer, final Supplier defaultValue) { return this.get(pointer).orElseGet(defaultValue); } @@ -114,7 +114,7 @@ public interface Pointers extends Buildable { * @return if the pointer is supported * @since 4.8.0 */ - boolean supports(final @NotNull Pointer pointer); + boolean supports(final Pointer pointer); /** * A builder of pointers. @@ -133,7 +133,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder * @since 4.8.0 */ @Contract("_, _ -> this") - default @NotNull Builder withStatic(final @NotNull Pointer pointer, final @Nullable T value) { + default Builder withStatic(final Pointer pointer, final @Nullable T value) { return this.withDynamic(pointer, () -> value); } @@ -147,6 +147,6 @@ interface Builder extends AbstractBuilder, Buildable.Builder * @since 4.8.0 */ @Contract("_, _ -> this") - @NotNull Builder withDynamic(final @NotNull Pointer pointer, @NotNull Supplier<@Nullable T> value); + Builder withDynamic(final Pointer pointer, Supplier<@Nullable T> value); } } diff --git a/api/src/main/java/net/kyori/adventure/pointer/PointersImpl.java b/api/src/main/java/net/kyori/adventure/pointer/PointersImpl.java index 985d07b71c..af27ad1eb3 100644 --- a/api/src/main/java/net/kyori/adventure/pointer/PointersImpl.java +++ b/api/src/main/java/net/kyori/adventure/pointer/PointersImpl.java @@ -28,23 +28,24 @@ import java.util.Objects; import java.util.Optional; import java.util.function.Supplier; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class PointersImpl implements Pointers { static final Pointers EMPTY = new Pointers() { @Override - public @NotNull Optional get(final @NotNull Pointer pointer) { + public Optional get(final Pointer pointer) { return Optional.empty(); } @Override - public boolean supports(final @NotNull Pointer pointer) { + public boolean supports(final Pointer pointer) { return false; } @Override - public Pointers.@NotNull Builder toBuilder() { + public Pointers.Builder toBuilder() { return new PointersImpl.BuilderImpl(); } @@ -56,13 +57,13 @@ public String toString() { private final Map, Supplier> pointers; - PointersImpl(final @NotNull BuilderImpl builder) { + PointersImpl(final BuilderImpl builder) { this.pointers = new HashMap<>(builder.pointers); } @Override @SuppressWarnings("unchecked") // all values are checked on entry - public @NotNull Optional get(final @NotNull Pointer pointer) { + public Optional get(final Pointer pointer) { Objects.requireNonNull(pointer, "pointer"); final Supplier supplier = this.pointers.get(pointer); if (supplier == null) { @@ -73,13 +74,13 @@ public String toString() { } @Override - public boolean supports(final @NotNull Pointer pointer) { + public boolean supports(final Pointer pointer) { Objects.requireNonNull(pointer, "pointer"); return this.pointers.containsKey(pointer); } @Override - public Pointers.@NotNull Builder toBuilder() { + public Pointers.Builder toBuilder() { return new BuilderImpl(this); } @@ -90,18 +91,18 @@ static final class BuilderImpl implements Builder { this.pointers = new HashMap<>(); } - BuilderImpl(final @NotNull PointersImpl pointers) { + BuilderImpl(final PointersImpl pointers) { this.pointers = new HashMap<>(pointers.pointers); } @Override - public @NotNull Builder withDynamic(final @NotNull Pointer pointer, final @NotNull Supplier<@Nullable T> value) { + public Builder withDynamic(final Pointer pointer, final Supplier<@Nullable T> value) { this.pointers.put(Objects.requireNonNull(pointer, "pointer"), Objects.requireNonNull(value, "value")); return this; } @Override - public @NotNull Pointers build() { + public Pointers build() { return new PointersImpl(this); } } diff --git a/api/src/main/java/net/kyori/adventure/sound/Sound.java b/api/src/main/java/net/kyori/adventure/sound/Sound.java index 5229772c14..73aa09da52 100644 --- a/api/src/main/java/net/kyori/adventure/sound/Sound.java +++ b/api/src/main/java/net/kyori/adventure/sound/Sound.java @@ -32,8 +32,8 @@ import net.kyori.adventure.util.Index; import net.kyori.examination.Examinable; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Range; +import org.jspecify.annotations.NullMarked; import static java.util.Objects.requireNonNull; @@ -58,6 +58,7 @@ * @since 4.0.0 */ @ApiStatus.NonExtendable +@NullMarked public interface Sound extends Examinable { /** * Create a new builder for {@link Sound} instances. @@ -65,7 +66,7 @@ public interface Sound extends Examinable { * @return a new builder * @since 4.12.0 */ - static @NotNull Builder sound() { + static Builder sound() { return new SoundImpl.BuilderImpl(); } @@ -76,7 +77,7 @@ public interface Sound extends Examinable { * @return a new builder * @since 4.12.0 */ - static @NotNull Builder sound(final @NotNull Sound existing) { + static Builder sound(final Sound existing) { return new SoundImpl.BuilderImpl(existing); } @@ -87,7 +88,7 @@ public interface Sound extends Examinable { * @return a new builder * @since 4.12.0 */ - static @NotNull Sound sound(final @NotNull Consumer configurer) { + static Sound sound(final Consumer configurer) { return AbstractBuilder.configureAndBuild(sound(), configurer); } @@ -101,7 +102,7 @@ public interface Sound extends Examinable { * @return the sound * @since 4.0.0 */ - static @NotNull Sound sound(final @NotNull Key name, final @NotNull Source source, final float volume, final float pitch) { + static Sound sound(final Key name, final Source source, final float volume, final float pitch) { return sound().type(name).source(source).volume(volume).pitch(pitch).build(); } @@ -115,7 +116,7 @@ public interface Sound extends Examinable { * @return the sound * @since 4.0.0 */ - static @NotNull Sound sound(final @NotNull Type type, final @NotNull Source source, final float volume, final float pitch) { + static Sound sound(final Type type, final Source source, final float volume, final float pitch) { requireNonNull(type, "type"); return sound(type.key(), source, volume, pitch); } @@ -130,7 +131,7 @@ public interface Sound extends Examinable { * @return the sound * @since 4.0.0 */ - static @NotNull Sound sound(final @NotNull Supplier type, final @NotNull Source source, final float volume, final float pitch) { + static Sound sound(final Supplier type, final Source source, final float volume, final float pitch) { return sound().type(type).source(source).volume(volume).pitch(pitch).build(); } @@ -144,7 +145,7 @@ public interface Sound extends Examinable { * @return the sound * @since 4.8.0 */ - static @NotNull Sound sound(final @NotNull Key name, final Source.@NotNull Provider source, final float volume, final float pitch) { + static Sound sound(final Key name, final Source.Provider source, final float volume, final float pitch) { return sound(name, source.soundSource(), volume, pitch); } @@ -158,7 +159,7 @@ public interface Sound extends Examinable { * @return the sound * @since 4.8.0 */ - static @NotNull Sound sound(final @NotNull Type type, final Source.@NotNull Provider source, final float volume, final float pitch) { + static Sound sound(final Type type, final Source.Provider source, final float volume, final float pitch) { return sound(type, source.soundSource(), volume, pitch); } @@ -172,7 +173,7 @@ public interface Sound extends Examinable { * @return the sound * @since 4.8.0 */ - static @NotNull Sound sound(final @NotNull Supplier type, final Source.@NotNull Provider source, final float volume, final float pitch) { + static Sound sound(final Supplier type, final Source.Provider source, final float volume, final float pitch) { return sound(type, source.soundSource(), volume, pitch); } @@ -182,7 +183,7 @@ public interface Sound extends Examinable { * @return the name * @since 4.0.0 */ - @NotNull Key name(); + Key name(); /** * Gets the source. @@ -190,7 +191,7 @@ public interface Sound extends Examinable { * @return the source * @since 4.0.0 */ - @NotNull Source source(); + Source source(); /** * Gets the volume. @@ -216,7 +217,7 @@ public interface Sound extends Examinable { * @return the seed to use * @since 4.12.0 */ - @NotNull OptionalLong seed(); + OptionalLong seed(); /** * Gets the {@link SoundStop} that will stop this specific sound. @@ -224,7 +225,7 @@ public interface Sound extends Examinable { * @return the sound stop * @since 4.8.0 */ - @NotNull SoundStop asStop(); + SoundStop asStop(); /** * The sound source. @@ -267,7 +268,7 @@ public interface Provider { * @return the source * @since 4.8.0 */ - @NotNull Source soundSource(); + Source soundSource(); } } @@ -284,7 +285,7 @@ interface Type extends Keyed { * @since 4.0.0 */ @Override - @NotNull Key key(); + Key key(); } /** @@ -302,7 +303,7 @@ interface Emitter { * @return the emitter * @since 4.8.0 */ - static @NotNull Emitter self() { + static Emitter self() { return SoundImpl.EMITTER_SELF; } } @@ -324,7 +325,7 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.12.0 */ - @NotNull Builder type(final @NotNull Key type); + Builder type(final Key type); /** * Set the type of this sound. @@ -335,7 +336,7 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.12.0 */ - @NotNull Builder type(final @NotNull Type type); + Builder type(final Type type); /** * Set the type of this sound. @@ -346,7 +347,7 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.12.0 */ - @NotNull Builder type(final @NotNull Supplier typeSupplier); + Builder type(final Supplier typeSupplier); /** * A {@link Source} to tell the game where the sound is coming from. @@ -357,7 +358,7 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.12.0 */ - @NotNull Builder source(final @NotNull Source source); + Builder source(final Source source); /** * A {@link Source} to tell the game where the sound is coming from. @@ -368,7 +369,7 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.12.0 */ - @NotNull Builder source(final Source.@NotNull Provider source); + Builder source(final Source.Provider source); /** * The volume for this sound, indicating how far away it can be heard. @@ -379,7 +380,7 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.12.0 */ - @NotNull Builder volume(final @Range(from = 0, to = Integer.MAX_VALUE) float volume); + Builder volume(final @Range(from = 0, to = Integer.MAX_VALUE) float volume); /** * The pitch for this sound, indicating how high or low the sound can be heard. @@ -390,7 +391,7 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.12.0 */ - @NotNull Builder pitch(final @Range(from = -1, to = 1) float pitch); + Builder pitch(final @Range(from = -1, to = 1) float pitch); /** * The seed for this sound, used for weighted choices. @@ -401,7 +402,7 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.12.0 */ - @NotNull Builder seed(final long seed); + Builder seed(final long seed); /** * The seed for this sound, used for weighted choices. @@ -412,6 +413,6 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.12.0 */ - @NotNull Builder seed(final @NotNull OptionalLong seed); + Builder seed(final OptionalLong seed); } } diff --git a/api/src/main/java/net/kyori/adventure/sound/SoundImpl.java b/api/src/main/java/net/kyori/adventure/sound/SoundImpl.java index f8de4a2536..fc908592c7 100644 --- a/api/src/main/java/net/kyori/adventure/sound/SoundImpl.java +++ b/api/src/main/java/net/kyori/adventure/sound/SoundImpl.java @@ -30,12 +30,13 @@ import net.kyori.adventure.key.Key; import net.kyori.adventure.util.ShadyPines; import net.kyori.examination.ExaminableProperty; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Range; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked abstract class SoundImpl implements Sound { static final Emitter EMITTER_SELF = new Emitter() { @Override @@ -50,7 +51,7 @@ public String toString() { private final OptionalLong seed; private SoundStop stop; - SoundImpl(final @NotNull Source source, final float volume, final float pitch, final OptionalLong seed) { + SoundImpl(final Source source, final float volume, final float pitch, final OptionalLong seed) { this.source = source; this.volume = volume; this.pitch = pitch; @@ -58,7 +59,7 @@ public String toString() { } @Override - public @NotNull Source source() { + public Source source() { return this.source; } @@ -78,7 +79,7 @@ public OptionalLong seed() { } @Override - public @NotNull SoundStop asStop() { + public SoundStop asStop() { if (this.stop == null) this.stop = SoundStop.namedOnSource(this.name(), this.source()); return this.stop; } @@ -106,7 +107,7 @@ public int hashCode() { } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("name", this.name()), ExaminableProperty.of("source", this.source), @@ -134,7 +135,7 @@ static final class BuilderImpl implements Builder { BuilderImpl() { } - BuilderImpl(final @NotNull Sound existing) { + BuilderImpl(final Sound existing) { if (existing instanceof Eager) { this.type(((Eager) existing).name); } else if (existing instanceof Lazy) { @@ -150,63 +151,63 @@ static final class BuilderImpl implements Builder { } @Override - public @NotNull Builder type(final @NotNull Key type) { + public Builder type(final Key type) { this.eagerType = requireNonNull(type, "type"); this.lazyType = null; return this; } @Override - public @NotNull Builder type(final @NotNull Type type) { + public Builder type(final Type type) { this.eagerType = requireNonNull(requireNonNull(type, "type").key(), "type.key()"); this.lazyType = null; return this; } @Override - public @NotNull Builder type(final @NotNull Supplier typeSupplier) { + public Builder type(final Supplier typeSupplier) { this.lazyType = requireNonNull(typeSupplier, "typeSupplier"); this.eagerType = null; return this; } @Override - public @NotNull Builder source(final @NotNull Source source) { + public Builder source(final Source source) { this.source = requireNonNull(source, "source"); return this; } @Override - public @NotNull Builder source(final Source.@NotNull Provider source) { + public Builder source(final Source.Provider source) { return this.source(source.soundSource()); } @Override - public @NotNull Builder volume(final @Range(from = 0, to = Integer.MAX_VALUE) float volume) { + public Builder volume(final @Range(from = 0, to = Integer.MAX_VALUE) float volume) { this.volume = volume; return this; } @Override - public @NotNull Builder pitch(final @Range(from = -1, to = 1) float pitch) { + public Builder pitch(final @Range(from = -1, to = 1) float pitch) { this.pitch = pitch; return this; } @Override - public @NotNull Builder seed(final long seed) { + public Builder seed(final long seed) { this.seed = OptionalLong.of(seed); return this; } @Override - public @NotNull Builder seed(final @NotNull OptionalLong seed) { + public Builder seed(final OptionalLong seed) { this.seed = requireNonNull(seed, "seed"); return this; } @Override - public @NotNull Sound build() { + public Sound build() { if (this.eagerType != null) { return new Eager(this.eagerType, this.source, this.volume, this.pitch, this.seed); } else if (this.lazyType != null) { @@ -220,13 +221,13 @@ static final class BuilderImpl implements Builder { static final class Eager extends SoundImpl { final Key name; - Eager(final @NotNull Key name, final @NotNull Source source, final float volume, final float pitch, final OptionalLong seed) { + Eager(final Key name, final Source source, final float volume, final float pitch, final OptionalLong seed) { super(source, volume, pitch, seed); this.name = name; } @Override - public @NotNull Key name() { + public Key name() { return this.name; } } @@ -234,13 +235,13 @@ static final class Eager extends SoundImpl { static final class Lazy extends SoundImpl { final Supplier supplier; - Lazy(final @NotNull Supplier supplier, final @NotNull Source source, final float volume, final float pitch, final OptionalLong seed) { + Lazy(final Supplier supplier, final Source source, final float volume, final float pitch, final OptionalLong seed) { super(source, volume, pitch, seed); this.supplier = supplier; } @Override - public @NotNull Key name() { + public Key name() { return this.supplier.get().key(); } } diff --git a/api/src/main/java/net/kyori/adventure/sound/SoundStop.java b/api/src/main/java/net/kyori/adventure/sound/SoundStop.java index 2cbe7aac10..1f870526af 100644 --- a/api/src/main/java/net/kyori/adventure/sound/SoundStop.java +++ b/api/src/main/java/net/kyori/adventure/sound/SoundStop.java @@ -28,8 +28,8 @@ import net.kyori.adventure.key.Key; import net.kyori.examination.Examinable; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; @@ -45,6 +45,7 @@ * @since 4.0.0 */ @ApiStatus.NonExtendable +@NullMarked public interface SoundStop extends Examinable { /** * Stops all sounds. @@ -52,7 +53,7 @@ public interface SoundStop extends Examinable { * @return a sound stopper * @since 4.0.0 */ - static @NotNull SoundStop all() { + static SoundStop all() { return SoundStopImpl.ALL; } @@ -63,11 +64,11 @@ public interface SoundStop extends Examinable { * @return a sound stopper * @since 4.0.0 */ - static @NotNull SoundStop named(final @NotNull Key sound) { + static SoundStop named(final Key sound) { requireNonNull(sound, "sound"); return new SoundStopImpl(null) { @Override - public @NotNull Key sound() { + public Key sound() { return sound; } }; @@ -80,11 +81,11 @@ public interface SoundStop extends Examinable { * @return a sound stopper * @since 4.0.0 */ - static @NotNull SoundStop named(final Sound.@NotNull Type sound) { + static SoundStop named(final Sound.Type sound) { requireNonNull(sound, "sound"); return new SoundStopImpl(null) { @Override - public @NotNull Key sound() { + public Key sound() { return sound.key(); } }; @@ -97,11 +98,11 @@ public interface SoundStop extends Examinable { * @return a sound stopper * @since 4.0.0 */ - static @NotNull SoundStop named(final @NotNull Supplier sound) { + static SoundStop named(final Supplier sound) { requireNonNull(sound, "sound"); return new SoundStopImpl(null) { @Override - public @NotNull Key sound() { + public Key sound() { return sound.get().key(); } }; @@ -114,7 +115,7 @@ public interface SoundStop extends Examinable { * @return a sound stopper * @since 4.0.0 */ - static @NotNull SoundStop source(final Sound.@NotNull Source source) { + static SoundStop source(final Sound.Source source) { requireNonNull(source, "source"); return new SoundStopImpl(source) { @Override @@ -132,12 +133,12 @@ public interface SoundStop extends Examinable { * @return a sound stopper * @since 4.0.0 */ - static @NotNull SoundStop namedOnSource(final @NotNull Key sound, final Sound.@NotNull Source source) { + static SoundStop namedOnSource(final Key sound, final Sound.Source source) { requireNonNull(sound, "sound"); requireNonNull(source, "source"); return new SoundStopImpl(source) { @Override - public @NotNull Key sound() { + public Key sound() { return sound; } }; @@ -151,7 +152,7 @@ public interface SoundStop extends Examinable { * @return a sound stopper * @since 4.0.0 */ - static @NotNull SoundStop namedOnSource(final Sound.@NotNull Type sound, final Sound.@NotNull Source source) { + static SoundStop namedOnSource(final Sound.Type sound, final Sound.Source source) { requireNonNull(sound, "sound"); return namedOnSource(sound.key(), source); } @@ -164,12 +165,12 @@ public interface SoundStop extends Examinable { * @return a sound stopper * @since 4.0.0 */ - static @NotNull SoundStop namedOnSource(final @NotNull Supplier sound, final Sound.@NotNull Source source) { + static SoundStop namedOnSource(final Supplier sound, final Sound.Source source) { requireNonNull(sound, "sound"); requireNonNull(source, "source"); return new SoundStopImpl(source) { @Override - public @NotNull Key sound() { + public Key sound() { return sound.get().key(); } }; diff --git a/api/src/main/java/net/kyori/adventure/sound/SoundStopImpl.java b/api/src/main/java/net/kyori/adventure/sound/SoundStopImpl.java index de76b9e14a..561a1fdeed 100644 --- a/api/src/main/java/net/kyori/adventure/sound/SoundStopImpl.java +++ b/api/src/main/java/net/kyori/adventure/sound/SoundStopImpl.java @@ -28,9 +28,10 @@ import net.kyori.adventure.internal.Internals; import net.kyori.adventure.key.Key; import net.kyori.examination.ExaminableProperty; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked abstract class SoundStopImpl implements SoundStop { static final SoundStop ALL = new SoundStopImpl(null) { @Override @@ -66,7 +67,7 @@ public int hashCode() { } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("name", this.sound()), ExaminableProperty.of("source", this.source) diff --git a/api/src/main/java/net/kyori/adventure/text/AbstractComponent.java b/api/src/main/java/net/kyori/adventure/text/AbstractComponent.java index b2245732d8..76747fc085 100644 --- a/api/src/main/java/net/kyori/adventure/text/AbstractComponent.java +++ b/api/src/main/java/net/kyori/adventure/text/AbstractComponent.java @@ -31,8 +31,8 @@ import net.kyori.examination.string.StringExaminer; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Debug; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * An abstract implementation of a text component. @@ -43,22 +43,23 @@ @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Debug.Renderer(text = "this.debuggerString()", childrenArray = "this.children().toArray()", hasChildren = "!this.children().isEmpty()") @Deprecated +@NullMarked public abstract class AbstractComponent implements Component { protected final List children; protected final Style style; - protected AbstractComponent(final @NotNull List children, final @NotNull Style style) { + protected AbstractComponent(final List children, final Style style) { this.children = ComponentLike.asComponents(children, IS_NOT_EMPTY); this.style = style; } @Override - public final @NotNull List children() { + public final List children() { return this.children; } @Override - public final @NotNull Style style() { + public final Style style() { return this.style; } diff --git a/api/src/main/java/net/kyori/adventure/text/AbstractComponentBuilder.java b/api/src/main/java/net/kyori/adventure/text/AbstractComponentBuilder.java index d7efecbbed..e95ca1cdd1 100644 --- a/api/src/main/java/net/kyori/adventure/text/AbstractComponentBuilder.java +++ b/api/src/main/java/net/kyori/adventure/text/AbstractComponentBuilder.java @@ -36,8 +36,8 @@ import net.kyori.adventure.text.format.Style; import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextDecoration; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; @@ -47,6 +47,7 @@ * @param the component type * @param the builder type */ +@NullMarked abstract class AbstractComponentBuilder, B extends ComponentBuilder> implements ComponentBuilder { // We use an empty list by default to prevent unnecessary list creation for components with no children protected List children = Collections.emptyList(); @@ -61,7 +62,7 @@ abstract class AbstractComponentBuilder, B ex protected AbstractComponentBuilder() { } - protected AbstractComponentBuilder(final @NotNull C component) { + protected AbstractComponentBuilder(final C component) { final List children = component.children(); if (!children.isEmpty()) { this.children = new ArrayList<>(children); @@ -73,7 +74,7 @@ protected AbstractComponentBuilder(final @NotNull C component) { @Override @SuppressWarnings("unchecked") - public @NotNull B append(final @NotNull Component component) { + public B append(final Component component) { if (component == Component.empty()) return (B) this; this.prepareChildren(); this.children.add(requireNonNull(component, "component")); @@ -81,13 +82,13 @@ protected AbstractComponentBuilder(final @NotNull C component) { } @Override - public @NotNull B append(final @NotNull Component@NotNull... components) { + public B append(final Component... components) { return this.append((ComponentLike[]) components); } @Override @SuppressWarnings("unchecked") - public @NotNull B append(final @NotNull ComponentLike@NotNull... components) { + public B append(final ComponentLike... components) { requireNonNull(components, "components"); boolean prepared = false; for (int i = 0, length = components.length; i < length; i++) { @@ -105,7 +106,7 @@ protected AbstractComponentBuilder(final @NotNull C component) { @Override @SuppressWarnings("unchecked") - public @NotNull B append(final @NotNull Iterable components) { + public B append(final Iterable components) { requireNonNull(components, "components"); boolean prepared = false; for (final ComponentLike like : components) { @@ -129,7 +130,7 @@ private void prepareChildren() { @Override @SuppressWarnings("unchecked") - public @NotNull B applyDeep(final @NotNull Consumer> consumer) { + public B applyDeep(final Consumer> consumer) { this.apply(consumer); if (this.children == Collections.emptyList()) { return (B) this; @@ -149,7 +150,7 @@ private void prepareChildren() { @Override @SuppressWarnings("unchecked") - public @NotNull B mapChildren(final @NotNull Function, ? extends BuildableComponent> function) { + public B mapChildren(final Function, ? extends BuildableComponent> function) { if (this.children == Collections.emptyList()) { return (B) this; } @@ -170,7 +171,7 @@ private void prepareChildren() { @Override @SuppressWarnings("unchecked") - public @NotNull B mapChildrenDeep(final @NotNull Function, ? extends BuildableComponent> function) { + public B mapChildrenDeep(final Function, ? extends BuildableComponent> function) { if (this.children == Collections.emptyList()) { return (B) this; } @@ -196,13 +197,13 @@ private void prepareChildren() { } @Override - public @NotNull List children() { + public List children() { return Collections.unmodifiableList(this.children); } @Override @SuppressWarnings("unchecked") - public @NotNull B style(final @NotNull Style style) { + public B style(final Style style) { this.style = style; this.styleBuilder = null; return (B) this; @@ -210,83 +211,83 @@ private void prepareChildren() { @Override @SuppressWarnings("unchecked") - public @NotNull B style(final @NotNull Consumer consumer) { + public B style(final Consumer consumer) { consumer.accept(this.styleBuilder()); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B font(final @Nullable Key font) { + public B font(final @Nullable Key font) { this.styleBuilder().font(font); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B color(final @Nullable TextColor color) { + public B color(final @Nullable TextColor color) { this.styleBuilder().color(color); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B colorIfAbsent(final @Nullable TextColor color) { + public B colorIfAbsent(final @Nullable TextColor color) { this.styleBuilder().colorIfAbsent(color); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B decoration(final @NotNull TextDecoration decoration, final TextDecoration.@NotNull State state) { + public B decoration(final TextDecoration decoration, final TextDecoration.State state) { this.styleBuilder().decoration(decoration, state); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B decorationIfAbsent(final @NotNull TextDecoration decoration, final TextDecoration.@NotNull State state) { + public B decorationIfAbsent(final TextDecoration decoration, final TextDecoration.State state) { this.styleBuilder().decorationIfAbsent(decoration, state); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B clickEvent(final @Nullable ClickEvent event) { + public B clickEvent(final @Nullable ClickEvent event) { this.styleBuilder().clickEvent(event); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B hoverEvent(final @Nullable HoverEventSource source) { + public B hoverEvent(final @Nullable HoverEventSource source) { this.styleBuilder().hoverEvent(source); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B insertion(final @Nullable String insertion) { + public B insertion(final @Nullable String insertion) { this.styleBuilder().insertion(insertion); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B mergeStyle(final @NotNull Component that, final @NotNull Set merges) { + public B mergeStyle(final Component that, final Set merges) { this.styleBuilder().merge(requireNonNull(that, "component").style(), merges); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B resetStyle() { + public B resetStyle() { this.style = null; this.styleBuilder = null; return (B) this; } - private Style.@NotNull Builder styleBuilder() { + private Style.Builder styleBuilder() { if (this.styleBuilder == null) { if (this.style != null) { this.styleBuilder = this.style.toBuilder(); @@ -302,7 +303,7 @@ protected final boolean hasStyle() { return this.styleBuilder != null || this.style != null; } - protected @NotNull Style buildStyle() { + protected Style buildStyle() { if (this.styleBuilder != null) { return this.styleBuilder.build(); } else if (this.style != null) { diff --git a/api/src/main/java/net/kyori/adventure/text/AbstractNBTComponentBuilder.java b/api/src/main/java/net/kyori/adventure/text/AbstractNBTComponentBuilder.java index 806728ec48..1c4bf98358 100644 --- a/api/src/main/java/net/kyori/adventure/text/AbstractNBTComponentBuilder.java +++ b/api/src/main/java/net/kyori/adventure/text/AbstractNBTComponentBuilder.java @@ -23,11 +23,12 @@ */ package net.kyori.adventure.text; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked abstract class AbstractNBTComponentBuilder, B extends NBTComponentBuilder> extends AbstractComponentBuilder implements NBTComponentBuilder { protected @Nullable String nbtPath; protected boolean interpret = NBTComponentImpl.INTERPRET_DEFAULT; @@ -36,7 +37,7 @@ abstract class AbstractNBTComponentBuilder, B exten AbstractNBTComponentBuilder() { } - AbstractNBTComponentBuilder(final @NotNull C component) { + AbstractNBTComponentBuilder(final C component) { super(component); this.nbtPath = component.nbtPath(); this.interpret = component.interpret(); @@ -45,21 +46,21 @@ abstract class AbstractNBTComponentBuilder, B exten @Override @SuppressWarnings("unchecked") - public @NotNull B nbtPath(final @NotNull String nbtPath) { + public B nbtPath(final String nbtPath) { this.nbtPath = requireNonNull(nbtPath, "nbtPath"); return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B interpret(final boolean interpret) { + public B interpret(final boolean interpret) { this.interpret = interpret; return (B) this; } @Override @SuppressWarnings("unchecked") - public @NotNull B separator(final @Nullable ComponentLike separator) { + public B separator(final @Nullable ComponentLike separator) { this.separator = ComponentLike.unbox(separator); return (B) this; } diff --git a/api/src/main/java/net/kyori/adventure/text/BlockNBTComponent.java b/api/src/main/java/net/kyori/adventure/text/BlockNBTComponent.java index 76aaa7ad08..16ac365879 100644 --- a/api/src/main/java/net/kyori/adventure/text/BlockNBTComponent.java +++ b/api/src/main/java/net/kyori/adventure/text/BlockNBTComponent.java @@ -29,7 +29,7 @@ import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Given an in-game position, this component reads the NBT of the associated block and displays that information. @@ -46,6 +46,7 @@ * @since 4.0.0 * @sinceMinecraft 1.14 */ +@NullMarked public interface BlockNBTComponent extends NBTComponent, ScopedComponent { /** * Gets the block position. @@ -53,7 +54,7 @@ public interface BlockNBTComponent extends NBTComponent examinableProperties() { + default Stream examinableProperties() { return Stream.concat( Stream.of( ExaminableProperty.of("pos", this.pos()) @@ -145,7 +146,7 @@ interface Builder extends NBTComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder pos(final @NotNull Pos pos); + Builder pos(final Pos pos); /** * Sets the block position to a {@link LocalPos} with the given values. @@ -157,7 +158,7 @@ interface Builder extends NBTComponentBuilder { * @since 4.0.0 */ @Contract("_, _, _ -> this") - default @NotNull Builder localPos(final double left, final double up, final double forwards) { + default Builder localPos(final double left, final double up, final double forwards) { return this.pos(LocalPos.localPos(left, up, forwards)); } @@ -171,7 +172,7 @@ interface Builder extends NBTComponentBuilder { * @since 4.0.0 */ @Contract("_, _, _ -> this") - default @NotNull Builder worldPos(final WorldPos.@NotNull Coordinate x, final WorldPos.@NotNull Coordinate y, final WorldPos.@NotNull Coordinate z) { + default Builder worldPos(final WorldPos.Coordinate x, final WorldPos.Coordinate y, final WorldPos.Coordinate z) { return this.pos(WorldPos.worldPos(x, y, z)); } @@ -185,7 +186,7 @@ interface Builder extends NBTComponentBuilder { * @since 4.0.0 */ @Contract("_, _, _ -> this") - default @NotNull Builder absoluteWorldPos(final int x, final int y, final int z) { + default Builder absoluteWorldPos(final int x, final int y, final int z) { return this.worldPos(WorldPos.Coordinate.absolute(x), WorldPos.Coordinate.absolute(y), WorldPos.Coordinate.absolute(z)); } @@ -199,7 +200,7 @@ interface Builder extends NBTComponentBuilder { * @since 4.0.0 */ @Contract("_, _, _ -> this") - default @NotNull Builder relativeWorldPos(final int x, final int y, final int z) { + default Builder relativeWorldPos(final int x, final int y, final int z) { return this.worldPos(WorldPos.Coordinate.relative(x), WorldPos.Coordinate.relative(y), WorldPos.Coordinate.relative(z)); } } @@ -222,7 +223,7 @@ interface Pos extends Examinable { * @throws IllegalArgumentException if the position was in an invalid format * @since 4.0.0 */ - static @NotNull Pos fromString(final @NotNull String input) throws IllegalArgumentException { + static Pos fromString(final String input) throws IllegalArgumentException { final Matcher localMatch = BlockNBTComponentImpl.Tokens.LOCAL_PATTERN.matcher(input); if (localMatch.matches()) { return BlockNBTComponent.LocalPos.localPos( @@ -251,7 +252,7 @@ interface Pos extends Examinable { * @see #fromString(String) * @since 4.0.0 */ - @NotNull String asString(); + String asString(); } /** @@ -269,7 +270,7 @@ interface LocalPos extends Pos { * @return a local position * @since 4.10.0 */ - static @NotNull LocalPos localPos(final double left, final double up, final double forwards) { + static LocalPos localPos(final double left, final double up, final double forwards) { return new BlockNBTComponentImpl.LocalPosImpl(left, up, forwards); } @@ -285,7 +286,7 @@ interface LocalPos extends Pos { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - static @NotNull LocalPos of(final double left, final double up, final double forwards) { + static LocalPos of(final double left, final double up, final double forwards) { return new BlockNBTComponentImpl.LocalPosImpl(left, up, forwards); } @@ -329,7 +330,7 @@ interface WorldPos extends Pos { * @return a world position * @since 4.10.0 */ - static @NotNull WorldPos worldPos(final @NotNull Coordinate x, final @NotNull Coordinate y, final @NotNull Coordinate z) { + static WorldPos worldPos(final Coordinate x, final Coordinate y, final Coordinate z) { return new BlockNBTComponentImpl.WorldPosImpl(x, y, z); } @@ -345,7 +346,7 @@ interface WorldPos extends Pos { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - static @NotNull WorldPos of(final @NotNull Coordinate x, final @NotNull Coordinate y, final @NotNull Coordinate z) { + static WorldPos of(final Coordinate x, final Coordinate y, final Coordinate z) { return new BlockNBTComponentImpl.WorldPosImpl(x, y, z); } @@ -355,7 +356,7 @@ interface WorldPos extends Pos { * @return the x coordinate * @since 4.0.0 */ - @NotNull Coordinate x(); + Coordinate x(); /** * Gets the y coordinate. @@ -363,7 +364,7 @@ interface WorldPos extends Pos { * @return the y coordinate * @since 4.0.0 */ - @NotNull Coordinate y(); + Coordinate y(); /** * Gets the z coordinate. @@ -371,7 +372,7 @@ interface WorldPos extends Pos { * @return the z coordinate * @since 4.0.0 */ - @NotNull Coordinate z(); + Coordinate z(); /** * A coordinate component within a {@link WorldPos}. @@ -386,7 +387,7 @@ interface Coordinate extends Examinable { * @return a coordinate * @since 4.0.0 */ - static @NotNull Coordinate absolute(final int value) { + static Coordinate absolute(final int value) { return coordinate(value, Type.ABSOLUTE); } @@ -397,7 +398,7 @@ interface Coordinate extends Examinable { * @return a coordinate * @since 4.0.0 */ - static @NotNull Coordinate relative(final int value) { + static Coordinate relative(final int value) { return coordinate(value, Type.RELATIVE); } @@ -409,7 +410,7 @@ interface Coordinate extends Examinable { * @return a coordinate * @since 4.10.0 */ - static @NotNull Coordinate coordinate(final int value, final @NotNull Type type) { + static Coordinate coordinate(final int value, final Type type) { return new BlockNBTComponentImpl.WorldPosImpl.CoordinateImpl(value, type); } @@ -424,7 +425,7 @@ interface Coordinate extends Examinable { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - static @NotNull Coordinate of(final int value, final @NotNull Type type) { + static Coordinate of(final int value, final Type type) { return new BlockNBTComponentImpl.WorldPosImpl.CoordinateImpl(value, type); } @@ -442,7 +443,7 @@ interface Coordinate extends Examinable { * @return the type * @since 4.0.0 */ - @NotNull Type type(); + Type type(); /** * The type of a coordinate. diff --git a/api/src/main/java/net/kyori/adventure/text/BlockNBTComponentImpl.java b/api/src/main/java/net/kyori/adventure/text/BlockNBTComponentImpl.java index e653f27de3..14124cbe2c 100644 --- a/api/src/main/java/net/kyori/adventure/text/BlockNBTComponentImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/BlockNBTComponentImpl.java @@ -31,15 +31,16 @@ import net.kyori.adventure.text.format.Style; import net.kyori.adventure.util.ShadyPines; import net.kyori.examination.ExaminableProperty; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked final class BlockNBTComponentImpl extends NBTComponentImpl implements BlockNBTComponent { private final Pos pos; - static BlockNBTComponent create(final @NotNull List children, final @NotNull Style style, final String nbtPath, final boolean interpret, final @Nullable ComponentLike separator, final @NotNull Pos pos) { + static BlockNBTComponent create(final List children, final Style style, final String nbtPath, final boolean interpret, final @Nullable ComponentLike separator, final Pos pos) { return new BlockNBTComponentImpl( ComponentLike.asComponents(children, IS_NOT_EMPTY), requireNonNull(style, "style"), @@ -50,19 +51,19 @@ static BlockNBTComponent create(final @NotNull List chi ); } - BlockNBTComponentImpl(final @NotNull List children, final @NotNull Style style, final String nbtPath, final boolean interpret, final @Nullable Component separator, final @NotNull Pos pos) { + BlockNBTComponentImpl(final List children, final Style style, final String nbtPath, final boolean interpret, final @Nullable Component separator, final Pos pos) { super(children, style, nbtPath, interpret, separator); this.pos = pos; } @Override - public @NotNull BlockNBTComponent nbtPath(final @NotNull String nbtPath) { + public BlockNBTComponent nbtPath(final String nbtPath) { if (Objects.equals(this.nbtPath, nbtPath)) return this; return create(this.children, this.style, nbtPath, this.interpret, this.separator, this.pos); } @Override - public @NotNull BlockNBTComponent interpret(final boolean interpret) { + public BlockNBTComponent interpret(final boolean interpret) { if (this.interpret == interpret) return this; return create(this.children, this.style, this.nbtPath, interpret, this.separator, this.pos); } @@ -73,27 +74,27 @@ static BlockNBTComponent create(final @NotNull List chi } @Override - public @NotNull BlockNBTComponent separator(final @Nullable ComponentLike separator) { + public BlockNBTComponent separator(final @Nullable ComponentLike separator) { return create(this.children, this.style, this.nbtPath, this.interpret, separator, this.pos); } @Override - public @NotNull Pos pos() { + public Pos pos() { return this.pos; } @Override - public @NotNull BlockNBTComponent pos(final @NotNull Pos pos) { + public BlockNBTComponent pos(final Pos pos) { return create(this.children, this.style, this.nbtPath, this.interpret, this.separator, pos); } @Override - public @NotNull BlockNBTComponent children(final @NotNull List children) { + public BlockNBTComponent children(final List children) { return create(children, this.style, this.nbtPath, this.interpret, this.separator, this.pos); } @Override - public @NotNull BlockNBTComponent style(final @NotNull Style style) { + public BlockNBTComponent style(final Style style) { return create(this.children, style, this.nbtPath, this.interpret, this.separator, this.pos); } @@ -119,7 +120,7 @@ public String toString() { } @Override - public BlockNBTComponent.@NotNull Builder toBuilder() { + public BlockNBTComponent.Builder toBuilder() { return new BuilderImpl(this); } @@ -129,19 +130,19 @@ static final class BuilderImpl extends AbstractNBTComponentBuilder examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("left", this.left), ExaminableProperty.of("up", this.up), @@ -207,7 +208,7 @@ public String toString() { } @Override - public @NotNull String asString() { + public String asString() { return Tokens.serializeLocal(this.left) + ' ' + Tokens.serializeLocal(this.up) + ' ' + Tokens.serializeLocal(this.forwards); } } @@ -224,22 +225,22 @@ static final class WorldPosImpl implements WorldPos { } @Override - public @NotNull Coordinate x() { + public Coordinate x() { return this.x; } @Override - public @NotNull Coordinate y() { + public Coordinate y() { return this.y; } @Override - public @NotNull Coordinate z() { + public Coordinate z() { return this.z; } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("x", this.x), ExaminableProperty.of("y", this.y), @@ -271,7 +272,7 @@ public String toString() { } @Override - public @NotNull String asString() { + public String asString() { return Tokens.serializeCoordinate(this.x()) + ' ' + Tokens.serializeCoordinate(this.y()) + ' ' + Tokens.serializeCoordinate(this.z()); } @@ -279,7 +280,7 @@ static final class CoordinateImpl implements Coordinate { private final int value; private final Type type; - CoordinateImpl(final int value, final @NotNull Type type) { + CoordinateImpl(final int value, final Type type) { this.value = value; this.type = requireNonNull(type, "type"); } @@ -290,12 +291,12 @@ public int value() { } @Override - public @NotNull Type type() { + public Type type() { return this.type; } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("value", this.value), ExaminableProperty.of("type", this.type) diff --git a/api/src/main/java/net/kyori/adventure/text/BuildableComponent.java b/api/src/main/java/net/kyori/adventure/text/BuildableComponent.java index 9198a9d801..4c8ee906c8 100644 --- a/api/src/main/java/net/kyori/adventure/text/BuildableComponent.java +++ b/api/src/main/java/net/kyori/adventure/text/BuildableComponent.java @@ -24,7 +24,7 @@ package net.kyori.adventure.text; import net.kyori.adventure.util.Buildable; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * A component which may be built. @@ -33,6 +33,7 @@ * @param the builder type * @since 4.0.0 */ +@NullMarked public interface BuildableComponent, B extends ComponentBuilder> extends Buildable, Component { /** * Create a builder from this component. @@ -40,5 +41,5 @@ public interface BuildableComponent, B extend * @return the builder */ @Override - @NotNull B toBuilder(); + B toBuilder(); } 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 dd7e5d0622..5c7cdd5295 100644 --- a/api/src/main/java/net/kyori/adventure/text/Component.java +++ b/api/src/main/java/net/kyori/adventure/text/Component.java @@ -60,9 +60,9 @@ import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; @@ -107,6 +107,7 @@ * @since 4.0.0 */ @ApiStatus.NonExtendable +@NullMarked public interface Component extends ComponentBuilderApplicable, ComponentLike, Examinable, HoverEventSource, StyleGetter, StyleSetter { /** * A predicate that checks equality of two {@code Component}s using {@link Objects#equals(Object, Object)}. @@ -133,7 +134,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @return an empty component * @since 4.0.0 */ - static @NotNull TextComponent empty() { + static TextComponent empty() { return TextComponentImpl.EMPTY; } @@ -143,7 +144,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @return a text component with a new line character as the content * @since 4.0.0 */ - static @NotNull TextComponent newline() { + static TextComponent newline() { return TextComponentImpl.NEWLINE; } @@ -153,7 +154,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @return a text component with a single space as the content * @since 4.0.0 */ - static @NotNull TextComponent space() { + static TextComponent space() { return TextComponentImpl.SPACE; } @@ -169,7 +170,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Deprecated @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent join(final @NotNull ComponentLike separator, final @NotNull ComponentLike@NotNull... components) { + static TextComponent join(final ComponentLike separator, final ComponentLike... components) { return join(separator, Arrays.asList(components)); } @@ -185,7 +186,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Deprecated @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent join(final @NotNull ComponentLike separator, final Iterable components) { + static TextComponent join(final ComponentLike separator, final Iterable components) { final Component component = join(JoinConfiguration.separator(separator), components); if (component instanceof TextComponent) return (TextComponent) component; @@ -204,7 +205,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.14.0 */ @Contract(pure = true) - static @NotNull Component join(final JoinConfiguration.@NotNull Builder configBuilder, final @NotNull ComponentLike@NotNull... components) { + static Component join(final JoinConfiguration.Builder configBuilder, final ComponentLike... components) { return join(configBuilder, Arrays.asList(components)); } @@ -220,7 +221,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.14.0 */ @Contract(pure = true) - static @NotNull Component join(final JoinConfiguration.@NotNull Builder configBuilder, final @NotNull Iterable components) { + static Component join(final JoinConfiguration.Builder configBuilder, final Iterable components) { return JoinConfigurationImpl.join(configBuilder.build(), components); } @@ -236,7 +237,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.9.0 */ @Contract(pure = true) - static @NotNull Component join(final @NotNull JoinConfiguration config, final @NotNull ComponentLike@NotNull... components) { + static Component join(final JoinConfiguration config, final ComponentLike... components) { return join(config, Arrays.asList(components)); } @@ -252,7 +253,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.9.0 */ @Contract(pure = true) - static @NotNull Component join(final @NotNull JoinConfiguration config, final @NotNull Iterable components) { + static Component join(final JoinConfiguration config, final Iterable components) { return JoinConfigurationImpl.join(config, components); } @@ -262,7 +263,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @return a collector that can join components * @since 4.6.0 */ - static @NotNull Collector, Component> toComponent() { + static Collector, Component> toComponent() { return toComponent(Component.empty()); } @@ -273,7 +274,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @return a collector that can join components * @since 4.6.0 */ - static @NotNull Collector, Component> toComponent(final @NotNull Component separator) { + static Collector, Component> toComponent(final Component separator) { return Collector.of( Component::text, (builder, add) -> { @@ -307,7 +308,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(pure = true) - static BlockNBTComponent.@NotNull Builder blockNBT() { + static BlockNBTComponent.Builder blockNBT() { return new BlockNBTComponentImpl.BuilderImpl(); } @@ -319,7 +320,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract("_ -> new") - static @NotNull BlockNBTComponent blockNBT(final @NotNull Consumer consumer) { + static BlockNBTComponent blockNBT(final Consumer consumer) { return AbstractBuilder.configureAndBuild(blockNBT(), consumer); } @@ -332,7 +333,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull BlockNBTComponent blockNBT(final @NotNull String nbtPath, final BlockNBTComponent.@NotNull Pos pos) { + static BlockNBTComponent blockNBT(final String nbtPath, final BlockNBTComponent.Pos pos) { return blockNBT(nbtPath, NBTComponentImpl.INTERPRET_DEFAULT, pos); } @@ -346,7 +347,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull BlockNBTComponent blockNBT(final @NotNull String nbtPath, final boolean interpret, final BlockNBTComponent.@NotNull Pos pos) { + static BlockNBTComponent blockNBT(final String nbtPath, final boolean interpret, final BlockNBTComponent.Pos pos) { return blockNBT(nbtPath, interpret, null, pos); } @@ -361,7 +362,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull BlockNBTComponent blockNBT(final @NotNull String nbtPath, final boolean interpret, final @Nullable ComponentLike separator, final BlockNBTComponent.@NotNull Pos pos) { + static BlockNBTComponent blockNBT(final String nbtPath, final boolean interpret, final @Nullable ComponentLike separator, final BlockNBTComponent.Pos pos) { return BlockNBTComponentImpl.create(Collections.emptyList(), Style.empty(), nbtPath, interpret, separator, pos); } @@ -378,7 +379,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(pure = true) - static EntityNBTComponent.@NotNull Builder entityNBT() { + static EntityNBTComponent.Builder entityNBT() { return new EntityNBTComponentImpl.BuilderImpl(); } @@ -390,7 +391,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract("_ -> new") - static @NotNull EntityNBTComponent entityNBT(final @NotNull Consumer consumer) { + static EntityNBTComponent entityNBT(final Consumer consumer) { return AbstractBuilder.configureAndBuild(entityNBT(), consumer); } @@ -403,7 +404,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract("_, _ -> new") - static @NotNull EntityNBTComponent entityNBT(final @NotNull String nbtPath, final @NotNull String selector) { + static EntityNBTComponent entityNBT(final String nbtPath, final String selector) { return entityNBT().nbtPath(nbtPath).selector(selector).build(); } @@ -420,7 +421,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(pure = true) - static KeybindComponent.@NotNull Builder keybind() { + static KeybindComponent.Builder keybind() { return new KeybindComponentImpl.BuilderImpl(); } @@ -432,7 +433,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract("_ -> new") - static @NotNull KeybindComponent keybind(final @NotNull Consumer consumer) { + static KeybindComponent keybind(final Consumer consumer) { return AbstractBuilder.configureAndBuild(keybind(), consumer); } @@ -444,7 +445,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull KeybindComponent keybind(final @NotNull String keybind) { + static KeybindComponent keybind(final String keybind) { return keybind(keybind, Style.empty()); } @@ -456,7 +457,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.9.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull KeybindComponent keybind(final KeybindComponent.@NotNull KeybindLike keybind) { + static KeybindComponent keybind(final KeybindComponent.KeybindLike keybind) { return keybind(requireNonNull(keybind, "keybind").asKeybind(), Style.empty()); } @@ -469,7 +470,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull KeybindComponent keybind(final @NotNull String keybind, final @NotNull Style style) { + static KeybindComponent keybind(final String keybind, final Style style) { return KeybindComponentImpl.create(Collections.emptyList(), requireNonNull(style, "style"), keybind); } @@ -482,7 +483,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.9.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull KeybindComponent keybind(final KeybindComponent.@NotNull KeybindLike keybind, final @NotNull Style style) { + static KeybindComponent keybind(final KeybindComponent.KeybindLike keybind, final Style style) { return KeybindComponentImpl.create(Collections.emptyList(), requireNonNull(style, "style"), requireNonNull(keybind, "keybind").asKeybind()); } @@ -495,7 +496,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull KeybindComponent keybind(final @NotNull String keybind, final @Nullable TextColor color) { + static KeybindComponent keybind(final String keybind, final @Nullable TextColor color) { return keybind(keybind, Style.style(color)); } @@ -508,7 +509,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.9.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull KeybindComponent keybind(final KeybindComponent.@NotNull KeybindLike keybind, final @Nullable TextColor color) { + static KeybindComponent keybind(final KeybindComponent.KeybindLike keybind, final @Nullable TextColor color) { return keybind(requireNonNull(keybind, "keybind").asKeybind(), Style.style(color)); } @@ -522,7 +523,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull KeybindComponent keybind(final @NotNull String keybind, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static KeybindComponent keybind(final String keybind, final @Nullable TextColor color, final TextDecoration... decorations) { return keybind(keybind, Style.style(color, decorations)); } @@ -536,7 +537,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.9.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull KeybindComponent keybind(final KeybindComponent.@NotNull KeybindLike keybind, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static KeybindComponent keybind(final KeybindComponent.KeybindLike keybind, final @Nullable TextColor color, final TextDecoration... decorations) { return keybind(requireNonNull(keybind, "keybind").asKeybind(), Style.style(color, decorations)); } @@ -550,7 +551,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull KeybindComponent keybind(final @NotNull String keybind, final @Nullable TextColor color, final @NotNull Set decorations) { + static KeybindComponent keybind(final String keybind, final @Nullable TextColor color, final Set decorations) { return keybind(keybind, Style.style(color, decorations)); } @@ -564,7 +565,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.9.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull KeybindComponent keybind(final KeybindComponent.@NotNull KeybindLike keybind, final @Nullable TextColor color, final @NotNull Set decorations) { + static KeybindComponent keybind(final KeybindComponent.KeybindLike keybind, final @Nullable TextColor color, final Set decorations) { return keybind(requireNonNull(keybind, "keybind").asKeybind(), Style.style(color, decorations)); } @@ -581,7 +582,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(pure = true) - static ScoreComponent.@NotNull Builder score() { + static ScoreComponent.Builder score() { return new ScoreComponentImpl.BuilderImpl(); } @@ -593,7 +594,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract("_ -> new") - static @NotNull ScoreComponent score(final @NotNull Consumer consumer) { + static ScoreComponent score(final Consumer consumer) { return AbstractBuilder.configureAndBuild(score(), consumer); } @@ -606,7 +607,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull ScoreComponent score(final @NotNull String name, final @NotNull String objective) { + static ScoreComponent score(final String name, final String objective) { return score(name, objective, null); } @@ -622,7 +623,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex */ @Contract(value = "_, _, _ -> new", pure = true) @Deprecated - static @NotNull ScoreComponent score(final @NotNull String name, final @NotNull String objective, final @Nullable String value) { + static ScoreComponent score(final String name, final String objective, final @Nullable String value) { return ScoreComponentImpl.create(Collections.emptyList(), Style.empty(), name, objective, value); } @@ -639,7 +640,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(pure = true) - static SelectorComponent.@NotNull Builder selector() { + static SelectorComponent.Builder selector() { return new SelectorComponentImpl.BuilderImpl(); } @@ -651,7 +652,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract("_ -> new") - static @NotNull SelectorComponent selector(final @NotNull Consumer consumer) { + static SelectorComponent selector(final Consumer consumer) { return AbstractBuilder.configureAndBuild(selector(), consumer); } @@ -663,7 +664,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull SelectorComponent selector(final @NotNull String pattern) { + static SelectorComponent selector(final String pattern) { return selector(pattern, null); } @@ -676,7 +677,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull SelectorComponent selector(final @NotNull String pattern, final @Nullable ComponentLike separator) { + static SelectorComponent selector(final String pattern, final @Nullable ComponentLike separator) { return SelectorComponentImpl.create(Collections.emptyList(), Style.empty(), pattern, separator); } @@ -693,7 +694,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(pure = true) - static StorageNBTComponent.@NotNull Builder storageNBT() { + static StorageNBTComponent.Builder storageNBT() { return new StorageNBTComponentImpl.BuilderImpl(); } @@ -705,7 +706,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract("_ -> new") - static @NotNull StorageNBTComponent storageNBT(final @NotNull Consumer consumer) { + static StorageNBTComponent storageNBT(final Consumer consumer) { return AbstractBuilder.configureAndBuild(storageNBT(), consumer); } @@ -718,7 +719,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull StorageNBTComponent storageNBT(final @NotNull String nbtPath, final @NotNull Key storage) { + static StorageNBTComponent storageNBT(final String nbtPath, final Key storage) { return storageNBT(nbtPath, NBTComponentImpl.INTERPRET_DEFAULT, storage); } @@ -732,7 +733,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull StorageNBTComponent storageNBT(final @NotNull String nbtPath, final boolean interpret, final @NotNull Key storage) { + static StorageNBTComponent storageNBT(final String nbtPath, final boolean interpret, final Key storage) { return storageNBT(nbtPath, interpret, null, storage); } @@ -747,7 +748,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull StorageNBTComponent storageNBT(final @NotNull String nbtPath, final boolean interpret, final @Nullable ComponentLike separator, final @NotNull Key storage) { + static StorageNBTComponent storageNBT(final String nbtPath, final boolean interpret, final @Nullable ComponentLike separator, final Key storage) { return StorageNBTComponentImpl.create(Collections.emptyList(), Style.empty(), nbtPath, interpret, separator, storage); } @@ -764,7 +765,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(pure = true) - static TextComponent.@NotNull Builder text() { + static TextComponent.Builder text() { return new TextComponentImpl.BuilderImpl(); } @@ -775,7 +776,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @return a text component * @since 4.10.0 */ - static @NotNull TextComponent textOfChildren(final @NotNull ComponentLike@NotNull... components) { + static TextComponent textOfChildren(final ComponentLike... components) { if (components.length == 0) return empty(); return TextComponentImpl.create(Arrays.asList(components), Style.empty(), ""); } @@ -788,7 +789,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract("_ -> new") - static @NotNull TextComponent text(final @NotNull Consumer consumer) { + static TextComponent text(final Consumer consumer) { return AbstractBuilder.configureAndBuild(text(), consumer); } @@ -800,7 +801,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull TextComponent text(final @NotNull String content) { + static TextComponent text(final String content) { if (content.isEmpty()) return empty(); return text(content, Style.empty()); } @@ -814,7 +815,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final @NotNull String content, final @NotNull Style style) { + static TextComponent text(final String content, final Style style) { return TextComponentImpl.create(Collections.emptyList(), requireNonNull(style, "style"), content); } @@ -827,7 +828,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final @NotNull String content, final @Nullable TextColor color) { + static TextComponent text(final String content, final @Nullable TextColor color) { return text(content, Style.style(color)); } @@ -841,7 +842,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final @NotNull String content, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static TextComponent text(final String content, final @Nullable TextColor color, final TextDecoration... decorations) { return text(content, Style.style(color, decorations)); } @@ -855,7 +856,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final @NotNull String content, final @Nullable TextColor color, final @NotNull Set decorations) { + static TextComponent text(final String content, final @Nullable TextColor color, final Set decorations) { return text(content, Style.style(color, decorations)); } @@ -867,7 +868,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull TextComponent text(final boolean value) { + static TextComponent text(final boolean value) { return text(String.valueOf(value)); } @@ -880,7 +881,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final boolean value, final @NotNull Style style) { + static TextComponent text(final boolean value, final Style style) { return text(String.valueOf(value), style); } @@ -893,7 +894,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final boolean value, final @Nullable TextColor color) { + static TextComponent text(final boolean value, final @Nullable TextColor color) { return text(String.valueOf(value), color); } @@ -907,7 +908,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final boolean value, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static TextComponent text(final boolean value, final @Nullable TextColor color, final TextDecoration... decorations) { return text(String.valueOf(value), color, decorations); } @@ -921,7 +922,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final boolean value, final @Nullable TextColor color, final @NotNull Set decorations) { + static TextComponent text(final boolean value, final @Nullable TextColor color, final Set decorations) { return text(String.valueOf(value), color, decorations); } @@ -933,7 +934,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(pure = true) - static @NotNull TextComponent text(final char value) { + static TextComponent text(final char value) { if (value == '\n') return newline(); if (value == ' ') return space(); return text(String.valueOf(value)); @@ -948,7 +949,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final char value, final @NotNull Style style) { + static TextComponent text(final char value, final Style style) { return text(String.valueOf(value), style); } @@ -961,7 +962,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final char value, final @Nullable TextColor color) { + static TextComponent text(final char value, final @Nullable TextColor color) { return text(String.valueOf(value), color); } @@ -975,7 +976,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final char value, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static TextComponent text(final char value, final @Nullable TextColor color, final TextDecoration... decorations) { return text(String.valueOf(value), color, decorations); } @@ -989,7 +990,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final char value, final @Nullable TextColor color, final @NotNull Set decorations) { + static TextComponent text(final char value, final @Nullable TextColor color, final Set decorations) { return text(String.valueOf(value), color, decorations); } @@ -1001,7 +1002,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull TextComponent text(final double value) { + static TextComponent text(final double value) { return text(String.valueOf(value)); } @@ -1014,7 +1015,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final double value, final @NotNull Style style) { + static TextComponent text(final double value, final Style style) { return text(String.valueOf(value), style); } @@ -1027,7 +1028,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final double value, final @Nullable TextColor color) { + static TextComponent text(final double value, final @Nullable TextColor color) { return text(String.valueOf(value), color); } @@ -1041,7 +1042,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final double value, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static TextComponent text(final double value, final @Nullable TextColor color, final TextDecoration... decorations) { return text(String.valueOf(value), color, decorations); } @@ -1055,7 +1056,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final double value, final @Nullable TextColor color, final @NotNull Set decorations) { + static TextComponent text(final double value, final @Nullable TextColor color, final Set decorations) { return text(String.valueOf(value), color, decorations); } @@ -1067,7 +1068,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull TextComponent text(final float value) { + static TextComponent text(final float value) { return text(String.valueOf(value)); } @@ -1080,7 +1081,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final float value, final @NotNull Style style) { + static TextComponent text(final float value, final Style style) { return text(String.valueOf(value), style); } @@ -1093,7 +1094,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final float value, final @Nullable TextColor color) { + static TextComponent text(final float value, final @Nullable TextColor color) { return text(String.valueOf(value), color); } @@ -1107,7 +1108,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final float value, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static TextComponent text(final float value, final @Nullable TextColor color, final TextDecoration... decorations) { return text(String.valueOf(value), color, decorations); } @@ -1121,7 +1122,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final float value, final @Nullable TextColor color, final @NotNull Set decorations) { + static TextComponent text(final float value, final @Nullable TextColor color, final Set decorations) { return text(String.valueOf(value), color, decorations); } @@ -1133,7 +1134,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull TextComponent text(final int value) { + static TextComponent text(final int value) { return text(String.valueOf(value)); } @@ -1146,7 +1147,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final int value, final @NotNull Style style) { + static TextComponent text(final int value, final Style style) { return text(String.valueOf(value), style); } @@ -1159,7 +1160,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final int value, final @Nullable TextColor color) { + static TextComponent text(final int value, final @Nullable TextColor color) { return text(String.valueOf(value), color); } @@ -1173,7 +1174,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final int value, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static TextComponent text(final int value, final @Nullable TextColor color, final TextDecoration... decorations) { return text(String.valueOf(value), color, decorations); } @@ -1187,7 +1188,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final int value, final @Nullable TextColor color, final @NotNull Set decorations) { + static TextComponent text(final int value, final @Nullable TextColor color, final Set decorations) { return text(String.valueOf(value), color, decorations); } @@ -1199,7 +1200,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull TextComponent text(final long value) { + static TextComponent text(final long value) { return text(String.valueOf(value)); } @@ -1212,7 +1213,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final long value, final @NotNull Style style) { + static TextComponent text(final long value, final Style style) { return text(String.valueOf(value), style); } @@ -1225,7 +1226,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TextComponent text(final long value, final @Nullable TextColor color) { + static TextComponent text(final long value, final @Nullable TextColor color) { return text(String.valueOf(value), color); } @@ -1239,7 +1240,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final long value, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static TextComponent text(final long value, final @Nullable TextColor color, final TextDecoration... decorations) { return text(String.valueOf(value), color, decorations); } @@ -1253,7 +1254,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TextComponent text(final long value, final @Nullable TextColor color, final @NotNull Set decorations) { + static TextComponent text(final long value, final @Nullable TextColor color, final Set decorations) { return text(String.valueOf(value), color, decorations); } @@ -1270,7 +1271,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(pure = true) - static TranslatableComponent.@NotNull Builder translatable() { + static TranslatableComponent.Builder translatable() { return new TranslatableComponentImpl.BuilderImpl(); } @@ -1282,7 +1283,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract("_ -> new") - static @NotNull TranslatableComponent translatable(final @NotNull Consumer consumer) { + static TranslatableComponent translatable(final Consumer consumer) { return AbstractBuilder.configureAndBuild(translatable(), consumer); } @@ -1294,7 +1295,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key) { + static TranslatableComponent translatable(final String key) { return translatable(key, Style.empty()); } @@ -1306,7 +1307,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable) { + static TranslatableComponent translatable(final Translatable translatable) { return translatable(requireNonNull(translatable, "translatable").translationKey(), Style.empty()); } @@ -1320,7 +1321,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable String fallback) { + static TranslatableComponent translatable(final String key, final @Nullable String fallback) { return translatable(key, fallback, Style.empty()); } @@ -1334,7 +1335,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable String fallback) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable String fallback) { return translatable(requireNonNull(translatable, "translatable").translationKey(), fallback, Style.empty()); } @@ -1347,7 +1348,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @NotNull Style style) { + static TranslatableComponent translatable(final String key, final Style style) { return TranslatableComponentImpl.create(Collections.emptyList(), requireNonNull(style, "style"), key, null, Collections.emptyList()); } @@ -1360,7 +1361,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @NotNull Style style) { + static TranslatableComponent translatable(final Translatable translatable, final Style style) { return translatable(requireNonNull(translatable, "translatable").translationKey(), style); } @@ -1375,7 +1376,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable String fallback, final @NotNull Style style) { + static TranslatableComponent translatable(final String key, final @Nullable String fallback, final Style style) { return TranslatableComponentImpl.create(Collections.emptyList(), requireNonNull(style, "style"), key, fallback, Collections.emptyList()); } @@ -1390,7 +1391,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable String fallback, final @NotNull Style style) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable String fallback, final Style style) { return translatable(requireNonNull(translatable, "translatable").translationKey(), fallback, style); } @@ -1405,7 +1406,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable String fallback, final @NotNull StyleBuilderApplicable... style) { + static TranslatableComponent translatable(final String key, final @Nullable String fallback, final StyleBuilderApplicable... style) { return translatable(requireNonNull(key, "key"), fallback, Style.style(style)); } @@ -1420,7 +1421,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable String fallback, final @NotNull Iterable style) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable String fallback, final Iterable style) { return translatable(requireNonNull(translatable, "translatable").translationKey(), fallback, Style.style(style)); } @@ -1435,7 +1436,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable String fallback, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final String key, final @Nullable String fallback, final ComponentLike... args) { return translatable(key, fallback, Style.empty(), args); } @@ -1450,7 +1451,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable String fallback, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable String fallback, final ComponentLike... args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), fallback, args); } @@ -1466,7 +1467,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable String fallback, final @NotNull Style style, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final String key, final @Nullable String fallback, final Style style, final ComponentLike... args) { return TranslatableComponentImpl.create(Collections.emptyList(), requireNonNull(style, "style"), key, fallback, requireNonNull(args, "args")); } @@ -1482,7 +1483,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable String fallback, final @NotNull Style style, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable String fallback, final Style style, final ComponentLike... args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), fallback, style, args); } @@ -1498,7 +1499,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable String fallback, final @NotNull Style style, final @NotNull List args) { + static TranslatableComponent translatable(final String key, final @Nullable String fallback, final Style style, final List args) { return TranslatableComponentImpl.create(Collections.emptyList(), style, key, fallback, requireNonNull(args, "args")); } @@ -1514,7 +1515,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable String fallback, final @NotNull Style style, final @NotNull List args) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable String fallback, final Style style, final List args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), fallback, style, args); } @@ -1530,7 +1531,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable String fallback, final @NotNull List args, final @NotNull Iterable style) { + static TranslatableComponent translatable(final String key, final @Nullable String fallback, final List args, final Iterable style) { return TranslatableComponentImpl.create(Collections.emptyList(), Style.style(style), key, fallback, requireNonNull(args, "args")); } @@ -1546,7 +1547,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable String fallback, final @NotNull List args, final @NotNull Iterable style) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable String fallback, final List args, final Iterable style) { return translatable(requireNonNull(translatable, "translatable").translationKey(), fallback, args, style); } @@ -1562,7 +1563,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable String fallback, final @NotNull List args, final @NotNull StyleBuilderApplicable... style) { + static TranslatableComponent translatable(final String key, final @Nullable String fallback, final List args, final StyleBuilderApplicable... style) { return TranslatableComponentImpl.create(Collections.emptyList(), Style.style(style), key, fallback, requireNonNull(args, "args")); } @@ -1578,7 +1579,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @sinceMinecraft 1.19.4 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable String fallback, final @NotNull List args, final @NotNull StyleBuilderApplicable... style) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable String fallback, final List args, final StyleBuilderApplicable... style) { return translatable(requireNonNull(translatable, "translatable").translationKey(), fallback, args, style); } @@ -1591,7 +1592,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable TextColor color) { + static TranslatableComponent translatable(final String key, final @Nullable TextColor color) { return translatable(key, Style.style(color)); } @@ -1604,7 +1605,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable TextColor color) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable TextColor color) { return translatable(requireNonNull(translatable, "translatable").translationKey(), color); } @@ -1618,7 +1619,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static TranslatableComponent translatable(final String key, final @Nullable TextColor color, final TextDecoration... decorations) { return translatable(key, Style.style(color, decorations)); } @@ -1632,7 +1633,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable TextColor color, final TextDecoration@NotNull... decorations) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable TextColor color, final TextDecoration... decorations) { return translatable(requireNonNull(translatable, "translatable").translationKey(), color, decorations); } @@ -1646,7 +1647,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable TextColor color, final @NotNull Set decorations) { + static TranslatableComponent translatable(final String key, final @Nullable TextColor color, final Set decorations) { return translatable(key, Style.style(color, decorations)); } @@ -1660,7 +1661,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable TextColor color, final @NotNull Set decorations) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable TextColor color, final Set decorations) { return translatable(requireNonNull(translatable, "translatable").translationKey(), color, decorations); } @@ -1673,7 +1674,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final String key, final ComponentLike... args) { return translatable(key, Style.empty(), args); } @@ -1686,7 +1687,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final Translatable translatable, final ComponentLike... args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), args); } @@ -1700,7 +1701,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @NotNull Style style, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final String key, final Style style, final ComponentLike... args) { return TranslatableComponentImpl.create(Collections.emptyList(), requireNonNull(style, "style"), key, null, requireNonNull(args, "args")); } @@ -1714,7 +1715,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @NotNull Style style, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final Translatable translatable, final Style style, final ComponentLike... args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), style, args); } @@ -1728,7 +1729,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable TextColor color, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final String key, final @Nullable TextColor color, final ComponentLike... args) { return translatable(key, Style.style(color), args); } @@ -1742,7 +1743,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable TextColor color, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable TextColor color, final ComponentLike... args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), color, args); } @@ -1757,7 +1758,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable TextColor color, final @NotNull Set decorations, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final String key, final @Nullable TextColor color, final Set decorations, final ComponentLike... args) { return translatable(key, Style.style(color, decorations), args); } @@ -1772,7 +1773,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable TextColor color, final @NotNull Set decorations, final @NotNull ComponentLike@NotNull... args) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable TextColor color, final Set decorations, final ComponentLike... args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), color, decorations, args); } @@ -1785,7 +1786,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @NotNull List args) { + static TranslatableComponent translatable(final String key, final List args) { return TranslatableComponentImpl.create(Collections.emptyList(), Style.empty(), key, null, requireNonNull(args, "args")); } @@ -1798,7 +1799,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @NotNull List args) { + static TranslatableComponent translatable(final Translatable translatable, final List args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), args); } @@ -1812,7 +1813,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @NotNull Style style, final @NotNull List args) { + static TranslatableComponent translatable(final String key, final Style style, final List args) { return TranslatableComponentImpl.create(Collections.emptyList(), requireNonNull(style, "style"), key, null, requireNonNull(args, "args")); } @@ -1826,7 +1827,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.8.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @NotNull Style style, final @NotNull List args) { + static TranslatableComponent translatable(final Translatable translatable, final Style style, final List args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), style, args); } @@ -1840,7 +1841,7 @@ public interface Component extends ComponentBuilderApplicable, ComponentLike, Ex * @since 4.0.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static TranslatableComponent translatable(final @NotNull String key, final @Nullable TextColor color, final @NotNull List args) { + static TranslatableComponent translatable(final String key, final @Nullable TextColor color, final List args) { return translatable(key, Style.style(color), args); } @@ -1854,7 +1855,7 @@ static TranslatableComponent translatable(final @NotNull String key, final @Null * @since 4.8.0 */ @Contract(value = "_, _, _ -> new", pure = true) - static TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable TextColor color, final @NotNull List args) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable TextColor color, final List args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), color, args); } @@ -1869,7 +1870,7 @@ static TranslatableComponent translatable(final @NotNull Translatable translatab * @since 4.0.0 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull String key, final @Nullable TextColor color, final @NotNull Set decorations, final @NotNull List args) { + static TranslatableComponent translatable(final String key, final @Nullable TextColor color, final Set decorations, final List args) { return translatable(key, Style.style(color, decorations), args); } @@ -1884,7 +1885,7 @@ static TranslatableComponent translatable(final @NotNull Translatable translatab * @since 4.8.0 */ @Contract(value = "_, _, _, _ -> new", pure = true) - static @NotNull TranslatableComponent translatable(final @NotNull Translatable translatable, final @Nullable TextColor color, final @NotNull Set decorations, final @NotNull List args) { + static TranslatableComponent translatable(final Translatable translatable, final @Nullable TextColor color, final Set decorations, final List args) { return translatable(requireNonNull(translatable, "translatable").translationKey(), color, decorations, args); } @@ -1894,7 +1895,7 @@ static TranslatableComponent translatable(final @NotNull Translatable translatab * @return the unmodifiable list of children * @since 4.0.0 */ - @Unmodifiable @NotNull List children(); + @Unmodifiable List children(); /** * Sets the list of children. @@ -1906,7 +1907,7 @@ static TranslatableComponent translatable(final @NotNull Translatable translatab * @since 4.0.0 */ @Contract(pure = true) - @NotNull Component children(final @NotNull List children); + Component children(final List children); /** * Checks if this component contains a component. @@ -1919,7 +1920,7 @@ static TranslatableComponent translatable(final @NotNull Translatable translatab * component, {@code false} otherwise * @since 4.0.0 */ - default boolean contains(final @NotNull Component that) { + default boolean contains(final Component that) { return this.contains(that, EQUALS_IDENTITY); } @@ -1932,7 +1933,7 @@ default boolean contains(final @NotNull Component that) { * component, {@code false} otherwise * @since 4.8.0 */ - default boolean contains(final @NotNull Component that, final @NotNull BiPredicate equals) { + default boolean contains(final Component that, final BiPredicate equals) { if (equals.test(this, that)) return true; for (final Component child : this.children()) { if (child.contains(that, equals)) return true; @@ -1965,7 +1966,7 @@ default boolean contains(final @NotNull Component that, final @NotNull BiPredica */ @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Deprecated - default void detectCycle(final @NotNull Component that) { + default void detectCycle(final Component that) { if (that.contains(this)) { throw new IllegalStateException("Component cycle detected between " + this + " and " + that); } @@ -1979,7 +1980,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.0.0 */ @Contract(pure = true) - default @NotNull Component append(final @NotNull Component component) { + default Component append(final Component component) { return this.append((ComponentLike) component); } @@ -1990,7 +1991,7 @@ default void detectCycle(final @NotNull Component that) { * @return a component with the component added * @since 4.0.0 */ - default @NotNull Component append(final @NotNull ComponentLike like) { + default Component append(final ComponentLike like) { requireNonNull(like, "like"); final Component component = like.asComponent(); requireNonNull(component, "component"); @@ -2007,7 +2008,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.0.0 */ @Contract(pure = true) - default @NotNull Component append(final @NotNull ComponentBuilder builder) { + default Component append(final ComponentBuilder builder) { return this.append(builder.build()); } @@ -2018,7 +2019,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.12.0 */ @Contract(pure = true) - default @NotNull Component appendNewline() { + default Component appendNewline() { return this.append(newline()); } @@ -2029,7 +2030,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.12.0 */ @Contract(pure = true) - default @NotNull Component appendSpace() { + default Component appendSpace() { return this.append(space()); } @@ -2043,7 +2044,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.10.0 */ @Contract(pure = true) - default @NotNull Component applyFallbackStyle(final @NotNull Style style) { + default Component applyFallbackStyle(final Style style) { Objects.requireNonNull(style, "style"); return this.style(this.style().merge(style, Style.Merge.Strategy.IF_ABSENT_ON_TARGET)); } @@ -2058,7 +2059,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.10.0 */ @Contract(pure = true) - default @NotNull Component applyFallbackStyle(final @NotNull StyleBuilderApplicable@NotNull... style) { + default Component applyFallbackStyle(final StyleBuilderApplicable... style) { return this.applyFallbackStyle(Style.style(style)); } @@ -2068,7 +2069,7 @@ default void detectCycle(final @NotNull Component that) { * @return the style of this component * @since 4.0.0 */ - @NotNull Style style(); + Style style(); /** * Sets the style of this component. @@ -2078,7 +2079,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.0.0 */ @Contract(pure = true) - @NotNull Component style(final @NotNull Style style); + Component style(final Style style); /** * Sets the style of this component. @@ -2088,7 +2089,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.0.0 */ @Contract(pure = true) - default @NotNull Component style(final @NotNull Consumer consumer) { + default Component style(final Consumer consumer) { return this.style(this.style().edit(consumer)); } @@ -2101,7 +2102,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.0.0 */ @Contract(pure = true) - default @NotNull Component style(final @NotNull Consumer consumer, final Style.Merge.@NotNull Strategy strategy) { + default Component style(final Consumer consumer, final Style.Merge.Strategy strategy) { return this.style(this.style().edit(consumer, strategy)); } @@ -2113,7 +2114,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.0.0 */ @Contract(pure = true) - default @NotNull Component style(final Style.@NotNull Builder style) { + default Component style(final Style.Builder style) { return this.style(style.build()); } @@ -2125,7 +2126,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.0.0 */ @Contract(pure = true) - default @NotNull Component mergeStyle(final @NotNull Component that) { + default Component mergeStyle(final Component that) { return this.mergeStyle(that, Style.Merge.all()); } @@ -2138,7 +2139,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.0.0 */ @Contract(pure = true) - default @NotNull Component mergeStyle(final @NotNull Component that, final Style.@NotNull Merge@NotNull... merges) { + default Component mergeStyle(final Component that, final Style.Merge... merges) { return this.mergeStyle(that, Style.Merge.merges(merges)); } @@ -2151,7 +2152,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.0.0 */ @Contract(pure = true) - default @NotNull Component mergeStyle(final @NotNull Component that, final @NotNull Set merges) { + default Component mergeStyle(final Component that, final Set merges) { return this.style(this.style().merge(that.style(), merges)); } @@ -2174,7 +2175,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.10.0 */ @Override - default @NotNull Component font(final @Nullable Key key) { + default Component font(final @Nullable Key key) { return this.style(this.style().font(key)); } @@ -2198,7 +2199,7 @@ default void detectCycle(final @NotNull Component that) { */ @Contract(pure = true) @Override - default @NotNull Component color(final @Nullable TextColor color) { + default Component color(final @Nullable TextColor color) { return this.style(this.style().color(color)); } @@ -2211,7 +2212,7 @@ default void detectCycle(final @NotNull Component that) { */ @Contract(pure = true) @Override - default @NotNull Component colorIfAbsent(final @Nullable TextColor color) { + default Component colorIfAbsent(final @Nullable TextColor color) { if (this.color() == null) return this.color(color); return this; } @@ -2225,7 +2226,7 @@ default void detectCycle(final @NotNull Component that) { * @since 4.0.0 */ @Override - default boolean hasDecoration(final @NotNull TextDecoration decoration) { + default boolean hasDecoration(final TextDecoration decoration) { return StyleGetter.super.hasDecoration(decoration); } @@ -2238,7 +2239,7 @@ default boolean hasDecoration(final @NotNull TextDecoration decoration) { */ @Contract(pure = true) @Override - default @NotNull Component decorate(final @NotNull TextDecoration decoration) { + default Component decorate(final TextDecoration decoration) { return StyleSetter.super.decorate(decoration); } @@ -2252,7 +2253,7 @@ default boolean hasDecoration(final @NotNull TextDecoration decoration) { * @since 4.0.0 */ @Override - default TextDecoration.@NotNull State decoration(final @NotNull TextDecoration decoration) { + default TextDecoration.State decoration(final TextDecoration decoration) { return this.style().decoration(decoration); } @@ -2267,7 +2268,7 @@ default boolean hasDecoration(final @NotNull TextDecoration decoration) { */ @Contract(pure = true) @Override - default @NotNull Component decoration(final @NotNull TextDecoration decoration, final boolean flag) { + default Component decoration(final TextDecoration decoration, final boolean flag) { return StyleSetter.super.decoration(decoration, flag); } @@ -2284,7 +2285,7 @@ default boolean hasDecoration(final @NotNull TextDecoration decoration) { */ @Contract(pure = true) @Override - default @NotNull Component decoration(final @NotNull TextDecoration decoration, final TextDecoration.@NotNull State state) { + default Component decoration(final TextDecoration decoration, final TextDecoration.State state) { return this.style(this.style().decoration(decoration, state)); } @@ -2298,10 +2299,10 @@ default boolean hasDecoration(final @NotNull TextDecoration decoration) { * @since 4.12.0 */ @Override - default @NotNull Component decorationIfAbsent(final @NotNull TextDecoration decoration, final TextDecoration.@NotNull State state) { + default Component decorationIfAbsent(final TextDecoration decoration, final TextDecoration.State state) { requireNonNull(state, "state"); // Not delegating this method prevents object creation if decoration is NOT absent - final TextDecoration.@NotNull State oldState = this.decoration(decoration); + final TextDecoration.State oldState = this.decoration(decoration); if (oldState == TextDecoration.State.NOT_SET) { return this.style(this.style().decoration(decoration, state)); } @@ -2315,7 +2316,7 @@ default boolean hasDecoration(final @NotNull TextDecoration decoration) { * @since 4.0.0 */ @Override - default @NotNull Map decorations() { + default Map decorations() { return this.style().decorations(); } @@ -2330,7 +2331,7 @@ default boolean hasDecoration(final @NotNull TextDecoration decoration) { */ @Contract(pure = true) @Override - default @NotNull Component decorations(final @NotNull Map decorations) { + default Component decorations(final Map decorations) { return this.style(this.style().decorations(decorations)); } @@ -2354,7 +2355,7 @@ default boolean hasDecoration(final @NotNull TextDecoration decoration) { */ @Contract(pure = true) @Override - default @NotNull Component clickEvent(final @Nullable ClickEvent event) { + default Component clickEvent(final @Nullable ClickEvent event) { return this.style(this.style().clickEvent(event)); } @@ -2378,7 +2379,7 @@ default boolean hasDecoration(final @NotNull TextDecoration decoration) { */ @Contract(pure = true) @Override - default @NotNull Component hoverEvent(final @Nullable HoverEventSource source) { + default Component hoverEvent(final @Nullable HoverEventSource source) { return this.style(this.style().hoverEvent(source)); } @@ -2402,7 +2403,7 @@ default boolean hasDecoration(final @NotNull TextDecoration decoration) { */ @Contract(pure = true) @Override - default @NotNull Component insertion(final @Nullable String insertion) { + default Component insertion(final @Nullable String insertion) { return this.style(this.style().insertion(insertion)); } @@ -2425,7 +2426,7 @@ default boolean hasStyling() { * @since 4.2.0 */ @Contract(pure = true) - default @NotNull Component replaceText(final @NotNull Consumer configurer) { + default Component replaceText(final Consumer configurer) { requireNonNull(configurer, "configurer"); return this.replaceText(AbstractBuilder.configureAndBuild(TextReplacementConfig.builder(), configurer)); } @@ -2438,7 +2439,7 @@ default boolean hasStyling() { * @since 4.2.0 */ @Contract(pure = true) - default @NotNull Component replaceText(final @NotNull TextReplacementConfig config) { + default Component replaceText(final TextReplacementConfig config) { requireNonNull(config, "replacement"); if (!(config instanceof TextReplacementConfigImpl)) { throw new IllegalArgumentException("Provided replacement was a custom TextReplacementConfig implementation, which is not supported."); @@ -2452,7 +2453,7 @@ default boolean hasStyling() { * @return the optimized component * @since 4.9.0 */ - default @NotNull Component compact() { + default Component compact() { return ComponentCompaction.compact(this, null); } @@ -2464,7 +2465,7 @@ default boolean hasStyling() { * @return the iterable * @since 4.9.0 */ - default @NotNull Iterable iterable(final @NotNull ComponentIteratorType type, final @NotNull ComponentIteratorFlag@Nullable... flags) { + default Iterable iterable(final ComponentIteratorType type, final ComponentIteratorFlag@Nullable... flags) { return this.iterable(type, flags == null ? Collections.emptySet() : MonkeyBars.enumSet(ComponentIteratorFlag.class, flags)); } @@ -2476,7 +2477,7 @@ default boolean hasStyling() { * @return the iterable * @since 4.9.0 */ - default @NotNull Iterable iterable(final @NotNull ComponentIteratorType type, final @NotNull Set flags) { + default Iterable iterable(final ComponentIteratorType type, final Set flags) { requireNonNull(type, "type"); requireNonNull(flags, "flags"); return new ForwardingIterator<>(() -> this.iterator(type, flags), () -> this.spliterator(type, flags)); @@ -2492,7 +2493,7 @@ default boolean hasStyling() { * @return the iterator * @since 4.9.0 */ - default @NotNull Iterator iterator(final @NotNull ComponentIteratorType type, final @NotNull ComponentIteratorFlag@Nullable... flags) { + default Iterator iterator(final ComponentIteratorType type, final ComponentIteratorFlag@Nullable... flags) { return this.iterator(type, flags == null ? Collections.emptySet() : MonkeyBars.enumSet(ComponentIteratorFlag.class, flags)); } @@ -2506,7 +2507,7 @@ default boolean hasStyling() { * @return the iterator * @since 4.9.0 */ - default @NotNull Iterator iterator(final @NotNull ComponentIteratorType type, final @NotNull Set flags) { + default Iterator iterator(final ComponentIteratorType type, final Set flags) { return new ComponentIterator(this, requireNonNull(type, "type"), requireNonNull(flags, "flags")); } @@ -2520,7 +2521,7 @@ default boolean hasStyling() { * @return the spliterator * @since 4.9.0 */ - default @NotNull Spliterator spliterator(final @NotNull ComponentIteratorType type, final @NotNull ComponentIteratorFlag@Nullable... flags) { + default Spliterator spliterator(final ComponentIteratorType type, final ComponentIteratorFlag@Nullable... flags) { return this.spliterator(type, flags == null ? Collections.emptySet() : MonkeyBars.enumSet(ComponentIteratorFlag.class, flags)); } @@ -2534,7 +2535,7 @@ default boolean hasStyling() { * @return the spliterator * @since 4.9.0 */ - default @NotNull Spliterator spliterator(final @NotNull ComponentIteratorType type, final @NotNull Set flags) { + default Spliterator spliterator(final ComponentIteratorType type, final Set flags) { return Spliterators.spliteratorUnknownSize(this.iterator(type, flags), Spliterator.IMMUTABLE | Spliterator.NONNULL | Spliterator.ORDERED); } @@ -2550,7 +2551,7 @@ default boolean hasStyling() { @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Contract(pure = true) @Deprecated - default @NotNull Component replaceText(final @NotNull String search, final @Nullable ComponentLike replacement) { + default Component replaceText(final String search, final @Nullable ComponentLike replacement) { return this.replaceText(b -> b.matchLiteral(search).replacement(replacement)); } @@ -2566,7 +2567,7 @@ default boolean hasStyling() { @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Contract(pure = true) @Deprecated - default @NotNull Component replaceText(final @NotNull Pattern pattern, final @NotNull Function replacement) { + default Component replaceText(final Pattern pattern, final Function replacement) { return this.replaceText(b -> b.match(pattern).replacement(replacement)); } @@ -2582,7 +2583,7 @@ default boolean hasStyling() { @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Contract(pure = true) @Deprecated - default @NotNull Component replaceFirstText(final @NotNull String search, final @Nullable ComponentLike replacement) { + default Component replaceFirstText(final String search, final @Nullable ComponentLike replacement) { return this.replaceText(b -> b.matchLiteral(search).once().replacement(replacement)); } @@ -2598,7 +2599,7 @@ default boolean hasStyling() { @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Contract(pure = true) @Deprecated - default @NotNull Component replaceFirstText(final @NotNull Pattern pattern, final @NotNull Function replacement) { + default Component replaceFirstText(final Pattern pattern, final Function replacement) { return this.replaceText(b -> b.match(pattern).once().replacement(replacement)); } @@ -2615,7 +2616,7 @@ default boolean hasStyling() { @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Contract(pure = true) @Deprecated - default @NotNull Component replaceText(final @NotNull String search, final @Nullable ComponentLike replacement, final int numberOfReplacements) { + default Component replaceText(final String search, final @Nullable ComponentLike replacement, final int numberOfReplacements) { return this.replaceText(b -> b.matchLiteral(search).times(numberOfReplacements).replacement(replacement)); } @@ -2632,7 +2633,7 @@ default boolean hasStyling() { @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Contract(pure = true) @Deprecated - default @NotNull Component replaceText(final @NotNull Pattern pattern, final @NotNull Function replacement, final int numberOfReplacements) { + default Component replaceText(final Pattern pattern, final Function replacement, final int numberOfReplacements) { return this.replaceText(b -> b.match(pattern).times(numberOfReplacements).replacement(replacement)); } @@ -2651,7 +2652,7 @@ default boolean hasStyling() { @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Contract(pure = true) @Deprecated - default @NotNull Component replaceText(final @NotNull String search, final @Nullable ComponentLike replacement, final @NotNull IntFunction2 fn) { + default Component replaceText(final String search, final @Nullable ComponentLike replacement, final IntFunction2 fn) { return this.replaceText(b -> b.matchLiteral(search).replacement(replacement).condition(fn)); } @@ -2670,27 +2671,27 @@ default boolean hasStyling() { @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") @Contract(pure = true) @Deprecated - default @NotNull Component replaceText(final @NotNull Pattern pattern, final @NotNull Function replacement, final @NotNull IntFunction2 fn) { + default Component replaceText(final Pattern pattern, final Function replacement, final IntFunction2 fn) { return this.replaceText(b -> b.match(pattern).replacement(replacement).condition(fn)); } @Override - default void componentBuilderApply(final @NotNull ComponentBuilder component) { + default void componentBuilderApply(final ComponentBuilder component) { component.append(this); } @Override - default @NotNull Component asComponent() { + default Component asComponent() { return this; } @Override - default @NotNull HoverEvent asHoverEvent(final @NotNull UnaryOperator op) { + default HoverEvent asHoverEvent(final UnaryOperator op) { return HoverEvent.showText(op.apply(this)); } @Override - default @NotNull Stream examinableProperties() { + default Stream examinableProperties() { return Stream.of( ExaminableProperty.of("style", this.style()), ExaminableProperty.of(ComponentInternals.CHILDREN_PROPERTY, this.children()) diff --git a/api/src/main/java/net/kyori/adventure/text/ComponentApplicable.java b/api/src/main/java/net/kyori/adventure/text/ComponentApplicable.java index ed831c642b..98da6d2304 100644 --- a/api/src/main/java/net/kyori/adventure/text/ComponentApplicable.java +++ b/api/src/main/java/net/kyori/adventure/text/ComponentApplicable.java @@ -23,7 +23,7 @@ */ package net.kyori.adventure.text; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Something that can be applied to a {@link Component}. @@ -31,6 +31,7 @@ * @since 4.0.0 */ @FunctionalInterface +@NullMarked public interface ComponentApplicable { /** * Applies to {@code component}. @@ -39,5 +40,5 @@ public interface ComponentApplicable { * @return a component with something applied. * @since 4.0.0 */ - @NotNull Component componentApply(final @NotNull Component component); + Component componentApply(final Component component); } diff --git a/api/src/main/java/net/kyori/adventure/text/ComponentBuilder.java b/api/src/main/java/net/kyori/adventure/text/ComponentBuilder.java index ccd7429a3f..5fb88cdd44 100644 --- a/api/src/main/java/net/kyori/adventure/text/ComponentBuilder.java +++ b/api/src/main/java/net/kyori/adventure/text/ComponentBuilder.java @@ -39,8 +39,8 @@ import net.kyori.adventure.util.Buildable; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A component builder. @@ -50,6 +50,7 @@ * @since 4.0.0 */ @ApiStatus.NonExtendable +@NullMarked public interface ComponentBuilder, B extends ComponentBuilder> extends AbstractBuilder, Buildable.Builder, ComponentBuilderApplicable, ComponentLike, MutableStyleSetter { /** * Appends a component to this component. @@ -59,7 +60,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B append(final @NotNull Component component); + B append(final Component component); /** * Appends a component to this component. @@ -69,7 +70,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - default @NotNull B append(final @NotNull ComponentLike component) { + default B append(final ComponentLike component) { return this.append(component.asComponent()); } @@ -81,7 +82,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - default @NotNull B append(final @NotNull ComponentBuilder builder) { + default B append(final ComponentBuilder builder) { return this.append(builder.build()); } @@ -93,7 +94,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B append(final @NotNull Component@NotNull... components); + B append(final Component... components); /** * Appends components to this component. @@ -103,7 +104,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B append(final @NotNull ComponentLike@NotNull... components); + B append(final ComponentLike... components); /** * Appends components to this component. @@ -113,7 +114,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B append(final @NotNull Iterable components); + B append(final Iterable components); /** * Appends a newline to this component. @@ -121,7 +122,7 @@ public interface ComponentBuilder, B extends * @return this builder * @since 4.12.0 */ - default @NotNull B appendNewline() { + default B appendNewline() { return this.append(Component.newline()); } @@ -131,7 +132,7 @@ public interface ComponentBuilder, B extends * @return this builder * @since 4.12.0 */ - default @NotNull B appendSpace() { + default B appendSpace() { return this.append(Component.space()); } @@ -144,7 +145,7 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @SuppressWarnings("unchecked") - default @NotNull B apply(final @NotNull Consumer> consumer) { + default B apply(final Consumer> consumer) { consumer.accept(this); return (B) this; } @@ -158,7 +159,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B applyDeep(final @NotNull Consumer> action); + B applyDeep(final Consumer> action); /** * Replaces each child of this component with the resultant component from the function. @@ -168,7 +169,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B mapChildren(final @NotNull Function, ? extends BuildableComponent> function); + B mapChildren(final Function, ? extends BuildableComponent> function); /** * Replaces each child and sub-child of this component with the resultant @@ -179,7 +180,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B mapChildrenDeep(final @NotNull Function, ? extends BuildableComponent> function); + B mapChildrenDeep(final Function, ? extends BuildableComponent> function); /** * Get an unmodifiable list containing all children currently in this builder. @@ -187,7 +188,7 @@ public interface ComponentBuilder, B extends * @return the list of children * @since 4.6.0 */ - @NotNull List children(); + List children(); /** * Sets the style. @@ -197,7 +198,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B style(final @NotNull Style style); + B style(final Style style); /** * Configures the style. @@ -207,7 +208,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B style(final @NotNull Consumer consumer); + B style(final Consumer consumer); /** * Sets the font of this component. @@ -218,7 +219,7 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @Override - @NotNull B font(final @Nullable Key font); + B font(final @Nullable Key font); /** * Sets the color of this component. @@ -229,7 +230,7 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @Override - @NotNull B color(final @Nullable TextColor color); + B color(final @Nullable TextColor color); /** * Sets the color of this component if there isn't one set already. @@ -240,7 +241,7 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @Override - @NotNull B colorIfAbsent(final @Nullable TextColor color); + B colorIfAbsent(final @Nullable TextColor color); /** * Sets the state of a set of decorations to {@code flag} on this component. @@ -253,7 +254,7 @@ public interface ComponentBuilder, B extends */ @Contract("_, _ -> this") @Override - default @NotNull B decorations(final @NotNull Set decorations, final boolean flag) { + default B decorations(final Set decorations, final boolean flag) { return MutableStyleSetter.super.decorations(decorations, flag); } @@ -266,7 +267,7 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @Override - default @NotNull B decorate(final @NotNull TextDecoration decoration) { + default B decorate(final TextDecoration decoration) { return this.decoration(decoration, TextDecoration.State.TRUE); } @@ -279,7 +280,7 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @Override - default @NotNull B decorate(final @NotNull TextDecoration@NotNull... decorations) { + default B decorate(final TextDecoration... decorations) { return MutableStyleSetter.super.decorate(decorations); } @@ -294,7 +295,7 @@ public interface ComponentBuilder, B extends */ @Contract("_, _ -> this") @Override - default @NotNull B decoration(final @NotNull TextDecoration decoration, final boolean flag) { + default B decoration(final TextDecoration decoration, final boolean flag) { return this.decoration(decoration, TextDecoration.State.byBoolean(flag)); } @@ -309,7 +310,7 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @Override - default @NotNull B decorations(final @NotNull Map decorations) { + default B decorations(final Map decorations) { return MutableStyleSetter.super.decorations(decorations); } @@ -326,7 +327,7 @@ public interface ComponentBuilder, B extends */ @Contract("_, _ -> this") @Override - @NotNull B decoration(final @NotNull TextDecoration decoration, final TextDecoration.@NotNull State state); + B decoration(final TextDecoration decoration, final TextDecoration.State state); /** * Sets the state of a decoration on this component to {@code state} if the current state of @@ -339,7 +340,7 @@ public interface ComponentBuilder, B extends */ @Contract("_, _ -> this") @Override - @NotNull B decorationIfAbsent(final @NotNull TextDecoration decoration, final TextDecoration.@NotNull State state); + B decorationIfAbsent(final TextDecoration decoration, final TextDecoration.State state); /** * Sets the click event of this component. @@ -350,7 +351,7 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @Override - @NotNull B clickEvent(final @Nullable ClickEvent event); + B clickEvent(final @Nullable ClickEvent event); /** * Sets the hover event of this component. @@ -361,7 +362,7 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @Override - @NotNull B hoverEvent(final @Nullable HoverEventSource source); + B hoverEvent(final @Nullable HoverEventSource source); /** * Sets the string to be inserted when this component is shift-clicked. @@ -372,7 +373,7 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @Override - @NotNull B insertion(final @Nullable String insertion); + B insertion(final @Nullable String insertion); /** * Merges styling from another component into this component. @@ -382,7 +383,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_ -> this") - default @NotNull B mergeStyle(final @NotNull Component that) { + default B mergeStyle(final Component that) { return this.mergeStyle(that, Style.Merge.all()); } @@ -395,7 +396,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_, _ -> this") - default @NotNull B mergeStyle(final @NotNull Component that, final Style.@NotNull Merge@NotNull... merges) { + default B mergeStyle(final Component that, final Style.Merge... merges) { return this.mergeStyle(that, Style.Merge.merges(merges)); } @@ -408,7 +409,7 @@ public interface ComponentBuilder, B extends * @since 4.0.0 */ @Contract("_, _ -> this") - @NotNull B mergeStyle(final @NotNull Component that, final @NotNull Set merges); + B mergeStyle(final Component that, final Set merges); /** * Resets all styling on this component. @@ -416,7 +417,7 @@ public interface ComponentBuilder, B extends * @return this builder * @since 4.0.0 */ - @NotNull B resetStyle(); + B resetStyle(); /** * Build a component. @@ -424,7 +425,7 @@ public interface ComponentBuilder, B extends * @return the component */ @Override - @NotNull C build(); + C build(); /** * Applies {@code applicable}. @@ -435,18 +436,18 @@ public interface ComponentBuilder, B extends */ @Contract("_ -> this") @SuppressWarnings("unchecked") - default @NotNull B applicableApply(final @NotNull ComponentBuilderApplicable applicable) { + default B applicableApply(final ComponentBuilderApplicable applicable) { applicable.componentBuilderApply(this); return (B) this; } @Override - default void componentBuilderApply(final @NotNull ComponentBuilder component) { + default void componentBuilderApply(final ComponentBuilder component) { component.append(this); } @Override - default @NotNull Component asComponent() { + default Component asComponent() { return this.build(); } } diff --git a/api/src/main/java/net/kyori/adventure/text/ComponentBuilderApplicable.java b/api/src/main/java/net/kyori/adventure/text/ComponentBuilderApplicable.java index 9a93a2c8fa..f67e97de26 100644 --- a/api/src/main/java/net/kyori/adventure/text/ComponentBuilderApplicable.java +++ b/api/src/main/java/net/kyori/adventure/text/ComponentBuilderApplicable.java @@ -25,7 +25,7 @@ import net.kyori.adventure.text.format.StyleBuilderApplicable; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Something that can be applied to a {@link ComponentBuilder}. @@ -34,6 +34,7 @@ * @since 4.0.0 */ @FunctionalInterface +@NullMarked public interface ComponentBuilderApplicable { /** * Applies to {@code component}. @@ -42,5 +43,5 @@ public interface ComponentBuilderApplicable { * @since 4.0.0 */ @Contract(mutates = "param") - void componentBuilderApply(final @NotNull ComponentBuilder component); + void componentBuilderApply(final ComponentBuilder component); } diff --git a/api/src/main/java/net/kyori/adventure/text/ComponentCompaction.java b/api/src/main/java/net/kyori/adventure/text/ComponentCompaction.java index a0300af285..e3937b659f 100644 --- a/api/src/main/java/net/kyori/adventure/text/ComponentCompaction.java +++ b/api/src/main/java/net/kyori/adventure/text/ComponentCompaction.java @@ -29,10 +29,11 @@ import java.util.Objects; import net.kyori.adventure.text.format.Style; import net.kyori.adventure.text.format.TextDecoration; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class ComponentCompaction { @VisibleForTesting static final boolean SIMPLIFY_STYLE_FOR_BLANK_COMPONENTS = false; @@ -40,7 +41,7 @@ final class ComponentCompaction { private ComponentCompaction() { } - static Component compact(final @NotNull Component self, final @Nullable Style parentStyle) { + static Component compact(final Component self, final @Nullable Style parentStyle) { final List children = self.children(); Component optimized = self.children(Collections.emptyList()); if (parentStyle != null) { @@ -185,7 +186,7 @@ private static boolean isBlank(final Component component) { * @param parentStyle style from component's parents, for context * @return a new, simplified style */ - private static @NotNull Style simplifyStyleForBlank(final @NotNull Style style, final @Nullable Style parentStyle) { + private static Style simplifyStyleForBlank(final Style style, final @Nullable Style parentStyle) { if (!SIMPLIFY_STYLE_FOR_BLANK_COMPONENTS) { // todo: can this be fixed a better way? // https://github.com/KyoriPowered/adventure/issues/849 diff --git a/api/src/main/java/net/kyori/adventure/text/ComponentIterator.java b/api/src/main/java/net/kyori/adventure/text/ComponentIterator.java index 9d9dc7ce50..9dea060ae3 100644 --- a/api/src/main/java/net/kyori/adventure/text/ComponentIterator.java +++ b/api/src/main/java/net/kyori/adventure/text/ComponentIterator.java @@ -28,15 +28,16 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Set; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; +@NullMarked final class ComponentIterator implements Iterator { private Component component; private final ComponentIteratorType type; private final Set flags; private final Deque deque; - ComponentIterator(final @NotNull Component component, final @NotNull ComponentIteratorType type, final @NotNull Set flags) { + ComponentIterator(final Component component, final ComponentIteratorType type, final Set flags) { this.component = component; this.type = type; this.flags = flags; diff --git a/api/src/main/java/net/kyori/adventure/text/ComponentIteratorType.java b/api/src/main/java/net/kyori/adventure/text/ComponentIteratorType.java index 404d5bbb65..1211083e49 100644 --- a/api/src/main/java/net/kyori/adventure/text/ComponentIteratorType.java +++ b/api/src/main/java/net/kyori/adventure/text/ComponentIteratorType.java @@ -28,7 +28,7 @@ import java.util.Set; import net.kyori.adventure.text.event.HoverEvent; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * The iterator types. @@ -40,6 +40,7 @@ */ @ApiStatus.NonExtendable @FunctionalInterface +@NullMarked public interface ComponentIteratorType { /** * A depth-first iteration. @@ -104,5 +105,5 @@ public interface ComponentIteratorType { * @param flags the flags * @since 4.9.0 */ - void populate(final @NotNull Component component, final @NotNull Deque deque, final @NotNull Set flags); + void populate(final Component component, final Deque deque, final Set flags); } diff --git a/api/src/main/java/net/kyori/adventure/text/ComponentLike.java b/api/src/main/java/net/kyori/adventure/text/ComponentLike.java index 3d6e7d8e9a..ea48859b98 100644 --- a/api/src/main/java/net/kyori/adventure/text/ComponentLike.java +++ b/api/src/main/java/net/kyori/adventure/text/ComponentLike.java @@ -28,8 +28,8 @@ import java.util.List; import java.util.function.Predicate; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; @@ -39,6 +39,7 @@ * @since 4.0.0 */ @FunctionalInterface +@NullMarked public interface ComponentLike { /** * Converts a list of {@link ComponentLike}s to a list of {@link Component}s. @@ -47,7 +48,7 @@ public interface ComponentLike { * @return the components * @since 4.8.0 */ - static @NotNull List asComponents(final @NotNull List likes) { + static List asComponents(final List likes) { return asComponents(likes, null); } @@ -61,7 +62,7 @@ public interface ComponentLike { * @return the components * @since 4.8.0 */ - static @NotNull List asComponents(final @NotNull List likes, final @Nullable Predicate filter) { + static List asComponents(final List likes, final @Nullable Predicate filter) { requireNonNull(likes, "likes"); final int size = likes.size(); if (size == 0) { @@ -109,5 +110,5 @@ public interface ComponentLike { * @since 4.0.0 */ @Contract(pure = true) - @NotNull Component asComponent(); + Component asComponent(); } diff --git a/api/src/main/java/net/kyori/adventure/text/EntityNBTComponent.java b/api/src/main/java/net/kyori/adventure/text/EntityNBTComponent.java index 759cdab325..7dabdcb330 100644 --- a/api/src/main/java/net/kyori/adventure/text/EntityNBTComponent.java +++ b/api/src/main/java/net/kyori/adventure/text/EntityNBTComponent.java @@ -26,7 +26,7 @@ import java.util.stream.Stream; import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Given a Minecraft selector, this component reads the NBT of the associated entity and displays that information. @@ -43,6 +43,7 @@ * @since 4.0.0 * @sinceMinecraft 1.14 */ +@NullMarked public interface EntityNBTComponent extends NBTComponent, ScopedComponent { /** * Gets the entity selector. @@ -50,7 +51,7 @@ public interface EntityNBTComponent extends NBTComponent examinableProperties() { + default Stream examinableProperties() { return Stream.concat( Stream.of( ExaminableProperty.of("selector", this.selector()) @@ -86,6 +87,6 @@ interface Builder extends NBTComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder selector(final @NotNull String selector); + Builder selector(final String selector); } } diff --git a/api/src/main/java/net/kyori/adventure/text/EntityNBTComponentImpl.java b/api/src/main/java/net/kyori/adventure/text/EntityNBTComponentImpl.java index 2e56672fc0..bd24d70c07 100644 --- a/api/src/main/java/net/kyori/adventure/text/EntityNBTComponentImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/EntityNBTComponentImpl.java @@ -27,15 +27,16 @@ import java.util.Objects; import net.kyori.adventure.internal.Internals; import net.kyori.adventure.text.format.Style; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked final class EntityNBTComponentImpl extends NBTComponentImpl implements EntityNBTComponent { private final String selector; - static EntityNBTComponent create(final @NotNull List children, final @NotNull Style style, final String nbtPath, final boolean interpret, final @Nullable ComponentLike separator, final String selector) { + static EntityNBTComponent create(final List children, final Style style, final String nbtPath, final boolean interpret, final @Nullable ComponentLike separator, final String selector) { return new EntityNBTComponentImpl( ComponentLike.asComponents(children, IS_NOT_EMPTY), requireNonNull(style, "style"), @@ -46,19 +47,19 @@ static EntityNBTComponent create(final @NotNull List ch ); } - EntityNBTComponentImpl(final @NotNull List children, final @NotNull Style style, final String nbtPath, final boolean interpret, final @Nullable Component separator, final String selector) { + EntityNBTComponentImpl(final List children, final Style style, final String nbtPath, final boolean interpret, final @Nullable Component separator, final String selector) { super(children, style, nbtPath, interpret, separator); this.selector = selector; } @Override - public @NotNull EntityNBTComponent nbtPath(final @NotNull String nbtPath) { + public EntityNBTComponent nbtPath(final String nbtPath) { if (Objects.equals(this.nbtPath, nbtPath)) return this; return create(this.children, this.style, nbtPath, this.interpret, this.separator, this.selector); } @Override - public @NotNull EntityNBTComponent interpret(final boolean interpret) { + public EntityNBTComponent interpret(final boolean interpret) { if (this.interpret == interpret) return this; return create(this.children, this.style, this.nbtPath, interpret, this.separator, this.selector); } @@ -69,28 +70,28 @@ static EntityNBTComponent create(final @NotNull List ch } @Override - public @NotNull EntityNBTComponent separator(final @Nullable ComponentLike separator) { + public EntityNBTComponent separator(final @Nullable ComponentLike separator) { return create(this.children, this.style, this.nbtPath, this.interpret, separator, this.selector); } @Override - public @NotNull String selector() { + public String selector() { return this.selector; } @Override - public @NotNull EntityNBTComponent selector(final @NotNull String selector) { + public EntityNBTComponent selector(final String selector) { if (Objects.equals(this.selector, selector)) return this; return create(this.children, this.style, this.nbtPath, this.interpret, this.separator, selector); } @Override - public @NotNull EntityNBTComponent children(final @NotNull List children) { + public EntityNBTComponent children(final List children) { return create(children, this.style, this.nbtPath, this.interpret, this.separator, this.selector); } @Override - public @NotNull EntityNBTComponent style(final @NotNull Style style) { + public EntityNBTComponent style(final Style style) { return create(this.children, style, this.nbtPath, this.interpret, this.separator, this.selector); } @@ -116,7 +117,7 @@ public String toString() { } @Override - public EntityNBTComponent.@NotNull Builder toBuilder() { + public EntityNBTComponent.Builder toBuilder() { return new BuilderImpl(this); } @@ -126,19 +127,19 @@ static final class BuilderImpl extends AbstractNBTComponentBuilder, Examinable { /** * Creates a new builder. @@ -91,7 +92,7 @@ public interface JoinConfiguration extends Buildable convertor(); + Function convertor(); /** * Gets the predicate of this join configuration. @@ -244,7 +245,7 @@ public interface JoinConfiguration extends Buildable predicate(); + Predicate predicate(); /** * Gets the style of the parent component that contains the joined components. @@ -252,7 +253,7 @@ public interface JoinConfiguration extends Buildable, Buildable.Builder< * @since 4.9.0 */ @Contract("_ -> this") - @NotNull Builder prefix(final @Nullable ComponentLike prefix); + Builder prefix(final @Nullable ComponentLike prefix); /** * Sets the suffix of this join configuration builder. @@ -278,7 +279,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder< * @since 4.9.0 */ @Contract("_ -> this") - @NotNull Builder suffix(final @Nullable ComponentLike suffix); + Builder suffix(final @Nullable ComponentLike suffix); /** * Sets the separator of this join configuration builder. @@ -288,7 +289,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder< * @since 4.9.0 */ @Contract("_ -> this") - @NotNull Builder separator(final @Nullable ComponentLike separator); + Builder separator(final @Nullable ComponentLike separator); /** * Sets the last separator of this join configuration builder. @@ -298,7 +299,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder< * @since 4.9.0 */ @Contract("_ -> this") - @NotNull Builder lastSeparator(final @Nullable ComponentLike lastSeparator); + Builder lastSeparator(final @Nullable ComponentLike lastSeparator); /** * Sets the last separator that will be used instead of the normal last separator in the case where there @@ -311,7 +312,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder< * @since 4.9.0 */ @Contract("_ -> this") - @NotNull Builder lastSeparatorIfSerial(final @Nullable ComponentLike lastSeparatorIfSerial); + Builder lastSeparatorIfSerial(final @Nullable ComponentLike lastSeparatorIfSerial); /** * Sets the convertor of this join configuration builder. @@ -323,7 +324,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder< * @since 4.9.0 */ @Contract("_ -> this") - @NotNull Builder convertor(final @NotNull Function convertor); + Builder convertor(final Function convertor); /** * Sets the predicate of this join configuration builder. @@ -335,7 +336,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder< * @since 4.9.0 */ @Contract("_ -> this") - @NotNull Builder predicate(final @NotNull Predicate predicate); + Builder predicate(final Predicate predicate); /** * Sets the style of the parent component that contains the joined components. @@ -345,6 +346,6 @@ interface Builder extends AbstractBuilder, Buildable.Builder< * @since 4.11.0 */ @Contract("_ -> this") - @NotNull Builder parentStyle(final @NotNull Style parentStyle); + Builder parentStyle(final Style parentStyle); } } diff --git a/api/src/main/java/net/kyori/adventure/text/JoinConfigurationImpl.java b/api/src/main/java/net/kyori/adventure/text/JoinConfigurationImpl.java index 621a0ccfb2..235b66b100 100644 --- a/api/src/main/java/net/kyori/adventure/text/JoinConfigurationImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/JoinConfigurationImpl.java @@ -32,9 +32,10 @@ import net.kyori.adventure.text.format.Style; import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class JoinConfigurationImpl implements JoinConfiguration { static final Function DEFAULT_CONVERTOR = ComponentLike::asComponent; static final Predicate DEFAULT_PREDICATE = componentLike -> true; @@ -70,7 +71,7 @@ private JoinConfigurationImpl() { this.rootStyle = Style.empty(); } - private JoinConfigurationImpl(final @NotNull BuilderImpl builder) { + private JoinConfigurationImpl(final BuilderImpl builder) { this.prefix = ComponentLike.unbox(builder.prefix); this.suffix = ComponentLike.unbox(builder.suffix); this.separator = ComponentLike.unbox(builder.separator); @@ -107,27 +108,27 @@ private JoinConfigurationImpl(final @NotNull BuilderImpl builder) { } @Override - public @NotNull Function convertor() { + public Function convertor() { return this.convertor; } @Override - public @NotNull Predicate predicate() { + public Predicate predicate() { return this.predicate; } @Override - public @NotNull Style parentStyle() { + public Style parentStyle() { return this.rootStyle; } @Override - public JoinConfiguration.@NotNull Builder toBuilder() { + public JoinConfiguration.Builder toBuilder() { return new BuilderImpl(this); } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("prefix", this.prefix), ExaminableProperty.of("suffix", this.suffix), @@ -146,7 +147,7 @@ public String toString() { } @Contract(pure = true) - static @NotNull Component join(final @NotNull JoinConfiguration config, final @NotNull Iterable components) { + static Component join(final JoinConfiguration config, final Iterable components) { Objects.requireNonNull(config, "config"); Objects.requireNonNull(components, "components"); @@ -218,7 +219,7 @@ public String toString() { return builder.build(); } - static @NotNull Component singleElementJoin(final @NotNull JoinConfiguration config, final @Nullable ComponentLike component) { + static Component singleElementJoin(final JoinConfiguration config, final @Nullable ComponentLike component) { final Component prefix = config.prefix(); final Component suffix = config.suffix(); final Function convertor = config.convertor(); @@ -257,7 +258,7 @@ static final class BuilderImpl implements JoinConfiguration.Builder { this(JoinConfigurationImpl.NULL); } - private BuilderImpl(final @NotNull JoinConfigurationImpl joinConfig) { + private BuilderImpl(final JoinConfigurationImpl joinConfig) { this.separator = joinConfig.separator; this.lastSeparator = joinConfig.lastSeparator; this.prefix = joinConfig.prefix; @@ -269,55 +270,55 @@ private BuilderImpl(final @NotNull JoinConfigurationImpl joinConfig) { } @Override - public @NotNull Builder prefix(final @Nullable ComponentLike prefix) { + public Builder prefix(final @Nullable ComponentLike prefix) { this.prefix = prefix; return this; } @Override - public @NotNull Builder suffix(final @Nullable ComponentLike suffix) { + public Builder suffix(final @Nullable ComponentLike suffix) { this.suffix = suffix; return this; } @Override - public @NotNull Builder separator(final @Nullable ComponentLike separator) { + public Builder separator(final @Nullable ComponentLike separator) { this.separator = separator; return this; } @Override - public @NotNull Builder lastSeparator(final @Nullable ComponentLike lastSeparator) { + public Builder lastSeparator(final @Nullable ComponentLike lastSeparator) { this.lastSeparator = lastSeparator; return this; } @Override - public @NotNull Builder lastSeparatorIfSerial(final @Nullable ComponentLike lastSeparatorIfSerial) { + public Builder lastSeparatorIfSerial(final @Nullable ComponentLike lastSeparatorIfSerial) { this.lastSeparatorIfSerial = lastSeparatorIfSerial; return this; } @Override - public @NotNull Builder convertor(final @NotNull Function convertor) { + public Builder convertor(final Function convertor) { this.convertor = Objects.requireNonNull(convertor, "convertor"); return this; } @Override - public @NotNull Builder predicate(final @NotNull Predicate predicate) { + public Builder predicate(final Predicate predicate) { this.predicate = Objects.requireNonNull(predicate, "predicate"); return this; } @Override - public @NotNull Builder parentStyle(final @NotNull Style parentStyle) { + public Builder parentStyle(final Style parentStyle) { this.rootStyle = Objects.requireNonNull(parentStyle, "rootStyle"); return this; } @Override - public @NotNull JoinConfiguration build() { + public JoinConfiguration build() { return new JoinConfigurationImpl(this); } } diff --git a/api/src/main/java/net/kyori/adventure/text/KeybindComponent.java b/api/src/main/java/net/kyori/adventure/text/KeybindComponent.java index 9fbf04440d..5770e99bad 100644 --- a/api/src/main/java/net/kyori/adventure/text/KeybindComponent.java +++ b/api/src/main/java/net/kyori/adventure/text/KeybindComponent.java @@ -27,7 +27,7 @@ import java.util.stream.Stream; import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * A {@link Component} that displays the client's current keybind for the supplied action. @@ -41,6 +41,7 @@ * @since 4.0.0 * @sinceMinecraft 1.12 */ +@NullMarked public interface KeybindComponent extends BuildableComponent, ScopedComponent { /** * Gets the keybind. @@ -48,7 +49,7 @@ public interface KeybindComponent extends BuildableComponent examinableProperties() { + default Stream examinableProperties() { return Stream.concat( Stream.of( ExaminableProperty.of("keybind", this.keybind()) @@ -94,7 +95,7 @@ interface KeybindLike { * @return the keybind identifier * @since 4.9.0 */ - @NotNull String asKeybind(); + String asKeybind(); } /** @@ -111,7 +112,7 @@ interface Builder extends ComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder keybind(final @NotNull String keybind); + Builder keybind(final String keybind); /** * Sets the keybind. @@ -121,7 +122,7 @@ interface Builder extends ComponentBuilder { * @since 4.9.0 */ @Contract(pure = true) - default @NotNull Builder keybind(final @NotNull KeybindLike keybind) { + default Builder keybind(final KeybindLike keybind) { return this.keybind(Objects.requireNonNull(keybind, "keybind").asKeybind()); } } diff --git a/api/src/main/java/net/kyori/adventure/text/KeybindComponentImpl.java b/api/src/main/java/net/kyori/adventure/text/KeybindComponentImpl.java index 077064a879..f0523cc60b 100644 --- a/api/src/main/java/net/kyori/adventure/text/KeybindComponentImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/KeybindComponentImpl.java @@ -27,15 +27,16 @@ import java.util.Objects; import net.kyori.adventure.internal.Internals; import net.kyori.adventure.text.format.Style; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked final class KeybindComponentImpl extends AbstractComponent implements KeybindComponent { private final String keybind; - static KeybindComponent create(final @NotNull List children, final @NotNull Style style, final @NotNull String keybind) { + static KeybindComponent create(final List children, final Style style, final String keybind) { return new KeybindComponentImpl( ComponentLike.asComponents(children, IS_NOT_EMPTY), requireNonNull(style, "style"), @@ -43,29 +44,29 @@ static KeybindComponent create(final @NotNull List chil ); } - KeybindComponentImpl(final @NotNull List children, final @NotNull Style style, final @NotNull String keybind) { + KeybindComponentImpl(final List children, final Style style, final String keybind) { super(children, style); this.keybind = keybind; } @Override - public @NotNull String keybind() { + public String keybind() { return this.keybind; } @Override - public @NotNull KeybindComponent keybind(final @NotNull String keybind) { + public KeybindComponent keybind(final String keybind) { if (Objects.equals(this.keybind, keybind)) return this; return create(this.children, this.style, keybind); } @Override - public @NotNull KeybindComponent children(final @NotNull List children) { + public KeybindComponent children(final List children) { return create(children, this.style, this.keybind); } @Override - public @NotNull KeybindComponent style(final @NotNull Style style) { + public KeybindComponent style(final Style style) { return create(this.children, style, this.keybind); } @@ -91,7 +92,7 @@ public String toString() { } @Override - public @NotNull Builder toBuilder() { + public Builder toBuilder() { return new BuilderImpl(this); } @@ -101,19 +102,19 @@ static final class BuilderImpl extends AbstractComponentBuilder, B extends NBTComponentBuilder> extends BuildableComponent { /** * Gets the NBT path. @@ -58,7 +59,7 @@ public interface NBTComponent, B extends NBTCompone * @return the NBT path * @since 4.0.0 */ - @NotNull String nbtPath(); + String nbtPath(); /** * Sets the NBT path. @@ -68,7 +69,7 @@ public interface NBTComponent, B extends NBTCompone * @since 4.0.0 */ @Contract(pure = true) - @NotNull C nbtPath(final @NotNull String nbtPath); + C nbtPath(final String nbtPath); /** * Gets if we should be interpreting. @@ -86,7 +87,7 @@ public interface NBTComponent, B extends NBTCompone * @since 4.0.0 */ @Contract(pure = true) - @NotNull C interpret(final boolean interpret); + C interpret(final boolean interpret); /** * Gets the separator. @@ -103,10 +104,10 @@ public interface NBTComponent, B extends NBTCompone * @return the separator * @since 4.8.0 */ - @NotNull C separator(final @Nullable ComponentLike separator); + C separator(final @Nullable ComponentLike separator); @Override - default @NotNull Stream examinableProperties() { + default Stream examinableProperties() { return Stream.concat( Stream.of( ExaminableProperty.of("nbtPath", this.nbtPath()), diff --git a/api/src/main/java/net/kyori/adventure/text/NBTComponentBuilder.java b/api/src/main/java/net/kyori/adventure/text/NBTComponentBuilder.java index fcd91f4e27..f460398836 100644 --- a/api/src/main/java/net/kyori/adventure/text/NBTComponentBuilder.java +++ b/api/src/main/java/net/kyori/adventure/text/NBTComponentBuilder.java @@ -24,8 +24,7 @@ package net.kyori.adventure.text; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /* * This can't be a child of NBTComponent. @@ -47,7 +46,7 @@ public interface NBTComponentBuilder, B extends NBT * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B nbtPath(final @NotNull String nbtPath); + B nbtPath(final String nbtPath); /** * Sets whether to interpret. @@ -57,7 +56,7 @@ public interface NBTComponentBuilder, B extends NBT * @since 4.0.0 */ @Contract("_ -> this") - @NotNull B interpret(final boolean interpret); + B interpret(final boolean interpret); /** * Sets the separator. @@ -67,5 +66,5 @@ public interface NBTComponentBuilder, B extends NBT * @since 4.8.0 */ @Contract("_ -> this") - @NotNull B separator(final @Nullable ComponentLike separator); + B separator(final @Nullable ComponentLike separator); } diff --git a/api/src/main/java/net/kyori/adventure/text/NBTComponentImpl.java b/api/src/main/java/net/kyori/adventure/text/NBTComponentImpl.java index 0e139473da..4a1bb8146e 100644 --- a/api/src/main/java/net/kyori/adventure/text/NBTComponentImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/NBTComponentImpl.java @@ -26,16 +26,17 @@ import java.util.List; import java.util.Objects; import net.kyori.adventure.text.format.Style; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked abstract class NBTComponentImpl, B extends NBTComponentBuilder> extends AbstractComponent implements NBTComponent { static final boolean INTERPRET_DEFAULT = false; final String nbtPath; final boolean interpret; final @Nullable Component separator; - NBTComponentImpl(final @NotNull List children, final @NotNull Style style, final String nbtPath, final boolean interpret, final @Nullable Component separator) { + NBTComponentImpl(final List children, final Style style, final String nbtPath, final boolean interpret, final @Nullable Component separator) { super(children, style); this.nbtPath = nbtPath; this.interpret = interpret; @@ -43,7 +44,7 @@ abstract class NBTComponentImpl, B extends NBTCompo } @Override - public @NotNull String nbtPath() { + public String nbtPath() { return this.nbtPath; } diff --git a/api/src/main/java/net/kyori/adventure/text/ScopedComponent.java b/api/src/main/java/net/kyori/adventure/text/ScopedComponent.java index 1982a56800..38320acc59 100644 --- a/api/src/main/java/net/kyori/adventure/text/ScopedComponent.java +++ b/api/src/main/java/net/kyori/adventure/text/ScopedComponent.java @@ -31,8 +31,8 @@ import net.kyori.adventure.text.format.Style; import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextDecoration; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Some magic to change return types. @@ -40,106 +40,107 @@ * @param the component type * @since 4.0.0 */ +@NullMarked public interface ScopedComponent extends Component { @Override - @NotNull C children(final @NotNull List children); + C children(final List children); @Override - @NotNull C style(final @NotNull Style style); + C style(final Style style); @Override @SuppressWarnings("unchecked") - default @NotNull C style(final @NotNull Consumer style) { + default C style(final Consumer style) { return (C) Component.super.style(style); } @Override @SuppressWarnings("unchecked") - default @NotNull C style(final Style.@NotNull Builder style) { + default C style(final Style.Builder style) { return (C) Component.super.style(style); } @Override @SuppressWarnings("unchecked") - default @NotNull C mergeStyle(final @NotNull Component that) { + default C mergeStyle(final Component that) { return (C) Component.super.mergeStyle(that); } @Override @SuppressWarnings("unchecked") - default @NotNull C mergeStyle(final @NotNull Component that, final Style.@NotNull Merge@NotNull... merges) { + default C mergeStyle(final Component that, final Style.Merge... merges) { return (C) Component.super.mergeStyle(that, merges); } @Override @SuppressWarnings("unchecked") - default @NotNull C append(final @NotNull Component component) { + default C append(final Component component) { return (C) Component.super.append(component); } @Override @SuppressWarnings("unchecked") - default @NotNull C append(final @NotNull ComponentLike like) { + default C append(final ComponentLike like) { return (C) Component.super.append(like); } @Override @SuppressWarnings("unchecked") - default @NotNull C append(final @NotNull ComponentBuilder builder) { + default C append(final ComponentBuilder builder) { return (C) Component.super.append(builder); } @Override @SuppressWarnings("unchecked") - default @NotNull C mergeStyle(final @NotNull Component that, final @NotNull Set merges) { + default C mergeStyle(final Component that, final Set merges) { return (C) Component.super.mergeStyle(that, merges); } @Override @SuppressWarnings("unchecked") - default @NotNull C color(final @Nullable TextColor color) { + default C color(final @Nullable TextColor color) { return (C) Component.super.color(color); } @Override @SuppressWarnings("unchecked") - default @NotNull C colorIfAbsent(final @Nullable TextColor color) { + default C colorIfAbsent(final @Nullable TextColor color) { return (C) Component.super.colorIfAbsent(color); } @Override @SuppressWarnings("unchecked") - default @NotNull C decorate(final @NotNull TextDecoration decoration) { + default C decorate(final TextDecoration decoration) { return (C) Component.super.decorate(decoration); } @Override @SuppressWarnings("unchecked") - default @NotNull C decoration(final @NotNull TextDecoration decoration, final boolean flag) { + default C decoration(final TextDecoration decoration, final boolean flag) { return (C) Component.super.decoration(decoration, flag); } @Override @SuppressWarnings("unchecked") - default @NotNull C decoration(final @NotNull TextDecoration decoration, final TextDecoration.@NotNull State state) { + default C decoration(final TextDecoration decoration, final TextDecoration.State state) { return (C) Component.super.decoration(decoration, state); } @Override @SuppressWarnings("unchecked") - default @NotNull C clickEvent(final @Nullable ClickEvent event) { + default C clickEvent(final @Nullable ClickEvent event) { return (C) Component.super.clickEvent(event); } @Override @SuppressWarnings("unchecked") - default @NotNull C hoverEvent(final @Nullable HoverEventSource event) { + default C hoverEvent(final @Nullable HoverEventSource event) { return (C) Component.super.hoverEvent(event); } @Override @SuppressWarnings("unchecked") - default @NotNull C insertion(final @Nullable String insertion) { + default C insertion(final @Nullable String insertion) { return (C) Component.super.insertion(insertion); } } diff --git a/api/src/main/java/net/kyori/adventure/text/ScoreComponent.java b/api/src/main/java/net/kyori/adventure/text/ScoreComponent.java index 2f54998b47..982c08e892 100644 --- a/api/src/main/java/net/kyori/adventure/text/ScoreComponent.java +++ b/api/src/main/java/net/kyori/adventure/text/ScoreComponent.java @@ -26,8 +26,8 @@ import java.util.stream.Stream; import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A component that can display a player's score from a scoreboard objective, @@ -51,6 +51,7 @@ * * @since 4.0.0 */ +@NullMarked public interface ScoreComponent extends BuildableComponent, ScopedComponent { /** * Gets the score name. @@ -58,7 +59,7 @@ public interface ScoreComponent extends BuildableComponent examinableProperties() { + default Stream examinableProperties() { return Stream.concat( Stream.of( ExaminableProperty.of("name", this.name()), @@ -136,7 +137,7 @@ interface Builder extends ComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder name(final @NotNull String name); + Builder name(final String name); /** * Sets the score objective. @@ -146,7 +147,7 @@ interface Builder extends ComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder objective(final @NotNull String objective); + Builder objective(final String objective); /** * Sets the value. @@ -158,6 +159,6 @@ interface Builder extends ComponentBuilder { */ @Deprecated @Contract("_ -> this") - @NotNull Builder value(final @Nullable String value); + Builder value(final @Nullable String value); } } diff --git a/api/src/main/java/net/kyori/adventure/text/ScoreComponentImpl.java b/api/src/main/java/net/kyori/adventure/text/ScoreComponentImpl.java index 6aed06727c..c784b59bc7 100644 --- a/api/src/main/java/net/kyori/adventure/text/ScoreComponentImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/ScoreComponentImpl.java @@ -27,18 +27,19 @@ import java.util.Objects; import net.kyori.adventure.internal.Internals; import net.kyori.adventure.text.format.Style; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked final class ScoreComponentImpl extends AbstractComponent implements ScoreComponent { private final String name; private final String objective; @Deprecated private final @Nullable String value; - static ScoreComponent create(final @NotNull List children, final @NotNull Style style, final @NotNull String name, final @NotNull String objective, final @Nullable String value) { + static ScoreComponent create(final List children, final Style style, final String name, final String objective, final @Nullable String value) { return new ScoreComponentImpl( ComponentLike.asComponents(children, IS_NOT_EMPTY), requireNonNull(style, "style"), @@ -48,7 +49,7 @@ static ScoreComponent create(final @NotNull List childr ); } - ScoreComponentImpl(final @NotNull List children, final @NotNull Style style, final @NotNull String name, final @NotNull String objective, final @Nullable String value) { + ScoreComponentImpl(final List children, final Style style, final String name, final String objective, final @Nullable String value) { super(children, style); this.name = name; this.objective = objective; @@ -56,23 +57,23 @@ static ScoreComponent create(final @NotNull List childr } @Override - public @NotNull String name() { + public String name() { return this.name; } @Override - public @NotNull ScoreComponent name(final @NotNull String name) { + public ScoreComponent name(final String name) { if (Objects.equals(this.name, name)) return this; return create(this.children, this.style, name, this.objective, this.value); } @Override - public @NotNull String objective() { + public String objective() { return this.objective; } @Override - public @NotNull ScoreComponent objective(final @NotNull String objective) { + public ScoreComponent objective(final String objective) { if (Objects.equals(this.objective, objective)) return this; return create(this.children, this.style, this.name, objective, this.value); } @@ -85,18 +86,18 @@ static ScoreComponent create(final @NotNull List childr @Override @Deprecated - public @NotNull ScoreComponent value(final @Nullable String value) { + public ScoreComponent value(final @Nullable String value) { if (Objects.equals(this.value, value)) return this; return create(this.children, this.style, this.name, this.objective, value); } @Override - public @NotNull ScoreComponent children(final @NotNull List children) { + public ScoreComponent children(final List children) { return create(children, this.style, this.name, this.objective, this.value); } @Override - public @NotNull ScoreComponent style(final @NotNull Style style) { + public ScoreComponent style(final Style style) { return create(this.children, style, this.name, this.objective, this.value); } @@ -127,7 +128,7 @@ public String toString() { } @Override - public @NotNull Builder toBuilder() { + public Builder toBuilder() { return new BuilderImpl(this); } @@ -140,7 +141,7 @@ static final class BuilderImpl extends AbstractComponentBuilder, ScopedComponent { /** * Gets the selector pattern. @@ -51,7 +52,7 @@ public interface SelectorComponent extends BuildableComponent examinableProperties() { + default Stream examinableProperties() { return Stream.concat( Stream.of( ExaminableProperty.of("pattern", this.pattern()), @@ -105,7 +106,7 @@ interface Builder extends ComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder pattern(final @NotNull String pattern); + Builder pattern(final String pattern); /** * Sets the separator. @@ -115,6 +116,6 @@ interface Builder extends ComponentBuilder { * @since 4.8.0 */ @Contract("_ -> this") - @NotNull Builder separator(final @Nullable ComponentLike separator); + Builder separator(final @Nullable ComponentLike separator); } } diff --git a/api/src/main/java/net/kyori/adventure/text/SelectorComponentImpl.java b/api/src/main/java/net/kyori/adventure/text/SelectorComponentImpl.java index aecff04fee..61af34f5c0 100644 --- a/api/src/main/java/net/kyori/adventure/text/SelectorComponentImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/SelectorComponentImpl.java @@ -27,16 +27,17 @@ import java.util.Objects; import net.kyori.adventure.internal.Internals; import net.kyori.adventure.text.format.Style; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked final class SelectorComponentImpl extends AbstractComponent implements SelectorComponent { private final String pattern; private final @Nullable Component separator; - static SelectorComponent create(final @NotNull List children, final @NotNull Style style, final @NotNull String pattern, final @Nullable ComponentLike separator) { + static SelectorComponent create(final List children, final Style style, final String pattern, final @Nullable ComponentLike separator) { return new SelectorComponentImpl( ComponentLike.asComponents(children, IS_NOT_EMPTY), requireNonNull(style, "style"), @@ -45,19 +46,19 @@ static SelectorComponent create(final @NotNull List chi ); } - SelectorComponentImpl(final @NotNull List children, final @NotNull Style style, final @NotNull String pattern, final @Nullable Component separator) { + SelectorComponentImpl(final List children, final Style style, final String pattern, final @Nullable Component separator) { super(children, style); this.pattern = pattern; this.separator = separator; } @Override - public @NotNull String pattern() { + public String pattern() { return this.pattern; } @Override - public @NotNull SelectorComponent pattern(final @NotNull String pattern) { + public SelectorComponent pattern(final String pattern) { if (Objects.equals(this.pattern, pattern)) return this; return create(this.children, this.style, pattern, this.separator); } @@ -68,17 +69,17 @@ static SelectorComponent create(final @NotNull List chi } @Override - public @NotNull SelectorComponent separator(final @Nullable ComponentLike separator) { + public SelectorComponent separator(final @Nullable ComponentLike separator) { return create(this.children, this.style, this.pattern, separator); } @Override - public @NotNull SelectorComponent children(final @NotNull List children) { + public SelectorComponent children(final List children) { return create(children, this.style, this.pattern, this.separator); } @Override - public @NotNull SelectorComponent style(final @NotNull Style style) { + public SelectorComponent style(final Style style) { return create(this.children, style, this.pattern, this.separator); } @@ -105,7 +106,7 @@ public String toString() { } @Override - public @NotNull Builder toBuilder() { + public Builder toBuilder() { return new BuilderImpl(this); } @@ -116,26 +117,26 @@ static final class BuilderImpl extends AbstractComponentBuilder, ScopedComponent { /** * Gets the NBT storage's ID. @@ -51,7 +52,7 @@ public interface StorageNBTComponent extends NBTComponent examinableProperties() { + default Stream examinableProperties() { return Stream.concat( Stream.of( ExaminableProperty.of("storage", this.storage()) @@ -87,6 +88,6 @@ interface Builder extends NBTComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder storage(final @NotNull Key storage); + Builder storage(final Key storage); } } diff --git a/api/src/main/java/net/kyori/adventure/text/StorageNBTComponentImpl.java b/api/src/main/java/net/kyori/adventure/text/StorageNBTComponentImpl.java index 97f34a4c1b..f19d54876e 100644 --- a/api/src/main/java/net/kyori/adventure/text/StorageNBTComponentImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/StorageNBTComponentImpl.java @@ -28,15 +28,16 @@ import net.kyori.adventure.internal.Internals; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.format.Style; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked final class StorageNBTComponentImpl extends NBTComponentImpl implements StorageNBTComponent { private final Key storage; - static @NotNull StorageNBTComponent create(final @NotNull List children, final @NotNull Style style, final String nbtPath, final boolean interpret, final @Nullable ComponentLike separator, final @NotNull Key storage) { + static StorageNBTComponent create(final List children, final Style style, final String nbtPath, final boolean interpret, final @Nullable ComponentLike separator, final Key storage) { return new StorageNBTComponentImpl( ComponentLike.asComponents(children, IS_NOT_EMPTY), requireNonNull(style, "style"), @@ -47,19 +48,19 @@ final class StorageNBTComponentImpl extends NBTComponentImpl children, final @NotNull Style style, final String nbtPath, final boolean interpret, final @Nullable Component separator, final Key storage) { + StorageNBTComponentImpl(final List children, final Style style, final String nbtPath, final boolean interpret, final @Nullable Component separator, final Key storage) { super(children, style, nbtPath, interpret, separator); this.storage = storage; } @Override - public @NotNull StorageNBTComponent nbtPath(final @NotNull String nbtPath) { + public StorageNBTComponent nbtPath(final String nbtPath) { if (Objects.equals(this.nbtPath, nbtPath)) return this; return create(this.children, this.style, nbtPath, this.interpret, this.separator, this.storage); } @Override - public @NotNull StorageNBTComponent interpret(final boolean interpret) { + public StorageNBTComponent interpret(final boolean interpret) { if (this.interpret == interpret) return this; return create(this.children, this.style, this.nbtPath, interpret, this.separator, this.storage); } @@ -70,28 +71,28 @@ final class StorageNBTComponentImpl extends NBTComponentImpl children) { + public StorageNBTComponent children(final List children) { return create(children, this.style, this.nbtPath, this.interpret, this.separator, this.storage); } @Override - public @NotNull StorageNBTComponent style(final @NotNull Style style) { + public StorageNBTComponent style(final Style style) { return create(this.children, style, this.nbtPath, this.interpret, this.separator, this.storage); } @@ -117,7 +118,7 @@ public String toString() { } @Override - public StorageNBTComponent.@NotNull Builder toBuilder() { + public StorageNBTComponent.Builder toBuilder() { return new BuilderImpl(this); } @@ -127,19 +128,19 @@ static class BuilderImpl extends AbstractNBTComponentBuilder, ScopedComponent { /** * Creates a component with {@code components} as the children. @@ -51,7 +52,7 @@ public interface TextComponent extends BuildableComponent examinableProperties() { + default Stream examinableProperties() { return Stream.concat( Stream.of( ExaminableProperty.of("content", this.content()) @@ -95,7 +96,7 @@ interface Builder extends ComponentBuilder { * @return the plain text content * @since 4.0.0 */ - @NotNull String content(); + String content(); /** * Sets the plain text content. @@ -105,6 +106,6 @@ interface Builder extends ComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder content(final @NotNull String content); + Builder content(final String content); } } diff --git a/api/src/main/java/net/kyori/adventure/text/TextComponentImpl.java b/api/src/main/java/net/kyori/adventure/text/TextComponentImpl.java index f29847603f..2a573b626c 100644 --- a/api/src/main/java/net/kyori/adventure/text/TextComponentImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/TextComponentImpl.java @@ -30,12 +30,13 @@ import net.kyori.adventure.internal.properties.AdventureProperties; import net.kyori.adventure.text.format.Style; import net.kyori.adventure.util.Nag; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked final class TextComponentImpl extends AbstractComponent implements TextComponent { private static final boolean WARN_WHEN_LEGACY_FORMATTING_DETECTED = Boolean.TRUE.equals(AdventureProperties.TEXT_WARN_WHEN_LEGACY_FORMATTING_DETECTED.value()); @VisibleForTesting @@ -45,7 +46,7 @@ final class TextComponentImpl extends AbstractComponent implements TextComponent static final TextComponent NEWLINE = createDirect("\n"); static final TextComponent SPACE = createDirect(" "); - static TextComponent create(final @NotNull List children, final @NotNull Style style, final @NotNull String content) { + static TextComponent create(final List children, final Style style, final String content) { final List filteredChildren = ComponentLike.asComponents(children, IS_NOT_EMPTY); if (filteredChildren.isEmpty() && style.isEmpty() && content.isEmpty()) return Component.empty(); @@ -56,13 +57,13 @@ static TextComponent create(final @NotNull List childre ); } - private static @NotNull TextComponent createDirect(final @NotNull String content) { + private static TextComponent createDirect(final String content) { return new TextComponentImpl(Collections.emptyList(), Style.empty(), content); } private final String content; - TextComponentImpl(final @NotNull List children, final @NotNull Style style, final @NotNull String content) { + TextComponentImpl(final List children, final Style style, final String content) { super(children, style); this.content = content; @@ -83,23 +84,23 @@ static TextComponent create(final @NotNull List childre } @Override - public @NotNull String content() { + public String content() { return this.content; } @Override - public @NotNull TextComponent content(final @NotNull String content) { + public TextComponent content(final String content) { if (Objects.equals(this.content, content)) return this; return create(this.children, this.style, content); } @Override - public @NotNull TextComponent children(final @NotNull List children) { + public TextComponent children(final List children) { return create(children, this.style, this.content); } @Override - public @NotNull TextComponent style(final @NotNull Style style) { + public TextComponent style(final Style style) { return create(this.children, style, this.content); } @@ -125,7 +126,7 @@ public String toString() { } @Override - public @NotNull Builder toBuilder() { + public Builder toBuilder() { return new BuilderImpl(this); } @@ -140,24 +141,24 @@ static final class BuilderImpl extends AbstractComponentBuilder, Examinable { /** * Create a new builder. @@ -53,7 +54,7 @@ public interface TextReplacementConfig extends Buildable this") - default @NotNull Builder match(final @NotNull @RegExp String pattern) { + default Builder match(final @RegExp String pattern) { return this.match(Pattern.compile(pattern)); } @@ -111,7 +112,7 @@ default Builder matchLiteral(final String literal) { * @since 4.2.0 */ @Contract("_ -> this") - @NotNull Builder match(final @NotNull Pattern pattern); + Builder match(final Pattern pattern); /* * --------------------------- @@ -125,7 +126,7 @@ default Builder matchLiteral(final String literal) { * @return this builder * @since 4.2.0 */ - default @NotNull Builder once() { + default Builder once() { return this.times(1); } @@ -137,7 +138,7 @@ default Builder matchLiteral(final String literal) { * @since 4.2.0 */ @Contract("_ -> this") - default @NotNull Builder times(final int times) { + default Builder times(final int times) { return this.condition((index, replaced) -> replaced < times ? PatternReplacementResult.REPLACE : PatternReplacementResult.STOP); } @@ -150,7 +151,7 @@ default Builder matchLiteral(final String literal) { * @since 4.2.0 */ @Contract("_ -> this") - default @NotNull Builder condition(final @NotNull IntFunction2 condition) { + default Builder condition(final IntFunction2 condition) { return this.condition((result, matchCount, replaced) -> condition.apply(matchCount, replaced)); } @@ -163,7 +164,7 @@ default Builder matchLiteral(final String literal) { * @since 4.8.0 */ @Contract("_ -> this") - @NotNull Builder condition(final @NotNull Condition condition); + Builder condition(final Condition condition); /* * ------------------------- @@ -179,7 +180,7 @@ default Builder matchLiteral(final String literal) { * @since 4.2.0 */ @Contract("_ -> this") - default @NotNull Builder replacement(final @NotNull String replacement) { + default Builder replacement(final String replacement) { requireNonNull(replacement, "replacement"); return this.replacement(builder -> builder.content(replacement)); } @@ -192,7 +193,7 @@ default Builder matchLiteral(final String literal) { * @since 4.2.0 */ @Contract("_ -> this") - default @NotNull Builder replacement(final @Nullable ComponentLike replacement) { + default Builder replacement(final @Nullable ComponentLike replacement) { final @Nullable Component baked = ComponentLike.unbox(replacement); return this.replacement((result, input) -> baked); } @@ -205,7 +206,7 @@ default Builder matchLiteral(final String literal) { * @since 4.2.0 */ @Contract("_ -> this") - default @NotNull Builder replacement(final @NotNull Function replacement) { + default Builder replacement(final Function replacement) { requireNonNull(replacement, "replacement"); return this.replacement((result, input) -> replacement.apply(input)); @@ -219,7 +220,7 @@ default Builder matchLiteral(final String literal) { * @since 4.2.0 */ @Contract("_ -> this") - @NotNull Builder replacement(final @NotNull BiFunction replacement); + Builder replacement(final BiFunction replacement); } /** @@ -238,6 +239,6 @@ interface Condition { * @return whether a certain match should * @since 4.8.0 */ - @NotNull PatternReplacementResult shouldReplace(final @NotNull MatchResult result, final int matchCount, final int replaced); + PatternReplacementResult shouldReplace(final MatchResult result, final int matchCount, final int replaced); } } diff --git a/api/src/main/java/net/kyori/adventure/text/TextReplacementConfigImpl.java b/api/src/main/java/net/kyori/adventure/text/TextReplacementConfigImpl.java index c04e32a0df..f5bf61b5e2 100644 --- a/api/src/main/java/net/kyori/adventure/text/TextReplacementConfigImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/TextReplacementConfigImpl.java @@ -29,11 +29,12 @@ import java.util.stream.Stream; import net.kyori.adventure.internal.Internals; import net.kyori.examination.ExaminableProperty; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked final class TextReplacementConfigImpl implements TextReplacementConfig { private final Pattern matchPattern; private final BiFunction replacement; @@ -46,7 +47,7 @@ final class TextReplacementConfigImpl implements TextReplacementConfig { } @Override - public @NotNull Pattern matchPattern() { + public Pattern matchPattern() { return this.matchPattern; } @@ -55,12 +56,12 @@ TextReplacementRenderer.State createState() { } @Override - public TextReplacementConfig.@NotNull Builder toBuilder() { + public TextReplacementConfig.Builder toBuilder() { return new Builder(this); } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("matchPattern", this.matchPattern), ExaminableProperty.of("replacement", this.replacement), @@ -88,25 +89,25 @@ static final class Builder implements TextReplacementConfig.Builder { } @Override - public @NotNull Builder match(final @NotNull Pattern pattern) { + public Builder match(final Pattern pattern) { this.matchPattern = requireNonNull(pattern, "pattern"); return this; } @Override - public @NotNull Builder condition(final TextReplacementConfig.@NotNull Condition condition) { + public Builder condition(final TextReplacementConfig.Condition condition) { this.continuer = requireNonNull(condition, "continuation"); return this; } @Override - public @NotNull Builder replacement(final @NotNull BiFunction replacement) { + public Builder replacement(final BiFunction replacement) { this.replacement = requireNonNull(replacement, "replacement"); return this; } @Override - public @NotNull TextReplacementConfig build() { + public TextReplacementConfig build() { if (this.matchPattern == null) throw new IllegalStateException("A pattern must be provided to match against"); if (this.replacement == null) throw new IllegalStateException("A replacement action must be provided"); return new TextReplacementConfigImpl(this); diff --git a/api/src/main/java/net/kyori/adventure/text/TextReplacementRenderer.java b/api/src/main/java/net/kyori/adventure/text/TextReplacementRenderer.java index 9034a61313..916fe97ff0 100644 --- a/api/src/main/java/net/kyori/adventure/text/TextReplacementRenderer.java +++ b/api/src/main/java/net/kyori/adventure/text/TextReplacementRenderer.java @@ -32,12 +32,13 @@ import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.Style; import net.kyori.adventure.text.renderer.ComponentRenderer; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A renderer performing a replacement on every {@link TextComponent} element of a component tree. */ +@NullMarked final class TextReplacementRenderer implements ComponentRenderer { static final TextReplacementRenderer INSTANCE = new TextReplacementRenderer(); @@ -45,7 +46,7 @@ private TextReplacementRenderer() { } @Override - public @NotNull Component render(final @NotNull Component component, final @NotNull State state) { + public Component render(final Component component, final State state) { if (!state.running) return component; final boolean prevFirstMatch = state.firstMatch; state.firstMatch = true; @@ -205,7 +206,7 @@ static final class State { int replaceCount = 0; boolean firstMatch = true; - State(final @NotNull Pattern pattern, final @NotNull BiFunction replacement, final TextReplacementConfig.@NotNull Condition continuer) { + State(final Pattern pattern, final BiFunction replacement, final TextReplacementConfig.Condition continuer) { this.pattern = pattern; this.replacement = replacement; this.continuer = continuer; diff --git a/api/src/main/java/net/kyori/adventure/text/TranslatableComponent.java b/api/src/main/java/net/kyori/adventure/text/TranslatableComponent.java index 809fd728d6..1043fda935 100644 --- a/api/src/main/java/net/kyori/adventure/text/TranslatableComponent.java +++ b/api/src/main/java/net/kyori/adventure/text/TranslatableComponent.java @@ -33,8 +33,8 @@ import net.kyori.adventure.translation.TranslationRegistry; import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A component that can display translated text. @@ -61,6 +61,7 @@ * @see TranslationRegistry * @since 4.0.0 */ +@NullMarked public interface TranslatableComponent extends BuildableComponent, ScopedComponent { /** * Gets the translation key. @@ -68,7 +69,7 @@ public interface TranslatableComponent extends BuildableComponent args(); + List args(); /** * Sets the translation arguments for this component. @@ -108,7 +109,7 @@ public interface TranslatableComponent extends BuildableComponent args); + TranslatableComponent args(final List args); /** * Gets the translation fallback text for this component. @@ -142,10 +143,10 @@ public interface TranslatableComponent extends BuildableComponent examinableProperties() { + default Stream examinableProperties() { return Stream.concat( Stream.of( ExaminableProperty.of("key", this.key()), @@ -170,7 +171,7 @@ interface Builder extends ComponentBuilder { * @since 4.8.0 */ @Contract(pure = true) - default @NotNull Builder key(final @NotNull Translatable translatable) { + default Builder key(final Translatable translatable) { return this.key(Objects.requireNonNull(translatable, "translatable").translationKey()); } @@ -182,7 +183,7 @@ interface Builder extends ComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder key(final @NotNull String key); + Builder key(final String key); /** * Sets the translation args. @@ -192,7 +193,7 @@ interface Builder extends ComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder args(final @NotNull ComponentBuilder arg); + Builder args(final ComponentBuilder arg); /** * Sets the translation args. @@ -203,7 +204,7 @@ interface Builder extends ComponentBuilder { */ @Contract("_ -> this") @SuppressWarnings("checkstyle:GenericWhitespace") - @NotNull Builder args(final @NotNull ComponentBuilder@NotNull... args); + Builder args(final ComponentBuilder... args); /** * Sets the translation args. @@ -213,7 +214,7 @@ interface Builder extends ComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder args(final @NotNull Component arg); + Builder args(final Component arg); /** * Sets the translation args. @@ -223,7 +224,7 @@ interface Builder extends ComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder args(final @NotNull ComponentLike@NotNull... args); + Builder args(final ComponentLike... args); /** * Sets the translation args. @@ -233,7 +234,7 @@ interface Builder extends ComponentBuilder { * @since 4.0.0 */ @Contract("_ -> this") - @NotNull Builder args(final @NotNull List args); + Builder args(final List args); /** * Sets the translation fallback text. @@ -246,6 +247,6 @@ interface Builder extends ComponentBuilder { * @sinceMinecraft 1.19.4 */ @Contract("_ -> this") - @NotNull Builder fallback(final @Nullable String fallback); + Builder fallback(final @Nullable String fallback); } } diff --git a/api/src/main/java/net/kyori/adventure/text/TranslatableComponentImpl.java b/api/src/main/java/net/kyori/adventure/text/TranslatableComponentImpl.java index df7f1c7353..e86e45a32b 100644 --- a/api/src/main/java/net/kyori/adventure/text/TranslatableComponentImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/TranslatableComponentImpl.java @@ -31,18 +31,19 @@ import java.util.stream.Stream; import net.kyori.adventure.internal.Internals; import net.kyori.adventure.text.format.Style; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked final class TranslatableComponentImpl extends AbstractComponent implements TranslatableComponent { - static TranslatableComponent create(final @NotNull List children, final @NotNull Style style, final @NotNull String key, final @Nullable String fallback, final @NotNull ComponentLike@NotNull[] args) { + static TranslatableComponent create(final List children, final Style style, final String key, final @Nullable String fallback, final ComponentLike[] args) { requireNonNull(args, "args"); return create(children, style, key, fallback, Arrays.asList(args)); } - static TranslatableComponent create(final @NotNull List children, final @NotNull Style style, final @NotNull String key, final @Nullable String fallback, final @NotNull List args) { + static TranslatableComponent create(final List children, final Style style, final String key, final @Nullable String fallback, final List args) { return new TranslatableComponentImpl( ComponentLike.asComponents(children, IS_NOT_EMPTY), requireNonNull(style, "style"), @@ -56,7 +57,7 @@ static TranslatableComponent create(final @NotNull List private final @Nullable String fallback; private final List args; - TranslatableComponentImpl(final @NotNull List children, final @NotNull Style style, final @NotNull String key, final @Nullable String fallback, final @NotNull List args) { + TranslatableComponentImpl(final List children, final Style style, final String key, final @Nullable String fallback, final List args) { super(children, style); this.key = key; this.fallback = fallback; @@ -64,28 +65,28 @@ static TranslatableComponent create(final @NotNull List } @Override - public @NotNull String key() { + public String key() { return this.key; } @Override - public @NotNull TranslatableComponent key(final @NotNull String key) { + public TranslatableComponent key(final String key) { if (Objects.equals(this.key, key)) return this; return create(this.children, this.style, key, this.fallback, this.args); } @Override - public @NotNull List args() { + public List args() { return this.args; } @Override - public @NotNull TranslatableComponent args(final @NotNull ComponentLike@NotNull... args) { + public TranslatableComponent args(final ComponentLike... args) { return create(this.children, this.style, this.key, this.fallback, args); } @Override - public @NotNull TranslatableComponent args(final @NotNull List args) { + public TranslatableComponent args(final List args) { return create(this.children, this.style, this.key, this.fallback, args); } @@ -95,17 +96,17 @@ static TranslatableComponent create(final @NotNull List } @Override - public @NotNull TranslatableComponent fallback(final @Nullable String fallback) { + public TranslatableComponent fallback(final @Nullable String fallback) { return create(this.children, this.style, this.key, fallback, this.args); } @Override - public @NotNull TranslatableComponent children(final @NotNull List children) { + public TranslatableComponent children(final List children) { return create(children, this.style, this.key, this.fallback, this.args); } @Override - public @NotNull TranslatableComponent style(final @NotNull Style style) { + public TranslatableComponent style(final Style style) { return create(this.children, style, this.key, this.fallback, this.args); } @@ -133,7 +134,7 @@ public String toString() { } @Override - public @NotNull Builder toBuilder() { + public Builder toBuilder() { return new BuilderImpl(this); } @@ -145,7 +146,7 @@ static final class BuilderImpl extends AbstractComponentBuilder arg) { + public Builder args(final ComponentBuilder arg) { return this.args(Collections.singletonList(requireNonNull(arg, "arg").build())); } @Override @SuppressWarnings("checkstyle:GenericWhitespace") - public @NotNull Builder args(final @NotNull ComponentBuilder@NotNull... args) { + public Builder args(final ComponentBuilder... args) { requireNonNull(args, "args"); if (args.length == 0) return this.args(Collections.emptyList()); return this.args(Stream.of(args).map(ComponentBuilder::build).collect(Collectors.toList())); } @Override - public @NotNull Builder args(final @NotNull Component arg) { + public Builder args(final Component arg) { return this.args(Collections.singletonList(requireNonNull(arg, "arg"))); } @Override - public @NotNull Builder args(final @NotNull ComponentLike@NotNull... args) { + public Builder args(final ComponentLike... args) { requireNonNull(args, "args"); if (args.length == 0) return this.args(Collections.emptyList()); return this.args(Arrays.asList(args)); } @Override - public @NotNull Builder args(final @NotNull List args) { + public Builder args(final List args) { this.args = ComponentLike.asComponents(requireNonNull(args, "args")); return this; } @Override - public @NotNull Builder fallback(final @Nullable String fallback) { + public Builder fallback(final @Nullable String fallback) { this.fallback = fallback; return this; } @Override - public @NotNull TranslatableComponent build() { + public TranslatableComponent build() { if (this.key == null) throw new IllegalStateException("key must be set"); return create(this.children, this.buildStyle(), this.key, this.fallback, this.args); } diff --git a/api/src/main/java/net/kyori/adventure/text/event/ClickCallback.java b/api/src/main/java/net/kyori/adventure/text/event/ClickCallback.java index a11bdd38bb..d7599b65b5 100644 --- a/api/src/main/java/net/kyori/adventure/text/event/ClickCallback.java +++ b/api/src/main/java/net/kyori/adventure/text/event/ClickCallback.java @@ -35,8 +35,8 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.CheckReturnValue; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A handler for callback click events. @@ -45,6 +45,7 @@ * @since 4.13.0 */ @FunctionalInterface +@NullMarked public interface ClickCallback { /** * The default lifetime of a callback after creating it, 12 hours. @@ -73,7 +74,7 @@ public interface ClickCallback { */ @CheckReturnValue @Contract(pure = true) - static @NotNull ClickCallback widen(final @NotNull ClickCallback original, final @NotNull Class type, final @Nullable Consumer otherwise) { + static ClickCallback widen(final ClickCallback original, final Class type, final @Nullable Consumer otherwise) { return audience -> { if (type.isInstance(audience)) { original.accept(type.cast(audience)); @@ -97,7 +98,7 @@ public interface ClickCallback { */ @CheckReturnValue @Contract(pure = true) - static @NotNull ClickCallback widen(final @NotNull ClickCallback original, final @NotNull Class type) { + static ClickCallback widen(final ClickCallback original, final Class type) { return widen(original, type, null); } @@ -107,7 +108,7 @@ public interface ClickCallback { * @param audience the single-user audience who is attempting to execute this callback function. * @since 4.13.0 */ - void accept(final @NotNull T audience); + void accept(final T audience); /** * Filter audiences that receive this click callback. @@ -120,7 +121,7 @@ public interface ClickCallback { */ @CheckReturnValue @Contract(pure = true) - default @NotNull ClickCallback filter(final @NotNull Predicate filter) { + default ClickCallback filter(final Predicate filter) { return this.filter(filter, null); } @@ -134,7 +135,7 @@ public interface ClickCallback { */ @CheckReturnValue @Contract(pure = true) - default @NotNull ClickCallback filter(final @NotNull Predicate filter, final @Nullable Consumer otherwise) { + default ClickCallback filter(final Predicate filter, final @Nullable Consumer otherwise) { return audience -> { if (filter.test(audience)) { this.accept(audience); @@ -157,7 +158,7 @@ public interface ClickCallback { */ @CheckReturnValue @Contract(pure = true) - default @NotNull ClickCallback requiringPermission(final @NotNull String permission) { + default ClickCallback requiringPermission(final String permission) { return this.requiringPermission(permission, null); } @@ -173,7 +174,7 @@ public interface ClickCallback { */ @CheckReturnValue @Contract(pure = true) - default @NotNull ClickCallback requiringPermission(final @NotNull String permission, final @Nullable Consumer otherwise) { + default ClickCallback requiringPermission(final String permission, final @Nullable Consumer otherwise) { return this.filter(audience -> audience.getOrDefault(PermissionChecker.POINTER, ClickCallbackInternals.ALWAYS_FALSE).test(permission), otherwise); } @@ -190,7 +191,7 @@ interface Options extends Examinable { * @return the new builder * @since 4.13.0 */ - static @NotNull Builder builder() { + static Builder builder() { return new ClickCallbackOptionsImpl.BuilderImpl(); } @@ -201,7 +202,7 @@ interface Options extends Examinable { * @return the new builder * @since 4.13.0 */ - static @NotNull Builder builder(final @NotNull Options existing) { + static Builder builder(final Options existing) { return new ClickCallbackOptionsImpl.BuilderImpl(existing); } @@ -223,7 +224,7 @@ interface Options extends Examinable { * @return the duration of this callback * @since 4.13.0 */ - @NotNull Duration lifetime(); + Duration lifetime(); /** * A builder for callback options. @@ -239,7 +240,7 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.13.0 */ - @NotNull Builder uses(int useCount); + Builder uses(int useCount); /** * Set how long the callback should last from sending. @@ -248,7 +249,7 @@ interface Builder extends AbstractBuilder { * @return this builder * @since 4.13.0 */ - @NotNull Builder lifetime(final @NotNull TemporalAmount duration); + Builder lifetime(final TemporalAmount duration); } } @@ -268,6 +269,6 @@ interface Provider { * @return a created click event that will execute the provided callback with options * @since 4.13.0 */ - @NotNull ClickEvent create(final @NotNull ClickCallback callback, final @NotNull Options options); + ClickEvent create(final ClickCallback callback, final Options options); } } diff --git a/api/src/main/java/net/kyori/adventure/text/event/ClickCallbackInternals.java b/api/src/main/java/net/kyori/adventure/text/event/ClickCallbackInternals.java index 4a7fb4014d..ec9dbca47b 100644 --- a/api/src/main/java/net/kyori/adventure/text/event/ClickCallbackInternals.java +++ b/api/src/main/java/net/kyori/adventure/text/event/ClickCallbackInternals.java @@ -27,8 +27,9 @@ import net.kyori.adventure.permission.PermissionChecker; import net.kyori.adventure.util.Services; import net.kyori.adventure.util.TriState; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; +@NullMarked final class ClickCallbackInternals { private ClickCallbackInternals() { } @@ -40,7 +41,7 @@ private ClickCallbackInternals() { static final class Fallback implements ClickCallback.Provider { @Override - public @NotNull ClickEvent create(final @NotNull ClickCallback callback, final ClickCallback.@NotNull Options options) { + public ClickEvent create(final ClickCallback callback, final ClickCallback.Options options) { return ClickEvent.suggestCommand("Callbacks are not supported on this platform!"); } } diff --git a/api/src/main/java/net/kyori/adventure/text/event/ClickCallbackOptionsImpl.java b/api/src/main/java/net/kyori/adventure/text/event/ClickCallbackOptionsImpl.java index 55bd330fab..7e88d508f4 100644 --- a/api/src/main/java/net/kyori/adventure/text/event/ClickCallbackOptionsImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/event/ClickCallbackOptionsImpl.java @@ -28,10 +28,11 @@ import java.util.stream.Stream; import net.kyori.adventure.internal.Internals; import net.kyori.examination.ExaminableProperty; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import static java.util.Objects.requireNonNull; +@NullMarked final class ClickCallbackOptionsImpl implements ClickCallback.Options { static final ClickCallback.Options DEFAULT = new ClickCallbackOptionsImpl.BuilderImpl().build(); @@ -49,12 +50,12 @@ public int uses() { } @Override - public @NotNull Duration lifetime() { + public Duration lifetime() { return this.lifetime; } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("uses", this.uses), ExaminableProperty.of("expiration", this.lifetime) @@ -77,24 +78,24 @@ static final class BuilderImpl implements Builder { this.lifetime = ClickCallback.DEFAULT_LIFETIME; } - BuilderImpl(final ClickCallback.@NotNull Options existing) { + BuilderImpl(final ClickCallback.Options existing) { this.uses = existing.uses(); this.lifetime = existing.lifetime(); } @Override - public ClickCallback.@NotNull Options build() { + public ClickCallback.Options build() { return new ClickCallbackOptionsImpl(this.uses, this.lifetime); } @Override - public @NotNull Builder uses(final int uses) { + public Builder uses(final int uses) { this.uses = uses; return this; } @Override - public @NotNull Builder lifetime(final @NotNull TemporalAmount lifetime) { + public Builder lifetime(final TemporalAmount lifetime) { this.lifetime = lifetime instanceof Duration ? (Duration) lifetime : Duration.from(requireNonNull(lifetime, "lifetime")); return this; } diff --git a/api/src/main/java/net/kyori/adventure/text/event/ClickEvent.java b/api/src/main/java/net/kyori/adventure/text/event/ClickEvent.java index 1a6bee3a28..e33c300a42 100644 --- a/api/src/main/java/net/kyori/adventure/text/event/ClickEvent.java +++ b/api/src/main/java/net/kyori/adventure/text/event/ClickEvent.java @@ -35,8 +35,8 @@ import net.kyori.adventure.util.Index; import net.kyori.examination.Examinable; import net.kyori.examination.ExaminableProperty; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; @@ -47,6 +47,7 @@ * * @since 4.0.0 */ +@NullMarked public final class ClickEvent implements Examinable, StyleBuilderApplicable { /** * Creates a click event that opens a url. @@ -55,7 +56,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a click event * @since 4.0.0 */ - public static @NotNull ClickEvent openUrl(final @NotNull String url) { + public static ClickEvent openUrl(final String url) { return new ClickEvent(Action.OPEN_URL, url); } @@ -66,7 +67,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a click event * @since 4.0.0 */ - public static @NotNull ClickEvent openUrl(final @NotNull URL url) { + public static ClickEvent openUrl(final URL url) { return openUrl(url.toExternalForm()); } @@ -79,7 +80,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a click event * @since 4.0.0 */ - public static @NotNull ClickEvent openFile(final @NotNull String file) { + public static ClickEvent openFile(final String file) { return new ClickEvent(Action.OPEN_FILE, file); } @@ -90,7 +91,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a click event * @since 4.0.0 */ - public static @NotNull ClickEvent runCommand(final @NotNull String command) { + public static ClickEvent runCommand(final String command) { return new ClickEvent(Action.RUN_COMMAND, command); } @@ -101,7 +102,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a click event * @since 4.0.0 */ - public static @NotNull ClickEvent suggestCommand(final @NotNull String command) { + public static ClickEvent suggestCommand(final String command) { return new ClickEvent(Action.SUGGEST_COMMAND, command); } @@ -112,7 +113,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a click event * @since 4.0.0 */ - public static @NotNull ClickEvent changePage(final @NotNull String page) { + public static ClickEvent changePage(final String page) { return new ClickEvent(Action.CHANGE_PAGE, page); } @@ -123,7 +124,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a click event * @since 4.0.0 */ - public static @NotNull ClickEvent changePage(final int page) { + public static ClickEvent changePage(final int page) { return changePage(String.valueOf(page)); } @@ -135,7 +136,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @since 4.0.0 * @sinceMinecraft 1.15 */ - public static @NotNull ClickEvent copyToClipboard(final @NotNull String text) { + public static ClickEvent copyToClipboard(final String text) { return new ClickEvent(Action.COPY_TO_CLIPBOARD, text); } @@ -148,7 +149,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a callback click event * @since 4.13.0 */ - public static @NotNull ClickEvent callback(final @NotNull ClickCallback function) { + public static ClickEvent callback(final ClickCallback function) { return ClickCallbackInternals.PROVIDER.create(requireNonNull(function, "function"), ClickCallbackOptionsImpl.DEFAULT); } @@ -160,7 +161,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a callback click event * @since 4.13.0 */ - public static @NotNull ClickEvent callback(final @NotNull ClickCallback function, final ClickCallback.@NotNull Options options) { + public static ClickEvent callback(final ClickCallback function, final ClickCallback.Options options) { return ClickCallbackInternals.PROVIDER.create(requireNonNull(function, "function"), requireNonNull(options, "options")); } @@ -172,7 +173,7 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a callback click event * @since 4.13.0 */ - public static @NotNull ClickEvent callback(final @NotNull ClickCallback function, final @NotNull Consumer optionsBuilder) { + public static ClickEvent callback(final ClickCallback function, final Consumer optionsBuilder) { return ClickCallbackInternals.PROVIDER.create( requireNonNull(function, "function"), AbstractBuilder.configureAndBuild(ClickCallback.Options.builder(), requireNonNull(optionsBuilder, "optionsBuilder")) @@ -187,14 +188,14 @@ public final class ClickEvent implements Examinable, StyleBuilderApplicable { * @return a click event * @since 4.0.0 */ - public static @NotNull ClickEvent clickEvent(final @NotNull Action action, final @NotNull String value) { + public static ClickEvent clickEvent(final Action action, final String value) { return new ClickEvent(action, value); } private final Action action; private final String value; - private ClickEvent(final @NotNull Action action, final @NotNull String value) { + private ClickEvent(final Action action, final String value) { this.action = requireNonNull(action, "action"); this.value = requireNonNull(value, "value"); } @@ -205,7 +206,7 @@ private ClickEvent(final @NotNull Action action, final @NotNull String value) { * @return the click event action * @since 4.0.0 */ - public @NotNull Action action() { + public Action action() { return this.action; } @@ -215,12 +216,12 @@ private ClickEvent(final @NotNull Action action, final @NotNull String value) { * @return the click event value * @since 4.0.0 */ - public @NotNull String value() { + public String value() { return this.value; } @Override - public void styleApply(final Style.@NotNull Builder style) { + public void styleApply(final Style.Builder style) { style.clickEvent(this); } @@ -240,7 +241,7 @@ public int hashCode() { } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("action", this.action), ExaminableProperty.of("value", this.value) @@ -312,7 +313,7 @@ public enum Action { */ private final boolean readable; - Action(final @NotNull String name, final boolean readable) { + Action(final String name, final boolean readable) { this.name = name; this.readable = readable; } @@ -329,7 +330,7 @@ public boolean readable() { } @Override - public @NotNull String toString() { + public String toString() { return this.name; } } diff --git a/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java b/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java index a662a94bd5..52144da166 100644 --- a/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java +++ b/api/src/main/java/net/kyori/adventure/text/event/HoverEvent.java @@ -40,9 +40,9 @@ import net.kyori.examination.Examinable; import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Range; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; @@ -55,6 +55,7 @@ * @param the value type * @since 4.0.0 */ +@NullMarked public final class HoverEvent implements Examinable, HoverEventSource, StyleBuilderApplicable { /** * Creates a hover event that shows text on hover. @@ -63,7 +64,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a hover event * @since 4.2.0 */ - public static @NotNull HoverEvent showText(final @NotNull ComponentLike text) { + public static HoverEvent showText(final ComponentLike text) { return showText(text.asComponent()); } @@ -74,7 +75,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a hover event * @since 4.0.0 */ - public static @NotNull HoverEvent showText(final @NotNull Component text) { + public static HoverEvent showText(final Component text) { return new HoverEvent<>(Action.SHOW_TEXT, text); } @@ -86,7 +87,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a hover event * @since 4.0.0 */ - public static @NotNull HoverEvent showItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { + public static HoverEvent showItem(final Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { return showItem(item, count, null); } @@ -98,7 +99,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a hover event * @since 4.6.0 */ - public static @NotNull HoverEvent showItem(final @NotNull Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { + public static HoverEvent showItem(final Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { return showItem(item, count, null); } @@ -111,7 +112,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a hover event * @since 4.0.0 */ - public static @NotNull HoverEvent showItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { + public static HoverEvent showItem(final Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { return showItem(ShowItem.of(item, count, nbt)); } @@ -124,7 +125,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a hover event * @since 4.6.0 */ - public static @NotNull HoverEvent showItem(final @NotNull Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { + public static HoverEvent showItem(final Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { return showItem(ShowItem.of(item, count, nbt)); } @@ -135,7 +136,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a hover event * @since 4.0.0 */ - public static @NotNull HoverEvent showItem(final @NotNull ShowItem item) { + public static HoverEvent showItem(final ShowItem item) { return new HoverEvent<>(Action.SHOW_ITEM, item); } @@ -149,7 +150,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a {@code ShowEntity} * @since 4.0.0 */ - public static @NotNull HoverEvent showEntity(final @NotNull Key type, final @NotNull UUID id) { + public static HoverEvent showEntity(final Key type, final UUID id) { return showEntity(type, id, null); } @@ -163,7 +164,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a {@code ShowEntity} * @since 4.6.0 */ - public static @NotNull HoverEvent showEntity(final @NotNull Keyed type, final @NotNull UUID id) { + public static HoverEvent showEntity(final Keyed type, final UUID id) { return showEntity(type, id, null); } @@ -178,7 +179,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a {@code ShowEntity} * @since 4.0.0 */ - public static @NotNull HoverEvent showEntity(final @NotNull Key type, final @NotNull UUID id, final @Nullable Component name) { + public static HoverEvent showEntity(final Key type, final UUID id, final @Nullable Component name) { return showEntity(ShowEntity.of(type, id, name)); } @@ -193,7 +194,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a {@code ShowEntity} * @since 4.6.0 */ - public static @NotNull HoverEvent showEntity(final @NotNull Keyed type, final @NotNull UUID id, final @Nullable Component name) { + public static HoverEvent showEntity(final Keyed type, final UUID id, final @Nullable Component name) { return showEntity(ShowEntity.of(type, id, name)); } @@ -206,7 +207,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a hover event * @since 4.0.0 */ - public static @NotNull HoverEvent showEntity(final @NotNull ShowEntity entity) { + public static HoverEvent showEntity(final ShowEntity entity) { return new HoverEvent<>(Action.SHOW_ENTITY, entity); } @@ -219,7 +220,7 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @deprecated Removed in Vanilla 1.12, but we keep it for backwards compat */ @Deprecated - public static @NotNull HoverEvent showAchievement(final @NotNull String value) { + public static HoverEvent showAchievement(final String value) { return new HoverEvent<>(Action.SHOW_ACHIEVEMENT, value); } @@ -232,14 +233,14 @@ public final class HoverEvent implements Examinable, HoverEventSource, Sty * @return a click event * @since 4.0.0 */ - public static @NotNull HoverEvent hoverEvent(final @NotNull Action action, final @NotNull V value) { + public static HoverEvent hoverEvent(final Action action, final V value) { return new HoverEvent<>(action, value); } private final Action action; private final V value; - private HoverEvent(final @NotNull Action action, final @NotNull V value) { + private HoverEvent(final Action action, final V value) { this.action = requireNonNull(action, "action"); this.value = requireNonNull(value, "value"); } @@ -250,7 +251,7 @@ private HoverEvent(final @NotNull Action action, final @NotNull V value) { * @return the hover event action * @since 4.0.0 */ - public @NotNull Action action() { + public Action action() { return this.action; } @@ -260,7 +261,7 @@ private HoverEvent(final @NotNull Action action, final @NotNull V value) { * @return the hover event value * @since 4.0.0 */ - public @NotNull V value() { + public V value() { return this.value; } @@ -271,7 +272,7 @@ private HoverEvent(final @NotNull Action action, final @NotNull V value) { * @return a hover event * @since 4.0.0 */ - public @NotNull HoverEvent value(final @NotNull V value) { + public HoverEvent value(final V value) { return new HoverEvent<>(this.action, value); } @@ -284,7 +285,7 @@ private HoverEvent(final @NotNull Action action, final @NotNull V value) { * @return a hover event * @since 4.0.0 */ - public @NotNull HoverEvent withRenderedValue(final @NotNull ComponentRenderer renderer, final @NotNull C context) { + public HoverEvent withRenderedValue(final ComponentRenderer renderer, final C context) { final V oldValue = this.value; final V newValue = this.action.renderer.render(renderer, context, oldValue); if (newValue != oldValue) return new HoverEvent<>(this.action, newValue); @@ -292,18 +293,18 @@ private HoverEvent(final @NotNull Action action, final @NotNull V value) { } @Override - public @NotNull HoverEvent asHoverEvent() { + public HoverEvent asHoverEvent() { return this; // i already am a hover event! hehehehe } @Override - public @NotNull HoverEvent asHoverEvent(final @NotNull UnaryOperator op) { + public HoverEvent asHoverEvent(final UnaryOperator op) { if (op == UnaryOperator.identity()) return this; // nothing to do, can return ourself return new HoverEvent<>(this.action, op.apply(this.value)); } @Override - public void styleApply(final Style.@NotNull Builder style) { + public void styleApply(final Style.Builder style) { style.hoverEvent(this); } @@ -323,7 +324,7 @@ public int hashCode() { } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("action", this.action), ExaminableProperty.of("value", this.value) @@ -353,7 +354,7 @@ public static final class ShowItem implements Examinable { * @return a {@code ShowItem} * @since 4.14.0 */ - public static @NotNull ShowItem showItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { + public static ShowItem showItem(final Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { return showItem(item, count, null); } @@ -368,7 +369,7 @@ public static final class ShowItem implements Examinable { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - public static @NotNull ShowItem of(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { + public static ShowItem of(final Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { return of(item, count, null); } @@ -380,7 +381,7 @@ public static final class ShowItem implements Examinable { * @return a {@code ShowItem} * @since 4.14.0 */ - public static @NotNull ShowItem showItem(final @NotNull Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { + public static ShowItem showItem(final Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { return showItem(item, count, null); } @@ -395,7 +396,7 @@ public static final class ShowItem implements Examinable { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - public static @NotNull ShowItem of(final @NotNull Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { + public static ShowItem of(final Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count) { return of(item, count, null); } @@ -408,7 +409,7 @@ public static final class ShowItem implements Examinable { * @return a {@code ShowItem} * @since 4.14.0 */ - public static @NotNull ShowItem showItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { + public static ShowItem showItem(final Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { return new ShowItem(requireNonNull(item, "item"), count, nbt); } @@ -424,7 +425,7 @@ public static final class ShowItem implements Examinable { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - public static @NotNull ShowItem of(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { + public static ShowItem of(final Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { return new ShowItem(requireNonNull(item, "item"), count, nbt); } @@ -437,7 +438,7 @@ public static final class ShowItem implements Examinable { * @return a {@code ShowItem} * @since 4.14.0 */ - public static @NotNull ShowItem showItem(final @NotNull Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { + public static ShowItem showItem(final Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { return new ShowItem(requireNonNull(item, "item").key(), count, nbt); } @@ -453,11 +454,11 @@ public static final class ShowItem implements Examinable { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - public static @NotNull ShowItem of(final @NotNull Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { + public static ShowItem of(final Keyed item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { return new ShowItem(requireNonNull(item, "item").key(), count, nbt); } - private ShowItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { + private ShowItem(final Key item, final @Range(from = 0, to = Integer.MAX_VALUE) int count, final @Nullable BinaryTagHolder nbt) { this.item = item; this.count = count; this.nbt = nbt; @@ -469,7 +470,7 @@ private ShowItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MA * @return the item * @since 4.0.0 */ - public @NotNull Key item() { + public Key item() { return this.item; } @@ -480,7 +481,7 @@ private ShowItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MA * @return a {@code ShowItem} * @since 4.0.0 */ - public @NotNull ShowItem item(final @NotNull Key item) { + public ShowItem item(final Key item) { if (requireNonNull(item, "item").equals(this.item)) return this; return new ShowItem(item, this.count, this.nbt); } @@ -502,7 +503,7 @@ private ShowItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MA * @return a {@code ShowItem} * @since 4.0.0 */ - public @NotNull ShowItem count(final @Range(from = 0, to = Integer.MAX_VALUE) int count) { + public ShowItem count(final @Range(from = 0, to = Integer.MAX_VALUE) int count) { if (count == this.count) return this; return new ShowItem(this.item, count, this.nbt); } @@ -524,7 +525,7 @@ private ShowItem(final @NotNull Key item, final @Range(from = 0, to = Integer.MA * @return a {@code ShowItem} * @since 4.0.0 */ - public @NotNull ShowItem nbt(final @Nullable BinaryTagHolder nbt) { + public ShowItem nbt(final @Nullable BinaryTagHolder nbt) { if (Objects.equals(nbt, this.nbt)) return this; return new ShowItem(this.item, this.count, nbt); } @@ -546,7 +547,7 @@ public int hashCode() { } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("item", this.item), ExaminableProperty.of("count", this.count), @@ -578,7 +579,7 @@ public static final class ShowEntity implements Examinable { * @return a {@code ShowEntity} * @since 4.14.0 */ - public static @NotNull ShowEntity showEntity(final @NotNull Key type, final @NotNull UUID id) { + public static ShowEntity showEntity(final Key type, final UUID id) { return showEntity(type, id, null); } @@ -593,7 +594,7 @@ public static final class ShowEntity implements Examinable { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - public static @NotNull ShowEntity of(final @NotNull Key type, final @NotNull UUID id) { + public static ShowEntity of(final Key type, final UUID id) { return of(type, id, null); } @@ -605,7 +606,7 @@ public static final class ShowEntity implements Examinable { * @return a {@code ShowEntity} * @since 4.14.0 */ - public static @NotNull ShowEntity showEntity(final @NotNull Keyed type, final @NotNull UUID id) { + public static ShowEntity showEntity(final Keyed type, final UUID id) { return showEntity(type, id, null); } @@ -620,7 +621,7 @@ public static final class ShowEntity implements Examinable { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - public static @NotNull ShowEntity of(final @NotNull Keyed type, final @NotNull UUID id) { + public static ShowEntity of(final Keyed type, final UUID id) { return of(type, id, null); } @@ -633,7 +634,7 @@ public static final class ShowEntity implements Examinable { * @return a {@code ShowEntity} * @since 4.14.0 */ - public static @NotNull ShowEntity showEntity(final @NotNull Key type, final @NotNull UUID id, final @Nullable Component name) { + public static ShowEntity showEntity(final Key type, final UUID id, final @Nullable Component name) { return new ShowEntity(requireNonNull(type, "type"), requireNonNull(id, "id"), name); } @@ -649,7 +650,7 @@ public static final class ShowEntity implements Examinable { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - public static @NotNull ShowEntity of(final @NotNull Key type, final @NotNull UUID id, final @Nullable Component name) { + public static ShowEntity of(final Key type, final UUID id, final @Nullable Component name) { return new ShowEntity(requireNonNull(type, "type"), requireNonNull(id, "id"), name); } @@ -662,7 +663,7 @@ public static final class ShowEntity implements Examinable { * @return a {@code ShowEntity} * @since 4.14.0 */ - public static @NotNull ShowEntity showEntity(final @NotNull Keyed type, final @NotNull UUID id, final @Nullable Component name) { + public static ShowEntity showEntity(final Keyed type, final UUID id, final @Nullable Component name) { return new ShowEntity(requireNonNull(type, "type").key(), requireNonNull(id, "id"), name); } @@ -678,11 +679,11 @@ public static final class ShowEntity implements Examinable { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "5.0.0") - public static @NotNull ShowEntity of(final @NotNull Keyed type, final @NotNull UUID id, final @Nullable Component name) { + public static ShowEntity of(final Keyed type, final UUID id, final @Nullable Component name) { return new ShowEntity(requireNonNull(type, "type").key(), requireNonNull(id, "id"), name); } - private ShowEntity(final @NotNull Key type, final @NotNull UUID id, final @Nullable Component name) { + private ShowEntity(final Key type, final UUID id, final @Nullable Component name) { this.type = type; this.id = id; this.name = name; @@ -694,7 +695,7 @@ private ShowEntity(final @NotNull Key type, final @NotNull UUID id, final @Nulla * @return the type * @since 4.0.0 */ - public @NotNull Key type() { + public Key type() { return this.type; } @@ -705,7 +706,7 @@ private ShowEntity(final @NotNull Key type, final @NotNull UUID id, final @Nulla * @return a {@code ShowEntity} * @since 4.0.0 */ - public @NotNull ShowEntity type(final @NotNull Key type) { + public ShowEntity type(final Key type) { if (requireNonNull(type, "type").equals(this.type)) return this; return new ShowEntity(type, this.id, this.name); } @@ -717,7 +718,7 @@ private ShowEntity(final @NotNull Key type, final @NotNull UUID id, final @Nulla * @return a {@code ShowEntity} * @since 4.6.0 */ - public @NotNull ShowEntity type(final @NotNull Keyed type) { + public ShowEntity type(final Keyed type) { return this.type(requireNonNull(type, "type").key()); } @@ -727,7 +728,7 @@ private ShowEntity(final @NotNull Key type, final @NotNull UUID id, final @Nulla * @return the id * @since 4.0.0 */ - public @NotNull UUID id() { + public UUID id() { return this.id; } @@ -738,7 +739,7 @@ private ShowEntity(final @NotNull Key type, final @NotNull UUID id, final @Nulla * @return a {@code ShowEntity} * @since 4.0.0 */ - public @NotNull ShowEntity id(final @NotNull UUID id) { + public ShowEntity id(final UUID id) { if (requireNonNull(id).equals(this.id)) return this; return new ShowEntity(this.type, id, this.name); } @@ -760,7 +761,7 @@ private ShowEntity(final @NotNull Key type, final @NotNull UUID id, final @Nulla * @return a {@code ShowEntity} * @since 4.0.0 */ - public @NotNull ShowEntity name(final @Nullable Component name) { + public ShowEntity name(final @Nullable Component name) { if (Objects.equals(name, this.name)) return this; return new ShowEntity(this.type, this.id, name); } @@ -782,7 +783,7 @@ public int hashCode() { } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.of( ExaminableProperty.of("type", this.type), ExaminableProperty.of("id", this.id), @@ -810,7 +811,7 @@ public static final class Action { */ public static final Action SHOW_TEXT = new Action<>("show_text", Component.class, true, new Renderer() { @Override - public @NotNull Component render(final @NotNull ComponentRenderer renderer, final @NotNull C context, final @NotNull Component value) { + public Component render(final ComponentRenderer renderer, final C context, final Component value) { return renderer.render(value, context); } }); @@ -821,7 +822,7 @@ public static final class Action { */ public static final Action SHOW_ITEM = new Action<>("show_item", ShowItem.class, true, new Renderer() { @Override - public @NotNull ShowItem render(final @NotNull ComponentRenderer renderer, final @NotNull C context, final @NotNull ShowItem value) { + public ShowItem render(final ComponentRenderer renderer, final C context, final ShowItem value) { return value; } }); @@ -832,7 +833,7 @@ public static final class Action { */ public static final Action SHOW_ENTITY = new Action<>("show_entity", ShowEntity.class, true, new Renderer() { @Override - public @NotNull ShowEntity render(final @NotNull ComponentRenderer renderer, final @NotNull C context, final @NotNull ShowEntity value) { + public ShowEntity render(final ComponentRenderer renderer, final C context, final ShowEntity value) { if (value.name == null) return value; return value.name(renderer.render(value.name, context)); } @@ -846,7 +847,7 @@ public static final class Action { @Deprecated public static final Action SHOW_ACHIEVEMENT = new Action<>("show_achievement", String.class, true, new Renderer() { @Override - public @NotNull String render(final @NotNull ComponentRenderer renderer, final @NotNull C context, final @NotNull String value) { + public String render(final ComponentRenderer renderer, final C context, final String value) { return value; } }); @@ -880,7 +881,7 @@ public static final class Action { * @return the value type * @since 4.0.0 */ - public @NotNull Class type() { + public Class type() { return this.type; } @@ -896,13 +897,13 @@ public boolean readable() { } @Override - public @NotNull String toString() { + public String toString() { return this.name; } @FunctionalInterface interface Renderer { - @NotNull V render(final @NotNull ComponentRenderer renderer, final @NotNull C context, final @NotNull V value); + V render(final ComponentRenderer renderer, final C context, final V value); } } } diff --git a/api/src/main/java/net/kyori/adventure/text/event/HoverEventSource.java b/api/src/main/java/net/kyori/adventure/text/event/HoverEventSource.java index b443a29de4..2e1cf7f5b3 100644 --- a/api/src/main/java/net/kyori/adventure/text/event/HoverEventSource.java +++ b/api/src/main/java/net/kyori/adventure/text/event/HoverEventSource.java @@ -24,8 +24,8 @@ package net.kyori.adventure.text.event; import java.util.function.UnaryOperator; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Something that can provide a {@link HoverEvent}. @@ -33,6 +33,7 @@ * @param the value type * @since 4.0.0 */ +@NullMarked public interface HoverEventSource { /** * Fetches a {@link HoverEvent} from a {@code HoverEventSource}. @@ -52,7 +53,7 @@ public interface HoverEventSource { * @return a hover event * @since 4.0.0 */ - default @NotNull HoverEvent asHoverEvent() { + default HoverEvent asHoverEvent() { return this.asHoverEvent(UnaryOperator.identity()); } @@ -66,5 +67,5 @@ public interface HoverEventSource { * @return a hover event * @since 4.0.0 */ - @NotNull HoverEvent asHoverEvent(final @NotNull UnaryOperator op); + HoverEvent asHoverEvent(final UnaryOperator op); } diff --git a/api/src/main/java/net/kyori/adventure/text/flattener/ComponentFlattener.java b/api/src/main/java/net/kyori/adventure/text/flattener/ComponentFlattener.java index 8344bf9327..0d2877884f 100644 --- a/api/src/main/java/net/kyori/adventure/text/flattener/ComponentFlattener.java +++ b/api/src/main/java/net/kyori/adventure/text/flattener/ComponentFlattener.java @@ -29,14 +29,15 @@ import net.kyori.adventure.builder.AbstractBuilder; import net.kyori.adventure.text.Component; import net.kyori.adventure.util.Buildable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A 'flattener' to convert a component tree to a linear string for display. * * @since 4.7.0 */ +@NullMarked public interface ComponentFlattener extends Buildable { /** * Create a new builder for a flattener. @@ -44,7 +45,7 @@ public interface ComponentFlattener extends Buildable, Buildable.Builder * @see #complexMapper(Class, BiConsumer) for component types that are too complex to be directly rendered to a string * @since 4.7.0 */ - @NotNull Builder mapper(final @NotNull Class type, final @NotNull Function converter); + Builder mapper(final Class type, final Function converter); /** * Register a type of component that needs to be flattened to an intermediate stage. @@ -111,7 +112,7 @@ interface Builder extends AbstractBuilder, Buildable.Builder * @return this builder * @since 4.7.0 */ - @NotNull Builder complexMapper(final @NotNull Class type, final @NotNull BiConsumer> converter); + Builder complexMapper(final Class type, final BiConsumer> converter); /** * Register a handler for unknown component types. @@ -122,6 +123,6 @@ interface Builder extends AbstractBuilder, Buildable.Builder * @return this builder * @since 4.7.0 */ - @NotNull Builder unknownMapper(final @Nullable Function converter); + Builder unknownMapper(final @Nullable Function converter); } } diff --git a/api/src/main/java/net/kyori/adventure/text/flattener/ComponentFlattenerImpl.java b/api/src/main/java/net/kyori/adventure/text/flattener/ComponentFlattenerImpl.java index 51c1987b72..33d8a23f36 100644 --- a/api/src/main/java/net/kyori/adventure/text/flattener/ComponentFlattenerImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/flattener/ComponentFlattenerImpl.java @@ -38,11 +38,12 @@ import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.format.Style; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import static java.util.Objects.requireNonNull; +@NullMarked final class ComponentFlattenerImpl implements ComponentFlattener { @SuppressWarnings("deprecation") static final ComponentFlattener BASIC = new BuilderImpl() @@ -78,11 +79,11 @@ final class ComponentFlattenerImpl implements ComponentFlattener { } @Override - public void flatten(final @NotNull Component input, final @NotNull FlattenerListener listener) { + public void flatten(final Component input, final FlattenerListener listener) { this.flatten0(input, listener, 0); } - private void flatten0(final @NotNull Component input, final @NotNull FlattenerListener listener, final int depth) { + private void flatten0(final Component input, final FlattenerListener listener, final int depth) { requireNonNull(input, "input"); requireNonNull(listener, "listener"); if (input == Component.empty()) return; @@ -143,7 +144,7 @@ private void flatten0(final @NotNull Component input, final @NotNull FlattenerLi } @Override - public ComponentFlattener.@NotNull Builder toBuilder() { + public ComponentFlattener.Builder toBuilder() { return new BuilderImpl(this.flatteners, this.complexFlatteners, this.unknownHandler); } @@ -172,12 +173,12 @@ static final class BuilderImpl implements Builder { } @Override - public @NotNull ComponentFlattener build() { + public ComponentFlattener build() { return new ComponentFlattenerImpl(this.flatteners, this.complexFlatteners, this.unknownHandler); } @Override - public ComponentFlattener.@NotNull Builder mapper(final @NotNull Class type, final @NotNull Function converter) { + public ComponentFlattener.Builder mapper(final Class type, final Function converter) { this.validateNoneInHierarchy(requireNonNull(type, "type")); this.flatteners.put( type, @@ -188,7 +189,7 @@ static final class BuilderImpl implements Builder { } @Override - public ComponentFlattener.@NotNull Builder complexMapper(final @NotNull Class type, final @NotNull BiConsumer> converter) { + public ComponentFlattener.Builder complexMapper(final Class type, final BiConsumer> converter) { this.validateNoneInHierarchy(requireNonNull(type, "type")); this.complexFlatteners.put( type, @@ -216,7 +217,7 @@ private static void testHierarchy(final Class existing, final Class beingR } @Override - public ComponentFlattener.@NotNull Builder unknownMapper(final @Nullable Function converter) { + public ComponentFlattener.Builder unknownMapper(final @Nullable Function converter) { this.unknownHandler = converter; return this; } diff --git a/api/src/main/java/net/kyori/adventure/text/flattener/FlattenerListener.java b/api/src/main/java/net/kyori/adventure/text/flattener/FlattenerListener.java index 91584f6d52..33598e1c03 100644 --- a/api/src/main/java/net/kyori/adventure/text/flattener/FlattenerListener.java +++ b/api/src/main/java/net/kyori/adventure/text/flattener/FlattenerListener.java @@ -24,7 +24,7 @@ package net.kyori.adventure.text.flattener; import net.kyori.adventure.text.format.Style; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * A listener accepting styled information from flattened components. @@ -32,6 +32,7 @@ * @since 4.7.0 */ @FunctionalInterface +@NullMarked public interface FlattenerListener { /** * Begin a region of style in the component. @@ -39,7 +40,7 @@ public interface FlattenerListener { * @param style the style to push * @since 4.7.0 */ - default void pushStyle(final @NotNull Style style) { + default void pushStyle(final Style style) { } /** @@ -48,7 +49,7 @@ default void pushStyle(final @NotNull Style style) { * @param text the component text * @since 4.7.0 */ - void component(final @NotNull String text); + void component(final String text); /** * Pop a pushed style. @@ -58,6 +59,6 @@ default void pushStyle(final @NotNull Style style) { * @param style the style popped, as passed to {@link #pushStyle(Style)} * @since 4.7.0 */ - default void popStyle(final @NotNull Style style) { + default void popStyle(final Style style) { } } diff --git a/api/src/main/java/net/kyori/adventure/text/format/DecorationMap.java b/api/src/main/java/net/kyori/adventure/text/format/DecorationMap.java index 1943a05ca2..43e9118d73 100644 --- a/api/src/main/java/net/kyori/adventure/text/format/DecorationMap.java +++ b/api/src/main/java/net/kyori/adventure/text/format/DecorationMap.java @@ -37,8 +37,8 @@ import java.util.stream.Stream; import net.kyori.examination.Examinable; import net.kyori.examination.ExaminableProperty; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; +import org.jspecify.annotations.NullMarked; /** * Bit-set driven decoration -> state map. @@ -78,6 +78,7 @@ * a single {@code byte}, I however am not doing that because it's more effort than my time's worth.

*/ @Unmodifiable +@NullMarked final class DecorationMap extends AbstractMap implements Examinable { static final TextDecoration[] DECORATIONS = TextDecoration.values(); private static final TextDecoration.State[] STATES = TextDecoration.State.values(); @@ -125,7 +126,7 @@ private DecorationMap(final int bitSet) { this.bitSet = bitSet; } - public @NotNull DecorationMap with(final @NotNull TextDecoration decoration, final TextDecoration.@NotNull State state) { + public DecorationMap with(final TextDecoration decoration, final TextDecoration.State state) { Objects.requireNonNull(state, "state"); Objects.requireNonNull(decoration, "decoration"); final int offset = offset(decoration); @@ -134,7 +135,7 @@ private DecorationMap(final int bitSet) { } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Arrays.stream(DECORATIONS) .map(decoration -> ExaminableProperty.of(decoration.toString(), this.get(decoration))); } @@ -164,7 +165,7 @@ public boolean isEmpty() { } @Override - public @NotNull Set> entrySet() { + public Set> entrySet() { if (this.entrySet == null) { synchronized (this) { // re-check for lost race condition @@ -177,12 +178,12 @@ public boolean isEmpty() { } @Override - public @NotNull Set keySet() { + public Set keySet() { return KEY_SET; } @Override - public @NotNull Collection values() { + public Collection values() { if (this.values == null) { synchronized (this) { // re-check for lost race condition @@ -208,7 +209,7 @@ public int hashCode() { final class EntrySet extends AbstractSet> { @Override - public @NotNull Iterator> iterator() { + public Iterator> iterator() { return new Iterator>() { private final Iterator decorations = KEY_SET.iterator(); private final Iterator states = DecorationMap.this.values().iterator(); @@ -236,7 +237,7 @@ public int size() { final class Values extends AbstractCollection { @Override - public @NotNull Iterator iterator() { + public Iterator iterator() { return Spliterators.iterator(Arrays.spliterator(this.toArray(EMPTY_STATE_ARRAY))); } @@ -246,7 +247,7 @@ public boolean isEmpty() { } @Override - public Object @NotNull [] toArray() { + public Object[] toArray() { final Object[] states = new Object[MAP_SIZE]; for (int i = 0; i < MAP_SIZE; i++) { states[i] = DecorationMap.this.get(DECORATIONS[i]); @@ -256,7 +257,7 @@ public boolean isEmpty() { @Override @SuppressWarnings("unchecked") - public T @NotNull [] toArray(final T @NotNull [] dest) { + public T[] toArray(final T[] dest) { if (dest.length < MAP_SIZE) { return (T[]) Arrays.copyOf(this.toArray(), MAP_SIZE, dest.getClass()); } @@ -291,13 +292,13 @@ public boolean isEmpty() { } @Override - public Object @NotNull [] toArray() { + public Object[] toArray() { return Arrays.copyOf(DECORATIONS, MAP_SIZE, Object[].class); } @Override @SuppressWarnings("unchecked") - public T @NotNull [] toArray(final T @NotNull [] dest) { + public T[] toArray(final T[] dest) { if (dest.length < MAP_SIZE) { return (T[]) Arrays.copyOf(DECORATIONS, MAP_SIZE, dest.getClass()); } @@ -309,7 +310,7 @@ public boolean isEmpty() { } @Override - public @NotNull Iterator iterator() { + public Iterator iterator() { return Spliterators.iterator(Arrays.spliterator(DECORATIONS)); } diff --git a/api/src/main/java/net/kyori/adventure/text/format/MutableStyleSetter.java b/api/src/main/java/net/kyori/adventure/text/format/MutableStyleSetter.java index 1bf30b6dc5..f3ebd907d1 100644 --- a/api/src/main/java/net/kyori/adventure/text/format/MutableStyleSetter.java +++ b/api/src/main/java/net/kyori/adventure/text/format/MutableStyleSetter.java @@ -28,7 +28,7 @@ import net.kyori.adventure.text.Component; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import static java.util.Objects.requireNonNull; @@ -41,6 +41,7 @@ * @since 4.10.0 */ @ApiStatus.NonExtendable +@NullMarked public interface MutableStyleSetter> extends StyleSetter { /** * Sets {@code decorations} to {@link TextDecoration.State#TRUE}. @@ -52,7 +53,7 @@ public interface MutableStyleSetter> extends Sty @Override @Contract("_ -> this") @SuppressWarnings("unchecked") - default @NotNull T decorate(final @NotNull TextDecoration@NotNull... decorations) { + default T decorate(final TextDecoration... decorations) { for (int i = 0, length = decorations.length; i < length; i++) { this.decorate(decorations[i]); } @@ -71,7 +72,7 @@ public interface MutableStyleSetter> extends Sty @Override @Contract("_ -> this") @SuppressWarnings("unchecked") - default @NotNull T decorations(final @NotNull Map decorations) { + default T decorations(final Map decorations) { requireNonNull(decorations, "decorations"); for (final Map.Entry entry : decorations.entrySet()) { this.decoration(entry.getKey(), entry.getValue()); @@ -91,7 +92,7 @@ public interface MutableStyleSetter> extends Sty @Override @Contract("_, _ -> this") @SuppressWarnings("unchecked") - default @NotNull T decorations(final @NotNull Set decorations, final boolean flag) { + default T decorations(final Set decorations, final boolean flag) { final TextDecoration.State state = TextDecoration.State.byBoolean(flag); decorations.forEach(decoration -> this.decoration(decoration, state)); return (T) this; diff --git a/api/src/main/java/net/kyori/adventure/text/format/NamedTextColor.java b/api/src/main/java/net/kyori/adventure/text/format/NamedTextColor.java index 787daeeb31..6755c83652 100644 --- a/api/src/main/java/net/kyori/adventure/text/format/NamedTextColor.java +++ b/api/src/main/java/net/kyori/adventure/text/format/NamedTextColor.java @@ -31,14 +31,15 @@ import net.kyori.adventure.util.Index; import net.kyori.examination.ExaminableProperty; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * The named text colours in Minecraft: Java Edition. * * @since 4.0.0 */ +@NullMarked public final class NamedTextColor implements TextColor { private static final int BLACK_VALUE = 0x000000; private static final int DARK_BLUE_VALUE = 0x0000aa; @@ -230,7 +231,7 @@ public final class NamedTextColor implements TextColor { * @return nearest named colour. will always return a value * @since 4.0.0 */ - public static @NotNull NamedTextColor nearestTo(final @NotNull TextColor any) { + public static NamedTextColor nearestTo(final TextColor any) { if (any instanceof NamedTextColor) { return (NamedTextColor) any; } @@ -254,17 +255,17 @@ public int value() { } @Override - public @NotNull HSVLike asHSV() { + public HSVLike asHSV() { return this.hsv; } @Override - public @NotNull String toString() { + public String toString() { return this.name; } @Override - public @NotNull Stream examinableProperties() { + public Stream examinableProperties() { return Stream.concat( Stream.of(ExaminableProperty.of("name", this.name)), TextColor.super.examinableProperties() diff --git a/api/src/main/java/net/kyori/adventure/text/format/Style.java b/api/src/main/java/net/kyori/adventure/text/format/Style.java index 201b9a737e..0180ca059a 100644 --- a/api/src/main/java/net/kyori/adventure/text/format/Style.java +++ b/api/src/main/java/net/kyori/adventure/text/format/Style.java @@ -39,10 +39,9 @@ import net.kyori.examination.Examinable; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.UnknownNullability; import org.jetbrains.annotations.Unmodifiable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A style applies visual effects or extra functionality to {@link Component}s, @@ -61,6 +60,7 @@ * @since 4.0.0 */ @ApiStatus.NonExtendable +@NullMarked public interface Style extends Buildable, Examinable, StyleGetter, StyleSetter