From b73a6916cbe9c956c1c47c039910471514867b92 Mon Sep 17 00:00:00 2001 From: Sxtanna Date: Mon, 27 Jul 2020 11:40:58 -0400 Subject: [PATCH] updated classes with contract annotations --- .../clip/placeholderapi/PlaceholderAPI.java | 33 +++++++++++++++++-- .../clip/placeholderapi/PlaceholderHook.java | 4 +++ .../expansion/PlaceholderExpansion.java | 4 +++ .../manager/LocalExpansionManager.java | 7 ++-- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java index 1e48eaa..1e03609 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java @@ -29,6 +29,7 @@ import me.clip.placeholderapi.replacer.Replacer.Closure; import me.clip.placeholderapi.util.Msg; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -142,6 +143,9 @@ public final class PlaceholderAPI return ImmutableSet.copyOf(PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().getIdentifiers()); } + + // === Deprecated API === + /** * Get map of registered placeholders * @@ -149,15 +153,13 @@ public final class PlaceholderAPI */ @NotNull @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static Map getPlaceholders() { throw new UnsupportedOperationException("PlaceholderAPI no longer provides a view of the placeholder's map!\n" + "Use: PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByIdentifier(String)"); } - - // === Deprecated API === - /** * Translates all placeholders into their corresponding values. *
You set the pattern yourself through this method. @@ -172,6 +174,7 @@ public final class PlaceholderAPI */ @NotNull @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static String setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text, @NotNull final Pattern pattern, final boolean colorize) { return setPlaceholders(player, text); @@ -191,12 +194,14 @@ public final class PlaceholderAPI */ @NotNull @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static List setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List text, @NotNull final Pattern pattern, final boolean colorize) { return setPlaceholders(player, text); } @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static Set getExpansions() { Set set = getPlaceholders().values().stream() @@ -259,6 +264,7 @@ public final class PlaceholderAPI * @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static List setPlaceholders(OfflinePlayer player, List text, boolean colorize) { return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize); @@ -276,6 +282,7 @@ public final class PlaceholderAPI * @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static List setPlaceholders(OfflinePlayer player, List text, Pattern pattern) { return setPlaceholders(player, text, pattern, true); @@ -293,6 +300,7 @@ public final class PlaceholderAPI * @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static String setBracketPlaceholders(OfflinePlayer player, String text, boolean colorize) { return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize); @@ -309,6 +317,7 @@ public final class PlaceholderAPI * @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static String setPlaceholders(OfflinePlayer player, String text, boolean colorize) { return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize); @@ -326,6 +335,7 @@ public final class PlaceholderAPI * @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static String setPlaceholders(OfflinePlayer player, String text, Pattern pattern) { return setPlaceholders(player, text, pattern, true); @@ -342,6 +352,7 @@ public final class PlaceholderAPI * @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static List setRelationalPlaceholders(Player one, Player two, List text) { return setRelationalPlaceholders(one, two, text, true); @@ -359,6 +370,7 @@ public final class PlaceholderAPI * @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static List setRelationalPlaceholders(Player one, Player two, List text, boolean colorize) { if (text == null) @@ -382,6 +394,7 @@ public final class PlaceholderAPI * @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static String setRelationalPlaceholders(Player one, Player two, String text) { return setRelationalPlaceholders(one, two, text, true); @@ -400,6 +413,7 @@ public final class PlaceholderAPI */ @Deprecated @SuppressWarnings("DuplicatedCode") + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static String setRelationalPlaceholders(Player one, Player two, String text, boolean colorize) { if (text == null) @@ -452,6 +466,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static Pattern getPlaceholderPattern() { return PLACEHOLDER_PATTERN; @@ -464,6 +479,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static Pattern getBracketPlaceholderPattern() { return BRACKET_PLACEHOLDER_PATTERN; @@ -476,6 +492,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static Pattern getRelationalPlaceholderPattern() { return RELATIONAL_PLACEHOLDER_PATTERN; @@ -485,6 +502,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static Set getRegisteredPlaceholderPlugins() { return getRegisteredIdentifiers(); @@ -494,6 +512,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static Set getExternalPlaceholderPlugins() { return null; @@ -503,6 +522,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static String setPlaceholders(Player player, String text) { return setPlaceholders(((OfflinePlayer) player), text); @@ -512,6 +532,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static String setPlaceholders(Player player, String text, boolean colorize) { return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize); @@ -521,6 +542,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static List setPlaceholders(Player player, List text) { return setPlaceholders(player, text, PLACEHOLDER_PATTERN, true); @@ -530,6 +552,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static List setPlaceholders(Player player, List text, boolean colorize) { return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize); @@ -539,6 +562,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static String setBracketPlaceholders(Player player, String text) { return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, true); @@ -548,6 +572,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static String setBracketPlaceholders(Player player, String text, boolean colorize) { return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize); @@ -557,6 +582,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static List setBracketPlaceholders(Player player, List text) { return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, true); @@ -566,6 +592,7 @@ public final class PlaceholderAPI * @deprecated Will be removed in a future release. */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public static List setBracketPlaceholders(Player player, List text, boolean colorize) { return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize); diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderHook.java b/src/main/java/me/clip/placeholderapi/PlaceholderHook.java index 915f7ed..1fddefe 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderHook.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderHook.java @@ -22,6 +22,7 @@ package me.clip.placeholderapi; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,6 +30,8 @@ import org.jetbrains.annotations.Nullable; * @deprecated This class will be completely removed in the next release, please use {@link me.clip.placeholderapi.expansion.PlaceholderExpansion} */ @Deprecated +@ApiStatus.NonExtendable +@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public abstract class PlaceholderHook { @@ -64,6 +67,7 @@ public abstract class PlaceholderHook */ @Nullable @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public String onPlaceholderRequest(@Nullable final Player player, @NotNull final String params) { return null; diff --git a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java index ec86eef..8489764 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java +++ b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java @@ -25,6 +25,7 @@ import me.clip.placeholderapi.PlaceholderHook; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.configuration.ConfigurationSection; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -271,6 +272,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook * @deprecated As of versions greater than 2.8.7, use {@link #getRequiredPlugin()} */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public String getPlugin() { return null; @@ -280,6 +282,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook * @deprecated As of versions greater than 2.8.7, use the expansion cloud to show a description */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public String getDescription() { return null; @@ -289,6 +292,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook * @deprecated As of versions greater than 2.8.7, use the expansion cloud to display a link */ @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.10.8") public String getLink() { return null; diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java index e58317f..2781e7f 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -39,6 +39,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.server.PluginDisableEvent; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; @@ -163,13 +164,10 @@ public final class LocalExpansionManager implements Listener /** * Do not call this method yourself, use {@link PlaceholderExpansion#register()} */ + @ApiStatus.Internal public boolean register(@NotNull final PlaceholderExpansion expansion) { final String identifier = expansion.getIdentifier(); - if (identifier == null) - { - return false; - } if (expansion instanceof Configurable) { @@ -267,6 +265,7 @@ public final class LocalExpansionManager implements Listener /** * Do not call this method yourself, use {@link PlaceholderExpansion#unregister()} */ + @ApiStatus.Internal public boolean unregister(@NotNull final PlaceholderExpansion expansion) { if (expansions.remove(expansion.getIdentifier()) == null)