"Deprecated" current placeholders (their name need to be changed) and their implementation

This commit is contained in:
Florian CUNY 2019-11-23 14:43:24 +01:00
parent f97a252840
commit 8181fbc431
4 changed files with 17 additions and 2 deletions

View File

@ -143,6 +143,8 @@ public class Level extends Addon {
});
// Register placeholders
if (getPlugin().getPlaceholdersManager() != null) {
// DEPRECATED PLACEHOLDERS - remove in an upcoming version
getPlugin().getPlaceholdersManager().registerPlaceholder(this, gm.getDescription().getName().toLowerCase() + "-island-level", new LevelPlaceholder(this, gm));
// Top Ten
for (int i = 1; i < 11; i++) {

View File

@ -8,7 +8,9 @@ import world.bentobox.level.Level;
/**
* @author tastybento
*
* @deprecated As of 1.9.0, for removal.
*/
@Deprecated
public class LevelPlaceholder implements PlaceholderReplacer {
private final Level addon;
@ -29,6 +31,9 @@ public class LevelPlaceholder implements PlaceholderReplacer {
*/
@Override
public String onReplace(User user) {
addon.logWarning("You are using a deprecated placeholder.");
addon.log("Please replace any occurrence of 'Level_" + gm.getDescription().getName().toLowerCase() + "-island-level'");
addon.log("by 'Level_" + gm.getDescription().getName().toLowerCase() + "_island_level'");
return addon.getLevelPresenter().getLevelString(addon.getIslandLevel(gm.getOverWorld(), user.getUniqueId()));
}

View File

@ -10,8 +10,9 @@ import world.bentobox.level.Level;
/**
* @author tastybento
*
* @deprecated As of 1.9.0, for removal.
*/
@Deprecated
public class TopTenNamePlaceholder implements PlaceholderReplacer {
private final Level level;
@ -29,6 +30,9 @@ public class TopTenNamePlaceholder implements PlaceholderReplacer {
*/
@Override
public String onReplace(User user) {
level.logWarning("You are using a deprecated placeholder.");
level.log("Please replace any occurrence of 'Level_" + gm.getDescription().getName().toLowerCase() + "-island-top-name-#'");
level.log("by 'Level_" + gm.getDescription().getName().toLowerCase() + "_island_top_name_#'");
Collection<UUID> values = level.getTopTen().getTopTenList(gm.getOverWorld()).getTopTen().keySet();
return values.size() < i ? "" : level.getPlayers().getName(values.stream().skip(i).findFirst().orElse(null));
}

View File

@ -10,8 +10,9 @@ import world.bentobox.level.Level;
/**
* Provides the level values to placeholders
* @author tastybento
*
* @deprecated As of 1.9.0, for removal.
*/
@Deprecated
public class TopTenPlaceholder implements PlaceholderReplacer {
private final Level level;
@ -29,6 +30,9 @@ public class TopTenPlaceholder implements PlaceholderReplacer {
*/
@Override
public String onReplace(User user) {
level.logWarning("You are using a deprecated placeholder.");
level.log("Please replace any occurrence of 'Level_" + gm.getDescription().getName().toLowerCase() + "-island-top-value-#'");
level.log("by 'Level_" + gm.getDescription().getName().toLowerCase() + "_island_top_value_#'");
Collection<Long> values = level.getTopTen().getTopTenList(gm.getOverWorld()).getTopTen().values();
return values.size() < i ? "" : values.stream().skip(i).findFirst().map(String::valueOf).orElse("");
}