This commit is contained in:
nearfe 2024-06-19 14:25:02 -03:00
parent 85bbd29a89
commit 8482451eef
3 changed files with 56 additions and 12 deletions

View File

@ -110,8 +110,7 @@
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.11</version>
<scope>compile</scope>
<version>3.12.7</version>
</dependency>
<dependency>
<groupId>net.citizne</groupId>
@ -120,6 +119,12 @@
<scope>system</scope>
<systemPath>${basedir}/lib/Citizens-2.0.29-b2490.jar</systemPath>
</dependency>
<dependency>
<groupId>com.jonahseguin</groupId>
<artifactId>drink</artifactId>
<version>1.0.5</version> <!-- At time of writing, 1.0.5 is latest version. See the pom.xml for the latest version -->
<scope>compile</scope> <!-- Change scope to 'provided' if you are running drink as a plugin rather than shading it -->
</dependency>
<dependency>
<groupId>net.23</groupId>
<artifactId>qwoiufjwsodnmwso</artifactId>

View File

@ -40,6 +40,7 @@ import land.battle.practice.shop.item.statreset.NameColorItem;
import land.battle.practice.shop.item.statreset.StatisticResetItem;
import land.battle.practice.util.Animation;
import land.battle.practice.util.CC;
import land.battle.practice.util.ClassUtil;
import land.battle.practice.util.timer.TimerManager;
import land.battle.practice.util.timer.impl.EnderpearlTimer;
import land.battle.practice.vote.VoteManager;
@ -51,7 +52,9 @@ import me.lucko.helper.plugin.ExtendedJavaPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
@ -291,6 +294,7 @@ public class Practice extends ExtendedJavaPlugin {
).forEach(listener -> this.getServer().getPluginManager().registerEvents(listener, this));
}
public CompletableFuture<Boolean> fetchNitroReward(Player player) {
return CompletableFuture.supplyAsync(() -> {
final AtomicBoolean atomicBoolean = new AtomicBoolean();

View File

@ -16,6 +16,7 @@ import land.battle.practice.util.CC;
import land.battle.practice.util.division.RankedDivision;
import org.bson.Document;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
@ -27,11 +28,9 @@ import java.util.stream.IntStream;
* @author BattleLand Team
* @since 7/29/2021
*/
public class LeaderboardUpdateRunnable implements Runnable {
public static final List<String> GLOBAL_ELO_LEADERBOARD_LORE = new ArrayList<>();
public static final Map<Kit, List<String>> KIT_SPECIFIC_LEADERBOARD_LORE = new HashMap<>();
public static final Map<Kit, List<String>> KIT_SPECIFIC_LEADERBOARD_LORE_SHORT = new HashMap<>();
public static final Map<Kit, List<String>> KIT_SPECIFIC_WIN_STREAK_LORE = new HashMap<>();
@ -39,6 +38,8 @@ public class LeaderboardUpdateRunnable implements Runnable {
@Override
public void run() {
DecimalFormat decimalFormat = new DecimalFormat("#,###");
CompletableFuture.runAsync(() -> {
Practice.getInstance().getKitManager().getKits().stream().filter(Kit::isRanked).forEach(kit -> {
final Map<UUID, Integer> allEloMap = new HashMap<>();
@ -64,7 +65,6 @@ public class LeaderboardUpdateRunnable implements Runnable {
}
allKillStreaksMap.put(playerUuid, value);
}
});
final List<UUID> sortedUuids = new HashSet<>(allEloMap.keySet()).stream()
@ -80,7 +80,26 @@ public class LeaderboardUpdateRunnable implements Runnable {
final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection().find(Filters.eq("uuid", uuid.toString())).first();
if (playerDocument != null) {
lore.add(CC.GOLD + "#" + integer.incrementAndGet() + " " + CC.WHITE + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + allEloMap.getOrDefault(uuid, 1000));
int rank = integer.incrementAndGet();
String color = String.valueOf(CC.YELLOW);
String star = "";
switch (rank) {
case 1:
color = String.valueOf(CC.GOLD);
star = "";
break;
case 2:
color = String.valueOf(CC.GRAY);
star = "";
break;
case 3:
color = String.valueOf(CC.DARK_GRAY);
star = "";
break;
}
lore.add(color + "#" + rank + " " + playerDocument.getString("name") + star + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(allEloMap.getOrDefault(uuid, 1000)));
}
}
});
@ -90,7 +109,6 @@ public class LeaderboardUpdateRunnable implements Runnable {
}
LeaderboardUpdateRunnable.KIT_SPECIFIC_LEADERBOARD_LORE_SHORT.put(kit, loreEloShort);
LeaderboardUpdateRunnable.KIT_SPECIFIC_LEADERBOARD_LORE.put(kit, lore);
final List<String> loreForKillStreaks = new ArrayList<>();
@ -107,15 +125,13 @@ public class LeaderboardUpdateRunnable implements Runnable {
final Document playerDocument = CorePlugin.getInstance().getCoreDatabase().getPlayerCollection().find(Filters.eq("uuid", uuid.toString())).first();
if (playerDocument != null) {
loreForKillStreaks.add(CC.GOLD + "#" + integerForKillStreaks.incrementAndGet() + " " + CC.WHITE + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + allKillStreaksMap.get(uuid));
loreForKillStreaks.add(CC.GOLD + "#" + integerForKillStreaks.incrementAndGet() + " " + CC.WHITE + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(allKillStreaksMap.get(uuid))); // Adicione decimalFormat aqui
}
}
});
if (loreForKillStreaks.size() >= 3) {
IntStream.range(0, 3).forEach(i -> {
loreForKillStreaksShort.add(" " + loreForKillStreaks.get(i));
});
IntStream.range(0, 3).forEach(i -> loreForKillStreaksShort.add(" " + loreForKillStreaks.get(i)));
}
LeaderboardUpdateRunnable.KIT_SPECIFIC_WIN_STREAK_LORE.put(kit, loreForKillStreaks);
@ -149,7 +165,26 @@ public class LeaderboardUpdateRunnable implements Runnable {
final RankedDivision rankedDivision = RankedDivision.getByGlobalElo(globalElo);
if (rankedDivision != null) {
lore.add(CC.GOLD + "#" + integer.incrementAndGet() + " " + CC.WHITE + playerDocument.getString("name") + CC.GRAY + " - " + CC.YELLOW + globalElo + CC.GRAY + " - " + rankedDivision.getFancyName());
int rank = integer.incrementAndGet();
String color = String.valueOf(CC.YELLOW);
String star = "";
switch (rank) {
case 1:
color = String.valueOf(CC.GOLD);
star = "";
break;
case 2:
color = String.valueOf(CC.WHITE);
star = "";
break;
case 3:
color = String.valueOf(CC.BLACK);
star = "";
break;
}
lore.add(color + "#" + rank + " " + playerDocument.getString("name") + star + CC.GRAY + " - " + CC.YELLOW + decimalFormat.format(globalElo) + CC.GRAY + " - " + rankedDivision.getFancyName()); // Adicione decimalFormat aqui
}
}
}