Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit ac70294

Browse files
committed
(StatsOverlay) add options for each value column, add level column
1 parent 9fe5602 commit ac70294

File tree

5 files changed

+108
-64
lines changed

5 files changed

+108
-64
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup Gradle
1818
uses: gradle/actions/setup-gradle@v4
1919
with:
20-
cache-read-only: ${{ github.ref != 'refs/heads/multiversion' }}
20+
cache-read-only: ${{ github.ref != 'refs/heads/multiversion' || github.ref != 'refs/heads/dev' }}
2121

2222
- name: Build
2323
run: ./gradlew build collectBuilds

common/src/main/java/io/github/axolotlclient/modules/hypixel/StatsMod.java

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Arrays;
2626
import java.util.List;
2727
import java.util.Map;
28-
import java.util.stream.IntStream;
2928

3029
import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory;
3130
import io.github.axolotlclient.api.API;
@@ -35,7 +34,7 @@
3534
import io.github.axolotlclient.bridge.commands.PlayerArgument;
3635
import io.github.axolotlclient.bridge.events.Events;
3736
import io.github.axolotlclient.bridge.util.AxoText;
38-
import io.github.axolotlclient.bridge.util.AxoText.Color;
37+
import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPrestige;
3938
import lombok.Getter;
4039

4140
import static io.github.axolotlclient.bridge.commands.Commands.argument;
@@ -61,27 +60,6 @@ private static AxoText.Mutable statText(String key, Object... args) {
6160
}).toArray());
6261
}
6362

64-
private static final List<Color> RAINBOW = List.of(RED, GOLD, YELLOW, GREEN, AQUA, LIGHT_PURPLE, DARK_PURPLE);
65-
66-
private static AxoText formatBedwarsPrestige(int level) {
67-
String levelString = level + "☆";
68-
return switch (level / 100) {
69-
case 0 -> literal(levelString).br$color(GRAY);
70-
case 1 -> literal(levelString).br$color(WHITE);
71-
case 2 -> literal(levelString).br$color(GOLD);
72-
case 3 -> literal(levelString).br$color(AQUA);
73-
case 4 -> literal(levelString).br$color(DARK_GREEN);
74-
case 5 -> literal(levelString).br$color(DARK_AQUA);
75-
case 6 -> literal(levelString).br$color(DARK_RED);
76-
case 7 -> literal(levelString).br$color(LIGHT_PURPLE);
77-
case 8 -> literal(levelString).br$color(BLUE);
78-
case 9 -> literal(levelString).br$color(DARK_PURPLE);
79-
default -> IntStream.range(0, levelString.length())
80-
.mapToObj(x -> literal(levelString.substring(x, x + 1)).br$color(RAINBOW.get(x % RAINBOW.size())))
81-
.reduce(literal(""), AxoText.Mutable::br$append);
82-
};
83-
}
84-
8563
private static AxoText buildBedwarsGameMode(String key, PlayerData.Bedwars.BedwarsGameData data) {
8664
final var text = statText(key);
8765

@@ -186,7 +164,7 @@ private static AxoText buildDuelsGameModesLine(PlayerData.DuelsData data) {
186164
final var allStats = data.bedwars().all();
187165
List.of(
188166
translatable("playerstats.bedwars.title", data.formattedName(),
189-
formatBedwarsPrestige(data.bedwars().level())),
167+
BedwarsPrestige.format(data.bedwars().level())),
190168
statText("playerstats.bedwars.kdr", allStats.kills(), allStats.deaths(), allStats.kdr()),
191169
statText("playerstats.bedwars.fkdr", allStats.finalKills(), allStats.finalDeaths(), allStats.fkdr()),
192170
statText("playerstats.bedwars.beds", allStats.bedsBroken(), allStats.bedsLost(), allStats.bblr()),
@@ -204,12 +182,11 @@ private static AxoText buildDuelsGameModesLine(PlayerData.DuelsData data) {
204182
buildSkywarsGameModesLine(data.skywars())
205183
).forEach(c::br$sendFeedback);
206184
}),
207-
new Entry("duels", (c, uuid, username, data) -> {
185+
new Entry("duels", (c, uuid, username, data) ->
208186
List.of(
209-
translatable("playerstats.duels.title", data.formattedName()),
210-
buildDuelsGameModesLine(data.duels())
211-
).forEach(c::br$sendFeedback);
212-
})
187+
translatable("playerstats.duels.title", data.formattedName()),
188+
buildDuelsGameModesLine(data.duels())
189+
).forEach(c::br$sendFeedback))
213190
);
214191

