updated classes with contract annotations

This commit is contained in:
Sxtanna 2020-07-27 11:40:58 -04:00
parent 134086f6a9
commit b73a6916cb
4 changed files with 41 additions and 7 deletions

@ -29,6 +29,7 @@ import me.clip.placeholderapi.replacer.Replacer.Closure;
import me.clip.placeholderapi.util.Msg; import me.clip.placeholderapi.util.Msg;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -142,6 +143,9 @@ public final class PlaceholderAPI
return ImmutableSet.copyOf(PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().getIdentifiers()); return ImmutableSet.copyOf(PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().getIdentifiers());
} }
// === Deprecated API ===
/** /**
* Get map of registered placeholders * Get map of registered placeholders
* *
@ -149,15 +153,13 @@ public final class PlaceholderAPI
*/ */
@NotNull @NotNull
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Map<String, PlaceholderHook> getPlaceholders() public static Map<String, PlaceholderHook> getPlaceholders()
{ {
throw new UnsupportedOperationException("PlaceholderAPI no longer provides a view of the placeholder's map!\n" + throw new UnsupportedOperationException("PlaceholderAPI no longer provides a view of the placeholder's map!\n" +
"Use: PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByIdentifier(String)"); "Use: PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().findExpansionByIdentifier(String)");
} }
// === Deprecated API ===
/** /**
* Translates all placeholders into their corresponding values. * Translates all placeholders into their corresponding values.
* <br>You set the pattern yourself through this method. * <br>You set the pattern yourself through this method.
@ -172,6 +174,7 @@ public final class PlaceholderAPI
*/ */
@NotNull @NotNull
@Deprecated @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) public static String setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text, @NotNull final Pattern pattern, final boolean colorize)
{ {
return setPlaceholders(player, text); return setPlaceholders(player, text);
@ -191,12 +194,14 @@ public final class PlaceholderAPI
*/ */
@NotNull @NotNull
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List<String> text, @NotNull final Pattern pattern, final boolean colorize) public static List<String> setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List<String> text, @NotNull final Pattern pattern, final boolean colorize)
{ {
return setPlaceholders(player, text); return setPlaceholders(player, text);
} }
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Set<PlaceholderExpansion> getExpansions() public static Set<PlaceholderExpansion> getExpansions()
{ {
Set<PlaceholderExpansion> set = getPlaceholders().values().stream() Set<PlaceholderExpansion> set = getPlaceholders().values().stream()
@ -259,6 +264,7 @@ public final class PlaceholderAPI
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead. * @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text, boolean colorize) public static List<String> setPlaceholders(OfflinePlayer player, List<String> text, boolean colorize)
{ {
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize); return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
@ -276,6 +282,7 @@ public final class PlaceholderAPI
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead. * @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text, Pattern pattern) public static List<String> setPlaceholders(OfflinePlayer player, List<String> text, Pattern pattern)
{ {
return setPlaceholders(player, text, pattern, true); return setPlaceholders(player, text, pattern, true);
@ -293,6 +300,7 @@ public final class PlaceholderAPI
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead. * @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setBracketPlaceholders(OfflinePlayer player, String text, boolean colorize) public static String setBracketPlaceholders(OfflinePlayer player, String text, boolean colorize)
{ {
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, 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 Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setPlaceholders(OfflinePlayer player, String text, boolean colorize) public static String setPlaceholders(OfflinePlayer player, String text, boolean colorize)
{ {
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize); return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
@ -326,6 +335,7 @@ public final class PlaceholderAPI
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead. * @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setPlaceholders(OfflinePlayer player, String text, Pattern pattern) public static String setPlaceholders(OfflinePlayer player, String text, Pattern pattern)
{ {
return setPlaceholders(player, text, pattern, true); return setPlaceholders(player, text, pattern, true);
@ -342,6 +352,7 @@ public final class PlaceholderAPI
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead. * @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text) public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text)
{ {
return setRelationalPlaceholders(one, two, text, true); return setRelationalPlaceholders(one, two, text, true);
@ -359,6 +370,7 @@ public final class PlaceholderAPI
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead. * @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text, boolean colorize) public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text, boolean colorize)
{ {
if (text == null) if (text == null)
@ -382,6 +394,7 @@ public final class PlaceholderAPI
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead. * @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setRelationalPlaceholders(Player one, Player two, String text) public static String setRelationalPlaceholders(Player one, Player two, String text)
{ {
return setRelationalPlaceholders(one, two, text, true); return setRelationalPlaceholders(one, two, text, true);
@ -400,6 +413,7 @@ public final class PlaceholderAPI
*/ */
@Deprecated @Deprecated
@SuppressWarnings("DuplicatedCode") @SuppressWarnings("DuplicatedCode")
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setRelationalPlaceholders(Player one, Player two, String text, boolean colorize) public static String setRelationalPlaceholders(Player one, Player two, String text, boolean colorize)
{ {
if (text == null) if (text == null)
@ -452,6 +466,7 @@ public final class PlaceholderAPI
* @deprecated Will be removed in a future release. * @deprecated Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Pattern getPlaceholderPattern() public static Pattern getPlaceholderPattern()
{ {
return PLACEHOLDER_PATTERN; return PLACEHOLDER_PATTERN;
@ -464,6 +479,7 @@ public final class PlaceholderAPI
* @deprecated Will be removed in a future release. * @deprecated Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Pattern getBracketPlaceholderPattern() public static Pattern getBracketPlaceholderPattern()
{ {
return BRACKET_PLACEHOLDER_PATTERN; return BRACKET_PLACEHOLDER_PATTERN;
@ -476,6 +492,7 @@ public final class PlaceholderAPI
* @deprecated Will be removed in a future release. * @deprecated Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Pattern getRelationalPlaceholderPattern() public static Pattern getRelationalPlaceholderPattern()
{ {
return RELATIONAL_PLACEHOLDER_PATTERN; return RELATIONAL_PLACEHOLDER_PATTERN;
@ -485,6 +502,7 @@ public final class PlaceholderAPI
* @deprecated Will be removed in a future release. * @deprecated Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Set<String> getRegisteredPlaceholderPlugins() public static Set<String> getRegisteredPlaceholderPlugins()
{ {
return getRegisteredIdentifiers(); return getRegisteredIdentifiers();
@ -494,6 +512,7 @@ public final class PlaceholderAPI
* @deprecated Will be removed in a future release. * @deprecated Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static Set<String> getExternalPlaceholderPlugins() public static Set<String> getExternalPlaceholderPlugins()
{ {
return null; return null;
@ -503,6 +522,7 @@ public final class PlaceholderAPI
* @deprecated Will be removed in a future release. * @deprecated Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setPlaceholders(Player player, String text) public static String setPlaceholders(Player player, String text)
{ {
return setPlaceholders(((OfflinePlayer) player), text); return setPlaceholders(((OfflinePlayer) player), text);
@ -512,6 +532,7 @@ public final class PlaceholderAPI
* @deprecated Will be removed in a future release. * @deprecated Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setPlaceholders(Player player, String text, boolean colorize) public static String setPlaceholders(Player player, String text, boolean colorize)
{ {
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, 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 Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setPlaceholders(Player player, List<String> text) public static List<String> setPlaceholders(Player player, List<String> text)
{ {
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, true); return setPlaceholders(player, text, PLACEHOLDER_PATTERN, true);
@ -530,6 +552,7 @@ public final class PlaceholderAPI
* @deprecated Will be removed in a future release. * @deprecated Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setPlaceholders(Player player, List<String> text, boolean colorize) public static List<String> setPlaceholders(Player player, List<String> text, boolean colorize)
{ {
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, 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 Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setBracketPlaceholders(Player player, String text) public static String setBracketPlaceholders(Player player, String text)
{ {
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, true); 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 Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static String setBracketPlaceholders(Player player, String text, boolean colorize) public static String setBracketPlaceholders(Player player, String text, boolean colorize)
{ {
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, 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 Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setBracketPlaceholders(Player player, List<String> text) public static List<String> setBracketPlaceholders(Player player, List<String> text)
{ {
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, true); 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 Will be removed in a future release.
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public static List<String> setBracketPlaceholders(Player player, List<String> text, boolean colorize) public static List<String> setBracketPlaceholders(Player player, List<String> text, boolean colorize)
{ {
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize); return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);

@ -22,6 +22,7 @@ package me.clip.placeholderapi;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; 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 This class will be completely removed in the next release, please use {@link me.clip.placeholderapi.expansion.PlaceholderExpansion}
*/ */
@Deprecated @Deprecated
@ApiStatus.NonExtendable
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public abstract class PlaceholderHook public abstract class PlaceholderHook
{ {
@ -64,6 +67,7 @@ public abstract class PlaceholderHook
*/ */
@Nullable @Nullable
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public String onPlaceholderRequest(@Nullable final Player player, @NotNull final String params) public String onPlaceholderRequest(@Nullable final Player player, @NotNull final String params)
{ {
return null; return null;

@ -25,6 +25,7 @@ import me.clip.placeholderapi.PlaceholderHook;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; 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 As of versions greater than 2.8.7, use {@link #getRequiredPlugin()}
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public String getPlugin() public String getPlugin()
{ {
return null; 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 As of versions greater than 2.8.7, use the expansion cloud to show a description
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public String getDescription() public String getDescription()
{ {
return null; 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 As of versions greater than 2.8.7, use the expansion cloud to display a link
*/ */
@Deprecated @Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10.8")
public String getLink() public String getLink()
{ {
return null; return null;

@ -39,6 +39,7 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginDisableEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable; 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()} * Do not call this method yourself, use {@link PlaceholderExpansion#register()}
*/ */
@ApiStatus.Internal
public boolean register(@NotNull final PlaceholderExpansion expansion) public boolean register(@NotNull final PlaceholderExpansion expansion)
{ {
final String identifier = expansion.getIdentifier(); final String identifier = expansion.getIdentifier();
if (identifier == null)
{
return false;
}
if (expansion instanceof Configurable) if (expansion instanceof Configurable)
{ {
@ -267,6 +265,7 @@ public final class LocalExpansionManager implements Listener
/** /**
* Do not call this method yourself, use {@link PlaceholderExpansion#unregister()} * Do not call this method yourself, use {@link PlaceholderExpansion#unregister()}
*/ */
@ApiStatus.Internal
public boolean unregister(@NotNull final PlaceholderExpansion expansion) public boolean unregister(@NotNull final PlaceholderExpansion expansion)
{ {
if (expansions.remove(expansion.getIdentifier()) == null) if (expansions.remove(expansion.getIdentifier()) == null)