undeprecated bracket placeholder methods,

This commit is contained in:
Sxtanna 2020-07-20 19:50:36 -04:00
parent 9217147827
commit a2a736d909
2 changed files with 46 additions and 44 deletions

@ -50,7 +50,9 @@ import java.util.stream.Collectors;
public final class PlaceholderAPI public final class PlaceholderAPI
{ {
private static final Replacer REPLACER = new CharsReplacer(Closure.PERCENT); private static final Replacer REPLACER_PERCENT = new CharsReplacer(Closure.PERCENT);
private static final Replacer REPLACER_BRACKET = new CharsReplacer(Closure.BRACKET);
private static final Map<String, PlaceholderHook> PLACEHOLDERS = new HashMap<>(); private static final Map<String, PlaceholderHook> PLACEHOLDERS = new HashMap<>();
@ -80,7 +82,7 @@ public final class PlaceholderAPI
@NotNull @NotNull
public static String setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text) public static String setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text)
{ {
return REPLACER.apply(text, player, PLACEHOLDERS::get); return REPLACER_PERCENT.apply(text, player, PLACEHOLDERS::get);
} }
/** /**
@ -92,11 +94,42 @@ public final class PlaceholderAPI
* @return String containing all translated placeholders * @return String containing all translated placeholders
*/ */
@NotNull @NotNull
public static List<String> setPlaceholders(@Nullable final OfflinePlayer player, @NotNull List<@NotNull String> text) public static List<String> setPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List<@NotNull String> text)
{ {
return text.stream().map(line -> setPlaceholders(player, line)).collect(Collectors.toList()); return text.stream().map(line -> setPlaceholders(player, line)).collect(Collectors.toList());
} }
/**
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
*
* @param player Player to parse the placeholders against
* @param text Text to set the placeholder values in
*
* @return String containing all translated placeholders
*/
@NotNull
public static String setBracketPlaceholders(@Nullable final OfflinePlayer player, @NotNull final String text)
{
return REPLACER_BRACKET.apply(text, player, PLACEHOLDERS::get);
}
/**
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
*
* @param player Player to parse the placeholders against
* @param text List of Strings to set the placeholder values in
*
* @return String containing all translated placeholders
*/
@NotNull
public static List<String> setBracketPlaceholders(@Nullable final OfflinePlayer player, @NotNull final List<@NotNull String> text)
{
return text.stream().map(line -> setBracketPlaceholders(player, line)).collect(Collectors.toList());
}
/** /**
* Check if a specific placeholder identifier is currently registered * Check if a specific placeholder identifier is currently registered
* *
@ -304,21 +337,6 @@ public final class PlaceholderAPI
return text != null && BRACKET_PLACEHOLDER_PATTERN.matcher(text).find(); return text != null && BRACKET_PLACEHOLDER_PATTERN.matcher(text).find();
} }
/**
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
*
* @param player Player to parse the placeholders against
* @param text List of Strings to set the placeholder values in
* @return String containing all translated placeholders
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
*/
@Deprecated
public static List<String> setBracketPlaceholders(OfflinePlayer player, List<String> text)
{
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, true);
}
/** /**
* Translates all placeholders into their corresponding values. * Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}. * <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
@ -368,20 +386,6 @@ public final class PlaceholderAPI
return setPlaceholders(player, text, pattern, true); return setPlaceholders(player, text, pattern, true);
} }
/**
* Translates all placeholders into their corresponding values.
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
*
* @param player Player to parse the placeholders against
* @param text Text to set the placeholder values in
* @return String containing all translated placeholders
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
*/
@Deprecated
public static String setBracketPlaceholders(OfflinePlayer player, String text)
{
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, true);
}
/** /**
* Translates all placeholders into their corresponding values. * Translates all placeholders into their corresponding values.
@ -582,7 +586,6 @@ public final class PlaceholderAPI
return RELATIONAL_PLACEHOLDER_PATTERN; return RELATIONAL_PLACEHOLDER_PATTERN;
} }
/** /**
* @deprecated Will be removed in a future release. * @deprecated Will be removed in a future release.
*/ */

@ -16,8 +16,7 @@ public interface Replacer
enum Closure enum Closure
{ {
BRACES('{', '}'), BRACKET('{', '}'),
BRACKETS('[', ']'),
PERCENT('%', '%'); PERCENT('%', '%');