Skip to content

Commit

Permalink
Tweak @PlatformAPI implementation and use @ApiStatus.Internal to prod…
Browse files Browse the repository at this point in the history
…uce warnings
  • Loading branch information
KingOfSquares committed Nov 9, 2022
1 parent 36efb91 commit 9630a8a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
package net.kyori.adventure.bossbar;

import net.kyori.adventure.util.PlatformAPI;
import org.jetbrains.annotations.ApiStatus;

/**
* This class is a major hack, intended to allow certain platforms a way
* to define a platform-native counterpart to an Adventure boss bar.
*
* @deprecated not an official API, and may disappear without warning
*/
@ApiStatus.Internal
@Deprecated
@PlatformAPI
abstract class HackyBossBarPlatformBridge {
Expand Down
11 changes: 8 additions & 3 deletions api/src/main/java/net/kyori/adventure/util/PlatformAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,25 @@
*/
package net.kyori.adventure.util;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.jetbrains.annotations.ApiStatus;

/**
* Elements annotated with the {@code @PlatformAPI} annotation are intended for platform implementations of the Adventure api
* only.
* Elements annotated with the {@link PlatformAPI} annotation are intended for platform implementations of the Adventure API
* only and should not be used by standard developers. They are not public API and may change or be removed without warning at any time.
*
* <p>This annotation should always be used in tandem with the {@link ApiStatus.Internal} annotation to more consistently produce
* warnings</p>
*
* @since 4.12.0
*/
@ApiStatus.Internal
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PACKAGE})
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PACKAGE, ElementType.ANNOTATION_TYPE})
public @interface PlatformAPI {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.kyori.adventure.text.minimessage.tree.Node;
import net.kyori.adventure.text.serializer.ComponentSerializer;
import net.kyori.adventure.util.PlatformAPI;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -298,6 +299,7 @@ interface Builder extends AbstractBuilder<MiniMessage> {
* @since 4.10.0
* @hidden
*/
@ApiStatus.Internal
@PlatformAPI
interface Provider {
/**
Expand All @@ -306,6 +308,7 @@ interface Provider {
* @return a {@link MiniMessage} instance
* @since 4.10.0
*/
@ApiStatus.Internal
@PlatformAPI
@NotNull MiniMessage miniMessage();

Expand All @@ -315,6 +318,7 @@ interface Provider {
* @return a {@link Consumer} modifying a {@link Builder}
* @since 4.10.0
*/
@ApiStatus.Internal
@PlatformAPI
@NotNull Consumer<Builder> builder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.kyori.adventure.text.serializer.ComponentSerializer;
import net.kyori.adventure.util.Buildable;
import net.kyori.adventure.util.PlatformAPI;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -162,6 +163,7 @@ interface Builder extends AbstractBuilder<GsonComponentSerializer>, Buildable.Bu
*
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
interface Provider {
/**
Expand All @@ -170,6 +172,7 @@ interface Provider {
* @return a {@link GsonComponentSerializer}
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
@NotNull GsonComponentSerializer gson();

Expand All @@ -179,6 +182,7 @@ interface Provider {
* @return a {@link GsonComponentSerializer}
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
@NotNull GsonComponentSerializer gsonLegacy();

Expand All @@ -188,6 +192,7 @@ interface Provider {
* @return a {@link Consumer}
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
@NotNull Consumer<Builder> builder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.kyori.adventure.text.serializer.ComponentSerializer;
import net.kyori.adventure.util.Buildable;
import net.kyori.adventure.util.PlatformAPI;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -271,6 +272,7 @@ interface Builder extends AbstractBuilder<LegacyComponentSerializer>, Buildable.
*
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
interface Provider {
/**
Expand All @@ -279,6 +281,7 @@ interface Provider {
* @return a {@link LegacyComponentSerializer}
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
@NotNull LegacyComponentSerializer legacyAmpersand();

Expand All @@ -288,6 +291,7 @@ interface Provider {
* @return a {@link LegacyComponentSerializer}
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
@NotNull LegacyComponentSerializer legacySection();

Expand All @@ -297,6 +301,7 @@ interface Provider {
* @return a {@link Consumer}
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
@NotNull Consumer<Builder> legacy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.kyori.adventure.text.serializer.ComponentSerializer;
import net.kyori.adventure.util.Buildable;
import net.kyori.adventure.util.PlatformAPI;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

/**
Expand Down Expand Up @@ -108,6 +109,7 @@ interface Builder extends AbstractBuilder<PlainTextComponentSerializer>, Buildab
*
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
interface Provider {
/**
Expand All @@ -116,6 +118,7 @@ interface Provider {
* @return a {@link PlainTextComponentSerializer}
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
@NotNull PlainTextComponentSerializer plainTextSimple();

Expand All @@ -125,6 +128,7 @@ interface Provider {
* @return a {@link Consumer}
* @since 4.8.0
*/
@ApiStatus.Internal
@PlatformAPI
@NotNull Consumer<Builder> plainText();
}
Expand Down

0 comments on commit 9630a8a

Please sign in to comment.