Added last placeholders

This commit is contained in:
Fabrizio La Rosa 2020-08-03 14:30:06 +02:00
parent 70931439b4
commit c5dbeca38d
2 changed files with 359 additions and 297 deletions

View File

@ -1,25 +1,25 @@
package com.songoda.skyblock.placeholder; package com.songoda.skyblock.placeholder;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.utils.TextUtils;
import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.invite.Invite; import com.songoda.skyblock.invite.Invite;
import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.*;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.island.IslandStatus;
import com.songoda.skyblock.leaderboard.Leaderboard; import com.songoda.skyblock.leaderboard.Leaderboard;
import com.songoda.skyblock.leaderboard.LeaderboardManager; import com.songoda.skyblock.leaderboard.LeaderboardManager;
import com.songoda.skyblock.levelling.IslandLevelManager; import com.songoda.skyblock.levelling.IslandLevelManager;
import com.songoda.skyblock.upgrade.Upgrade; import com.songoda.skyblock.upgrade.Upgrade;
import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import com.songoda.skyblock.visit.Visit;
import com.songoda.skyblock.visit.VisitManager; import com.songoda.skyblock.visit.VisitManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ -34,6 +34,7 @@ public class PlaceholderProcessor {
IslandManager islandManager = plugin.getIslandManager(); IslandManager islandManager = plugin.getIslandManager();
VisitManager visitManager = plugin.getVisitManager(); VisitManager visitManager = plugin.getVisitManager();
IslandLevelManager levellingManager = plugin.getLevellingManager(); IslandLevelManager levellingManager = plugin.getLevellingManager();
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
FileManager fileManager = plugin.getFileManager(); FileManager fileManager = plugin.getFileManager();
FileConfiguration placeholdersLoad = fileManager.getConfig( FileConfiguration placeholdersLoad = fileManager.getConfig(
@ -50,45 +51,66 @@ public class PlaceholderProcessor {
switch (placeholder.toLowerCase()) { switch (placeholder.toLowerCase()) {
case "fabledskyblock_island_exists": case "fabledskyblock_island_exists":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_exists.Not-exists.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_exists.Not-exists"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_exists.Exists.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_exists.Exists"));
} }
break; break;
case "fabledskyblock_island_isopen": case "fabledskyblock_island_isopen": //Deprecated
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Empty"));
} else { } else {
if (island.getStatus().equals(IslandStatus.OPEN)) { // TODO Update to Status if (island.getStatus().equals(IslandStatus.OPEN)) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Open.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Open"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Closed.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_isopen.Closed"));
}
}
break;
case "fabledskyblock_island_status":
if (island == null) {
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_status.Empty"));
} else {
switch(island.getStatus()){
case OPEN:
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_status.Open"));
break;
case CLOSED:
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_status.Closed"));
break;
case WHITELISTED:
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_status.Whitelisted"));
break;
} }
} }
break; break;
case "fabledskyblock_island_size": case "fabledskyblock_island_size":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_size.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_size.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_size.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_size.Non-empty")
.replace("%placeholder", "" + island.getSize())); .replace("{PLACEHOLDER}", "" + island.getSize()));
} }
break; break;
case "fabledskyblock_island_radius": case "fabledskyblock_island_radius":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_radius.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_radius.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_radius.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_radius.Non-empty")
.replace("%placeholder", "" + island.getRadius())); .replace("{PLACEHOLDER}", "" + island.getRadius()));
} }
break; break;
case "fabledskyblock_island_level": case "fabledskyblock_island_level":
@ -96,12 +118,12 @@ public class PlaceholderProcessor {
break; break;
case "fabledskyblock_island_level_formatted": case "fabledskyblock_island_level_formatted":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Non-empty.Message").replace( placeholdersLoad.getString("Placeholders.fabledskyblock_island_level_formatted.Non-empty").replace(
"%placeholder", "" + NumberUtil.formatNumberBySuffix(island.getLevel().getLevel()))); "{PLACEHOLDER}", "" + NumberUtil.formatNumberBySuffix(island.getLevel().getLevel())));
} }
break; break;
case "fabledskyblock_island_points": case "fabledskyblock_island_points":
@ -109,168 +131,168 @@ public class PlaceholderProcessor {
break; break;
case "fabledskyblock_island_votes": case "fabledskyblock_island_votes":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_votes.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_votes.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_votes.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_votes.Non-empty")
.replace("%placeholder", "" + visitManager.getIslands().get(player.getUniqueId()).getVoters().size())); .replace("{PLACEHOLDER}", "" + visitManager.getIslands().get(player.getUniqueId()).getVoters().size()));
} }
break; break;
case "fabledskyblock_island_role": case "fabledskyblock_island_role":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_role.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_role.Empty"));
} else { } else {
for (IslandRole roleList : IslandRole.values()) { for (IslandRole roleList : IslandRole.values()) {
if (island.hasRole(roleList, player.getUniqueId())) { if (island.hasRole(roleList, player.getUniqueId())) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_role.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_role.Non-empty")
.replace("%placeholder", plugin.getLocalizationManager().getLocalizationFor(IslandRole.class).getLocale(roleList))); .replace("{PLACEHOLDER}", plugin.getLocalizationManager().getLocalizationFor(IslandRole.class).getLocale(roleList)));
} }
} }
} }
break; break;
case "fabledskyblock_island_owner": case "fabledskyblock_island_owner":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Empty"));
} else { } else {
UUID islandOwnerUUID = island.getOwnerUUID(); UUID islandOwnerUUID = island.getOwnerUUID();
Player targetPlayer = Bukkit.getServer().getPlayer(islandOwnerUUID); Player targetPlayer = Bukkit.getServer().getPlayer(islandOwnerUUID);
if (targetPlayer == null) { if (targetPlayer == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Other.Message").replace( placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Other").replace(
"%placeholder", Bukkit.getServer().getOfflinePlayer(islandOwnerUUID).getName())); "{PLACEHOLDER}", Bukkit.getServer().getOfflinePlayer(islandOwnerUUID).getName()));
} else { } else {
if (targetPlayer.getName().equals(player.getName())) { if (targetPlayer.getName().equals(player.getName())) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Yourself.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Yourself")
.replace("%placeholder", targetPlayer.getName())); .replace("{PLACEHOLDER}", targetPlayer.getName()));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Other.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_owner.Non-empty.Other")
.replace("%placeholder", targetPlayer.getName())); .replace("{PLACEHOLDER}", targetPlayer.getName()));
} }
} }
} }
break; break;
case "fabledskyblock_island_biome": case "fabledskyblock_island_biome":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_biome.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_biome.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_biome.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_biome.Non-empty")
.replace("%placeholder", island.getBiomeName())); .replace("{PLACEHOLDER}", island.getBiomeName()));
} }
break; break;
case "fabledskyblock_island_time": case "fabledskyblock_island_time":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_time.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_time.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_time.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_time.Non-empty")
.replace("%placeholder", "" + island.getTime())); .replace("{PLACEHOLDER}", "" + island.getTime()));
} }
break; break;
case "fabledskyblock_island_weather": case "fabledskyblock_island_weather":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_weather.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_weather.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_weather.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_weather.Non-empty")
.replace("%placeholder", "" + island.getWeatherName())); .replace("{PLACEHOLDER}", "" + island.getWeatherName()));
} }
break; break;
case "fabledskyblock_island_bans": case "fabledskyblock_island_bans":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_bans.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_bans.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_bans.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_bans.Non-empty")
.replace("%placeholder", "" + island.getBan().getBans().size())); .replace("{PLACEHOLDER}", "" + island.getBan().getBans().size()));
} }
break; break;
case "fabledskyblock_island_members_total": case "fabledskyblock_island_members_total":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_members_total.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_members_total.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_members_total.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_members_total.Non-empty")
.replace("%placeholder", "" + (island.getRole(IslandRole.Member).size() .replace("{PLACEHOLDER}", "" + (island.getRole(IslandRole.Member).size()
+ island.getRole(IslandRole.Operator).size() + 1))); + island.getRole(IslandRole.Operator).size() + 1)));
} }
break; break;
case "fabledskyblock_island_members": case "fabledskyblock_island_members":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_members.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_members.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_members.Non-empty.Message") placeholdersLoad.getString("Placeholder.fabledskyblock_island_members.Non-empty")
.replace("%placeholder", "" + island.getRole(IslandRole.Member).size())); .replace("{PLACEHOLDER}", "" + island.getRole(IslandRole.Member).size()));
} }
break; break;
case "fabledskyblock_island_maxmembers": case "fabledskyblock_island_maxmembers":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Non-empty")
.replace("%placeholder", "" + island.getMaxMembers())); .replace("{PLACEHOLDER}", "" + island.getMaxMembers()));
} }
break; break;
case "fabledskyblock_island_operators": case "fabledskyblock_island_operators":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_operators.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_operators.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_operators.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_operators.Non-empty")
.replace("%placeholder", "" + island.getRole(IslandRole.Operator).size())); .replace("{PLACEHOLDER}", "" + island.getRole(IslandRole.Operator).size()));
} }
break; break;
case "fabledskyblock_island_coops": case "fabledskyblock_island_coops":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops.Non-empty")
.replace("%placeholder", "" + islandManager.getCoopPlayersAtIsland(island).size())); .replace("{PLACEHOLDER}", "" + islandManager.getCoopPlayersAtIsland(island).size()));
} }
break; break;
case "fabledskyblock_island_coops_total": case "fabledskyblock_island_coops_total":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops_total.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops_total.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops_total.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_coops_total.Non-empty")
.replace("%placeholder", "" + island.getCoopPlayers().size())); .replace("{PLACEHOLDER}", "" + island.getCoopPlayers().size()));
} }
break; break;
case "fabledskyblock_island_visitors": case "fabledskyblock_island_visitors":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_visitors.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_visitors.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_visitors.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_visitors.Non-empty")
.replace("%placeholder", "" + islandManager.getVisitorsAtIsland(island).size())); .replace("{PLACEHOLDER}", "" + islandManager.getVisitorsAtIsland(island).size()));
} }
break; break;
case "fabledskyblock_island_invites": case "fabledskyblock_island_invites":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_invites.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_invites.Empty"));
} else { } else {
Map<UUID, Invite> invites = plugin.getInviteManager().getInvites(); Map<UUID, Invite> invites = plugin.getInviteManager().getInvites();
int invitedPlayers = 0; int invitedPlayers = 0;
@ -284,112 +306,213 @@ public class PlaceholderProcessor {
} }
} }
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_invites.Non-empty.Message") placeholdersLoad.getString("Placeholders.fabledskyblock_island_invites.Non-empty")
.replace("%placeholder", "" + invitedPlayers)); .replace("{PLACEHOLDER}", "" + invitedPlayers));
} }
break; break;
case "fabledskyblock_island_bank_balance": case "fabledskyblock_island_bank_balance":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Non-empty.Message")) placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance.Non-empty"))
.replace("%placeholder", "" + NumberUtil.formatNumberByDecimal(island.getBankBalance())); .replace("{PLACEHOLDER}", "" + NumberUtil.formatNumberByDecimal(island.getBankBalance()));
} }
break; break;
case "fabledskyblock_island_bank_balance_formatted": case "fabledskyblock_island_bank_balance_formatted":
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Empty.Message")); placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Empty"));
} else { } else {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Non-empty.Message")) placeholdersLoad.getString("Placeholders.fabledskyblock_island_bank_balance_formatted.Non-empty"))
.replace("%placeholder", "" + NumberUtil.formatNumberBySuffix((long) island.getBankBalance())); .replace("{PLACEHOLDER}", "" + NumberUtil.formatNumberBySuffix((long) island.getBankBalance()));
} }
break; break;
} }
if(returnValue == null) { if(returnValue == null) {
if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_level_rank")) { if(placeholder.toLowerCase().startsWith("fabledskyblock_leaderboard_votes_")){
if (island == null) { List<Leaderboard> leaderboardVotesPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Votes);
returnValue = ChatColor.translateAlternateColorCodes('&',
placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Empty.Message")); String[] values = placeholder.split("_");
int value;
try {
value = Integer.parseInt(values[values.length-1]);
} catch(NumberFormatException ignored) {
value = 1;
}
if (value > 0 && value < leaderboardVotesPlayers.size()) {
Leaderboard leaderboard = leaderboardVotesPlayers.get(value);
Visit visit = leaderboard.getVisit();
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName;
if (targetPlayer == null) {
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
} else {
islandOwnerName = targetPlayer.getName();
}
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Non-empty")
.replace("{POSITION}", "" + (value))
.replace("{PLAYER}", islandOwnerName)
.replace("{VOTES}", NumberUtil.formatNumberByDecimal(visit.getVoters().size())));
} else {
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Empty"));
}
} else if(placeholder.toLowerCase().startsWith("fabledskyblock_leaderboard_bank_")){
List<Leaderboard> leaderboardBankPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Bank);
String[] values = placeholder.split("_");
int value;
try {
value = Integer.parseInt(values[values.length-1]);
} catch(NumberFormatException ignored) {
value = 1;
}
if (value > 0 && value < leaderboardBankPlayers.size()) {
Leaderboard leaderboard = leaderboardBankPlayers.get(value);
Visit visit = leaderboard.getVisit();
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName;
if (targetPlayer == null) {
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
} else {
islandOwnerName = targetPlayer.getName();
}
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Non-empty")
.replace("{POSITION}", "" + (value))
.replace("{PLAYER}", islandOwnerName)
.replace("{BALANCE}", NumberUtil.formatNumberByDecimal(visit.getBankBalance())));
} else {
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Empty"));
}
} else if(placeholder.toLowerCase().startsWith("fabledskyblock_leaderboard_level_")){
List<Leaderboard> leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level);
String[] values = placeholder.split("_");
int value;
try {
value = Integer.parseInt(values[values.length-1]);
} catch(NumberFormatException ignored) {
value = 1;
}
if (value > 0 && value < leaderboardLevelPlayers.size()) {
Leaderboard leaderboard = leaderboardLevelPlayers.get(value);
Visit visit = leaderboard.getVisit();
IslandLevel level = visit.getLevel();
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName;
if (targetPlayer == null) {
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
} else {
islandOwnerName = targetPlayer.getName();
}
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Non-empty")
.replace("{POSITION}", "" + (value))
.replace("{PLAYER}", islandOwnerName)
.replace("{LEVEL}", NumberUtil.formatNumberByDecimal(level.getLevel()))
.replace("{POINTS}", NumberUtil.formatNumberByDecimal(level.getPoints())));
} else {
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Empty"));
}
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_level_rank")) {
if (island == null) {
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Empty"));
} else { } else {
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Level); int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Level);
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Non-empty.Message") placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Non-empty")
.replace("%placeholder", "" + rank)); .replace("{PLACEHOLDER}", "" + rank));
} }
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_bank_rank")) { } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_bank_rank")) {
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Empty.Message")); placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Empty"));
} else { } else {
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Bank); int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Bank);
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Non-empty.Message") placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Non-empty")
.replace("%placeholder", "" + rank)); .replace("{PLACEHOLDER}", "" + rank));
} }
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_votes_rank")) { } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_votes_rank")) {
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Empty.Message")); placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Empty"));
} else { } else {
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Votes); int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Votes);
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Non-empty.Message") placeholdersLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Non-empty")
.replace("%placeholder", "" + rank)); .replace("{PLACEHOLDER}", "" + rank));
} }
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_count_")) { } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_count_")) {
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Empty.Message")); placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Empty"));
} else { } else {
String materialName = placeholder.replace("fabledskyblock_island_level_block_count_", "").toUpperCase(); String materialName = placeholder.replace("fabledskyblock_island_level_block_count_", "").toUpperCase();
CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName);
if (materials == null) { if (materials == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Invalid.Message")); placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Invalid"));
} else { } else {
long blockCount = island.getLevel().getMaterialAmount(materials.name()); long blockCount = island.getLevel().getMaterialAmount(materials.name());
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Non-empty.Message") placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_count.Non-empty")
.replace("%placeholder", NumberUtil.formatNumberByDecimal(blockCount))); .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockCount)));
} }
} }
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_points_")) { } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_points_")) {
if (island == null) { if (island == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Empty.Message")); placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Empty"));
} else { } else {
String materialName = placeholder.replace("fabledskyblock_island_level_block_points_", "").toUpperCase(); String materialName = placeholder.replace("fabledskyblock_island_level_block_points_", "").toUpperCase();
CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName);
if (materials == null) { if (materials == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Invalid.Message")); placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Invalid"));
} else { } else {
long blockPoints = island.getLevel().getMaterialPoints(materials.name()); long blockPoints = island.getLevel().getMaterialPoints(materials.name());
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Non-empty.Message") placeholdersLoad.getString("Placeholder.fabledskyblock_island_level_block_points.Non-empty")
.replace("%placeholder", NumberUtil.formatNumberByDecimal(blockPoints))); .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockPoints)));
} }
} }
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_level_block_value_")) { } else if (placeholder.toLowerCase().startsWith("fabledskyblock_level_block_value_")) {
String materialName = placeholder.replace("fabledskyblock_level_block_value_", "").toUpperCase(); String materialName = placeholder.replace("fabledskyblock_level_block_value_", "").toUpperCase();
CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName);
if (materials == null) { if (materials == null) {
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Invalid.Message")); placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Invalid"));
} else { } else {
double blockValue = levellingManager.getWorth(materials); double blockValue = levellingManager.getWorth(materials);
returnValue = ChatColor.translateAlternateColorCodes('&', returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Non-empty.Message") placeholdersLoad.getString("Placeholder.fabledskyblock_level_block_value.Non-empty")
.replace("%placeholder", NumberUtil.formatNumberByDecimal(blockValue))); .replace("{PLACEHOLDER}", NumberUtil.formatNumberByDecimal(blockValue)));
} }
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_has_upgrade_")) { } else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_has_upgrade_")) {
Upgrade.Type type; Upgrade.Type type;

View File

@ -1,165 +1,104 @@
Placeholders: Placeholders:
fabledskyblock_leaderboard_votes: fabledskyblock_leaderboard_votes:
Empty: Empty: 'Unclaimed'
Message: 'Unclaimed' Non-empty: '[{POSITION}] {PLAYER} [{VOTES]'
Non-empty:
Message: '[%position] %player [%votes]'
fabledskyblock_leaderboard_bank: fabledskyblock_leaderboard_bank:
Empty: Empty: 'Unclaimed'
Message: 'Unclaimed' Non-empty: '[{POSITION}] {PLAYER} [${BALANCE}]'
Non-empty:
Message: '[%position] %player [$%balance]'
fabledskyblock_island_exists:
Exists:
Message: 'true'
Not-exists:
Message: 'false'
fabledskyblock_island_members:
Non-empty:
Message: '%placeholder'
Empty:
Message: '0'
fabledskyblock_island_coops:
Empty:
Message: '0'
Non-empty:
Message: '%placeholder'
fabledskyblock_leaderboard_level: fabledskyblock_leaderboard_level:
Empty: Empty: 'Unclaimed'
Message: 'Unclaimed' Non-empty: '[{POSITION}] {PLAYER} [{LEVEL}]'
Non-empty: fabledskyblock_island_exists:
Message: '[%position] %player [%level]' Exists: 'true'
Not-exists: 'false'
fabledskyblock_island_members:
Non-empty: '{PLACEHOLDER}'
Empty: '0'
fabledskyblock_island_coops:
Empty: '0'
Non-empty: '{PLACEHOLDER}'
fabledskyblock_island_visitors: fabledskyblock_island_visitors:
Non-empty: Non-empty: '{PLACEHOLDER}'
Message: '%placeholder' Empty: '0'
Empty:
Message: '0'
fabledskyblock_island_size: fabledskyblock_island_size:
Empty: Empty: '0'
Message: '0' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_maxmembers: fabledskyblock_island_maxmembers:
Empty: Empty: '0'
Message: '0' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_time: fabledskyblock_island_time:
Non-empty: Non-empty: '{PLACEHOLDER}'
Message: '%placeholder' Empty: '0'
Empty:
Message: '0'
fabledskyblock_island_bank_balance_formatted: fabledskyblock_island_bank_balance_formatted:
Empty: Empty: 0'
Message: '0' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_owner: fabledskyblock_island_owner:
Non-empty: Non-empty:
Yourself: Yourself: 'You'
Message: 'You' Other: '{PLACEHOLDER}'
Other: Empty: '&oNone'
Message: '%placeholder'
Empty:
Message: '&oNone'
fabledskyblock_island_leaderboard_bank_rank: fabledskyblock_island_leaderboard_bank_rank:
Non-empty: Non-empty: '{PLACEHOLDER}'
Message: '%placeholder' Empty: '0'
Empty:
Message: '0'
fabledskyblock_island_bans: fabledskyblock_island_bans:
Non-empty: Non-empty: '{PLACEHOLDER}'
Message: '%placeholder' Empty: '0'
Empty:
Message: '0'
fabledskyblock_island_coops_total: fabledskyblock_island_coops_total:
Non-empty: Non-empty: '{PLACEHOLDER}'
Message: '%placeholder' Empty: '0'
Empty:
Message: '0'
fabledskyblock_island_invites: fabledskyblock_island_invites:
Non-empty: Non-empty: '{PLACEHOLDER}'
Message: '%placeholder' Empty: '0'
Empty:
Message: '0'
fabledskyblock_island_level_block_count: fabledskyblock_island_level_block_count:
Invalid: Invalid: 'Invalid Type'
Message: 'Invalid Type' Non-empty: '{PLACEHOLDER}'
Non-empty: Empty: '0'
Message: '%placeholder'
Empty:
Message: '0'
fabledskyblock_island_weather: fabledskyblock_island_weather:
Empty: Empty: '0'
Message: '0' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_role: fabledskyblock_island_role:
Empty: Empty: '&oNone'
Message: '&oNone' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_operators: fabledskyblock_island_operators:
Empty: Empty: '0'
Message: '0' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_bank_balance: fabledskyblock_island_bank_balance:
Empty: Empty: '0'
Message: '0' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_biome: fabledskyblock_island_biome:
Empty: Empty: '&oNone'
Message: '&oNone' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_level_formatted: fabledskyblock_island_level_formatted:
Empty: Empty: '0'
Message: '0' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_members_total: fabledskyblock_island_members_total:
Non-empty: Non-empty: '{PLACEHOLDER}'
Message: '%placeholder' Empty: '0'
Empty:
Message: '0'
fabledskyblock_island_level_block_points: fabledskyblock_island_level_block_points:
Empty: Empty: '0'
Message: '0' Invalid: 'Invalid Type'
Invalid: Non-empty: '{PLACEHOLDER}'
Message: 'Invalid Type'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_isopen: fabledskyblock_island_isopen:
Closed: Closed: 'false'
Message: 'false' Open: 'true'
Open: Empty: 'false'
Message: 'true' fabledskyblock_island_status:
Empty: Closed: 'Closed'
Message: 'false' Open: 'Open'
Whitelisted: 'Whitelisted'
Empty: 'None'
fabledskyblock_island_votes: fabledskyblock_island_votes:
Empty: Empty: '0'
Message: '0' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_radius: fabledskyblock_island_radius:
Empty: Empty: '0'
Message: '0' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_leaderboard_votes_rank: fabledskyblock_island_leaderboard_votes_rank:
Non-empty: Non-empty: '{PLACEHOLDER}'
Message: '%placeholder' Empty: '0'
Empty:
Message: '0'
fabledskyblock_level_block_value: fabledskyblock_level_block_value:
Invalid: Invalid: 'Invalid Type'
Message: 'Invalid Type' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'
fabledskyblock_island_leaderboard_level_rank: fabledskyblock_island_leaderboard_level_rank:
Empty: Empty: '0'
Message: '0' Non-empty: '{PLACEHOLDER}'
Non-empty:
Message: '%placeholder'