|
38 | 38 | import net.minecraft.util.ActionResult; |
39 | 39 | import net.minecraft.util.Formatting; |
40 | 40 | import net.minecraft.util.Hand; |
| 41 | +import net.minecraft.util.Pair; |
41 | 42 | import net.minecraft.util.hit.BlockHitResult; |
42 | 43 | import net.minecraft.util.math.BlockPos; |
43 | 44 | import net.minecraft.util.math.Direction; |
|
62 | 63 | import xyz.nucleoid.stimuli.event.player.PlayerDamageEvent; |
63 | 64 | import xyz.nucleoid.stimuli.event.player.PlayerDeathEvent; |
64 | 65 |
|
65 | | -import java.util.ArrayList; |
66 | | -import java.util.HashMap; |
67 | | -import java.util.List; |
68 | | -import java.util.UUID; |
| 66 | +import java.util.*; |
69 | 67 |
|
70 | 68 | public class BRActive { |
71 | 69 | private final ServerWorld world; |
@@ -918,25 +916,41 @@ public void startElimination() { |
918 | 916 | this.perfectRoundsInARow++; |
919 | 917 | } |
920 | 918 |
|
| 919 | + List<Pair<ServerPlayerEntity, Integer>> scores = new ArrayList<>(); |
| 920 | + |
921 | 921 | for (var player : this.space.getPlayers()) { |
922 | 922 | var data = this.playerDataMap.get(player.getUuid()); |
923 | 923 | if (data == null || data.eliminated) { |
924 | 924 | continue; |
925 | 925 | } |
926 | 926 |
|
927 | | - if (data.score == this.maxScore) { |
928 | | - TextUtil.sendSubtitle(player, Text.translatable("title.build_rush.perfect").setStyle(Style.EMPTY.withColor(TextUtil.LEGENDARY).withBold(true)), 0, 3 * 20, 10); |
929 | | - player.playSoundToPlayer(SoundEvents.ENTITY_PLAYER_LEVELUP, SoundCategory.PLAYERS, 1.0f, 1.0f); |
930 | | - } else { |
931 | | - float scorePercentage = data.score / (float) this.maxScore; |
932 | | - String scoreAsPercent = String.format("%.2f", scorePercentage * 100).replaceAll("0*$", "").replaceAll("[,.]$", ""); |
933 | | - var scoreText = Text.translatable("generic.build_rush.score", scoreAsPercent) |
934 | | - .setStyle(Style.EMPTY.withColor(TextUtil.lerpScoreColor(scorePercentage)).withBold(true)); |
| 927 | + scores.add(new Pair<>(player, data.score)); |
| 928 | + } |
| 929 | + scores.sort(Comparator.comparing(Pair::getRight)); |
935 | 930 |
|
936 | | - player.sendMessage(TextUtil.translatable(TextUtil.DASH, TextUtil.NEUTRAL, "text.build_rush.score", scoreText), false); |
937 | | - TextUtil.sendSubtitle(player, scoreText, 0, 2 * 20, 5); |
938 | | - player.playSoundToPlayer(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 1.0f, 1.0f); |
| 931 | + this.world.getServer().getPlayerManager().broadcast(Text.translatable("generic.build_rush.round_stats.title").setStyle(Style.EMPTY.withColor(TextUtil.LEGENDARY).withBold(true)), false); |
| 932 | + int rank = 0; |
| 933 | + int previousScore = Integer.MAX_VALUE; |
| 934 | + for (int i = scores.size() - 1; i >= 0; i--) { |
| 935 | + Pair<ServerPlayerEntity, Integer> pair = scores.get(i); |
| 936 | + if (pair.getRight() < previousScore) { |
| 937 | + rank++; |
939 | 938 | } |
| 939 | + float scorePercentage = pair.getRight() / (float) this.maxScore; |
| 940 | + String scoreAsPercent = String.format("%.2f", scorePercentage * 100).replaceAll("0*$", "").replaceAll("[,.]$", ""); |
| 941 | + |
| 942 | + var scoreText = Text.translatable("generic.build_rush.score", scoreAsPercent) |
| 943 | + .setStyle(Style.EMPTY.withColor(TextUtil.lerpScoreColor(scorePercentage)).withBold(true)); |
| 944 | + |
| 945 | + int color = switch (rank) { |
| 946 | + case 1 -> TextUtil.GOLD; |
| 947 | + case 2 -> TextUtil.SILVER; |
| 948 | + case 3 -> TextUtil.BRONZE; |
| 949 | + default -> TextUtil.NEUTRAL; |
| 950 | + }; |
| 951 | + |
| 952 | + this.world.getServer().getPlayerManager().broadcast(Text.translatable("generic.build_rush.round_stats.entry", rank, pair.getLeft().getDisplayName(), scoreText).setStyle(Style.EMPTY.withColor(color)), false); |
| 953 | + previousScore = pair.getRight(); |
940 | 954 | } |
941 | 955 |
|
942 | 956 | if (this.loserUuid == null) { |
|
0 commit comments