215192
@Getter
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright © 2025 moehreag <moehreag@gmail.com> & Contributors
3+
*
4+
* This file is part of AxolotlClient.
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*
20+
* For more information, see the LICENSE file.
21+
*/
22+
23+
package io.github.axolotlclient.modules.hypixel.bedwars;
24+
25+
import java.util.List;
26+
import java.util.stream.IntStream;
27+
28+
import io.github.axolotlclient.bridge.util.AxoText;
29+
30+
import static io.github.axolotlclient.bridge.util.AxoText.Color.*;
31+
import static io.github.axolotlclient.bridge.util.AxoText.literal;
32+
33+
public final class BedwarsPrestige {
34+
private static final List<AxoText.Color> RAINBOW = List.of(RED, GOLD, YELLOW, GREEN, AQUA, LIGHT_PURPLE, DARK_PURPLE);
35+
36+
public static AxoText format(int level) {
37+
String levelString = level + "☆";
38+
return switch (level / 100) {
39+
case 0 -> literal(levelString).br$color(GRAY);
40+
case 1 -> literal(levelString).br$color(WHITE);
41+
case 2 -> literal(levelString).br$color(GOLD);
42+
case 3 -> literal(levelString).br$color(AQUA);
43+
case 4 -> literal(levelString).br$color(DARK_GREEN);
44+
case 5 -> literal(levelString).br$color(DARK_AQUA);
45+
case 6 -> literal(levelString).br$color(DARK_RED);
46+
case 7 -> literal(levelString).br$color(LIGHT_PURPLE);
47+
case 8 -> literal(levelString).br$color(BLUE);
48+
case 9 -> literal(levelString).br$color(DARK_PURPLE);
49+
default -> IntStream.range(0, levelString.length())
50+
.mapToObj(x -> literal(levelString.substring(x, x + 1)).br$color(RAINBOW.get(x % RAINBOW.size())))
51+
.reduce(literal(""), AxoText.Mutable::br$append);
52+
};
53+
}
54+
}

common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/StatsOverlay.java

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
import java.util.HashMap;
2727
import java.util.List;
2828
import java.util.Map;
29+
import java.util.function.Predicate;
2930

3031
import io.github.axolotlclient.AxolotlClientConfig.api.options.Option;
32+
import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption;
3133
import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption;
3234
import io.github.axolotlclient.AxolotlClientConfig.impl.options.IntegerOption;
3335
import io.github.axolotlclient.api.API;
@@ -44,6 +46,7 @@
4446
import io.github.axolotlclient.modules.hud.gui.layout.AnchorPoint;
4547
import io.github.axolotlclient.modules.hud.util.DefaultOptions;
4648
import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer;
49+
import io.github.axolotlclient.modules.hypixel.PlayerData;
4750
import io.github.axolotlclient.modules.hypixel.PlayerData.Bedwars.CombinedGameData;
4851
import lombok.AccessLevel;
4952
import lombok.AllArgsConstructor;
@@ -56,29 +59,30 @@ public class StatsOverlay extends BoxHudEntry implements DynamicallyPositionable
5659
@FunctionalInterface
5760
private interface EntryRenderer {
5861

59-
AxoText render(BedwarsTeam team, String name, CombinedGameData data, int winstreak);
62+
AxoText render(BedwarsTeam team, String name, PlayerData.Bedwars data, int winstreak);
6063
}
6164

