mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-26 20:26:34 +01:00
Is bank leaderboard and hologram
This commit is contained in:
parent
5c7f1bf5fd
commit
da8c162344
@ -43,10 +43,16 @@ public class RemoveHologramCommand extends SubCommand {
|
||||
if (args.length == 1) {
|
||||
HologramType hologramType = null;
|
||||
|
||||
if (args[0].equalsIgnoreCase("Level")) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "level":
|
||||
hologramType = HologramType.Level;
|
||||
} else if (args[0].equalsIgnoreCase("Votes")) {
|
||||
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" };
|
||||
}
|
||||
}
|
||||
|
@ -32,10 +32,16 @@ public class SetHologramCommand extends SubCommand {
|
||||
if (args.length == 1) {
|
||||
HologramType hologramType = null;
|
||||
|
||||
if (args[0].equalsIgnoreCase("Level")) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "level":
|
||||
hologramType = HologramType.Level;
|
||||
} else if (args[0].equalsIgnoreCase("Votes")) {
|
||||
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" };
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
switch (type) {
|
||||
case Level:
|
||||
leaderboardType = Leaderboard.Type.Level;
|
||||
} else if (type == HologramType.Votes) {
|
||||
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) {
|
||||
switch (hologramTypeList) {
|
||||
case Level:
|
||||
leaderboardType = Leaderboard.Type.Level;
|
||||
} else if (hologramTypeList == HologramType.Votes) {
|
||||
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()))));
|
||||
}
|
||||
|
@ -2,6 +2,6 @@ package me.goodandevil.skyblock.hologram;
|
||||
|
||||
public enum HologramType {
|
||||
|
||||
Level, Votes, Stackable;
|
||||
Level, Bank, Votes, Stackable;
|
||||
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class Leaderboard {
|
||||
|
||||
public enum Type {
|
||||
|
||||
Level, Votes;
|
||||
Level, Bank, Votes
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -37,22 +37,15 @@ 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);
|
||||
@ -70,21 +63,45 @@ public class MVdWPlaceholder {
|
||||
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())));
|
||||
.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);
|
||||
@ -109,14 +126,11 @@ public class MVdWPlaceholder {
|
||||
|
||||
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) {
|
||||
PlaceholderAPI.registerPlaceholder(skyblock, placeholderList, event -> {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player == null) {
|
||||
@ -124,7 +138,6 @@ public class MVdWPlaceholder {
|
||||
}
|
||||
|
||||
return placeholderManager.getPlaceholder(player, event.getPlaceholder());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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('&',
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -78,14 +78,6 @@ public class VisitManager {
|
||||
islandSignature = configLoad.getStringList("Visitor.Signature.Message");
|
||||
}
|
||||
|
||||
int division = skyblock.getFileManager()
|
||||
.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getInt("Island.Levelling.Division");
|
||||
|
||||
if (division == 0) {
|
||||
division = 1;
|
||||
}
|
||||
|
||||
int size = 100;
|
||||
|
||||
if (configLoad.getString("Size") != null) {
|
||||
@ -106,6 +98,7 @@ public class VisitManager {
|
||||
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) {
|
||||
@ -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) {
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user