Display position in scoreboard and fix sorting for top 10
This commit is contained in:
parent
df48d5da87
commit
12e7dee374
|
|
@ -21,8 +21,13 @@ public class Leaderboard extends SubCommand {
|
|||
UUID uuid = null;
|
||||
if (commandSender instanceof Player player)
|
||||
uuid = player.getUniqueId();
|
||||
int pos = 1;
|
||||
for (PlayerScore playerScore : top10) {
|
||||
component = component.append(Component.newline()).append(MiniMessage.miniMessage().deserialize("<player>'s biggest fish was the <rarity> <fish> at <length> cm",
|
||||
component = component
|
||||
.append(Component.newline())
|
||||
.append(Component.text(pos++))
|
||||
.append(Component.text(". "))
|
||||
.append(MiniMessage.miniMessage().deserialize("<player>'s biggest fish was the <rarity> <fish> at <length> cm",
|
||||
Placeholder.component("player", playerScore.player().displayName()),
|
||||
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish())),
|
||||
Placeholder.component("rarity", playerScore.fish().getRarity().displayName()),
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class ScoreboardManager {
|
|||
}
|
||||
|
||||
public List<PlayerScore> getTop10() {
|
||||
return playerScores.values().stream().sorted(Comparator.comparingDouble(PlayerScore::biggestFish)).limit(10).collect(Collectors.toList());
|
||||
return playerScores.values().stream().sorted(Comparator.comparingDouble(PlayerScore::biggestFish).reversed()).limit(10).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void updateScoreboard(Player player, double fishLength, Fish fish) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import java.time.Instant;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class EventManager {
|
||||
|
|
@ -24,7 +25,8 @@ public class EventManager {
|
|||
private EventAutoMessages eventAutoMessages;
|
||||
private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
|
||||
private EventManager() {}
|
||||
private EventManager() {
|
||||
}
|
||||
|
||||
public static EventManager getInstance() {
|
||||
if (instance == null)
|
||||
|
|
@ -64,13 +66,18 @@ public class EventManager {
|
|||
}
|
||||
running = false;
|
||||
AtomicReference<Component> message = new AtomicReference<>(MiniMessage.miniMessage().deserialize(Messages.TIMER.EVENT_END));
|
||||
AtomicInteger pos = new AtomicInteger(1);
|
||||
ScoreboardManager.getInstance().getTop10().stream().limit(3).forEachOrdered(playerScore ->
|
||||
message.set(message.get().append(Component.newline()).append(MiniMessage.miniMessage().deserialize(Messages.TIMER.WINNER_FORMAT, TagResolver.resolver(
|
||||
Placeholder.component("player", playerScore.player().displayName()),
|
||||
Placeholder.component("rarity", playerScore.fish().getRarity().displayName()),
|
||||
Placeholder.component("fish", playerScore.fish().fishName()),
|
||||
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish()))
|
||||
)))));
|
||||
message.set(message.get()
|
||||
.append(Component.newline())
|
||||
.append(Component.text(pos.getAndIncrement()))
|
||||
.append(Component.text(". "))
|
||||
.append(MiniMessage.miniMessage().deserialize(Messages.TIMER.WINNER_FORMAT, TagResolver.resolver(
|
||||
Placeholder.component("player", playerScore.player().displayName()),
|
||||
Placeholder.component("rarity", playerScore.fish().getRarity().displayName()),
|
||||
Placeholder.component("fish", playerScore.fish().fishName()),
|
||||
Placeholder.parsed("length", String.format("%.2f", playerScore.biggestFish()))
|
||||
)))));
|
||||
server.sendMessage(message.get());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user