62-
private record Entry(boolean acceptNull, String name, EntryRenderer compRenderer) {
65+
private record Entry(boolean acceptNull, String name, Predicate<StatsOverlay> condition, EntryRenderer compRenderer) {
6366

6467
}
6568

6669
private static final List<Entry> RENDER_ENTRIES = List.of(
67-
new Entry(true, "bedwars.stats_overlay.header.player", (t, n, bw, ws) -> AxoText.literal(t.getColorSection() + n)),
68-
new Entry(false, "bedwars.stats_overlay.header.fkdr", (t, n, bw, ws) -> AxoText.literal("%.2f (%s/%s)".formatted(bw.fkdr(), bw.finalKills(), bw.finalDeaths())).br$color(AxoText.Color.GOLD)),
69-
new Entry(false, "bedwars.stats_overlay.header.kdr", (t, n, bw, ws) -> AxoText.literal("%.2f (%s/%s)".formatted(bw.kdr(), bw.kills(), bw.deaths())).br$color(AxoText.Color.GOLD)),
70-
new Entry(false, "bedwars.stats_overlay.header.wlr", (t, n, bw, ws) -> AxoText.literal("%.2f (%s/%s)".formatted(bw.wlr(), bw.wins(), bw.losses())).br$color(AxoText.Color.GOLD)),
71-
new Entry(false, "bedwars.stats_overlay.header.ws", (t, n, bw, ws) -> AxoText.literal(ws).br$color(AxoText.Color.GOLD))
70+
new Entry(true, "bedwars.stats_overlay.header.player", hud -> true, (t, n, bw, ws) -> AxoText.literal(t.getColorSection() + n)),
71+
new Entry(false, "bedwars.stats.overlay.header.level", o -> o.columnLevel.get(), (t, n, bw, ws) -> BedwarsPrestige.format(bw.level())),
72+
new Entry(false, "bedwars.stats_overlay.header.fkdr", o -> o.columnFkdr.get(), (t, n, bw, ws) -> AxoText.literal("%.2f (%s/%s)".formatted(bw.core().fkdr(), bw.core().finalKills(), bw.core().finalDeaths())).br$color(AxoText.Color.GOLD)),
73+
new Entry(false, "bedwars.stats_overlay.header.kdr", o -> o.columnKdr.get(), (t, n, bw, ws) -> AxoText.literal("%.2f (%s/%s)".formatted(bw.core().kdr(), bw.core().kills(), bw.core().deaths())).br$color(AxoText.Color.GOLD)),
74+
new Entry(false, "bedwars.stats_overlay.header.wlr", o -> o.columnWlr.get(), (t, n, bw, ws) -> AxoText.literal("%.2f (%s/%s)".formatted(bw.core().wlr(), bw.core().wins(), bw.core().losses())).br$color(AxoText.Color.GOLD)),
75+
new Entry(false, "bedwars.stats_overlay.header.ws", o -> o.columnWs.get(), (t, n, bw, ws) -> AxoText.literal(ws).br$color(AxoText.Color.GOLD))
7276
);
7377

7478
private class RenderHelper {
7579

76-
private final Map<String, IntObjectPair<CombinedGameData>> stats;
80+
private final Map<String, PlayerData.Bedwars> stats;
7781
private final Map<BedwarsTeam, List<String>> playersByTeam;
7882
private int xCursor = getPos().x + padding.get();
7983
private int yFinal = 0;
8084

81-
private RenderHelper(Map<String, IntObjectPair<CombinedGameData>> stats, Map<BedwarsTeam, List<String>> playersByTeam) {
85+
private RenderHelper(Map<String, PlayerData.Bedwars> stats, Map<BedwarsTeam, List<String>> playersByTeam) {
8286
this.stats = stats;
8387
this.playersByTeam = playersByTeam;
8488
}
@@ -100,7 +104,7 @@ private void renderColumn(AxoRenderContext ctx, Entry renderEntry) {
100104
final var data = stats.get(playerName);
101105
final var text = data == null ?
102106
(renderEntry.acceptNull ? renderEntry.compRenderer.render(team, playerName, null, 0) : AxoText.literal("?").br$color(AxoText.Color.RED)) :
103-
renderEntry.compRenderer.render(team, playerName, data.right(), data.left());
107+
renderEntry.compRenderer.render(team, playerName, data, data.all().winstreak());
104108

105109
newXCursor = Math.max(newXCursor, ctx.br$drawString(text, xCursor, currY, 0xffffffff, shadow));
106110
currY += dy;
@@ -113,7 +117,9 @@ private void renderColumn(AxoRenderContext ctx, Entry renderEntry) {
113117

114118
private void render(AxoRenderContext ctx) {
115119
for (final var renderEntry : RENDER_ENTRIES) {
116-
renderColumn(ctx, renderEntry);
120+
if (renderEntry.condition().test(StatsOverlay.this)) {
121+
renderColumn(ctx, renderEntry);
122+
}
117123
}
118124

119125
// don't multiply the padding by two, since it's already accounted for by the cursors
@@ -129,7 +135,6 @@ private void render(AxoRenderContext ctx) {
129135
onBoundsUpdate();
130136
}
131137
}
132-
133138
}
134139

135140
private static final Map<BedwarsTeam, List<String>> SAMPLE_PLAYERS = new EnumMap<>(BedwarsTeam.class);
@@ -139,22 +144,34 @@ private void render(AxoRenderContext ctx) {
139144
SAMPLE_PLAYERS.put(BedwarsTeam.GREEN, List.of("herobrine", "steve"));
140145
}
141146

142-
private static final Map<String, IntObjectPair<CombinedGameData>> SAMPLE_STATS = Map.of(
143-
"FloweyTF", IntObjectPair.of(3, new CombinedGameData(4234, 5634, 500, 300, 1469, 336, 230, 123)),
144-
"Adaklys", IntObjectPair.of(3, new CombinedGameData(1984, 2048, 300, 500, 834, 737, 123, 273)),
145-
"steve", IntObjectPair.of(3, new CombinedGameData(10, 1, 10, 1, 10, 1, 10, 1))
147+
private static final Map<String, PlayerData.Bedwars> SAMPLE_STATS = Map.of(
148+
"FloweyTF", createFake(525, 3, new CombinedGameData(4234, 5634, 500, 300, 1469, 336, 230, 123)),
149+
"Adaklys", createFake(179, 3, new CombinedGameData(1984, 2048, 300, 500, 834, 737, 123, 273)),
150+
"steve", createFake(5, 3, new CombinedGameData(10, 1, 10, 1, 10, 1, 10, 1))
146151
);
147152

153+
private static PlayerData.Bedwars createFake(int level, int winstreak, CombinedGameData data) {
154+
return new PlayerData.Bedwars(level,
155+
new PlayerData.Bedwars.GameData(0, 0, 0, 0, winstreak, 0, 0, 0, 0),
156+
data, null, null, null, null, null, null, null, null, null,
157+
null, null, null, null, null, null, null, null);
158+
}
159+
148160
public final static AxoIdentifier ID = AxoIdentifier.of("axolotlclient", "bedwars_stats_overlay");
149161

150162
protected final EnumOption<AnchorPoint> anchor = DefaultOptions.getAnchorPoint();
151163

152164
protected final IntegerOption padding = new IntegerOption("hud.padding", 3, 1, 10);
153165
protected final IntegerOption columnMargin = new IntegerOption("hud.column_margin", 3, 0, 10);
154166
protected final IntegerOption rowMargin = new IntegerOption("hud.row_margin", 1, 0, 10);
167+
private final BooleanOption columnLevel = new BooleanOption("bedwars.stats_overlay.column.level", false);
168+
private final BooleanOption columnFkdr = new BooleanOption("bedwars.stats_overlay.column.fkdr", true);
169+
private final BooleanOption columnKdr = new BooleanOption("bedwars.stats_overlay.column.kdr", true);
170+
private final BooleanOption columnWlr = new BooleanOption("bedwars.stats_overlay.column.wlr", true);
171+
private final BooleanOption columnWs = new BooleanOption("bedwars.stats_overlay.column.ws", true);
155172
private final BedwarsMod mod;
156173

157-
private Map<String, IntObjectPair<CombinedGameData>> stats = new HashMap<>();
174+
private Map<String, PlayerData.Bedwars> stats = new HashMap<>();
158175
private final Map<BedwarsTeam, List<String>> playersByTeam = new EnumMap<>(BedwarsTeam.class);
159176
private final AxoKeybinding toggle = AxoKeybinding.create(AxoKeys.KEY_UNKNOWN, "bedwars.toggle_stats_overlay", "category.axolotlclient");
160177
private boolean shouldRender = false;
@@ -196,9 +213,7 @@ void onStart() {
196213
return;
197214
}
198215

199-
capturedStats.put(entry.br$getName(), IntObjectPair.of(
200-
playerData.get().bedwars().all().winstreak(),
201-
playerData.get().bedwars().core())
216+
capturedStats.put(entry.br$getName(), playerData.get().bedwars()
202217
);
203218
}, client));
204219
}));
@@ -260,19 +275,11 @@ public List<Option<?>> getConfigurationOptions() {
260275
opts.add(padding);
261276
opts.add(columnMargin);
262277
opts.add(rowMargin);
278+
opts.add(columnLevel);
279+
opts.add(columnFkdr);
280+
opts.add(columnKdr);
281+
opts.add(columnWlr);
282+
opts.add(columnWs);
263283
return opts;
264284
}
265-
266-
@Accessors(fluent = true)
267-
@Getter
268-
@Setter
269-
@AllArgsConstructor(access = AccessLevel.PRIVATE)
270-
private static class IntObjectPair<T> {
271-
private int left;
272-
private T right;
273-
274-
static <A> IntObjectPair<A> of(int left, A right) {
275-
return new IntObjectPair<>(left, right);
276-
}
277-
}
278285
}

common/src/main/resources/assets/axolotlclient/lang/en_us.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,5 +800,11 @@
800800
"hud.padding": "Padding",
801801
"hud.column_margin": "Column Margin",
802802
"hud.row_margin": "Row Margin",
803-
"bedwars.toggle_stats_overlay": "Toggle Stats Overlay"
803+
"bedwars.toggle_stats_overlay": "Toggle Stats Overlay",
804+
"bedwars.stats.overlay.header.level": "Level",
805+
"bedwars.stats_overlay.column.level": "Show Level",
806+
"bedwars.stats_overlay.column.fkdr": "Show Final Kill/Death Ratios",
807+
"bedwars.stats_overlay.column.kdr": "Show Kill/Death Ratios",
808+
"bedwars.stats_overlay.column.wlr": "Show Win/Loose Ratios",
809+
"bedwars.stats_overlay.column.ws": "Show Winstreaks"
804810
}

0 commit comments

Comments
 (0)