Is bank leaderboard and hologram

This commit is contained in:
Esophose 2019-04-10 23:50:24 -06:00
parent 5c7f1bf5fd
commit da8c162344
16 changed files with 362 additions and 162 deletions

View File

@ -43,10 +43,16 @@ public class RemoveHologramCommand extends SubCommand {
if (args.length == 1) {
HologramType hologramType = null;
if (args[0].equalsIgnoreCase("Level")) {
hologramType = HologramType.Level;
} else if (args[0].equalsIgnoreCase("Votes")) {
hologramType = HologramType.Votes;
switch (args[0].toLowerCase()) {
case "level":
hologramType = HologramType.Level;
break;
case "bank":
hologramType = HologramType.Bank;
break;
case "votes":
hologramType = HologramType.Votes;
break;
}
if (hologramType != null) {
@ -107,6 +113,6 @@ public class RemoveHologramCommand extends SubCommand {
@Override
public String[] getArguments() {
return new String[] { "level", "votes" };
return new String[] { "level", "bank", "votes" };
}
}

View File

@ -32,10 +32,16 @@ public class SetHologramCommand extends SubCommand {
if (args.length == 1) {
HologramType hologramType = null;
if (args[0].equalsIgnoreCase("Level")) {
hologramType = HologramType.Level;
} else if (args[0].equalsIgnoreCase("Votes")) {
hologramType = HologramType.Votes;
switch (args[0].toLowerCase()) {
case "level":
hologramType = HologramType.Level;
break;
case "bank":
hologramType = HologramType.Bank;
break;
case "votes":
hologramType = HologramType.Votes;
break;
}
if (hologramType != null) {
@ -91,6 +97,6 @@ public class SetHologramCommand extends SubCommand {
@Override
public String[] getArguments() {
return new String[] { "level", "votes" };
return new String[] { "level", "bank", "votes" };
}
}

View File

@ -41,7 +41,7 @@ public class HologramManager {
removeWorldHolograms();
for (HologramType hologramTypeList : HologramType.values()) {
if (hologramTypeList == HologramType.Level || hologramTypeList == HologramType.Votes) {
if (hologramTypeList == HologramType.Level || hologramTypeList == HologramType.Bank || hologramTypeList == HologramType.Votes) {
if (hologramTypeList == HologramType.Votes) {
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
@ -77,10 +77,16 @@ public class HologramManager {
List<String> hologramLines = new ArrayList<>();
Leaderboard.Type leaderboardType = null;
if (type == HologramType.Level) {
leaderboardType = Leaderboard.Type.Level;
} else if (type == HologramType.Votes) {
leaderboardType = Leaderboard.Type.Votes;
switch (type) {
case Level:
leaderboardType = Leaderboard.Type.Level;
break;
case Bank:
leaderboardType = Leaderboard.Type.Bank;
break;
case Votes:
leaderboardType = Leaderboard.Type.Votes;
break;
}
hologramLines.add(messageManager.replaceMessage(null,
@ -109,13 +115,22 @@ public class HologramManager {
IslandLevel level = visit.getLevel();
hologramLines.add(ChatColor.translateAlternateColorCodes('&',
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
.replace("%position", "" + (i + 1)).replace("%player", islandOwnerName)
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))
.replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints()))));
} else if (type == HologramType.Bank) {
hologramLines.add(ChatColor.translateAlternateColorCodes('&',
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%balance",
"" + NumberUtil.formatNumberByDecimal(visit.getBankBalance()))));
} else if (type == HologramType.Votes) {
hologramLines.add(ChatColor.translateAlternateColorCodes('&',
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
.replace("%position", "" + (i + 1)).replace("%player", islandOwnerName)
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%votes",
"" + NumberUtil.formatNumberByDecimal(visit.getVoters().size()))));
}
@ -166,7 +181,7 @@ public class HologramManager {
FileConfiguration configLoad = config.getFileConfiguration();
for (HologramType hologramTypeList : HologramType.values()) {
if (hologramTypeList == HologramType.Level || hologramTypeList == HologramType.Votes) {
if (hologramTypeList == HologramType.Level || hologramTypeList == HologramType.Bank || hologramTypeList == HologramType.Votes) {
if (configLoad.getString("Location.Hologram.Leaderboard." + hologramTypeList.name()) != null) {
locations.add(fileManager.getLocation(config,
"Location.Hologram.Leaderboard." + hologramTypeList.name(), true));
@ -220,7 +235,7 @@ public class HologramManager {
.getFileConfiguration();
for (HologramType hologramTypeList : HologramType.values()) {
if (hologramTypeList == HologramType.Level || hologramTypeList == HologramType.Votes) {
if (hologramTypeList == HologramType.Level || hologramTypeList == HologramType.Bank || hologramTypeList == HologramType.Votes) {
if (hologramTypeList == HologramType.Votes) {
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Visitor.Vote")) {
@ -238,10 +253,16 @@ public class HologramManager {
Leaderboard.Type leaderboardType = null;
if (hologramTypeList == HologramType.Level) {
leaderboardType = Leaderboard.Type.Level;
} else if (hologramTypeList == HologramType.Votes) {
leaderboardType = Leaderboard.Type.Votes;
switch (hologramTypeList) {
case Level:
leaderboardType = Leaderboard.Type.Level;
break;
case Bank:
leaderboardType = Leaderboard.Type.Bank;
break;
case Votes:
leaderboardType = Leaderboard.Type.Votes;
break;
}
for (int i = 0; i < 10; i++) {
@ -268,13 +289,22 @@ public class HologramManager {
IslandLevel level = visit.getLevel();
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
.replace("%position", "" + (i + 1)).replace("%player", islandOwnerName)
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))
.replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints()))));
} else if (hologramTypeList == HologramType.Bank) {
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%balance",
"" + NumberUtil.formatNumberByDecimal(visit.getBankBalance()))));
} else if (hologramTypeList == HologramType.Votes) {
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
.replace("%position", "" + (i + 1)).replace("%player", islandOwnerName)
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%votes",
"" + NumberUtil.formatNumberByDecimal(visit.getVoters().size()))));
}

View File

@ -2,6 +2,6 @@ package me.goodandevil.skyblock.hologram;
public enum HologramType {
Level, Votes, Stackable;
Level, Bank, Votes, Stackable;
}

View File

@ -619,17 +619,23 @@ public class Island {
}
public void addToBank(double value) {
value = value + getBankBalance();
skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Bank.Balance", value);
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager
.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml"));
value = getBankBalance() + value;
config.getFileConfiguration().set("Bank.Balance", value);
try {
config.getFileConfiguration().save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
public void removeFromBank(double value) {
value = getBankBalance() - value;
skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Bank.Balance", value);
addToBank(-value);
}
public boolean isOpen() {

View File

@ -165,6 +165,7 @@ public class IslandManager {
island.getIslandLocation(IslandWorld.End, IslandEnvironment.Island)},
island.getSize(),
island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1,
island.getBankBalance(),
visitManager.getIslandSafeLevel(island.getOwnerUUID()), island.getLevel(),
island.getMessage(IslandMessage.Signature), island.isOpen());
}
@ -524,6 +525,7 @@ public class IslandManager {
island.getIslandLocation(IslandWorld.End, IslandEnvironment.Island)},
island.getSize(),
island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1,
island.getBankBalance(),
visitManager.getIslandSafeLevel(island.getOwnerUUID()), island.getLevel(),
island.getMessage(IslandMessage.Signature), island.isOpen());
}

View File

@ -28,7 +28,7 @@ public class Leaderboard {
public enum Type {
Level, Votes;
Level, Bank, Votes
}
}

View File

@ -1,22 +1,20 @@
package me.goodandevil.skyblock.leaderboard;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.leaderboard.leaderheads.TopBank;
import me.goodandevil.skyblock.leaderboard.leaderheads.TopLevel;
import me.goodandevil.skyblock.leaderboard.leaderheads.TopVotes;
import me.goodandevil.skyblock.visit.Visit;
import me.goodandevil.skyblock.visit.VisitManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandManager;
import org.bukkit.Bukkit;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.leaderboard.leaderheads.TopLevel;
import me.goodandevil.skyblock.leaderboard.leaderheads.TopVotes;
import me.goodandevil.skyblock.visit.Visit;
import me.goodandevil.skyblock.visit.VisitManager;
import org.bukkit.entity.Player;
public class LeaderboardManager {
private final SkyBlock skyblock;
@ -39,16 +37,19 @@ public class LeaderboardManager {
visitManager.loadIslands();
List<LeaderboardPlayer> islandLevels = new ArrayList<>();
List<LeaderboardPlayer> islandBanks = new ArrayList<>();
List<LeaderboardPlayer> islandVotes = new ArrayList<>();
for (int i = 0; i < visitManager.getIslands().size(); i++) {
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
Visit visit = visitManager.getIslands().get(ownerUUID);
islandLevels.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel()));
islandBanks.add(new LeaderboardPlayer(ownerUUID, (long)visit.getBankBalance()));
islandVotes.add(new LeaderboardPlayer(ownerUUID, visit.getVoters().size()));
}
islandLevels.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed());
islandBanks.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed());
islandVotes.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed());
for (int i = 0; i < 10; i++) {
@ -57,6 +58,11 @@ public class LeaderboardManager {
leaderboardStorage.add(leaderboard);
}
if (!islandBanks.isEmpty() && i < islandBanks.size()) {
Leaderboard leaderboard = new Leaderboard(Leaderboard.Type.Bank, visitManager.getIsland(islandBanks.get(i).getUUID()), i);
leaderboardStorage.add(leaderboard);
}
if (!islandLevels.isEmpty() && i < islandLevels.size()) {
Leaderboard leaderboard = new Leaderboard(Leaderboard.Type.Level, visitManager.getIsland(islandLevels.get(i).getUUID()), i);
leaderboardStorage.add(leaderboard);
@ -78,6 +84,12 @@ public class LeaderboardManager {
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel()));
}
break;
case Bank:
for (int i = 0; i < visitManager.getIslands().size(); i++) {
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
Visit visit = visitManager.getIslands().get(ownerUUID);
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, (long)visit.getBankBalance()));
}
case Votes:
for (int i = 0; i < visitManager.getIslands().size(); i++) {
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
@ -101,6 +113,7 @@ public class LeaderboardManager {
public void setupLeaderHeads() {
if (Bukkit.getServer().getPluginManager().getPlugin("LeaderHeads") != null) {
new TopLevel(skyblock);
new TopBank(skyblock);
new TopVotes(skyblock);
}
}

View File

@ -0,0 +1,47 @@
package me.goodandevil.skyblock.leaderboard.leaderheads;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import java.util.UUID;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.leaderboard.Leaderboard;
import me.goodandevil.skyblock.leaderboard.Leaderboard.Type;
import me.goodandevil.skyblock.visit.Visit;
import me.robin.leaderheads.api.LeaderHeadsAPI;
import me.robin.leaderheads.datacollectors.DataCollector;
import me.robin.leaderheads.objects.BoardType;
public class TopBank extends DataCollector {
private final SkyBlock skyblock;
public TopBank(SkyBlock skyblock) {
super("topbank", skyblock.getDescription().getName(), BoardType.DEFAULT, "&bTop Bank", "topbank",
Arrays.asList(ChatColor.DARK_GRAY + "-=+=-", ChatColor.AQUA + "{name}",
ChatColor.WHITE + "Bal: ${amount}", ChatColor.DARK_GRAY + "-=+=-"),
true, UUID.class);
this.skyblock = skyblock;
}
@Override
public List<Entry<?, Double>> requestAll() {
Map<UUID, Double> topLevels = new HashMap<>();
List<Leaderboard> leaderboards = skyblock.getLeaderboardManager().getLeaderboard(Type.Bank);
for (Leaderboard leaderboard : leaderboards) {
Visit visit = leaderboard.getVisit();
topLevels.put(visit.getOwnerUUID(), visit.getBankBalance());
}
return LeaderHeadsAPI.sortMap(topLevels);
}
}

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import me.goodandevil.skyblock.utils.NumberUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -74,6 +75,14 @@ public class Leaderboard {
+ ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.Level.name()))))) {
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Level));
} else if ((is.getType() == Material.GOLD_INGOT) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad
.getString("Menu.Leaderboard." + Viewer.Type.Browse.name()
+ ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.Bank.name()))))) {
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Bank));
} else if ((is.getType() == Material.EMERALD) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&',
@ -109,6 +118,16 @@ public class Leaderboard {
new Placeholder[] { new Placeholder("%leaderboard", Viewer.Type.Level.name()) }, null,
null),
1);
nInv.addItem(
nInv.createItem(new ItemStack(Material.GOLD_INGOT), configLoad
.getString(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.Bank.name()),
configLoad.getStringList(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"),
new Placeholder[] { new Placeholder("%leaderboard", Viewer.Type.Bank.name()) }, null,
null),
2);
nInv.addItem(
nInv.createItem(new ItemStack(Material.EMERALD), configLoad
.getString(
@ -304,6 +323,7 @@ public class Leaderboard {
new Placeholder("%position", "" + (leaderboard.getPosition() + 1)),
new Placeholder("%owner", playerName),
new Placeholder("%level", "" + visit.getLevel().getLevel()),
new Placeholder("%balance", NumberUtil.formatNumberByDecimal(visit.getBankBalance())),
new Placeholder("%votes", "" + visit.getVoters().size()),
new Placeholder("%members", "" + visit.getMembers()) },
null, null),
@ -354,7 +374,7 @@ public class Leaderboard {
public enum Type {
Browse, Level, Votes;
Browse, Level, Bank, Votes
}
}

View File

@ -55,6 +55,7 @@ public class EZPlaceholder extends PlaceholderExpansion implements Listener {
FileConfiguration configLoad = config.getFileConfiguration();
List<Leaderboard> leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level);
List<Leaderboard> leaderboardBankPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Bank);
List<Leaderboard> leaderboardVotesPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Votes);
if (identifier.equalsIgnoreCase("islands")) {
@ -82,7 +83,30 @@ public class EZPlaceholder extends PlaceholderExpansion implements Listener {
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Empty.Message"));
configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Empty.Message"));
} else if (identifier.equalsIgnoreCase("leaderboard_bank_" + (i + 1))) {
if (i < leaderboardLevelPlayers.size()) {
Leaderboard leaderboard = leaderboardLevelPlayers.get(i);
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();
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Non-empty.Message")
.replace("%position", "" + (i + 1)).replace("%player", islandOwnerName)
.replace("%balance", NumberUtil.formatNumberByDecimal(level.getLevel())));
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Empty.Message"));
} else if (identifier.equalsIgnoreCase("leaderboard_level_" + (i + 1))) {
if (i < leaderboardLevelPlayers.size()) {
Leaderboard leaderboard = leaderboardLevelPlayers.get(i);

View File

@ -37,94 +37,107 @@ public class MVdWPlaceholder {
FileConfiguration configLoad = config.getFileConfiguration();
List<Leaderboard> leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level);
List<Leaderboard> leaderboardBankPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Bank);
List<Leaderboard> leaderboardVotesPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Votes);
PlaceholderAPI.registerPlaceholder(skyblock, "fabledskyblock_islands", new PlaceholderReplacer() {
@Override
public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
return "" + skyblock.getVisitManager().getIslands().size();
}
});
PlaceholderAPI.registerPlaceholder(skyblock, "fabledskyblock_islands", event -> "" + skyblock.getVisitManager().getIslands().size());
for (int i = 0; i < 10; i++) {
PlaceholderAPI.registerPlaceholder(skyblock, "fabledskyblock_leaderboard_votes_" + (i + 1),
new PlaceholderReplacer() {
@Override
public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
int index = Integer
.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_votes_", ""));
event -> {
int index = Integer.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_votes_", ""));
if (index < leaderboardVotesPlayers.size()) {
Leaderboard leaderboard = leaderboardVotesPlayers.get(index);
Visit visit = leaderboard.getVisit();
if (index < leaderboardVotesPlayers.size()) {
Leaderboard leaderboard = leaderboardVotesPlayers.get(index);
Visit visit = leaderboard.getVisit();
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName;
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName;
if (targetPlayer == null) {
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
} else {
islandOwnerName = targetPlayer.getName();
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Non-empty.Message")
.replace("%position", "" + (index + 1))
.replace("%player", islandOwnerName).replace("%votes",
NumberUtil.formatNumberByDecimal(visit.getVoters().size())));
if (targetPlayer == null) {
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
} else {
islandOwnerName = targetPlayer.getName();
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Empty.Message"));
configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Non-empty.Message")
.replace("%position", "" + (index + 1))
.replace("%player", islandOwnerName)
.replace("%votes", NumberUtil.formatNumberByDecimal(visit.getVoters().size())));
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Empty.Message"));
});
PlaceholderAPI.registerPlaceholder(skyblock, "fabledskyblock_leaderboard_bank_" + (i + 1),
event -> {
int index = Integer.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_bank_", ""));
if (index < leaderboardBankPlayers.size()) {
Leaderboard leaderboard = leaderboardBankPlayers.get(index);
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();
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Non-empty.Message")
.replace("%position", "" + (index + 1))
.replace("%player", islandOwnerName)
.replace("%balance", NumberUtil.formatNumberByDecimal(visit.getBankBalance())));
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Empty.Message"));
});
PlaceholderAPI.registerPlaceholder(skyblock, "fabledskyblock_leaderboard_level_" + (i + 1),
new PlaceholderReplacer() {
@Override
public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
int index = Integer
.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_level_", ""));
event -> {
int index = Integer.valueOf(event.getPlaceholder().replace("fabledskyblock_leaderboard_level_", ""));
if (index < leaderboardLevelPlayers.size()) {
Leaderboard leaderboard = leaderboardLevelPlayers.get(index);
Visit visit = leaderboard.getVisit();
IslandLevel level = visit.getLevel();
if (index < leaderboardLevelPlayers.size()) {
Leaderboard leaderboard = leaderboardLevelPlayers.get(index);
Visit visit = leaderboard.getVisit();
IslandLevel level = visit.getLevel();
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName;
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName;
if (targetPlayer == null) {
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
} else {
islandOwnerName = targetPlayer.getName();
}
return ChatColor.translateAlternateColorCodes('&', configLoad
.getString("Placeholder.fabledskyblock_leaderboard_level.Non-empty.Message")
.replace("%position", "" + (index + 1)).replace("%player", islandOwnerName)
.replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))
.replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints())));
if (targetPlayer == null) {
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
} else {
islandOwnerName = targetPlayer.getName();
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Empty.Message"));
return ChatColor.translateAlternateColorCodes('&', configLoad
.getString("Placeholder.fabledskyblock_leaderboard_level.Non-empty.Message")
.replace("%position", "" + (index + 1)).replace("%player", islandOwnerName)
.replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))
.replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints())));
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_level.Empty.Message"));
});
}
for (String placeholderList : placeholderManager.getPlaceholders()) {
PlaceholderAPI.registerPlaceholder(skyblock, placeholderList, new PlaceholderReplacer() {
@Override
public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
Player player = event.getPlayer();
PlaceholderAPI.registerPlaceholder(skyblock, placeholderList, event -> {
Player player = event.getPlayer();
if (player == null) {
return null;
}
return placeholderManager.getPlaceholder(player, event.getPlaceholder());
if (player == null) {
return null;
}
return placeholderManager.getPlaceholder(player, event.getPlaceholder());
});
}
}

View File

@ -318,6 +318,17 @@ public class PlaceholderManager {
configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Non-empty.Message")
.replace("%placeholder", "" + rank));
}
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_bank_rank")) {
if (island == null) {
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Empty.Message"));
} else {
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Bank);
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_bank_rank.Non-empty.Message")
.replace("%placeholder", "" + rank));
}
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_votes_rank")) {
if (island == null) {
return ChatColor.translateAlternateColorCodes('&',

View File

@ -30,6 +30,7 @@ public class Visit {
private int islandSize;
private int islandMembers;
private int safeLevel;
private double islandBankBalance;
private final IslandLevel islandLevel;
@ -38,12 +39,13 @@ public class Visit {
private boolean open;
protected Visit(SkyBlock skyblock, UUID islandOwnerUUID, IslandLocation[] islandLocations, int islandSize,
int islandMembers, int safeLevel, IslandLevel islandLevel, List<String> islandSignature, boolean open) {
int islandMembers, double islandBankBalance, int safeLevel, IslandLevel islandLevel, List<String> islandSignature, boolean open) {
this.skyblock = skyblock;
this.islandOwnerUUID = islandOwnerUUID;
this.islandLocations = islandLocations;
this.islandSize = islandSize;
this.islandMembers = islandMembers;
this.islandBankBalance = islandBankBalance;
this.safeLevel = safeLevel;
this.islandLevel = islandLevel;
this.islandSignature = islandSignature;
@ -103,6 +105,10 @@ public class Visit {
this.islandSize = islandSize;
}
public double getBankBalance() {
return this.islandBankBalance;
}
public IslandLevel getLevel() {
return islandLevel;
}

View File

@ -56,63 +56,56 @@ public class VisitManager {
if (!configFile.exists()) return;
for (File fileList : configFile.listFiles()) {
if (fileList != null && fileList.getName().contains(".yml") && fileList.getName().length() > 35) {
try {
Config config = new FileManager.Config(fileManager, fileList);
FileConfiguration configLoad = config.getFileConfiguration();
for (File fileList : configFile.listFiles()) {
if (fileList != null && fileList.getName().contains(".yml") && fileList.getName().length() > 35) {
try {
Config config = new FileManager.Config(fileManager, fileList);
FileConfiguration configLoad = config.getFileConfiguration();
UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", ""));
UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", ""));
if (islandOwnerUUID == null) {
islandOwnerUUID = UUID.fromString(fileList.getName().replaceFirst("[.][^.]+$", ""));
if (islandOwnerUUID == null) {
islandOwnerUUID = UUID.fromString(fileList.getName().replaceFirst("[.][^.]+$", ""));
if (islandOwnerUUID == null) {
continue;
}
}
if (islandOwnerUUID == null) {
continue;
}
}
List<String> islandSignature = new ArrayList<>();
List<String> islandSignature = new ArrayList<>();
if (configLoad.getString("Visitor.Signature.Message") != null) {
islandSignature = configLoad.getStringList("Visitor.Signature.Message");
}
if (configLoad.getString("Visitor.Signature.Message") != null) {
islandSignature = configLoad.getStringList("Visitor.Signature.Message");
}
int division = skyblock.getFileManager()
.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getInt("Island.Levelling.Division");
int size = 100;
if (division == 0) {
division = 1;
}
if (configLoad.getString("Size") != null) {
size = configLoad.getInt("Size");
}
int size = 100;
if (configLoad.getString("Size") != null) {
size = configLoad.getInt("Size");
}
createIsland(islandOwnerUUID,
new IslandLocation[] {
new IslandLocation(IslandWorld.Normal, null,
worldManager.getLocation(fileManager.getLocation(config,
"Location.Normal.Island", true), IslandWorld.Normal)),
new IslandLocation(IslandWorld.Nether, null,
worldManager.getLocation(fileManager.getLocation(config,
"Location.Nether.Island", true), IslandWorld.Nether)),
new IslandLocation(IslandWorld.End, null,
worldManager.getLocation(fileManager.getLocation(config,
"Location.Nether.Island", true), IslandWorld.End)) },
size,
configLoad.getStringList("Members").size()
+ configLoad.getStringList("Operators").size() + 1,
getIslandSafeLevel(islandOwnerUUID), new IslandLevel(islandOwnerUUID, skyblock),
islandSignature, configLoad.getBoolean("Visitor.Open"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
createIsland(islandOwnerUUID,
new IslandLocation[] {
new IslandLocation(IslandWorld.Normal, null,
worldManager.getLocation(fileManager.getLocation(config,
"Location.Normal.Island", true), IslandWorld.Normal)),
new IslandLocation(IslandWorld.Nether, null,
worldManager.getLocation(fileManager.getLocation(config,
"Location.Nether.Island", true), IslandWorld.Nether)),
new IslandLocation(IslandWorld.End, null,
worldManager.getLocation(fileManager.getLocation(config,
"Location.Nether.Island", true), IslandWorld.End)) },
size,
configLoad.getStringList("Members").size()
+ configLoad.getStringList("Operators").size() + 1,
configLoad.getDouble("Bank.Balance", 0),
getIslandSafeLevel(islandOwnerUUID), new IslandLevel(islandOwnerUUID, skyblock),
islandSignature, configLoad.getBoolean("Visitor.Open"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
@ -218,9 +211,9 @@ public class VisitManager {
}
public void createIsland(UUID islandOwnerUUID, IslandLocation[] islandLocations, int islandSize, int islandMembers,
int safeLevel, IslandLevel islandLevel, List<String> islandSignature, boolean open) {
double islandBankBalance, int safeLevel, IslandLevel islandLevel, List<String> islandSignature, boolean open) {
visitStorage.put(islandOwnerUUID, new Visit(skyblock, islandOwnerUUID, islandLocations, islandSize,
islandMembers, safeLevel, islandLevel, islandSignature, open));
islandMembers, islandBankBalance, safeLevel, islandLevel, islandSignature, open));
}
public void addIsland(UUID islandOwnerUUID, Visit visit) {

View File

@ -88,7 +88,7 @@ Command:
Info:
Message: "&f&oOpens the Leaderboard menu of the top 10 Islands."
Invalid:
Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island leaderboard [<Level|Votes>]"
Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island leaderboard [<Level|Bank|Votes>]"
Disabled:
Message: "&bSkyBlock &8| &cError&8: &eYou cannot view that leaderboard because that leaderboard is disabled."
Create:
@ -1104,6 +1104,11 @@ Placeholder:
Message: "&f&oUnclaimed"
Non-empty:
Message: "&f[%position] %player [%level]"
fabledskyblock_leaderboard_bank:
Empty:
Message: "&f&oUnclaimed"
Non-empty:
Message: "&f[%position] %player [$%balance]"
fabledskyblock_leaderboard_votes:
Empty:
Message: "&f&oUnclaimed"
@ -1229,6 +1234,11 @@ Placeholder:
Message: "&c0"
Non-empty:
Message: "&f%placeholder"
fabledskyblock_island_leaderboard_bank_rank:
Empty:
Message: "&c0"
Non-empty:
Message: "&f%placeholder"
fabledskyblock_island_leaderboard_votes_rank:
Empty:
Message: "&c0"
@ -1260,6 +1270,11 @@ Hologram:
Claimed: "&8* &f&o[%position] &a%player &7- &6%level"
Unclaimed: "&8* &f&o[%position] &7&oUnclaimed Position"
Footer: "&ewww.example.net"
Bank:
Header: "&b&lSkyBlock &8&l| &e&lTop 10 Bank Balances"
Claimed: "&8* &f&o[%position] &a%player &7- &6$%balance"
Unclaimed: "&8* &f&o[%position] &7&oUnclaimed Position"
Footer: "&ewww.example.net"
Votes:
Header: "&b&lSkyBlock &8&l| &e&lTop 10 Votes"
Claimed: "&8* &f&o[%position] &a%player &7- &6%votes"
@ -1707,6 +1722,14 @@ Menu:
- ""
- "&7Signature&8:"
- "%signature"
Bank:
Lore:
- "&7Owner&8: &f%owner"
- "&7Balance&8: &f$%balance"
- "&7Members&8: &f%members"
- ""
- "&7Signature&8:"
- "%signature"
Votes:
Lore:
- "&7Owner&8: &f%owner"