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) { if (args.length == 1) {
HologramType hologramType = null; HologramType hologramType = null;
if (args[0].equalsIgnoreCase("Level")) { switch (args[0].toLowerCase()) {
hologramType = HologramType.Level; case "level":
} else if (args[0].equalsIgnoreCase("Votes")) { hologramType = HologramType.Level;
hologramType = HologramType.Votes; break;
case "bank":
hologramType = HologramType.Bank;
break;
case "votes":
hologramType = HologramType.Votes;
break;
} }
if (hologramType != null) { if (hologramType != null) {
@ -107,6 +113,6 @@ public class RemoveHologramCommand extends SubCommand {
@Override @Override
public String[] getArguments() { 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) { if (args.length == 1) {
HologramType hologramType = null; HologramType hologramType = null;
if (args[0].equalsIgnoreCase("Level")) { switch (args[0].toLowerCase()) {
hologramType = HologramType.Level; case "level":
} else if (args[0].equalsIgnoreCase("Votes")) { hologramType = HologramType.Level;
hologramType = HologramType.Votes; break;
case "bank":
hologramType = HologramType.Bank;
break;
case "votes":
hologramType = HologramType.Votes;
break;
} }
if (hologramType != null) { if (hologramType != null) {
@ -91,6 +97,6 @@ public class SetHologramCommand extends SubCommand {
@Override @Override
public String[] getArguments() { public String[] getArguments() {
return new String[] { "level", "votes" }; return new String[] { "level", "bank", "votes" };
} }
} }

View File

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

View File

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

View File

@ -619,17 +619,23 @@ public class Island {
} }
public void addToBank(double value) { public void addToBank(double value) {
value = value + getBankBalance(); FileManager fileManager = skyblock.getFileManager();
skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) Config config = fileManager
.getFileConfiguration().set("Bank.Balance", value); .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) { public void removeFromBank(double value) {
value = getBankBalance() - value; addToBank(-value);
skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Bank.Balance", value);
} }
public boolean isOpen() { public boolean isOpen() {

View File

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

View File

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

View File

@ -1,22 +1,20 @@
package me.goodandevil.skyblock.leaderboard; 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.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.UUID; 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 { public class LeaderboardManager {
private final SkyBlock skyblock; private final SkyBlock skyblock;
@ -39,16 +37,19 @@ public class LeaderboardManager {
visitManager.loadIslands(); visitManager.loadIslands();
List<LeaderboardPlayer> islandLevels = new ArrayList<>(); List<LeaderboardPlayer> islandLevels = new ArrayList<>();
List<LeaderboardPlayer> islandBanks = new ArrayList<>();
List<LeaderboardPlayer> islandVotes = new ArrayList<>(); List<LeaderboardPlayer> islandVotes = new ArrayList<>();
for (int i = 0; i < visitManager.getIslands().size(); i++) { for (int i = 0; i < visitManager.getIslands().size(); i++) {
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i]; UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
Visit visit = visitManager.getIslands().get(ownerUUID); Visit visit = visitManager.getIslands().get(ownerUUID);
islandLevels.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel())); islandLevels.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel()));
islandBanks.add(new LeaderboardPlayer(ownerUUID, (long)visit.getBankBalance()));
islandVotes.add(new LeaderboardPlayer(ownerUUID, visit.getVoters().size())); islandVotes.add(new LeaderboardPlayer(ownerUUID, visit.getVoters().size()));
} }
islandLevels.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed()); islandLevels.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed());
islandBanks.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed());
islandVotes.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed()); islandVotes.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed());
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
@ -57,6 +58,11 @@ public class LeaderboardManager {
leaderboardStorage.add(leaderboard); 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()) { if (!islandLevels.isEmpty() && i < islandLevels.size()) {
Leaderboard leaderboard = new Leaderboard(Leaderboard.Type.Level, visitManager.getIsland(islandLevels.get(i).getUUID()), i); Leaderboard leaderboard = new Leaderboard(Leaderboard.Type.Level, visitManager.getIsland(islandLevels.get(i).getUUID()), i);
leaderboardStorage.add(leaderboard); leaderboardStorage.add(leaderboard);
@ -78,6 +84,12 @@ public class LeaderboardManager {
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel())); leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel()));
} }
break; 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: case Votes:
for (int i = 0; i < visitManager.getIslands().size(); i++) { for (int i = 0; i < visitManager.getIslands().size(); i++) {
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i]; UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
@ -101,6 +113,7 @@ public class LeaderboardManager {
public void setupLeaderHeads() { public void setupLeaderHeads() {
if (Bukkit.getServer().getPluginManager().getPlugin("LeaderHeads") != null) { if (Bukkit.getServer().getPluginManager().getPlugin("LeaderHeads") != null) {
new TopLevel(skyblock); new TopLevel(skyblock);
new TopBank(skyblock);
new TopVotes(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.ArrayList;
import java.util.List; import java.util.List;
import me.goodandevil.skyblock.utils.NumberUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -74,6 +75,14 @@ public class Leaderboard {
+ ".Item.Leaderboard.Displayname") + ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.Level.name()))))) { .replace("%leaderboard", Viewer.Type.Level.name()))))) {
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Level)); 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()) } else if ((is.getType() == Material.EMERALD) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName() && (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', .equals(ChatColor.translateAlternateColorCodes('&',
@ -109,6 +118,16 @@ public class Leaderboard {
new Placeholder[] { new Placeholder("%leaderboard", Viewer.Type.Level.name()) }, null, new Placeholder[] { new Placeholder("%leaderboard", Viewer.Type.Level.name()) }, null,
null), null),
1); 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.addItem(
nInv.createItem(new ItemStack(Material.EMERALD), configLoad nInv.createItem(new ItemStack(Material.EMERALD), configLoad
.getString( .getString(
@ -304,6 +323,7 @@ public class Leaderboard {
new Placeholder("%position", "" + (leaderboard.getPosition() + 1)), new Placeholder("%position", "" + (leaderboard.getPosition() + 1)),
new Placeholder("%owner", playerName), new Placeholder("%owner", playerName),
new Placeholder("%level", "" + visit.getLevel().getLevel()), new Placeholder("%level", "" + visit.getLevel().getLevel()),
new Placeholder("%balance", NumberUtil.formatNumberByDecimal(visit.getBankBalance())),
new Placeholder("%votes", "" + visit.getVoters().size()), new Placeholder("%votes", "" + visit.getVoters().size()),
new Placeholder("%members", "" + visit.getMembers()) }, new Placeholder("%members", "" + visit.getMembers()) },
null, null), null, null),
@ -354,7 +374,7 @@ public class Leaderboard {
public enum Type { 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(); FileConfiguration configLoad = config.getFileConfiguration();
List<Leaderboard> leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level); List<Leaderboard> leaderboardLevelPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Level);
List<Leaderboard> leaderboardBankPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Bank);
List<Leaderboard> leaderboardVotesPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Votes); List<Leaderboard> leaderboardVotesPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Votes);
if (identifier.equalsIgnoreCase("islands")) { if (identifier.equalsIgnoreCase("islands")) {
@ -82,7 +83,30 @@ public class EZPlaceholder extends PlaceholderExpansion implements Listener {
} }
return ChatColor.translateAlternateColorCodes('&', 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))) { } else if (identifier.equalsIgnoreCase("leaderboard_level_" + (i + 1))) {
if (i < leaderboardLevelPlayers.size()) { if (i < leaderboardLevelPlayers.size()) {
Leaderboard leaderboard = leaderboardLevelPlayers.get(i); Leaderboard leaderboard = leaderboardLevelPlayers.get(i);

View File

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

View File

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

View File

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

View File

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