mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-27 09:51:36 +01:00
Placeholders for island level/votes rank
This commit is contained in:
parent
80b856f7c0
commit
1d80ffbaeb
@ -15,6 +15,7 @@ import me.goodandevil.skyblock.leaderboard.leaderheads.TopLevel;
|
|||||||
import me.goodandevil.skyblock.leaderboard.leaderheads.TopVotes;
|
import me.goodandevil.skyblock.leaderboard.leaderheads.TopVotes;
|
||||||
import me.goodandevil.skyblock.visit.Visit;
|
import me.goodandevil.skyblock.visit.Visit;
|
||||||
import me.goodandevil.skyblock.visit.VisitManager;
|
import me.goodandevil.skyblock.visit.VisitManager;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class LeaderboardManager {
|
public class LeaderboardManager {
|
||||||
|
|
||||||
@ -63,6 +64,40 @@ public class LeaderboardManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPlayerIslandLeaderboardPosition(Player player, Leaderboard.Type type) {
|
||||||
|
VisitManager visitManager = skyblock.getVisitManager();
|
||||||
|
visitManager.loadIslands();
|
||||||
|
|
||||||
|
List<LeaderboardPlayer> leaderboardPlayers = new ArrayList<>();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case Level:
|
||||||
|
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, visit.getLevel().getLevel()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Votes:
|
||||||
|
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, visit.getVoters().size()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
leaderboardPlayers.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed());
|
||||||
|
|
||||||
|
for (int i = 0; i < leaderboardPlayers.size(); i++) {
|
||||||
|
if (leaderboardPlayers.get(i).getUUID().equals(player.getUniqueId())) {
|
||||||
|
return i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
@ -7,6 +7,7 @@ import me.goodandevil.skyblock.island.Island;
|
|||||||
import me.goodandevil.skyblock.island.IslandManager;
|
import me.goodandevil.skyblock.island.IslandManager;
|
||||||
import me.goodandevil.skyblock.island.IslandRole;
|
import me.goodandevil.skyblock.island.IslandRole;
|
||||||
import me.goodandevil.skyblock.leaderboard.Leaderboard;
|
import me.goodandevil.skyblock.leaderboard.Leaderboard;
|
||||||
|
import me.goodandevil.skyblock.leaderboard.LeaderboardManager;
|
||||||
import me.goodandevil.skyblock.levelling.LevellingManager;
|
import me.goodandevil.skyblock.levelling.LevellingManager;
|
||||||
import me.goodandevil.skyblock.levelling.LevellingMaterial;
|
import me.goodandevil.skyblock.levelling.LevellingMaterial;
|
||||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||||
@ -306,6 +307,28 @@ public class PlaceholderManager {
|
|||||||
configLoad.getString("Placeholder.fabledskyblock_island_bank_balance.Non-empty.Message"))
|
configLoad.getString("Placeholder.fabledskyblock_island_bank_balance.Non-empty.Message"))
|
||||||
.replace("%placeholder", "" + island.getBankBalance());
|
.replace("%placeholder", "" + island.getBankBalance());
|
||||||
}
|
}
|
||||||
|
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_level_rank")) {
|
||||||
|
if (island == null) {
|
||||||
|
return ChatColor.translateAlternateColorCodes('&',
|
||||||
|
configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Empty.Message"));
|
||||||
|
} else {
|
||||||
|
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||||
|
int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Level);
|
||||||
|
return ChatColor.translateAlternateColorCodes('&',
|
||||||
|
configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_level_rank.Non-empty.Message")
|
||||||
|
.replace("%placeholder", "" + rank));
|
||||||
|
}
|
||||||
|
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_leaderboard_votes_rank")) {
|
||||||
|
if (island == null) {
|
||||||
|
return ChatColor.translateAlternateColorCodes('&',
|
||||||
|
configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Empty.Message"));
|
||||||
|
} else {
|
||||||
|
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||||
|
int rank = leaderboardManager.getPlayerIslandLeaderboardPosition(player, Leaderboard.Type.Votes);
|
||||||
|
return ChatColor.translateAlternateColorCodes('&',
|
||||||
|
configLoad.getString("Placeholder.fabledskyblock_island_leaderboard_votes_rank.Non-empty.Message")
|
||||||
|
.replace("%placeholder", "" + rank));
|
||||||
|
}
|
||||||
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_count_")) {
|
} else if (placeholder.toLowerCase().startsWith("fabledskyblock_island_level_block_count_")) {
|
||||||
if (island == null) {
|
if (island == null) {
|
||||||
return ChatColor.translateAlternateColorCodes('&',
|
return ChatColor.translateAlternateColorCodes('&',
|
||||||
|
@ -1205,6 +1205,16 @@ Placeholder:
|
|||||||
Message: "&c0"
|
Message: "&c0"
|
||||||
Non-empty:
|
Non-empty:
|
||||||
Message: "&f%placeholder"
|
Message: "&f%placeholder"
|
||||||
|
fabledskyblock_island_leaderboard_level_rank:
|
||||||
|
Empty:
|
||||||
|
Message: "&c0"
|
||||||
|
Non-empty:
|
||||||
|
Message: "&f%placeholder"
|
||||||
|
fabledskyblock_island_leaderboard_votes_rank:
|
||||||
|
Empty:
|
||||||
|
Message: "&c0"
|
||||||
|
Non-empty:
|
||||||
|
Message: "&f%placeholder"
|
||||||
fabledskyblock_island_level_block_count:
|
fabledskyblock_island_level_block_count:
|
||||||
Empty:
|
Empty:
|
||||||
Message: "&c0"
|
Message: "&c0"
|
||||||
|
Loading…
Reference in New Issue
Block a user