mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2025-09-06 05:17:05 +02:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
3d2fca277f | ||
|
eeb9c8d5db | ||
|
6d38f411ba | ||
|
542ffd6b7b | ||
|
2a559fd240 | ||
|
51844cd291 | ||
|
12a358fbd0 | ||
|
0982505574 | ||
|
364635cd06 | ||
|
d3844711bc | ||
|
81038dab80 | ||
|
514e25454d | ||
|
203f02029c | ||
|
eb20a80b37 | ||
|
c38ecfc16c |
18
.github/ISSUE_TEMPLATE/bug_report.md
vendored
18
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -23,25 +23,21 @@ about: Report bugs of PlaceholderAPI with this template
|
||||
## Bug Report
|
||||
|
||||
### Issue
|
||||
> What is the issue? Describe it like you would tell a friend.
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
<!-- What is the issue? Describe it like you would tell a friend. -->
|
||||
|
||||
|
||||
### Expected behaviour
|
||||
> What should PlaceholderAPI do?
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
<!-- What should PlaceholderAPI do? -->
|
||||
|
||||
|
||||
### Actual behaviour
|
||||
> What does PlaceholderAPI actually do?
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
<!-- What does PlaceholderAPI actually do? -->
|
||||
|
||||
|
||||
### How to reproduce
|
||||
> What steps did you made, to get this bug?
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
<!-- What steps did you made, to get this bug? -->
|
||||
|
||||
1.
|
||||
|
||||
### Installed expansions
|
||||
> Please list all expansions that are displayed when running `/papi list`
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
### `/papi dump` output
|
||||
<!-- Please provide the URL that was generated when using /papi dump -->
|
||||
|
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -15,10 +15,9 @@ about: Request a update/change of the PlaceholderAPI-code
|
||||
## Feature Request
|
||||
|
||||
### Type
|
||||
> What kind of request is this? (Multiple selections possible)
|
||||
<!--
|
||||
Please select the right options by replacing the [ ] with a [x]
|
||||
-->
|
||||
<!-- What kind of request is this? (Multiple selections possible) -->
|
||||
<!-- To select an option change the [ ] to [x] -->
|
||||
|
||||
- [ ] New function for PlaceholderAPI.
|
||||
A new function that developers could use.
|
||||
- [ ] Change to code (Internal).
|
||||
@@ -27,7 +26,6 @@ Changes to code that won't affect the end-user.
|
||||
Changes to code that will affect the end-user (breaks stuff).
|
||||
- [ ] Other: __________ <!-- Use this if none of the above matches your request -->
|
||||
|
||||
### Info
|
||||
> What is the change?
|
||||
> Please provide as much information (including links, images and code-snippeds) as possible.
|
||||
<!-- Please write below this line to prevent formatting issues -->
|
||||
### Description
|
||||
<!-- Describe what this suggested change should do and why it would be useful -->
|
||||
<!-- When possible, add some code-examples to better illustrate the change -->
|
||||
|
23
.github/PULL_REQUEST_TEMPLATE.md
vendored
23
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,8 +1,13 @@
|
||||
## Please read
|
||||
Please make sure you checked the following:
|
||||
- You checked the [Pull requests] page for any upcoming changes.
|
||||
- You documented any public code that the end-user might use.
|
||||
- You followed the [contributing file]
|
||||
<!--
|
||||
### Please read ###
|
||||
Please make sure you checked the following:
|
||||
|
||||
- You checked the Pull requests page for any upcoming changes.
|
||||
- You documented any public code that the end-user might use.
|
||||
- You followed the contributing file (https://github.com/PlaceholderAPI/PlaceholderAPI/tree/master/.github/CONTRIBUTING.md).
|
||||
-->
|
||||
|
||||
## Pull Request
|
||||
|
||||
### Type
|
||||
<!--
|
||||
@@ -14,12 +19,10 @@ Please make sure you checked the following:
|
||||
- [ ] Other: __________ <!-- Use this if none of the above matches your request -->
|
||||
|
||||
### Description
|
||||
> Provide additional information if needed.
|
||||
<!-- Please type below this line -->
|
||||
<!-- What does your Pull request change? -->
|
||||
|
||||
Closes N/A <!-- If your PR is based on an issue, change "N/A" the the issue ID (#id) -->
|
||||
|
||||
|
||||
<!-- DO NOT ALTER ANYTHING BELOW THIS LINE! -->
|
||||
|
||||
[Pull requests]: https://github.com/PlaceholderAPI/PlaceholderAPI/pulls
|
||||
[contributing file]: https://github.com/PlaceholderAPI/PlaceholderAPI/tree/master/.github/CONTRIBUTING.md
|
||||
[Wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
|
||||
|
@@ -14,7 +14,7 @@
|
||||
[ci]: http://ci.extendedclip.com/job/PlaceholderAPI/
|
||||
[ciImg]: http://ci.extendedclip.com/buildStatus/icon?job=PlaceholderAPI
|
||||
|
||||
[APIversionImg]: https://img.shields.io/nexus/r/http/repo.extendedclip.com/me.clip/placeholderapi.svg?label=API-Version
|
||||
[APIversionImg]: https://img.shields.io/nexus/placeholderapi/me.clip/placeholderapi?server=https%3A%2F%2Frepo.extendedclip.com&label=API%20Version
|
||||
[logo]: https://i.imgur.com/Ea4PURv.png
|
||||
<!-- The stuff above isn't visible in the readme -->
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
Support for specific plugins are provided either by the plugin itself or through expansions. The expansions may be downloaded in-game through the PAPI Expansion Cloud. There are currently over 150+ expansions that support a wide variety of plugins, such as Essentials, Factions, LuckPerms, and Vault.
|
||||
|
||||
PlaceholderAPI has been downloaded over 300,000 times and has been used concurrently on over 20,000 servers, which makes it a must-have for a server of any type or scale.
|
||||
PlaceholderAPI has been downloaded over 400,000 times and has been used concurrently on over 20,000 servers, which makes it a must-have for a server of any type or scale.
|
||||
|
||||
<!-- TODO: Add contributing section -->
|
||||
<!-- TODO: Add expansion creation section (possibly add to a wiki?) -->
|
||||
|
10
build.gradle
10
build.gradle
@@ -6,7 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
group "me.clip"
|
||||
version "2.10.8"
|
||||
version "2.10.9"
|
||||
|
||||
description "An awesome placeholder provider!"
|
||||
|
||||
@@ -99,8 +99,16 @@ publishing {
|
||||
from components.java
|
||||
|
||||
pom.withXml {
|
||||
|
||||
asNode().appendNode("packaging", "jar")
|
||||
asNode().remove(asNode().get("dependencies"))
|
||||
|
||||
def dependenciesNode = asNode().appendNode("dependencies")
|
||||
// jetbrains annotations
|
||||
def jetbrainsAnnotations = dependenciesNode.appendNode("dependency")
|
||||
jetbrainsAnnotations.appendNode("groupId", "org.jetbrains")
|
||||
jetbrainsAnnotations.appendNode("artifactId", "annotations")
|
||||
jetbrainsAnnotations.appendNode("version", "19.0.0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -38,7 +38,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class PlaceholderAPI {
|
||||
|
||||
@@ -65,7 +64,7 @@ public final class PlaceholderAPI {
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static String setPlaceholders(@Nullable final OfflinePlayer player,
|
||||
public static String setPlaceholders(final OfflinePlayer player,
|
||||
@NotNull final String text) {
|
||||
return REPLACER_PERCENT.apply(text, player,
|
||||
PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()::getExpansion);
|
||||
@@ -80,11 +79,37 @@ public final class PlaceholderAPI {
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static List<String> setPlaceholders(@Nullable final OfflinePlayer player,
|
||||
public static List<String> setPlaceholders(final OfflinePlayer player,
|
||||
@NotNull final List<@NotNull String> text) {
|
||||
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 setPlaceholders(final Player player, @NotNull String text) {
|
||||
return setPlaceholders(((OfflinePlayer) player), text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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> setPlaceholders(final Player player, @NotNull List<@NotNull String> text) {
|
||||
return setPlaceholders(((OfflinePlayer) player), text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all placeholders into their corresponding values.
|
||||
* <br>The pattern of a valid placeholder is {@literal {<identifier>_<params>}}.
|
||||
@@ -94,7 +119,7 @@ public final class PlaceholderAPI {
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static String setBracketPlaceholders(@Nullable final OfflinePlayer player,
|
||||
public static String setBracketPlaceholders(final OfflinePlayer player,
|
||||
@NotNull final String text) {
|
||||
return REPLACER_BRACKET.apply(text, player,
|
||||
PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()::getExpansion);
|
||||
@@ -109,12 +134,72 @@ public final class PlaceholderAPI {
|
||||
* @return String containing all translated placeholders
|
||||
*/
|
||||
@NotNull
|
||||
public static List<String> setBracketPlaceholders(@Nullable final OfflinePlayer player,
|
||||
public static List<String> setBracketPlaceholders(final OfflinePlayer player,
|
||||
@NotNull final List<@NotNull String> text) {
|
||||
return text.stream().map(line -> setBracketPlaceholders(player, line))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static String setBracketPlaceholders(Player player, String text) {
|
||||
return setBracketPlaceholders((OfflinePlayer) player, text);
|
||||
}
|
||||
|
||||
public static List<String> setBracketPlaceholders(Player player, List<String> text) {
|
||||
return setPlaceholders((OfflinePlayer) player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* set relational placeholders in the text specified placeholders are matched with the pattern
|
||||
* %<rel_(identifier)_(params)>% when set with this method
|
||||
*
|
||||
* @param one First player to compare
|
||||
* @param two Second player to compare
|
||||
* @param text Text to parse the placeholders in
|
||||
* @return The text containing the parsed relational placeholders
|
||||
*/
|
||||
public static String setRelationalPlaceholders(Player one, Player two, String text) {
|
||||
final Matcher matcher = RELATIONAL_PLACEHOLDER_PATTERN.matcher(text);
|
||||
|
||||
while (matcher.find()) {
|
||||
final String format = matcher.group(2);
|
||||
final int index = format.indexOf("_");
|
||||
|
||||
if (index <= 0 || index >= format.length()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String identifier = format.substring(0, index).toLowerCase();
|
||||
String params = format.substring(index + 1);
|
||||
final PlaceholderExpansion expansion = PlaceholderAPIPlugin.getInstance()
|
||||
.getLocalExpansionManager().getExpansion(identifier);
|
||||
|
||||
if (!(expansion instanceof Relational)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String value = ((Relational) expansion).onPlaceholderRequest(one, two, params);
|
||||
|
||||
if (value != null) {
|
||||
text = text.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement(value));
|
||||
}
|
||||
}
|
||||
|
||||
return Msg.color(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate placeholders in the provided List based on the relation of the two provided players.
|
||||
* <br>The pattern of a valid placeholder is {@literal %rel_<identifier>_<param>%}.
|
||||
*
|
||||
* @param one Player to compare
|
||||
* @param two Player to compare
|
||||
* @param text text to parse the placeholder values to
|
||||
* @return The text containing the parsed relational placeholders
|
||||
*/
|
||||
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text) {
|
||||
return text.stream().map(line -> setRelationalPlaceholders(one, two, line))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a specific placeholder identifier is currently registered
|
||||
@@ -127,7 +212,6 @@ public final class PlaceholderAPI {
|
||||
.findExpansionByIdentifier(identifier).isPresent();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all registered placeholder identifiers
|
||||
*
|
||||
@@ -184,37 +268,6 @@ public final class PlaceholderAPI {
|
||||
|
||||
// === Deprecated API ===
|
||||
|
||||
/**
|
||||
* set relational placeholders in the text specified placeholders are matched with the pattern
|
||||
* %<rel_(identifier)_(params)>% when set with this method
|
||||
*
|
||||
* @param one First player to compare
|
||||
* @param two Second player to compare
|
||||
* @param text Text to parse the placeholders in
|
||||
* @return The text containing the parsed relational placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String setRelationalPlaceholders(Player one, Player two, String text) {
|
||||
return setRelationalPlaceholders(one, two, text, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate placeholders in the provided List based on the relation of the two provided players.
|
||||
* <br>The pattern of a valid placeholder is {@literal %rel_<identifier>_<param>%}.
|
||||
*
|
||||
* @param one Player to compare
|
||||
* @param two Player to compare
|
||||
* @param text text to parse the placeholder values to
|
||||
* @return The text containing the parsed relational placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text) {
|
||||
return setRelationalPlaceholders(one, two, text, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get map of registered placeholders
|
||||
*
|
||||
@@ -222,7 +275,6 @@ public final class PlaceholderAPI {
|
||||
* @deprecated Use {@link me.clip.placeholderapi.PlaceholderAPIPlugin().getLocalExpansionManager()
|
||||
* .getExpansions()} instead.
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static Map<String, PlaceholderHook> getPlaceholders() {
|
||||
@@ -231,83 +283,6 @@ public final class PlaceholderAPI {
|
||||
.collect(Collectors.toMap(PlaceholderExpansion::getIdentifier, ex -> ex));
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate placeholders in the provided list based on the relation of the two provided players.
|
||||
* <br>The pattern of a valid placeholder is {@literal %rel_<identifier>_<params>%}.
|
||||
*
|
||||
* @param one First player to compare
|
||||
* @param two Second player to compare
|
||||
* @param text Text to parse the placeholders in
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return The text containing the parsed relational placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text,
|
||||
boolean colorize) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return text.stream()
|
||||
.map(line -> setRelationalPlaceholders(one, two, line, colorize))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* set relational placeholders in the text specified placeholders are matched with the pattern
|
||||
* %<rel_(identifier)_(params)>% when set with this method
|
||||
*
|
||||
* @param one Player to compare
|
||||
* @param two Player to compare
|
||||
* @param text Text to parse the placeholders in
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return The text containing the parsed relational placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setRelationalPlaceholders(Player one, Player two, String text,
|
||||
boolean colorize) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (PlaceholderAPIPlugin.getInstance().getLocalExpansionManager().getExpansionsCount() == 0) {
|
||||
return colorize ? Msg.color(text) : text;
|
||||
}
|
||||
|
||||
final Matcher matcher = RELATIONAL_PLACEHOLDER_PATTERN.matcher(text);
|
||||
|
||||
while (matcher.find()) {
|
||||
final String format = matcher.group(2);
|
||||
final int index = format.indexOf("_");
|
||||
|
||||
if (index <= 0 || index >= format.length()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String identifier = format.substring(0, index).toLowerCase();
|
||||
String params = format.substring(index + 1);
|
||||
final PlaceholderExpansion expansion = PlaceholderAPIPlugin.getInstance()
|
||||
.getLocalExpansionManager().getExpansion(identifier);
|
||||
|
||||
if (!(expansion instanceof Relational)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String value = ((Relational) expansion).onPlaceholderRequest(one, two, params);
|
||||
|
||||
if (value != null) {
|
||||
text = text.replaceAll(Pattern.quote(matcher.group()), Matcher.quoteReplacement(value));
|
||||
}
|
||||
}
|
||||
|
||||
return colorize ? Msg.color(text) : text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link me.clip.placeholderapi.expansion.PlaceholderExpansion} to
|
||||
* register placeholders instead
|
||||
@@ -335,7 +310,6 @@ public final class PlaceholderAPI {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link me.clip.placeholderapi.expansion.PlaceholderExpansion} to
|
||||
* unregister placeholders instead
|
||||
@@ -362,86 +336,6 @@ public final class PlaceholderAPI {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link #setPlaceholders(OfflinePlayer, String)} instead
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setPlaceholders(@Nullable final OfflinePlayer player,
|
||||
@NotNull final String text, @NotNull final Pattern pattern, final boolean colorize) {
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link #setPlaceholders(OfflinePlayer, List)} instead
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setBracketPlaceholders(OfflinePlayer player, List<String> text,
|
||||
boolean colorize) {
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text,
|
||||
boolean colorize) {
|
||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text,
|
||||
Pattern pattern) {
|
||||
return setPlaceholders(player, text, pattern, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setBracketPlaceholders(OfflinePlayer player, String text, boolean colorize) {
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setPlaceholders(OfflinePlayer player, String text, boolean colorize) {
|
||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setPlaceholders(OfflinePlayer player, String text, Pattern pattern) {
|
||||
return setPlaceholders(player, text, pattern, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@@ -461,30 +355,51 @@ public final class PlaceholderAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
* @deprecated Please use {@link #setPlaceholders(OfflinePlayer, String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setPlaceholders(Player player, String text) {
|
||||
return setPlaceholders(((OfflinePlayer) player), text);
|
||||
public static String setPlaceholders(OfflinePlayer player,
|
||||
String text, Pattern pattern, boolean colorize) {
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link #setPlaceholders(OfflinePlayer, List)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setPlaceholders(OfflinePlayer player,
|
||||
List<String> text, Pattern pattern, boolean colorize) {
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text,
|
||||
boolean colorize) {
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text,
|
||||
Pattern pattern) {
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setPlaceholders(Player player, String text, boolean colorize) {
|
||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setPlaceholders(Player player, List<String> text) {
|
||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, true);
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,16 +408,44 @@ public final class PlaceholderAPI {
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setPlaceholders(Player player, List<String> text, boolean colorize) {
|
||||
return setPlaceholders(player, text, PLACEHOLDER_PATTERN, colorize);
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setBracketPlaceholders(Player player, String text) {
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, true);
|
||||
public static String setPlaceholders(OfflinePlayer player, String text, boolean colorize) {
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setPlaceholders(OfflinePlayer player, String text, Pattern pattern) {
|
||||
return setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setBracketPlaceholders(OfflinePlayer player, List<String> text,
|
||||
boolean colorize) {
|
||||
return setBracketPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setBracketPlaceholders(OfflinePlayer player, String text, boolean colorize) {
|
||||
return setBracketPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -511,16 +454,7 @@ public final class PlaceholderAPI {
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setBracketPlaceholders(Player player, String text, boolean colorize) {
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setBracketPlaceholders(Player player, List<String> text) {
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, true);
|
||||
return setBracketPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -530,7 +464,42 @@ public final class PlaceholderAPI {
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setBracketPlaceholders(Player player, List<String> text,
|
||||
boolean colorize) {
|
||||
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN, colorize);
|
||||
return setBracketPlaceholders(player, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* set relational placeholders in the text specified placeholders are matched with the pattern
|
||||
* %<rel_(identifier)_(params)>% when set with this method
|
||||
*
|
||||
* @param one Player to compare
|
||||
* @param two Player to compare
|
||||
* @param text Text to parse the placeholders in
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return The text containing the parsed relational placeholders
|
||||
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static String setRelationalPlaceholders(Player one, Player two, String text,
|
||||
boolean colorize) {
|
||||
return setRelationalPlaceholders(one, two, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate placeholders in the provided list based on the relation of the two provided players.
|
||||
* <br>The pattern of a valid placeholder is {@literal %rel_<identifier>_<params>%}.
|
||||
*
|
||||
* @param one First player to compare
|
||||
* @param two Second player to compare
|
||||
* @param text Text to parse the placeholders in
|
||||
* @param colorize If color codes (&[0-1a-fk-o]) should be translated
|
||||
* @return The text containing the parsed relational placeholders
|
||||
* @deprecated Use {@link #setRelationalPlaceholders(Player, Player, List<String>)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text,
|
||||
boolean colorize) {
|
||||
return setRelationalPlaceholders(one, two, text);
|
||||
}
|
||||
}
|
||||
|
@@ -22,21 +22,11 @@ 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;
|
||||
|
||||
/**
|
||||
* @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.11.0")
|
||||
public abstract class PlaceholderHook {
|
||||
|
||||
@Nullable
|
||||
public String onRequest(@Nullable final OfflinePlayer player, @NotNull final String params) {
|
||||
public String onRequest(final OfflinePlayer player, @NotNull final String params) {
|
||||
if (player != null && player.isOnline()) {
|
||||
return onPlaceholderRequest((Player) player, params);
|
||||
}
|
||||
@@ -44,14 +34,7 @@ public abstract class PlaceholderHook {
|
||||
return onPlaceholderRequest(null, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method will be completely removed, please use {@link
|
||||
* me.clip.placeholderapi.expansion.PlaceholderExpansion#onRequest(OfflinePlayer, String)}
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public String onPlaceholderRequest(@Nullable final Player player, @NotNull final String params) {
|
||||
public String onPlaceholderRequest(final Player player, @NotNull final String params) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ import java.util.Objects;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
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;
|
||||
@@ -59,13 +58,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||
@NotNull
|
||||
public abstract String getVersion();
|
||||
|
||||
@Nullable
|
||||
@Override /* override for now >:) */
|
||||
public String onRequest(@Nullable final OfflinePlayer player, @NotNull final String params) {
|
||||
return super.onRequest(player, params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The name of this expansion
|
||||
*
|
||||
@@ -137,7 +129,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||
* @return true if this expansion is now registered with PlaceholderAPI
|
||||
*/
|
||||
public boolean register() {
|
||||
return canRegister() && getPlaceholderAPI().getLocalExpansionManager().register(this);
|
||||
return getPlaceholderAPI().getLocalExpansionManager().register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -20,6 +20,7 @@
|
||||
|
||||
package me.clip.placeholderapi.expansion.manager;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.io.File;
|
||||
@@ -114,17 +115,14 @@ public final class LocalExpansionManager implements Listener {
|
||||
return ImmutableSet.copyOf(expansions.values());
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public PlaceholderExpansion getExpansion(@NotNull final String identifier) {
|
||||
return expansions.get(identifier.toLowerCase());
|
||||
return ImmutableMap.copyOf(expansions).get(identifier.toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public Optional<PlaceholderExpansion> findExpansionByName(@NotNull final String name) {
|
||||
return expansions.values().stream()
|
||||
.filter(expansion -> name.equalsIgnoreCase(expansion.getName())).findFirst();
|
||||
return getExpansions().stream().filter(expansion -> name.equalsIgnoreCase(expansion.getName())).findFirst();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -159,6 +157,10 @@ public final class LocalExpansionManager implements Listener {
|
||||
public boolean register(@NotNull final PlaceholderExpansion expansion) {
|
||||
final String identifier = expansion.getIdentifier().toLowerCase();
|
||||
|
||||
if (!expansion.canRegister()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expansion instanceof Configurable) {
|
||||
Map<String, Object> defaults = ((Configurable) expansion).getDefaults();
|
||||
String pre = "expansions." + identifier + ".";
|
||||
|
@@ -55,7 +55,7 @@ public final class CharsReplacer implements Replacer {
|
||||
|
||||
if (c != '0' && c != '1' && c != '2' && c != '3' && c != '4' && c != '5' && c != '6'
|
||||
&& c != '7' && c != '8' && c != '9' && c != 'a' && c != 'b' && c != 'c' && c != 'd'
|
||||
&& c != 'e' && c != 'f' && c != 'k' && c != 'l' && c != 'm' && c != 'o' && c != 'r'
|
||||
&& c != 'e' && c != 'f' && c != 'k' && c != 'l' && c != 'm' && c != 'n' && c != 'o' && c != 'r'
|
||||
&& c != 'x') {
|
||||
builder.append(l).append(chars[i]);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user