LB MT FODA

This commit is contained in:
nearfe 2024-06-19 22:07:33 -03:00
parent e69d767b40
commit 86579763ae
1 changed files with 66 additions and 33 deletions

View File

@ -93,14 +93,29 @@ public class LeaderboardUpdateRunnable implements Runnable {
break; break;
} }
lore.add(color + "" + rank + " " + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(allEloMap.getOrDefault(uuid, 1000))); lore.add(color + "" + rank + " " + CC.GREEN + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(allEloMap.getOrDefault(uuid, 1000)));
} }
} else if (integer.get() >= 3 && integer.get() < 10) { } else if (integer.get() >= 3 && integer.get() < 10) {
final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection().find(Filters.eq("uuid", uuid.toString())).first(); final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection().find(Filters.eq("uuid", uuid.toString())).first();
if (playerDocument != null) { if (playerDocument != null) {
int rank = integer.incrementAndGet(); int rank = integer.incrementAndGet();
lore.add(String.valueOf(CC.YELLOW) + "#" + rank + " " + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(allEloMap.getOrDefault(uuid, 1000))); String color = String.valueOf(CC.YELLOW);
switch (rank) {
case 1:
color = String.valueOf(CC.GOLD);
break;
case 2:
color = String.valueOf(CC.GRAY);
break;
case 3:
color = String.valueOf(CC.DARK_GRAY);
break;
}
lore.add(color + "#" + rank + " " + CC.GREEN + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(allEloMap.getOrDefault(uuid, 1000)));
} }
} }
}); });
@ -126,19 +141,49 @@ public class LeaderboardUpdateRunnable implements Runnable {
final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection().find(Filters.eq("uuid", uuid.toString())).first(); final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection().find(Filters.eq("uuid", uuid.toString())).first();
if (playerDocument != null) { if (playerDocument != null) {
loreForKillStreaks.add(CC.GOLD + "" + integerForKillStreaks.incrementAndGet() + " " + CC.WHITE + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(allKillStreaksMap.get(uuid))); // Adicione decimalFormat aqui int rank = integerForKillStreaks.incrementAndGet();
String color = String.valueOf(CC.YELLOW);
switch (rank) {
case 1:
color = String.valueOf(CC.GOLD);
break;
case 2:
color = String.valueOf(CC.GRAY);
break;
case 3:
color = String.valueOf(CC.DARK_GRAY);
break;
}
loreForKillStreaks.add(color + "" + rank + " " + CC.GREEN + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(allKillStreaksMap.get(uuid)));
} }
} else if (integerForKillStreaks.get() >= 3 && integerForKillStreaks.get() < 10) { // quarto até o décimo lugar } else if (integerForKillStreaks.get() >= 3 && integerForKillStreaks.get() < 10) { // quarto até o décimo lugar
final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection().find(Filters.eq("uuid", uuid.toString())).first(); final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection().find(Filters.eq("uuid", uuid.toString())).first();
if (playerDocument != null) { if (playerDocument != null) {
loreForKillStreaks.add(CC.YELLOW + "#" + integerForKillStreaks.incrementAndGet() + " " + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(allKillStreaksMap.get(uuid))); // Adicione decimalFormat aqui int rank = integerForKillStreaks.incrementAndGet();
String color = String.valueOf(CC.YELLOW);
switch (rank) {
case 1:
color = String.valueOf(CC.GOLD);
break;
case 2:
color = String.valueOf(CC.GRAY);
break;
case 3:
color = String.valueOf(CC.DARK_GRAY);
break;
}
loreForKillStreaks.add(color + "#" + rank + " " + CC.GREEN + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(allKillStreaksMap.get(uuid)));
} }
} }
}); });
if (loreForKillStreaks.size() >= 3) { if (loreForKillStreaks.size() >= 3) {
IntStream.range(0, 3).forEach(i -> loreForKillStreaksShort.add(" " + loreForKillStreaks.get(i).replace("", ""))); // Remove from loreForKillStreaksShort IntStream.range(0, 3).forEach(i -> loreForKillStreaksShort.add(" " + loreForKillStreaks.get(i).replace("", "#")));
} }
LeaderboardUpdateRunnable.KIT_SPECIFIC_WIN_STREAK_LORE.put(kit, loreForKillStreaks); LeaderboardUpdateRunnable.KIT_SPECIFIC_WIN_STREAK_LORE.put(kit, loreForKillStreaks);
@ -152,7 +197,7 @@ public class LeaderboardUpdateRunnable implements Runnable {
final Map<String, Integer> eloMap = CorePlugin.GSON.fromJson(document.getString("elo"), PracticeConstants.STRING_INTEGER_MAP_TYPE); final Map<String, Integer> eloMap = CorePlugin.GSON.fromJson(document.getString("elo"), PracticeConstants.STRING_INTEGER_MAP_TYPE);
if (eloMap != null) { if (eloMap != null) {
globalEloMap.put(UUID.fromString(document.getString("uuid")), document.getInteger("globalElo")); globalEloMap.put(UUID.fromString(document.getString("uuid")), eloMap.values().stream().mapToInt(i -> i).sum() / eloMap.size());
} }
}); });
@ -163,44 +208,32 @@ public class LeaderboardUpdateRunnable implements Runnable {
final AtomicInteger integer = new AtomicInteger(); final AtomicInteger integer = new AtomicInteger();
sortedUuids.forEach(uuid -> { sortedUuids.forEach(uuid -> {
if (integer.get() < 3) { // primeiro, segundo e terceiro lugar if (integer.get() < 10) { // top 10 players
final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection() final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection().find(Filters.eq("uuid", uuid.toString())).first();
.find(Filters.eq("uuid", uuid.toString())).first();
if (playerDocument != null) { if (playerDocument != null) {
final int globalElo = globalEloMap.get(uuid); int rank = integer.incrementAndGet();
final RankedDivision rankedDivision = RankedDivision.getByGlobalElo(globalElo); String color = String.valueOf(CC.YELLOW);
if (rankedDivision != null) { switch (rank) {
int rank = integer.incrementAndGet(); case 1:
String color = String.valueOf(CC.YELLOW); color = String.valueOf(CC.GOLD);
break;
lore.add(color + "" + rank + " " + playerDocument.getString("name") + CC.GRAY + " - " + case 2:
String.valueOf(CC.YELLOW) + decimalFormat.format(globalElo) + CC.GRAY + " - " + rankedDivision.getFancyName()); color = String.valueOf(CC.GRAY);
break;
case 3:
color = String.valueOf(CC.DARK_GRAY);
break;
} }
}
} else if (integer.get() >= 3 && integer.get() < 11) { // quarto até o décimo primeiro lugar
final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection()
.find(Filters.eq("uuid", uuid.toString())).first();
if (playerDocument != null) { lore.add(color + "#" + rank + " " + CC.GREEN + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(globalEloMap.getOrDefault(uuid, 1000)));
final int globalElo = globalEloMap.get(uuid);
final RankedDivision rankedDivision = RankedDivision.getByGlobalElo(globalElo);
if (rankedDivision != null) {
int rank = integer.incrementAndGet();
lore.add(String.valueOf(CC.YELLOW) + "#" + rank + " " + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(globalElo) + CC.GRAY + " - " + rankedDivision.getFancyName());
}
} }
} }
}); });
LeaderboardUpdateRunnable.GLOBAL_ELO_LEADERBOARD_LORE.clear(); LeaderboardUpdateRunnable.GLOBAL_ELO_LEADERBOARD_LORE.clear();
LeaderboardUpdateRunnable.GLOBAL_ELO_LEADERBOARD_LORE.addAll(lore); LeaderboardUpdateRunnable.GLOBAL_ELO_LEADERBOARD_LORE.addAll(lore);
}).whenComplete((unused, throwable) -> {
if (throwable != null) {
throwable.printStackTrace();
}
}); });
} }
} }