From 118ad0516c5045da9622f3da308a5aa7acbbc25d Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Sat, 28 Jan 2023 19:17:07 -0700 Subject: [PATCH 01/23] Basic bedwars stats --- .../solclient/client/mod/ModManager.java | 2 + .../impl/hud/bedwarsoverlay/BedwarsGame.java | 246 ++++++++++++++++++ .../impl/hud/bedwarsoverlay/BedwarsMod.java | 52 ++++ .../impl/hud/bedwarsoverlay/BedwarsMode.java | 21 ++ .../hud/bedwarsoverlay/BedwarsPlayer.java | 15 ++ .../impl/hud/bedwarsoverlay/BedwarsTeam.java | 37 +++ 6 files changed, 373 insertions(+) create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/ModManager.java b/wrapper/src/main/java/io/github/solclient/client/mod/ModManager.java index dc08c334..8b38fb78 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/ModManager.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/ModManager.java @@ -6,6 +6,7 @@ import java.util.*; import java.util.stream.Stream; +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMod; import org.apache.logging.log4j.*; import com.google.gson.*; @@ -99,6 +100,7 @@ public void loadStandard(Path storageFile) { // integration new CosmeticaMod(), new HypixelAdditionsMod(), + new BedwarsMod(), new QuickPlayMod(), new DiscordIntegrationMod() ); diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java new file mode 100644 index 00000000..b5ac332a --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -0,0 +1,246 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + +import io.github.solclient.client.event.impl.ReceiveChatMessageEvent; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.PlayerListEntry; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class BedwarsGame { + + private final static Pattern DISCONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) disconnected\\.$"); + private final static Pattern RECONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) reconnected\\.$"); + private final static Pattern FINAL_KILL = Pattern.compile("FINAL KILL!$"); + private final static Pattern BED_DESTROY = Pattern.compile("^BED DESTRUCTION > (\\w*?) Bed"); + private final static Pattern TEAM_ELIMINATED = Pattern.compile("^TEAM ELIMINATED > (\\w*?) Team"); + private final static Pattern[] DIED = { + Pattern.compile(formatPlaceholder("{killed} fell into the void.")), + Pattern.compile(formatPlaceholder("{killed} died.")) + }; + + private final static String[] KILLS = { + "{killed} was struck down by {player}.", + "{killed} was turned to dust by {player}.", + "{killed} was melted by {player}.", + "{killed} was turned to ash by {player}.", + "{killed} was fried by {player}'s Golem.", + "{killed} was filled full of lead by {player}.", + "{killed} met their end by {player}.", + "{killed} was killed with dynamite by {player}.", + "{killed} lost a drinking contest with {player}.", + "{killed} lost the draw to {player}'s Golem.", + "{killed} died in close combat to {player}.", + "{killed} fought to the edge with {player}.", + "{killed} fell to the great marksmanship of {player}.", + "{killed} stumbled off a ledge with help by {player}.", + "{killed} tangoed with {player}'s Golem.", + "{killed} was given the cold shoulder by {player}.", + "{killed} was hit off by a love bomb from {player}.", + "{killed} was struck with Cupid's arrow by {player}.", + "{killed} was out of the league of {player}.", + "{killed} was no match for {player}'s Golem.", + "{killed} was glazed in BBQ sauce by {player}.", + "{killed} slipped in BBQ sauce off the edge spilled by {player}.", + "{killed} was thrown chili powder at by {player}.", + "{killed} was not spicy enough for {player}.", + "{killed} was sliced up by {player}'s Golem.", + "{killed} was bitten by {player}.", + "{killed} howled into the void for {player}.", + "{killed} caught the ball thrown by {player}.", + "{killed} was distracted by a puppy placed by {player}.", + "{killed} played too rough with {player}'s Golem.", + "{killed} was wrapped into a gift by {player}.", + "{killed} hit the hard-wood floor because of {player}.", + "{killed} was put on the naughty list by {player}.", + "{killed} was pushed down a slope by {player}.", + "{killed} was turned to gingerbread by {player}'s Golem.", + "{killed} was hunted down by {player}.", + "{killed} stumbled on a trap set by {player}.", + "{killed} got skewered by {player}.", + "{killed} was thrown into a volcano by {player}.", + "{killed} was mauled by {player}'s Golem.", + "{killed} was oinked by {player}.", + "{killed} slipped into void for {player}.", + "{killed} got attacked by a carrot from {player}.", + "{killed} was distracted by a piglet from {player}.", + "{killed} was oinked by {player}'s Golem.", + "{killed} was chewed up by {player}.", + "{killed} was scared into the void by {player}.", + "{killed} stepped in a mouse trap placed by {player}.", + "{killed} was distracted by a rat dragging pizza from {player}.", + "{killed} squeaked around with {player}'s Golem.", + "{killed} was buzzed to death by {player}.", + "{killed} was bzzz'd into the void by {player}.", + "{killed} was startled by {player}.", + "{killed} was stung off the edge by {player}.", + "{killed} was bee'd by {player}'s Golem.", + "{killed} was trampled by {player}.", + "{killed} was back kicked into the void by {player}.", + "{killed} was impaled from a distance by {player}.", + "{killed} was headbutted off a cliff by {player}.", + "{killed} was trampled by {player}'s Golem.", + "{killed} be sent to Davy Jones' locker by {player}.", + "{killed} be cannonballed to death by {player}.", + "{killed} be shot and killed by {player}.", + "{killed} be killed with magic by {player}.", + "{killed} be killed with metal by {player}'s Golem.", + "{killed} got rekt by {player}.", + "{killed} took the L to {player}.", + "{killed} got smacked by {player}.", + "{killed} got roasted by {player}.", + "{killed} got bamboozled by {player}'s Golem.", + "{killed} was locked outside during a snow storm by {player}.", + "{killed} was pushed into a snowbank by {player}.", + "{killed} was hit with a snowball from {player}.", + "{killed} was shoved down an icy slope by {player}.", + "{killed} got snowed in by {player}'s Golem.", + "{killed} was painted pretty by {player}.", + "{killed} was deviled into the void by {player}.", + "{killed} slipped into a pan placed by {player}.", + "{killed} was flipped off the edge by {player}.", + "{killed} was made sunny side up by {player}'s Golem.", + "{killed} was wrapped up by {player}.", + "{killed} was tied into a bow by {player}.", + "{killed} was glued up by {player}.", + "{killed} tripped over a present placed by {player}.", + "{killed} was taped together by {player}'s Golem.", + "{killed} was stomped by {player}.", + "{killed} was {player}'s final #{number}.", + "{killed} was thrown down a pit by {player}.", + "{killed} was shot by {player}.", + "{killed} was thrown to the ground by {player}.", + "{killed} was outclassed by {player}'s Golem.", + "{killed} was spooked by {player}.", + "{killed} was spooked off the map by {player}.", + "{killed} was remotely spooked by {player}.", + "{killed} was totally spooked by {player}.", + "{killed} was spooked by {player}'s Golem.", + "{killed} was tragically backstabbed by {player}.", + "{killed} was heartlessly let go by {player}.", + "{killed}'s heart was pierced by {player}.", + "{killed} was delivered into nothingness by {player}.", + "{killed} was dismembered by {player}'s Golem.", + "{killed} was crushed by {player}.", + "{killed} was {player}'s final #5,794.", + "{killed} was dominated by {player}.", + "{killed} was assassinated by {player}.", + "{killed} was thrown off their high horse by {player}.", + "{killed} was degraded by {player}'s Golem.", + "{killed} was whacked with a party balloon by {player}.", + "{killed} was popped into the void by {player}.", + "{killed} was shot with a roman candle by {player}.", + "{killed} was launched like a firework by {player}.", + "{killed} was lit up by {player}'s Golem.", + "{killed} was crushed into moon dust by {player}.", + "{killed} was sent the wrong way by {player}.", + "{killed} was hit by an asteroid from {player}.", + "{killed} was blasted to the moon by {player}.", + "{killed} was blown up by {player}'s Golem.", + "{killed} was smothered in holiday cheer by {player}.", + "{killed} was banished into the ether by {player}'s holiday spirit.", + "{killed} was sniped by a missile of festivity by {player}.", + "{killed} was pushed by {player}'s holiday spirit.", + "{killed} was sung holiday tunes to by {player}'s Golem.", + "{killed} was ripped to shreds by {player}.", + "{killed} was charged by {player}.", + "{killed} was pounced on by {player}.", + "{killed} was ripped and thrown by {player}.", + "{killed} was ripped to shreds by {player}'s Golem.", + "{killed} was bested by {player}.", + "{killed} was {player}'s final #5,794.", + "{killed} was knocked into the void by {player}.", + "{killed} was shot by {player}.", + "{killed} was knocked off an edge by {player}.", + "{killed} was bested by {player}'s Golem.", + "{killed} had a small brain moment while fighting {player}.", + "{killed} was not able to block clutch against {player}.", + "{killed} got 360 no-scoped by {player}.", + "{killed} forgot how many blocks they had left while fighting {player}.", + "{killed} got absolutely destroyed by {player}'s Golem.", + "{killed} was too shy to meet {player}.", + "{killed} didn't distance themselves properly from {player}.", + "{killed} was coughed at by {player}.", + "{killed} tripped while trying to run away from {player}.", + "{killed} got too close to {player}'s Golem.", + "{killed} was yelled at by {player}.", + "{killed} was thrown off the lawn by {player}.", + "{killed} was accidentally spit on by {player}.", + "{killed} slipped on the fake teeth of {player}.", + "{killed} was chased away by {player}'s Golem.", + "{killed} was killed by {player}.", + "{killed} was knocked into the void by {player}." + }; + + private final static Pattern[] KILLS_COMPILED = new Pattern[KILLS.length]; + + private static String formatPlaceholder(String input) { + return input.replace("{killed}", "(\\b[A-Za-z0-9_§]{3,16}\\b)").replace("{player}", "(\\b[A-Za-z0-9_§]{3,16}\\b)"); + } + + static { + for (int i = 0; i < KILLS.length; i++) { + String kill = KILLS[i]; + KILLS_COMPILED[i] = Pattern.compile(formatPlaceholder(kill.replace(".", "\\."))); + } + } + + private final List players = new ArrayList<>(); + private final MinecraftClient mc; + private boolean started = false; + + + public BedwarsGame() { + mc = MinecraftClient.getInstance(); + } + + public void onStart() { + this.started = true; + players.clear(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + System.out.println(player.getProfile().getName() + " is in team " + team); + } + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + matched(DIED, rawMessage).ifPresent(m -> System.out.println(m.group(1) + " died by themselves")); + matched(KILLS_COMPILED, rawMessage).ifPresent(m -> System.out.println(m.group(1) + " was killed by " + m.group(2))); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void tick() {} + + private static Optional matched(Pattern[] pattern, String input) { + for (Pattern p : pattern) { + Optional m = matched(p, input); + if (m.isPresent()) { + return m; + } + } + return Optional.empty(); + } + + private static Optional matched(Pattern pattern, String input) { + Matcher matcher = pattern.matcher(input); + if (matcher.matches()) { + return Optional.of(matcher); + } + return Optional.empty(); + } + +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java new file mode 100644 index 00000000..7e1a903e --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -0,0 +1,52 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + +import io.github.solclient.client.event.EventHandler; +import io.github.solclient.client.event.impl.PreTickEvent; +import io.github.solclient.client.event.impl.ReceiveChatMessageEvent; +import io.github.solclient.client.mod.Mod; +import io.github.solclient.client.mod.ModCategory; + +import java.util.regex.Pattern; + +public class BedwarsMod extends Mod { + + private final static Pattern GAME_START = Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$"); + + private BedwarsGame currentGame = null; + private int targetTick = -1; + + @EventHandler + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.message.replaceAll("§.", ""); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + } else if (targetTick < 0 && GAME_START.matcher(rawMessage).matches()) { + // Give time for Hypixel to sync + targetTick = mc.inGameHud.getTicks() + 10; + } + } + + @EventHandler + public void onTick(PreTickEvent event) { + if (currentGame != null) { + currentGame.tick(); + } else { + if (targetTick > 0 && mc.inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(); + currentGame.onStart(); + } + } + } + + @Override + public String getId() { + return "bedwars"; + } + + @Override + public ModCategory getCategory() { + return ModCategory.HUD; + } + +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java new file mode 100644 index 00000000..fb7be1b0 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java @@ -0,0 +1,21 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + +import lombok.Getter; + + +public enum BedwarsMode { + SOLO(BedwarsTeam.values()), + DOUBLES(BedwarsTeam.values()), + THREES(BedwarsTeam.BLUE, BedwarsTeam.GREEN, BedwarsTeam.YELLOW, BedwarsTeam.RED), + FOURS(BedwarsTeam.BLUE, BedwarsTeam.GREEN, BedwarsTeam.YELLOW, BedwarsTeam.RED), + FOUR_V_FOUR(BedwarsTeam.BLUE, BedwarsTeam.RED) + ; + + @Getter + private final BedwarsTeam[] teams; + + BedwarsMode(BedwarsTeam... teams) { + this.teams = teams; + } + +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java new file mode 100644 index 00000000..41bec8ef --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java @@ -0,0 +1,15 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + + +import lombok.Data; +import lombok.Value; +import net.minecraft.client.network.PlayerListEntry; + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + private final PlayerListEntry entry; + private boolean alive; + +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java new file mode 100644 index 00000000..e13e562c --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java @@ -0,0 +1,37 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Optional; + + +@AllArgsConstructor +public enum BedwarsTeam { + AQUA('b', 'A'), + WHITE('f', 'W'), + PINK('d', 'P'), + GRAY('8', 'S'), + RED('c', 'R'), + BLUE('9', 'B'), + GREEN('a', 'G'), + YELLOW('e', 'Y') + ; + + @Getter + private final char code; + + @Getter + private final char prefix; + + public static Optional fromPrefix(char prefix) { + for (BedwarsTeam t : values()) { + if (t.getPrefix() == prefix) { + return Optional.of(t); + } + } + return Optional.empty(); + } + +} From 99ae6a5f60cd133f5ac3cfdf6833537fd78ce912 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Sat, 28 Jan 2023 19:18:30 -0700 Subject: [PATCH 02/23] Github actions --- .../client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java | 1 + 1 file changed, 1 insertion(+) diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index b5ac332a..261ee853 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -218,6 +218,7 @@ public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { try { matched(DIED, rawMessage).ifPresent(m -> System.out.println(m.group(1) + " died by themselves")); matched(KILLS_COMPILED, rawMessage).ifPresent(m -> System.out.println(m.group(1) + " was killed by " + m.group(2))); + matched(BED_DESTROY, rawMessage).ifPresent(m -> System.out.println(m.group(1) + " bed broke")); } catch (Exception e) { e.printStackTrace(); } From e9515f337cbd18d40e408dd1ad2ea7d8495b60f0 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Sun, 29 Jan 2023 20:54:44 -0700 Subject: [PATCH 03/23] Fix parsing --- .../impl/hud/bedwarsoverlay/BedwarsGame.java | 105 +++++++++++++++--- .../impl/hud/bedwarsoverlay/BedwarsMod.java | 4 +- .../hud/bedwarsoverlay/BedwarsPlayer.java | 10 +- .../impl/hud/bedwarsoverlay/BedwarsTeam.java | 13 +++ 4 files changed, 116 insertions(+), 16 deletions(-) diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index 261ee853..5fa52044 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -4,10 +4,13 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.text.LiteralText; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -15,12 +18,12 @@ public class BedwarsGame { private final static Pattern DISCONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) disconnected\\.$"); private final static Pattern RECONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) reconnected\\.$"); - private final static Pattern FINAL_KILL = Pattern.compile("FINAL KILL!$"); - private final static Pattern BED_DESTROY = Pattern.compile("^BED DESTRUCTION > (\\w*?) Bed"); - private final static Pattern TEAM_ELIMINATED = Pattern.compile("^TEAM ELIMINATED > (\\w*?) Team"); + private final static Pattern FINAL_KILL = Pattern.compile("FINAL KILL!"); + private final static Pattern BED_DESTROY = Pattern.compile("^\\s*?BED DESTRUCTION > (\\w+) Bed"); + private final static Pattern TEAM_ELIMINATED = Pattern.compile("^\\s*?TEAM ELIMINATED > (\\w+) Team"); private final static Pattern[] DIED = { - Pattern.compile(formatPlaceholder("{killed} fell into the void.")), - Pattern.compile(formatPlaceholder("{killed} died.")) + Pattern.compile(formatPlaceholder("^{killed} fell into the void.(?: FINAL KILL!)?\\s*?")), + Pattern.compile(formatPlaceholder("^{killed} died.(?: FINAL KILL!)?\\s*?")) }; private final static String[] KILLS = { @@ -179,13 +182,16 @@ public class BedwarsGame { private final static Pattern[] KILLS_COMPILED = new Pattern[KILLS.length]; private static String formatPlaceholder(String input) { - return input.replace("{killed}", "(\\b[A-Za-z0-9_§]{3,16}\\b)").replace("{player}", "(\\b[A-Za-z0-9_§]{3,16}\\b)"); + return input + .replace("{killed}", "(\\b[A-Za-z0-9_§]{3,16}\\b)") + .replace("{player}", "(\\b[A-Za-z0-9_§]{3,16}\\b)") + .replace("{number}", "[0-9,]+"); } static { for (int i = 0; i < KILLS.length; i++) { String kill = KILLS[i]; - KILLS_COMPILED[i] = Pattern.compile(formatPlaceholder(kill.replace(".", "\\."))); + KILLS_COMPILED[i] = Pattern.compile(formatPlaceholder("^" + kill.replace(".", "\\.") + "(?: FINAL KILL!)?\\s*?")); } } @@ -199,6 +205,7 @@ public BedwarsGame() { } public void onStart() { + debug("Game started"); this.started = true; players.clear(); for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { @@ -210,22 +217,94 @@ public void onStart() { if (team == null) { continue; } - System.out.println(player.getProfile().getName() + " is in team " + team); + players.add(new BedwarsPlayer(team, player)); + } + } + + public Optional getPlayer(String name) { + return players.stream().filter(player -> player.getName().equals(name)).findFirst(); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(new LiteralText("§b§lINFO:§8 " + message)); + } + + private void died(BedwarsPlayer player, @Nullable BedwarsPlayer killer, boolean finalDeath) { + if (killer == null) { + if (finalDeath) { + debug(player.coloredName() + " §7was final killed."); + } else { + debug(player.coloredName() + " §7was killed."); + } + } else { + if (finalDeath) { + debug(player.coloredName() + " §7was final killed by " + killer.coloredName()); + } else { + debug(player.coloredName() + " §7was killed by " + killer.coloredName()); + } } } public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { try { - matched(DIED, rawMessage).ifPresent(m -> System.out.println(m.group(1) + " died by themselves")); - matched(KILLS_COMPILED, rawMessage).ifPresent(m -> System.out.println(m.group(1) + " was killed by " + m.group(2))); - matched(BED_DESTROY, rawMessage).ifPresent(m -> System.out.println(m.group(1) + " bed broke")); + if (matched(DIED, rawMessage, m -> { + BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); + if (killed == null) { + debug("Player " + m.group(1) + " was not found"); + return; + } + died(killed, null, matched(FINAL_KILL, rawMessage).isPresent()); + })) { + return; + } + if (matched(KILLS_COMPILED, rawMessage, m -> { + BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); + BedwarsPlayer killer = getPlayer(m.group(2)).orElse(null); + if (killed == null) { + debug("Player " + m.group(1) + " was not found"); + return; + } + died(killed, killer, matched(FINAL_KILL, rawMessage).isPresent()); + })) { + return; + } + if (matched(BED_DESTROY, rawMessage, m -> debug(m.group(1) + " Team's bed was broken"))) { + return; + } + if (matched(TEAM_ELIMINATED, rawMessage, m -> debug(m.group(1) + " Team was eliminated"))) { + return; + } + if (matched(DISCONNECT, rawMessage, m -> debug(m.group(1) + " has disconnected"))) { + return; + } + if (matched(RECONNECT, rawMessage, m -> debug(m.group(1) + " has reconnected"))) { + return; + } } catch (Exception e) { - e.printStackTrace(); + debug("Error: " + e); } } public void tick() {} + private static boolean matched(Pattern pattern, String input, Consumer consumer) { + Optional matcher = matched(pattern, input); + if (!matcher.isPresent()) { + return false; + } + consumer.accept(matcher.get()); + return true; + } + + private static boolean matched(Pattern[] pattern, String input, Consumer consumer) { + Optional matcher = matched(pattern, input); + if (!matcher.isPresent()) { + return false; + } + consumer.accept(matcher.get()); + return true; + } + private static Optional matched(Pattern[] pattern, String input) { for (Pattern p : pattern) { Optional m = matched(p, input); @@ -238,7 +317,7 @@ private static Optional matched(Pattern[] pattern, String input) { private static Optional matched(Pattern pattern, String input) { Matcher matcher = pattern.matcher(input); - if (matcher.matches()) { + if (matcher.find()) { return Optional.of(matcher); } return Optional.empty(); diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java index 7e1a903e..d1642eea 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -3,12 +3,12 @@ import io.github.solclient.client.event.EventHandler; import io.github.solclient.client.event.impl.PreTickEvent; import io.github.solclient.client.event.impl.ReceiveChatMessageEvent; -import io.github.solclient.client.mod.Mod; import io.github.solclient.client.mod.ModCategory; +import io.github.solclient.client.mod.impl.SolClientMod; import java.util.regex.Pattern; -public class BedwarsMod extends Mod { +public class BedwarsMod extends SolClientMod { private final static Pattern GAME_START = Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$"); diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java index 41bec8ef..5f6b3e42 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java @@ -2,7 +2,6 @@ import lombok.Data; -import lombok.Value; import net.minecraft.client.network.PlayerListEntry; @Data @@ -11,5 +10,14 @@ public class BedwarsPlayer { private final BedwarsTeam team; private final PlayerListEntry entry; private boolean alive; + private boolean bed; + + public String getName() { + return entry.getProfile().getName(); + } + + public String coloredName() { + return team.getColorSection() + getName(); + } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java index e13e562c..274471a3 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java @@ -25,6 +25,10 @@ public enum BedwarsTeam { @Getter private final char prefix; + public String getColorSection() { + return "§" + code; + } + public static Optional fromPrefix(char prefix) { for (BedwarsTeam t : values()) { if (t.getPrefix() == prefix) { @@ -34,4 +38,13 @@ public static Optional fromPrefix(char prefix) { return Optional.empty(); } + public static Optional fromName(String name) { + for (BedwarsTeam t : values()) { + if (name.equalsIgnoreCase(t.name())) { + return Optional.of(t); + } + } + return Optional.empty(); + } + } From ab32878c88a7a24630c8d483b92acefed0279719 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Fri, 3 Feb 2023 18:42:59 -0700 Subject: [PATCH 04/23] Setting up game parsing and tablist changes --- package-lock.json | 4 +- wrapper/build.gradle | 8 + .../client/mixin/mod/MixinBedwars.java | 65 +++++++ .../solclient/client/mod/ModManager.java | 2 +- .../impl/hud/bedwarsoverlay/BedwarsGame.java | 181 +++++++++++++++--- .../impl/hud/bedwarsoverlay/BedwarsMod.java | 72 ++++++- .../hud/bedwarsoverlay/BedwarsPlayer.java | 74 ++++++- .../impl/hud/bedwarsoverlay/BedwarsTeam.java | 8 +- .../hud/bedwarsoverlay/GameLogDisplay.java | 63 ++++++ .../src/main/resources/sol-client.mixins.json | 1 + 10 files changed, 429 insertions(+), 49 deletions(-) create mode 100644 wrapper/src/main/java/io/github/solclient/client/mixin/mod/MixinBedwars.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java diff --git a/package-lock.json b/package-lock.json index b5ddef96..0e4da750 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "Sol Client", - "version": "1.8.9", + "version": "1.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "Sol Client", - "version": "1.8.9", + "version": "1.9.0", "license": "GPL-3.0+", "dependencies": { "archiver": "^5.3.0", diff --git a/wrapper/build.gradle b/wrapper/build.gradle index 9b9ca48a..be061a0a 100644 --- a/wrapper/build.gradle +++ b/wrapper/build.gradle @@ -17,6 +17,14 @@ repositories { maven { url 'https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1' } } +tasks.withType(JavaExec).configureEach { + System.properties.each { k, v -> + if (k.startsWith('run.')) { + systemProperty k - 'run.', v + } + } +} + configurations { ship } diff --git a/wrapper/src/main/java/io/github/solclient/client/mixin/mod/MixinBedwars.java b/wrapper/src/main/java/io/github/solclient/client/mixin/mod/MixinBedwars.java new file mode 100644 index 00000000..38381132 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mixin/mod/MixinBedwars.java @@ -0,0 +1,65 @@ +package io.github.solclient.client.mixin.mod; + +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsGame; +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMod; +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsPlayer; +import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.List; + +public class MixinBedwars { + + @Mixin(PlayerListHud.class) + public static class MixinBedwarsPlayerListHud { + + @Shadow private Text header; + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null || !game.isStarted()) { + return; + } + BedwarsPlayer player = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + if (player == null) { + return; + } + cir.setReturnValue(player.getTabListDisplay()); + } + + @ModifyVariable(method = "render", at = @At(value = "INVOKE_ASSIGN", target = "Lcom/google/common/collect/Ordering;sortedCopy(Ljava/lang/Iterable;)Ljava/util/List;")) + public List overrideSortedPlayers(List original) { + if (!BedwarsMod.getInstance().inGame()) { + return original; + } + List players = BedwarsMod.getInstance().getGame().get().getTabPlayerList(original); + if (players == null) { + return original; + } + return players; + } + + @Inject(method = "setHeader", at = @At("HEAD"), cancellable = true) + public void changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + } + + } + +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/ModManager.java b/wrapper/src/main/java/io/github/solclient/client/mod/ModManager.java index 20e01b26..bafb3471 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/ModManager.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/ModManager.java @@ -100,7 +100,7 @@ public void loadStandard(Path storageFile) { // integration new CosmeticaMod(), new HypixelAdditionsMod(), - new BedwarsMod(), + BedwarsMod.getInstance(), new QuickPlayMod(), new DiscordIntegrationMod() ); diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index 5fa52044..855eb6ec 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -1,18 +1,22 @@ package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import io.github.solclient.client.event.impl.ReceiveChatMessageEvent; +import io.github.solclient.client.event.impl.ScoreboardRenderEvent; +import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; +import java.util.*; import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; public class BedwarsGame { @@ -21,6 +25,9 @@ public class BedwarsGame { private final static Pattern FINAL_KILL = Pattern.compile("FINAL KILL!"); private final static Pattern BED_DESTROY = Pattern.compile("^\\s*?BED DESTRUCTION > (\\w+) Bed"); private final static Pattern TEAM_ELIMINATED = Pattern.compile("^\\s*?TEAM ELIMINATED > (\\w+) Team"); + + private final static Pattern GAME_END = Pattern.compile("^ +1st Killer - ?\\[?\\w*\\+*\\]? \\w+ - \\d+(?: Kills?)?$"); + private final static Pattern[] DIED = { Pattern.compile(formatPlaceholder("^{killed} fell into the void.(?: FINAL KILL!)?\\s*?")), Pattern.compile(formatPlaceholder("^{killed} died.(?: FINAL KILL!)?\\s*?")) @@ -181,6 +188,9 @@ public class BedwarsGame { private final static Pattern[] KILLS_COMPILED = new Pattern[KILLS.length]; + private int seconds = 0; + private Text topBarText = new LiteralText(""); + private static String formatPlaceholder(String input) { return input .replace("{killed}", "(\\b[A-Za-z0-9_§]{3,16}\\b)") @@ -195,19 +205,23 @@ private static String formatPlaceholder(String input) { } } - private final List players = new ArrayList<>(); + // Use a treemap here for the O(log(n)) time + private final Map players = new TreeMap<>(); private final MinecraftClient mc; + @Getter private boolean started = false; + private final BedwarsMod mod; - public BedwarsGame() { + public BedwarsGame(BedwarsMod mod) { mc = MinecraftClient.getInstance(); + this.mod = mod; } public void onStart() { debug("Game started"); - this.started = true; players.clear(); + Map> teamPlayers = new HashMap<>(); for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { String name = mc.inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); if (name.charAt(1) != ' ') { @@ -217,12 +231,45 @@ public void onStart() { if (team == null) { continue; } - players.add(new BedwarsPlayer(team, player)); + teamPlayers.compute(team, (t, entries) -> { + if (entries == null) { + List players = new ArrayList<>(); + players.add(player); + return players; + } + entries.add(player); + return entries; + }); + } + for (Map.Entry> teamPlayerList : teamPlayers.entrySet()) { + teamPlayerList.getValue().sort(Comparator.comparing(p -> p.getProfile().getName())); + List value = teamPlayerList.getValue(); + for (int i = 0; i < value.size(); i++) { + PlayerListEntry e = value.get(i); + players.put(e.getProfile().getName(), new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1)); + } + } + this.started = true; + } + + public Text getTopBarText() { + return topBarText; + } + + private String calculateTopBarText() { + int minute = seconds / 60; + int second = seconds % 60; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; } + return time; } public Optional getPlayer(String name) { - return players.stream().filter(player -> player.getName().equals(name)).findFirst(); + return Optional.ofNullable(players.getOrDefault(name, null)); } private void debug(String message) { @@ -230,19 +277,12 @@ private void debug(String message) { } private void died(BedwarsPlayer player, @Nullable BedwarsPlayer killer, boolean finalDeath) { - if (killer == null) { - if (finalDeath) { - debug(player.coloredName() + " §7was final killed."); - } else { - debug(player.coloredName() + " §7was killed."); - } - } else { - if (finalDeath) { - debug(player.coloredName() + " §7was final killed by " + killer.coloredName()); - } else { - debug(player.coloredName() + " §7was killed by " + killer.coloredName()); - } - } + player.died(); + mod.gameLog.died(player, killer, true); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); } public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { @@ -268,16 +308,23 @@ public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { })) { return; } - if (matched(BED_DESTROY, rawMessage, m -> debug(m.group(1) + " Team's bed was broken"))) { + if (matched(BED_DESTROY, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(this::bedDestroyed))) { + return; + } + if (matched(DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(this::disconnected))) { return; } - if (matched(TEAM_ELIMINATED, rawMessage, m -> debug(m.group(1) + " Team was eliminated"))) { + if (matched(RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(this::reconnected))) { return; } - if (matched(DISCONNECT, rawMessage, m -> debug(m.group(1) + " has disconnected"))) { + if (matched(GAME_END, rawMessage, m -> { + debug("END OF THE GAME!!!"); + BedwarsMod.getInstance().gameEnd(); + })) { + return; } - if (matched(RECONNECT, rawMessage, m -> debug(m.group(1) + " has reconnected"))) { + if (matched(TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(this::teamEliminated))) { return; } } catch (Exception e) { @@ -285,9 +332,64 @@ public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { } } - public void tick() {} + private void teamEliminated(BedwarsTeam team) { + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> { + b.setBed(false); + b.died(); + }); + } + + private void bedDestroyed(BedwarsTeam team) { + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); + } + + private void disconnected(BedwarsPlayer player) { + player.disconnected(); + } + + private void reconnected(BedwarsPlayer player) { + player.reconnected(); + } - private static boolean matched(Pattern pattern, String input, Consumer consumer) { + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.objective.getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.objective); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + Collections.reverse(filteredScores); + if (filteredScores.size() < 3) { + return; + } + ScoreboardPlayerScore score = filteredScores.get(2); + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String timer = Team.decorateName(team, score.getPlayerName()); + if (!timer.contains(":")) { + return; + } + int seconds; + try { + seconds = Integer.parseInt(timer.split(":")[1].substring(0, 2)); + } catch (Exception e) { + e.printStackTrace(); + return; + } + int target = (60 - seconds) % 60; + if (this.seconds % 60 != target) { + // Update seconds + while (this.seconds % 60 != target) { + this.seconds++; + } + topBarText = new LiteralText(calculateTopBarText()); + } + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + players.values().forEach(p -> p.tick(currentTick)); + } + + protected static boolean matched(Pattern pattern, String input, Consumer consumer) { Optional matcher = matched(pattern, input); if (!matcher.isPresent()) { return false; @@ -296,7 +398,7 @@ private static boolean matched(Pattern pattern, String input, Consumer return true; } - private static boolean matched(Pattern[] pattern, String input, Consumer consumer) { + protected static boolean matched(Pattern[] pattern, String input, Consumer consumer) { Optional matcher = matched(pattern, input); if (!matcher.isPresent()) { return false; @@ -305,7 +407,7 @@ private static boolean matched(Pattern[] pattern, String input, Consumer matched(Pattern[] pattern, String input) { + protected static Optional matched(Pattern[] pattern, String input) { for (Pattern p : pattern) { Optional m = matched(p, input); if (m.isPresent()) { @@ -315,7 +417,7 @@ private static Optional matched(Pattern[] pattern, String input) { return Optional.empty(); } - private static Optional matched(Pattern pattern, String input) { + protected static Optional matched(Pattern pattern, String input) { Matcher matcher = pattern.matcher(input); if (matcher.find()) { return Optional.of(matcher); @@ -323,4 +425,21 @@ private static Optional matched(Pattern pattern, String input) { return Optional.empty(); } + public void updateEntries(List entries) { + // Update latencies and other information for entries + entries.forEach(entry -> + getPlayer(entry.getProfile().getName()).ifPresent(player -> player.updateListEntry(entry)) + ); + } + + public List getTabPlayerList(List original) { + updateEntries(original); + return players.values().stream().filter(b -> !b.isFinalKilled()).sorted((b1, b2) -> { + if (b1.getTeam() == b2.getTeam()) { + return Integer.compare(b1.getNumber(), b2.getNumber()); + } + return Integer.compare(b1.getTeam().ordinal(), b2.getTeam().ordinal()); + }).map(BedwarsPlayer::getProfile).collect(Collectors.toList()); + } + } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java index d1642eea..babaa65f 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -3,42 +3,88 @@ import io.github.solclient.client.event.EventHandler; import io.github.solclient.client.event.impl.PreTickEvent; import io.github.solclient.client.event.impl.ReceiveChatMessageEvent; +import io.github.solclient.client.event.impl.ScoreboardRenderEvent; import io.github.solclient.client.mod.ModCategory; +import io.github.solclient.client.mod.hud.HudElement; import io.github.solclient.client.mod.impl.SolClientMod; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.text.Text; + +import java.util.*; import java.util.regex.Pattern; public class BedwarsMod extends SolClientMod { - private final static Pattern GAME_START = Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$"); + private final static Pattern[] GAME_START = { + Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$"), + Pattern.compile("^\\s*?Bed Wars Lucky Blocks\\s*?$"), + Pattern.compile("^\\s*?Bed Wars Swappage\\s*?$") + }; + + private final static BedwarsMod INSTANCE = new BedwarsMod(); - private BedwarsGame currentGame = null; + public static BedwarsMod getInstance() { + return INSTANCE; + } + + protected BedwarsGame currentGame = null; + protected final GameLogDisplay gameLog; private int targetTick = -1; + private BedwarsMod() { + gameLog = new GameLogDisplay(this); + } + @EventHandler public void onMessage(ReceiveChatMessageEvent event) { // Remove formatting String rawMessage = event.message.replaceAll("§.", ""); if (currentGame != null) { currentGame.onChatMessage(rawMessage, event); - } else if (targetTick < 0 && GAME_START.matcher(rawMessage).matches()) { + } else if (targetTick < 0 && BedwarsGame.matched(GAME_START, rawMessage).isPresent()) { // Give time for Hypixel to sync targetTick = mc.inGameHud.getTicks() + 10; } } + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + @EventHandler public void onTick(PreTickEvent event) { if (currentGame != null) { - currentGame.tick(); + if (currentGame.isStarted()) { + // Trigger setting the header + mc.inGameHud.getPlayerListWidget().setHeader(null); + currentGame.tick(); + } else { + boolean ready = false; + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + ready = true; + break; + } + } + if (ready) { + currentGame.onStart(); + } + } } else { if (targetTick > 0 && mc.inGameHud.getTicks() > targetTick) { - currentGame = new BedwarsGame(); - currentGame.onStart(); + currentGame = new BedwarsGame(this); + targetTick = -1; } } } + @Override + public List getHudElements() { + return Arrays.asList(gameLog); + } + @Override public String getId() { return "bedwars"; @@ -49,4 +95,18 @@ public ModCategory getCategory() { return ModCategory.HUD; } + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + @EventHandler + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + currentGame.onScoreboardRender(event); + } + } + + public void gameEnd() { + currentGame = null; + } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java index 5f6b3e42..a32da74d 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java @@ -2,22 +2,86 @@ import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.PlayerListEntry; @Data public class BedwarsPlayer { private final BedwarsTeam team; - private final PlayerListEntry entry; - private boolean alive; - private boolean bed; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + private boolean disconnected = false; + private boolean bed = true; + private final int number; + private int tickAlive = -1; + + public BedwarsPlayer(BedwarsTeam team, PlayerListEntry profile, int number) { + this.team = team; + this.profile = profile; + this.number = number; + } public String getName() { - return entry.getProfile().getName(); + return profile.getProfile().getName(); } - public String coloredName() { + public String getColoredName() { return team.getColorSection() + getName(); } + public String getTabListDisplay() { + if (alive) { + if (bed) { + return team.getColorSection() + "§l" + team.getPrefix() + number + " " + getColoredName(); + } + return team.getColorSection() + "§l" + team.getPrefix() + number + team.getColorSection() + "§o " + getName(); + } + if (disconnected) { + return team.getColorSection() + "§l§m" + team.getPrefix() + number + " §7§o§n" + getName(); + } + return team.getColorSection() + "§l§m" + team.getPrefix() + number + " §7§m" + getName(); + } + + public void updateListEntry(PlayerListEntry entry) { + this.profile = entry; + } + + public boolean isFinalKilled() { + return tickAlive < 0 && !bed && !alive; + } + + public void tick(int currentTick) { + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + public void died() { + alive = false; + if (!bed) { + tickAlive = -1; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 10; // 10 second respawn + } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java index 274471a3..6fc9780f 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java @@ -9,14 +9,14 @@ @AllArgsConstructor public enum BedwarsTeam { + RED('c', 'R'), + BLUE('9', 'B'), + GREEN('a', 'G'), + YELLOW('e', 'Y'), AQUA('b', 'A'), WHITE('f', 'W'), PINK('d', 'P'), GRAY('8', 'S'), - RED('c', 'R'), - BLUE('9', 'B'), - GREEN('a', 'G'), - YELLOW('e', 'Y') ; @Getter diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java new file mode 100644 index 00000000..6787afa2 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java @@ -0,0 +1,63 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + +import io.github.solclient.client.mod.Mod; +import io.github.solclient.client.mod.hud.BaseHudElement; +import io.github.solclient.client.mod.hud.HudPosition; +import io.github.solclient.client.util.data.Position; +import io.github.solclient.client.util.data.Rectangle; +import org.jetbrains.annotations.Nullable; + +public class GameLogDisplay extends BaseHudElement { + + private final BedwarsMod mod; + private HudPosition position = new HudPosition(0, 0); + + public GameLogDisplay(BedwarsMod mod) { + this.mod = mod; + } + + @Override + public HudPosition getHudPosition() { + return position; + } + + @Override + public void setHudPosition(HudPosition position) { + this.position = position; + } + + @Override + public float getHudScale() { + return 1f; + } + + @Override + public boolean isVisible() { + return mod.inGame(); + } + + @Override + public Rectangle getBounds(Position position) { + return position.rectangle(100, 200); + } + + @Override + public void render(Position position, boolean editMode) { + + } + + @Override + public Mod getMod() { + return mod; + } + + @Override + public boolean isShownInReplay() { + return false; + } + + public void died(BedwarsPlayer player, @Nullable BedwarsPlayer killer, boolean finaled) { + + } + +} diff --git a/wrapper/src/main/resources/sol-client.mixins.json b/wrapper/src/main/resources/sol-client.mixins.json index 65609573..3468e15d 100644 --- a/wrapper/src/main/resources/sol-client.mixins.json +++ b/wrapper/src/main/resources/sol-client.mixins.json @@ -99,6 +99,7 @@ "mod.MixinScrollableTooltipsMod$MixinHandledScreen", "mod.MixinTNTTimerMod$MixinTntEntityRenderer", "mod.MixinTabListMod$MixinPlayerListHud", + "mod.MixinBedwars$MixinBedwarsPlayerListHud", "mod.MixinTweaksMod$MixinInGameHud", "mod.MixinTweaksMod$MixinEnchantment", "mod.MixinTweaksMod$MixinInventoryScreen", From 120780fe24233a52a19e58a4c05fff1d06798a6b Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Fri, 3 Feb 2023 18:46:55 -0700 Subject: [PATCH 05/23] Fixing tabs --- .../client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java | 4 ++-- wrapper/src/main/resources/sol-client.mixins.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java index a32da74d..433c6ea1 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java @@ -40,9 +40,9 @@ public String getTabListDisplay() { return team.getColorSection() + "§l" + team.getPrefix() + number + team.getColorSection() + "§o " + getName(); } if (disconnected) { - return team.getColorSection() + "§l§m" + team.getPrefix() + number + " §7§o§n" + getName(); + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §o§n" + getName(); } - return team.getColorSection() + "§l§m" + team.getPrefix() + number + " §7§m" + getName(); + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §m" + getName(); } public void updateListEntry(PlayerListEntry entry) { diff --git a/wrapper/src/main/resources/sol-client.mixins.json b/wrapper/src/main/resources/sol-client.mixins.json index 3468e15d..909195a8 100644 --- a/wrapper/src/main/resources/sol-client.mixins.json +++ b/wrapper/src/main/resources/sol-client.mixins.json @@ -99,7 +99,7 @@ "mod.MixinScrollableTooltipsMod$MixinHandledScreen", "mod.MixinTNTTimerMod$MixinTntEntityRenderer", "mod.MixinTabListMod$MixinPlayerListHud", - "mod.MixinBedwars$MixinBedwarsPlayerListHud", + "mod.MixinBedwars$MixinBedwarsPlayerListHud", "mod.MixinTweaksMod$MixinInGameHud", "mod.MixinTweaksMod$MixinEnchantment", "mod.MixinTweaksMod$MixinInventoryScreen", From 227fd1d736ed082f4bd76098744824e0518cccda Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Mon, 6 Feb 2023 10:38:44 -0700 Subject: [PATCH 06/23] Team upgrades --- .../client/mixin/mod/BedwarsMixins.java | 1 + .../impl/hud/bedwarsoverlay/BedwarsGame.java | 15 ++-- .../hud/bedwarsoverlay/BedwarsPlayer.java | 8 ++ .../hud/bedwarsoverlay/GameLogDisplay.java | 57 +++++++++++++- .../upgrades/BedwarsTeamUpgrades.java | 55 ++++++++++++++ .../upgrades/BinaryUpgrade.java | 35 +++++++++ .../bedwarsoverlay/upgrades/TeamUpgrade.java | 32 ++++++++ .../upgrades/TieredUpgrade.java | 41 ++++++++++ .../bedwarsoverlay/upgrades/TrapUpgrade.java | 75 +++++++++++++++++++ 9 files changed, 310 insertions(+), 9 deletions(-) create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java diff --git a/wrapper/src/main/java/io/github/solclient/client/mixin/mod/BedwarsMixins.java b/wrapper/src/main/java/io/github/solclient/client/mixin/mod/BedwarsMixins.java index 5b1bd662..25ed61ac 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mixin/mod/BedwarsMixins.java +++ b/wrapper/src/main/java/io/github/solclient/client/mixin/mod/BedwarsMixins.java @@ -57,6 +57,7 @@ public void changeHeader(Text header, CallbackInfo ci) { return; } this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index 855eb6ec..0d32a993 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -2,6 +2,7 @@ import io.github.solclient.client.event.impl.ReceiveChatMessageEvent; import io.github.solclient.client.event.impl.ScoreboardRenderEvent; +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.BedwarsTeamUpgrades; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.PlayerListEntry; @@ -211,6 +212,8 @@ private static String formatPlaceholder(String input) { @Getter private boolean started = false; private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); public BedwarsGame(BedwarsMod mod) { @@ -265,7 +268,7 @@ private String calculateTopBarText() { } else { time += second; } - return time; + return "Time: " + time; } public Optional getPlayer(String name) { @@ -321,12 +324,12 @@ public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { debug("END OF THE GAME!!!"); BedwarsMod.getInstance().gameEnd(); })) { - return; } if (matched(TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(this::teamEliminated))) { return; } + upgrades.onMessage(rawMessage); } catch (Exception e) { debug("Error: " + e); } @@ -389,7 +392,7 @@ public void tick() { players.values().forEach(p -> p.tick(currentTick)); } - protected static boolean matched(Pattern pattern, String input, Consumer consumer) { + public static boolean matched(Pattern pattern, String input, Consumer consumer) { Optional matcher = matched(pattern, input); if (!matcher.isPresent()) { return false; @@ -398,7 +401,7 @@ protected static boolean matched(Pattern pattern, String input, Consumer consumer) { + public static boolean matched(Pattern[] pattern, String input, Consumer consumer) { Optional matcher = matched(pattern, input); if (!matcher.isPresent()) { return false; @@ -407,7 +410,7 @@ protected static boolean matched(Pattern[] pattern, String input, Consumer matched(Pattern[] pattern, String input) { + public static Optional matched(Pattern[] pattern, String input) { for (Pattern p : pattern) { Optional m = matched(p, input); if (m.isPresent()) { @@ -417,7 +420,7 @@ protected static Optional matched(Pattern[] pattern, String input) { return Optional.empty(); } - protected static Optional matched(Pattern pattern, String input) { + public static Optional matched(Pattern pattern, String input) { Matcher matcher = pattern.matcher(input); if (matcher.find()) { return Optional.of(matcher); diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java index 433c6ea1..11fa25d5 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java @@ -24,6 +24,14 @@ public BedwarsPlayer(BedwarsTeam team, PlayerListEntry profile, int number) { this.number = number; } + public String getColoredTeamNumber(String format) { + return getTeam().getColorSection() + format + getTeam().getPrefix() + getNumber(); + } + + public String getColoredTeamNumber() { + return getTeam().getColorSection() + getTeam().getPrefix() + getNumber(); + } + public String getName() { return profile.getProfile().getName(); } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java index abee8731..13b51116 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java @@ -2,17 +2,33 @@ import io.github.solclient.client.mod.Mod; import io.github.solclient.client.mod.hud.HudElement; +import io.github.solclient.client.util.data.Colour; import io.github.solclient.client.util.data.Position; import io.github.solclient.client.util.data.Rectangle; +import lombok.Value; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + public class GameLogDisplay implements HudElement { private final BedwarsMod mod; - private Position position = new Position(0, 0); + private final MinecraftClient mc; + private final List messages = new ArrayList<>(); + private final static List EDIT_MESSAGES = Arrays.asList( + new Message(-1, "☠ §9B1§7 //§c R2"), + new Message(-1, "☠ §bA1") + ); + private Position position = new Position(100, 100); public GameLogDisplay(BedwarsMod mod) { this.mod = mod; + this.mc = MinecraftClient.getInstance(); } @Override @@ -32,7 +48,7 @@ public Position getConfiguredPosition() { @Override public boolean isVisible() { - return mod.inGame(); + return true; } @Override @@ -42,7 +58,19 @@ public Rectangle getBounds(Position position) { @Override public void render(Position position, boolean editMode) { - + int tick = mc.inGameHud.getTicks(); + int y = 0; + for (Message message : (editMode ? EDIT_MESSAGES : messages)) { + y += 9; + int color = -1; + if (!editMode && message.tickCreated > 20 * 5 + tick) { + if (message.tickCreated > 20 * 8 + tick) { + break; + } + color = new Colour(255, 255, 255, (int) ((1 - ((float) 20 * 5 - tick) / (20 * 3)) * 255)).getValue(); + } + mc.textRenderer.draw(message.content, position.getX(), position.getY() - y, color); + } } @Override @@ -55,7 +83,30 @@ public boolean isShownInReplay() { return false; } + public void push(Text content) { + push(content.asFormattedString()); + } + + public void push(String content) { + int tick = mc.inGameHud.getTicks(); + messages.add(0, new Message(tick, content)); + while (messages.size() > 300) { + messages.remove(300); + } + } + public void died(BedwarsPlayer player, @Nullable BedwarsPlayer killer, boolean finaled) { + if (killer == null) { + push(new LiteralText("☠ " + player.getColoredTeamNumber())); + } else { + push(new LiteralText("☠ " + player.getColoredTeamNumber() + "§7 // " + killer.getColoredTeamNumber())); + } + } + + @Value + public static class Message { + int tickCreated; + String content; } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 00000000..d8faed59 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,55 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; + + +import java.util.regex.Pattern; + +public class BedwarsTeamUpgrades { + + public final TrapUpgrade trap = new TrapUpgrade(); + + + public final TeamUpgrade sharpness = new BinaryUpgrade( + "sharpness", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords\\s*$"), + 8, 4 + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragon_buff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5 + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "heal_pool", Pattern.compile("^(\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1 + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "protection", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Protection .{1,2}\\s*$"), + new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16} + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "maniac_miner", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,2}\\s*$"), + new int[]{2, 4}, new int[]{4, 6} + ); + + public final TeamUpgrade forge = new TieredUpgrade( + "forge", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (?:Iron|Golden|Emerald|Molten) Forge\\s*$"), + new int[]{2, 4}, new int[]{4, 6} + ); + + private final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; + + public BedwarsTeamUpgrades() { + + } + + public void onMessage(String rawMessage) { + for (TeamUpgrade upgrade : upgrades) { + if (upgrade.match(rawMessage)) { + return; + } + } + } + +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java new file mode 100644 index 00000000..6374968a --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java @@ -0,0 +1,35 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; + +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class BinaryUpgrade extends TeamUpgrade { + + @Getter + private boolean purchased = false; + + private final int foursPrice; + private final int doublesPrice; + + public BinaryUpgrade(String name, Pattern regex, int foursPrice, int doublesPrice) { + super(name, regex); + this.foursPrice = foursPrice; + this.doublesPrice = doublesPrice; + } + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + purchased = true; + } + + @Override + public int getPrice(BedwarsMode mode) { + if (mode.getTeams().length == 8) { + return doublesPrice; + } + return foursPrice; + } + +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java new file mode 100644 index 00000000..cd35d622 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java @@ -0,0 +1,32 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; + +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsGame; +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public abstract class TeamUpgrade { + private final String name; + private final Pattern[] regex; + + public TeamUpgrade(String name, Pattern pattern) { + this(name, new Pattern[]{pattern}); + } + + public TeamUpgrade(String name, Pattern[] pattern) { + this.name = name; + this.regex = pattern; + } + + public boolean match(String unformatedMessage) { + return BedwarsGame.matched(regex, unformatedMessage, matcher -> onMatch(this, matcher)); + } + + protected abstract void onMatch(TeamUpgrade upgrade, Matcher matcher); + + public abstract int getPrice(BedwarsMode mode); + + +} + diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java new file mode 100644 index 00000000..1940efc1 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java @@ -0,0 +1,41 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; + +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TieredUpgrade extends TeamUpgrade { + + private final int[] doublesPrice; + private final int[] foursPrice; + @Getter + private int level = 0; + + public TieredUpgrade(String name, Pattern regex, int[] foursPrice, int[] doublesPrice) { + super(name, regex); + this.foursPrice = foursPrice; + this.doublesPrice = doublesPrice; + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + level += 1; + } + + public boolean isMaxedOut(BedwarsMode mode) { + if (mode.getTeams().length == 8) { + return level >= doublesPrice.length; + } + return level >= foursPrice.length; + } + + @Override + public int getPrice(BedwarsMode mode) { + if (mode.getTeams().length == 8) { + return doublesPrice[level]; + } + return foursPrice[level]; + } +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java new file mode 100644 index 00000000..600e62dc --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java @@ -0,0 +1,75 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; + +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TrapUpgrade extends TeamUpgrade { + + private final static Pattern[] REGEX = { + Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap\\s*$"), + Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap\\s*$"), + Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap\\s*$"), + Pattern.compile("Trap was set (off)!"), + }; + + private final List traps = new ArrayList<>(3); + + public TrapUpgrade() { + super("trap", REGEX); + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + if (matcher.group(1).equals("off")) { + // Trap went off + traps.remove(0); + return; + } + traps.add(TrapType.getFuzzy(matcher.group(1))); + } + + public boolean canPurchase() { + return traps.size() < 3; + } + + @Override + public int getPrice(BedwarsMode mode) { + switch (traps.size()) { + case 0: + return 1; + case 1: + return 2; + case 2: + return 4; + }; + return 0; + } + + + public enum TrapType { + ITS_A_TRAP, + COUNTER_OFFENSIVE, + ALARM, + MINER_FATIGUE + ; + + public static TrapType getFuzzy(String s) { + s = s.toLowerCase(Locale.ROOT); + if (s.contains("miner")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} From 89a52098ebc21f153f0ebe9b3385b2f753cc34f5 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Mon, 6 Feb 2023 13:18:50 -0700 Subject: [PATCH 07/23] Refactor API --- .../hud/bedwarsoverlay/GameLogDisplay.java | 20 +++- .../hud/bedwarsoverlay/LobbyStatsHud.java | 58 ++++++++++ .../hypixeladditions/HypixelAPICache.java | 105 ++++++++++++++++++ .../hypixeladditions/HypixelAdditionsMod.java | 38 +------ 4 files changed, 183 insertions(+), 38 deletions(-) create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/LobbyStatsHud.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java index 13b51116..540cdf9d 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java @@ -56,18 +56,30 @@ public Rectangle getBounds(Position position) { return position.rectangle(100, 200); } + public int getSecondsBeforeFade() { + return 10; + } + + public int getFadeSeconds() { + return 3; + } + @Override public void render(Position position, boolean editMode) { int tick = mc.inGameHud.getTicks(); - int y = 0; + int y = -200; for (Message message : (editMode ? EDIT_MESSAGES : messages)) { y += 9; int color = -1; - if (!editMode && message.tickCreated > 20 * 5 + tick) { - if (message.tickCreated > 20 * 8 + tick) { + int tickAlive = (tick - message.tickCreated); + if (!editMode && tickAlive > 20 * getSecondsBeforeFade()) { + if (tickAlive > 20 * getSecondsBeforeFade() + getFadeSeconds()) { + // Stop rendering break; } - color = new Colour(255, 255, 255, (int) ((1 - ((float) 20 * 5 - tick) / (20 * 3)) * 255)).getValue(); + int tickFade = tickAlive - 20 * getSecondsBeforeFade(); + float alpha = 1 - (tickFade / (20f * getFadeSeconds())); + color = new Colour(255, 255, 255, (int) (alpha * 255)).getValue(); } mc.textRenderer.draw(message.content, position.getX(), position.getY() - y, color); } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/LobbyStatsHud.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/LobbyStatsHud.java new file mode 100644 index 00000000..29080ee4 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/LobbyStatsHud.java @@ -0,0 +1,58 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + +import io.github.solclient.client.mod.Mod; +import io.github.solclient.client.mod.hud.HudElement; +import io.github.solclient.client.util.data.Position; +import io.github.solclient.client.util.data.Rectangle; + + +public class LobbyStatsHud implements HudElement { + + public LobbyStatsHud() { + + } + + public void update() { + + } + + @Override + public float getScale() { + return 0; + } + + @Override + public Position getConfiguredPosition() { + return null; + } + + @Override + public void setPosition(Position position) { + + } + + @Override + public boolean isVisible() { + return false; + } + + @Override + public Rectangle getBounds(Position position) { + return null; + } + + @Override + public void render(Position position, boolean editMode) { + + } + + @Override + public Mod getMod() { + return null; + } + + @Override + public boolean isShownInReplay() { + return false; + } +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java new file mode 100644 index 00000000..589a2ed2 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java @@ -0,0 +1,105 @@ +package io.github.solclient.client.mod.impl.hypixeladditions; + +import io.github.solclient.client.util.ApacheHttpClient; +import io.github.solclient.client.util.MinecraftUtils; +import net.hypixel.api.HypixelAPI; +import net.hypixel.api.reply.PlayerReply; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +public class HypixelAPICache { + + private static final HypixelAPICache INSTANCE = new HypixelAPICache(); + + private HypixelAPI api = null; + private final Map playerCache = new HashMap<>(); + private final Map> responseCache = new HashMap<>(); + private final Map levelCache = new HashMap<>(); + + public static HypixelAPICache getInstance() { + return INSTANCE; + } + + private HypixelAPICache() {} + + public Optional getPlayerFromCache(UUID uuid) { + return Optional.ofNullable(playerCache.get(uuid)); + } + + + public Optional> getPlayerOrRequest(UUID uuid) { + PlayerReply.Player cached = playerCache.get(uuid); + if (cached != null) { + return Optional.of(CompletableFuture.completedFuture(cached)); + } + CompletableFuture cachedResponse = responseCache.get(uuid); + if (cachedResponse != null) { + return Optional.of(cachedResponse); + } + if (api == null) { + return Optional.empty(); + } + CompletableFuture reply = api.getPlayerByUuid(uuid).thenApplyAsync(playerReply -> { + responseCache.remove(uuid); + if (!playerReply.isSuccess()) { + return null; + } + playerCache.put(uuid, playerReply.getPlayer()); + return playerReply.getPlayer(); + }); + responseCache.put(uuid, reply); + return Optional.of(reply); + } + + + public String getLevelHead(UUID id) { + + if (levelCache.containsKey(id)) { + // If it exists in cache then we are computing it/have the result + Integer result = levelCache.get(id); + if (result < 0) { + return null; + } + return String.valueOf(result); + } + + if (api == null) { + return null; + } + + // Put here first because we are waiting for computation to come back + levelCache.put(id, -1); + getPlayerOrRequest(id).ifPresent(c -> c.whenCompleteAsync((player, error) -> { + if (player == null || error != null) { + return; + } + + if (player.exists()) { + levelCache.put(id, (int) player.getNetworkLevel()); + } else { + // At this stage, the player is either nicked, or an NPC, but all NPCs and fake + // players I've tested do not get to this stage. + levelCache.put(id, MinecraftUtils.randomInt(120, 280)); + // Based on looking at YouTubers' Hypixel levels. It won't + // actually be the true level, and may not look quite right, + // but it's more plausible than a Level 1 god bridger. + } + })); + return null; + } + + public void setAPIKey(String apiKey) { + api = new HypixelAPI(new ApacheHttpClient(UUID.fromString(apiKey))); + } + + public void clear() { + responseCache.forEach((k, v) -> v.obtrudeValue(null)); + responseCache.clear(); + playerCache.clear(); + levelCache.clear(); + } +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAdditionsMod.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAdditionsMod.java index cb3f5f34..5c7bc8a2 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAdditionsMod.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAdditionsMod.java @@ -18,6 +18,7 @@ import io.github.solclient.client.packet.Popup; import io.github.solclient.client.util.*; import io.github.solclient.client.util.data.*; +import lombok.Getter; import net.hypixel.api.HypixelAPI; import net.minecraft.item.ItemStack; import net.minecraft.text.*; @@ -88,10 +89,8 @@ public class HypixelAdditionsMod extends SolClientMod { @Expose @Option public boolean levelhead; - private final Map levelCache = new HashMap<>(); @Expose private String apiKey; - private HypixelAPI api; private HypixelLocationData locationData; private final Pattern locrawTrigger = Pattern.compile("\\{(\".*\":\".*\",)?+\".*\":\".*\"\\}"); @@ -111,36 +110,7 @@ public String getLevelhead(boolean isMainPlayer, String name, UUID id) { return null; } - if (levelCache.containsKey(id)) { - String result = levelCache.get(id); - if (result.isEmpty()) { - return null; - } - return result; - } - - else if (api != null) { - levelCache.put(id, ""); - api.getPlayerByUuid(id).whenCompleteAsync((response, error) -> { - if (!response.isSuccess() || error != null) { - return; - } - - if (response.getPlayer().exists()) { - levelCache.put(id, Integer.toString((int) response.getPlayer().getNetworkLevel())); - } else { - // At this stage, the player is either nicked, or an NPC, but all NPCs and fake - // players I've tested do not get to this stage. - levelCache.put(id, Integer.toString(MinecraftUtils.randomInt(180, 280))); // Based on looking at YouTubers' - // Hypixel levels. It won't - // actually be the true level, - // and may not look quite right, - // but it's more plausible than - // a Level 1 god bridger. - } - }); - } - return null; + return HypixelAPICache.getInstance().getLevelHead(id); } public boolean isLobby() { @@ -217,7 +187,7 @@ private void updateState() { public void setApiKey(String apiKey) { this.apiKey = apiKey; if (apiKey != null) { - api = new HypixelAPI(new ApacheHttpClient(UUID.fromString(apiKey))); + HypixelAPICache.getInstance().setAPIKey(apiKey); } } @@ -250,7 +220,7 @@ public void onServerChange(ServerConnectEvent event) { @EventHandler public void onWorldLoad(WorldLoadEvent event) { donegg = donegl = false; - levelCache.clear(); + HypixelAPICache.getInstance().clear(); if (!isHypixel()) { return; From 9baee405a776d8025d6d67e5d20b3e88eb0dbaf6 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Wed, 8 Feb 2023 15:29:52 -0700 Subject: [PATCH 08/23] Changing death messages --- .../event/impl/ReceiveChatMessageEvent.java | 3 +- .../client/ClientPlayNetworkHandlerMixin.java | 11 +- .../impl/hud/bedwarsoverlay/BedwarsGame.java | 113 ++++++++++++++++-- .../impl/hud/bedwarsoverlay/BedwarsMod.java | 4 +- .../hud/bedwarsoverlay/BedwarsPlayer.java | 52 ++++++++ .../bedwarsoverlay/BedwarsPlayerStats.java | 96 +++++++++++++++ .../hud/bedwarsoverlay/GameLogDisplay.java | 40 ++++++- .../{ => stats}/LobbyStatsHud.java | 2 +- .../upgrades/BedwarsTeamUpgrades.java | 3 +- .../upgrades/BinaryUpgrade.java | 3 + .../upgrades/TieredUpgrade.java | 3 + .../bedwarsoverlay/upgrades/TrapUpgrade.java | 4 + .../client/mod/impl/hud/chat/ChatMod.java | 2 +- .../hypixeladditions/HypixelAdditionsMod.java | 22 ++-- 14 files changed, 322 insertions(+), 36 deletions(-) create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java rename wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/{ => stats}/LobbyStatsHud.java (88%) diff --git a/wrapper/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java b/wrapper/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java index 42e327dc..68678fce 100644 --- a/wrapper/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java +++ b/wrapper/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java @@ -6,11 +6,12 @@ public class ReceiveChatMessageEvent { public final boolean actionBar; - public final String message; + public final String originalMessage; /** * Whether the event is fired from the replay mod. */ public final boolean replay; public boolean cancelled; + public String newMessage = null; } diff --git a/wrapper/src/main/java/io/github/solclient/client/mixin/client/ClientPlayNetworkHandlerMixin.java b/wrapper/src/main/java/io/github/solclient/client/mixin/client/ClientPlayNetworkHandlerMixin.java index 7624a9b7..8ecb8337 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mixin/client/ClientPlayNetworkHandlerMixin.java +++ b/wrapper/src/main/java/io/github/solclient/client/mixin/client/ClientPlayNetworkHandlerMixin.java @@ -1,5 +1,6 @@ package io.github.solclient.client.mixin.client; +import net.minecraft.text.LiteralText; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -38,9 +39,13 @@ public void handleEntityStatus(EntityStatusS2CPacket packet, CallbackInfo callba @Redirect(method = "onChatMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;)V")) public void handleChat(ChatHud instance, Text message) { - if (!Client.INSTANCE.getEvents().post( - new ReceiveChatMessageEvent(false, Formatting.strip(message.asUnformattedString()), false)).cancelled) { - instance.addMessage(message); + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, Formatting.strip(message.asUnformattedString()), false); + if (!Client.INSTANCE.getEvents().post(event).cancelled) { + if (event.newMessage != null) { + instance.addMessage(new LiteralText(event.newMessage)); + } else { + instance.addMessage(message); + } } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index 0d32a993..c8118d3e 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -34,6 +34,52 @@ public class BedwarsGame { Pattern.compile(formatPlaceholder("^{killed} died.(?: FINAL KILL!)?\\s*?")) }; + private final static Pattern[] ANNOYING_MESSAGES = { + Pattern.compile("^You will respawn in \\d* seconds!$"), + Pattern.compile("^You purchased Wool$"), + Pattern.compile("^Cross-teaming is not allowed"), + Pattern.compile("^\\+\\d+ Coins!"), + Pattern.compile("^\\+\\d+ coins!"), + Pattern.compile("^Coins just earned DOUBLE"), + Pattern.compile("^\\+\\d+ Bed Wars Experience"), + Pattern.compile("^You have respawned"), + }; + + private final static Pattern[] BED_BREAK = { + Pattern.compile(formatPlaceholder("Bed was broken by {player}")), + Pattern.compile(formatPlaceholder("Bed was incinerated by {player}")), + Pattern.compile(formatPlaceholder("Bed was iced by {player}")), + Pattern.compile(formatPlaceholder("Bed had to raise the white flag to {player}")), + Pattern.compile(formatPlaceholder("Bed was dismantled by {player}")), + Pattern.compile(formatPlaceholder("Bed was deep fried by {player}")), + Pattern.compile(formatPlaceholder("Bed was ripped apart by {player}")), + Pattern.compile(formatPlaceholder("Bed was traded in for milk and cookies by {player}")), + Pattern.compile(formatPlaceholder("Bed was sacrificed by {player}")), + Pattern.compile(formatPlaceholder("Bed was gulped by {player}")), + Pattern.compile(formatPlaceholder("Bed was gulped by {player}")), + Pattern.compile(formatPlaceholder("Bed was squeaked apart by {player}")), + Pattern.compile(formatPlaceholder("Bed was stung by {player}")), + Pattern.compile(formatPlaceholder("Bed was impaled by {player}")), + Pattern.compile(formatPlaceholder("Bed be shot with cannon by {player}")), + Pattern.compile(formatPlaceholder("Bed got memed by {player}")), + Pattern.compile(formatPlaceholder("Bed was made into a snowman by {player}")), + Pattern.compile(formatPlaceholder("Bed was scrambled by {player}")), + Pattern.compile(formatPlaceholder("Bed was stuffed with tissue paper by {player}")), + Pattern.compile(formatPlaceholder("Bed was scrambled by {player}")), + Pattern.compile(formatPlaceholder("Bed was bed #{number} destroyed by {player}")), + Pattern.compile(formatPlaceholder("Bed was spooked by {player}")), + Pattern.compile(formatPlaceholder("Bed was dreadfully corrupted by {player}")), + Pattern.compile(formatPlaceholder("Bed was bed #{number} destroyed by {player}")), + Pattern.compile(formatPlaceholder("Bed exploded from a firework by {player}")), + Pattern.compile(formatPlaceholder("Bed was blasted to dust by {player}")), + Pattern.compile(formatPlaceholder("Bed was melted by {player}'s holiday spirit")), + Pattern.compile(formatPlaceholder("Bed was ripped to shreds by {player}")), + Pattern.compile(formatPlaceholder("Bed has left the game after seeing {player}")), + Pattern.compile(formatPlaceholder("Bed was spooked by {player}")), + Pattern.compile(formatPlaceholder("Bed was contaminated by {player}")), + Pattern.compile(formatPlaceholder("Bed was sold in a garage sale by {player}")), + }; + private final static String[] KILLS = { "{killed} was struck down by {player}.", "{killed} was turned to dust by {player}.", @@ -189,6 +235,9 @@ public class BedwarsGame { private final static Pattern[] KILLS_COMPILED = new Pattern[KILLS.length]; + private BedwarsTeam won = null; + private int wonTick = -1; + private int seconds = 0; private Text topBarText = new LiteralText(""); @@ -206,6 +255,8 @@ private static String formatPlaceholder(String input) { } } + private BedwarsPlayer me = null; + // Use a treemap here for the O(log(n)) time private final Map players = new TreeMap<>(); private final MinecraftClient mc; @@ -225,6 +276,7 @@ public void onStart() { debug("Game started"); players.clear(); Map> teamPlayers = new HashMap<>(); + int maxLength = 1; for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { String name = mc.inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); if (name.charAt(1) != ' ') { @@ -249,9 +301,15 @@ public void onStart() { List value = teamPlayerList.getValue(); for (int i = 0; i < value.size(); i++) { PlayerListEntry e = value.get(i); - players.put(e.getProfile().getName(), new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1)); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + maxLength = Math.max(e.getProfile().getName().length(), maxLength); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); } } + mod.gameLog.gameStart(maxLength); this.started = true; } @@ -260,6 +318,10 @@ public Text getTopBarText() { } private String calculateTopBarText() { + return getFormattedTime(); + } + + public String getFormattedTime() { int minute = seconds / 60; int second = seconds % 60; String time = minute + ":"; @@ -268,7 +330,7 @@ private String calculateTopBarText() { } else { time += second; } - return "Time: " + time; + return time; } public Optional getPlayer(String name) { @@ -279,9 +341,12 @@ private void debug(String message) { mc.inGameHud.getChatHud().addMessage(new LiteralText("§b§lINFO:§8 " + message)); } - private void died(BedwarsPlayer player, @Nullable BedwarsPlayer killer, boolean finalDeath) { + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, boolean finalDeath) { player.died(); - mod.gameLog.died(player, killer, true); + if (killer != null) { + killer.killed(finalDeath); + } + event.newMessage = mod.gameLog.died(player, killer, finalDeath); } public boolean isTeamEliminated(BedwarsTeam team) { @@ -290,13 +355,17 @@ public boolean isTeamEliminated(BedwarsTeam team) { public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { try { + if (matched(ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.cancelled = true; + return; + } if (matched(DIED, rawMessage, m -> { BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); if (killed == null) { debug("Player " + m.group(1) + " was not found"); return; } - died(killed, null, matched(FINAL_KILL, rawMessage).isPresent()); + died(event, killed, null, matched(FINAL_KILL, rawMessage).isPresent()); })) { return; } @@ -307,11 +376,15 @@ public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { debug("Player " + m.group(1) + " was not found"); return; } - died(killed, killer, matched(FINAL_KILL, rawMessage).isPresent()); + died(event, killed, killer, matched(FINAL_KILL, rawMessage).isPresent()); })) { return; } - if (matched(BED_DESTROY, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(this::bedDestroyed))) { + if (matched(BED_DESTROY, rawMessage, m -> { + BedwarsPlayer player = matched(BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); + BedwarsTeam.fromName(m.group(1)).ifPresent(t -> bedDestroyed(t, player)); + + })) { return; } if (matched(DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(this::disconnected))) { @@ -321,8 +394,9 @@ public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { return; } if (matched(GAME_END, rawMessage, m -> { - debug("END OF THE GAME!!!"); - BedwarsMod.getInstance().gameEnd(); + BedwarsTeam win = players.values().stream().filter(p -> !p.isFinalKilled()).findFirst().map(BedwarsPlayer::getTeam).orElse(null); + this.won = win; + this.wonTick = mc.inGameHud.getTicks() + 10; })) { return; } @@ -335,14 +409,30 @@ public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { } } + private void gameEnd(BedwarsTeam win) { + if (me == null) { + BedwarsMod.getInstance().gameEnd(); + return; + } + + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null) { + mc.inGameHud.getChatHud().addMessage(new LiteralText(p.getProfile().getProfile().getName() + " - " + p.getStats().getWinstreak())); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + private void teamEliminated(BedwarsTeam team) { + // Make sure everyone is dead, just in case players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> { b.setBed(false); b.died(); }); } - private void bedDestroyed(BedwarsTeam team) { + private void bedDestroyed(BedwarsTeam team, @Nullable BedwarsPlayer breaker) { players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); } @@ -389,6 +479,9 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { public void tick() { int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } players.values().forEach(p -> p.tick(currentTick)); } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java index babaa65f..5feb90e5 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -8,7 +8,6 @@ import io.github.solclient.client.mod.hud.HudElement; import io.github.solclient.client.mod.impl.SolClientMod; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.text.Text; import java.util.*; @@ -39,7 +38,7 @@ private BedwarsMod() { @EventHandler public void onMessage(ReceiveChatMessageEvent event) { // Remove formatting - String rawMessage = event.message.replaceAll("§.", ""); + String rawMessage = event.originalMessage.replaceAll("§.", ""); if (currentGame != null) { currentGame.onChatMessage(rawMessage, event); } else if (targetTick < 0 && BedwarsGame.matched(GAME_START, rawMessage).isPresent()) { @@ -109,4 +108,5 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { public void gameEnd() { currentGame = null; } + } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java index 11fa25d5..fe39a035 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java @@ -1,11 +1,16 @@ package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; +import io.github.solclient.client.mod.impl.hypixeladditions.HypixelAPICache; import lombok.Data; import lombok.Getter; +import net.hypixel.api.reply.PlayerReply; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.PlayerListEntry; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + @Data public class BedwarsPlayer { @@ -16,6 +21,8 @@ public class BedwarsPlayer { private boolean disconnected = false; private boolean bed = true; private final int number; + private BedwarsPlayerStats stats = null; + private boolean triedStats = false; private int tickAlive = -1; public BedwarsPlayer(BedwarsTeam team, PlayerListEntry profile, int number) { @@ -62,6 +69,21 @@ public boolean isFinalKilled() { } public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + Optional> future = HypixelAPICache.getInstance().getPlayerOrRequest(profile.getProfile().getId()); + if (!future.isPresent()) { + stats = BedwarsPlayerStats.generateFake(); + } else { + future.get().whenCompleteAsync((player, error) -> { + if (error != null) { + stats = BedwarsPlayerStats.generateFake(); + return; + } + stats = BedwarsPlayerStats.fromAPI(player); + }); + } + } if (alive || tickAlive < 0) { return; } @@ -72,6 +94,19 @@ public void tick(int currentTick) { } public void died() { + if (!alive) { + if (!bed) { + tickAlive = -1; + } + return; + } + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } alive = false; if (!bed) { tickAlive = -1; @@ -82,6 +117,13 @@ public void died() { } public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } disconnected = true; tickAlive = -1; alive = false; @@ -92,4 +134,14 @@ public void reconnected() { int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); tickAlive = currentTick + 20 * 10; // 10 second respawn } + + public void killed(boolean finalKill) { + if (stats != null) { + if (finalKill) { + stats.addFinalKill(); + } else { + stats.addKill(); + } + } + } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java new file mode 100644 index 00000000..a7b19403 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java @@ -0,0 +1,96 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import lombok.AllArgsConstructor; +import lombok.Getter; +import net.hypixel.api.reply.PlayerReply; +import org.jetbrains.annotations.Nullable; + + +@AllArgsConstructor +public class BedwarsPlayerStats { + + @Getter + private int finalKills; + @Getter + private int finalDeaths; + @Getter + private int bedsBroken; + @Getter + private int deaths; + @Getter + private int kills; + @Getter + private final int losses; + @Getter + private final int wins; + @Getter + private final int winstreak; + + + public static BedwarsPlayerStats generateFake() { + return new BedwarsPlayerStats(0, 0, 0, 0, 0, 0, 0, 0); + } + + @Nullable + public static BedwarsPlayerStats fromAPI(PlayerReply.Player player) { + JsonElement rawStats = player.getProperty("stats"); + if (rawStats == null || !rawStats.isJsonObject()) { + return null; + } + JsonObject stats = rawStats.getAsJsonObject(); + JsonObject bedwars = getObjectSafe(stats, "Bedwars"); + if (bedwars == null) { + return null; + } + int finalKills = getAsIntElse(bedwars, "final_kills_bedwars", 0); + int finalDeaths = getAsIntElse(bedwars, "final_deaths_bedwars", 0); + int bedsBroken = getAsIntElse(bedwars, "beds_broken_bedwars", 0); + int deaths = getAsIntElse(bedwars, "deaths_bedwars", 0); + int kills = getAsIntElse(bedwars, "kills_bedwars", 0); + int losses = getAsIntElse(bedwars, "losses_bedwars", 0); + int wins = getAsIntElse(bedwars, "wins_bedwars", 0); + int winstreak = getAsIntElse(bedwars, "winstreak", 0); + return new BedwarsPlayerStats(finalKills, finalDeaths, bedsBroken, deaths, kills, losses, wins, winstreak); + } + + private static int getAsIntElse(JsonObject obj, String key, int other) { + if (obj.has(key)) { + try { + return obj.get(key).getAsInt(); + } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { + // Not actually an int + } + } + return other; + } + + private static JsonObject getObjectSafe(JsonObject object, String key) { + if (!object.has(key)) { + return null; + } + JsonElement el = object.get(key); + if (!el.isJsonObject()) { + return null; + } + return el.getAsJsonObject(); + } + + public void addDeath() { + deaths++; + } + + public void addFinalDeath() { + finalDeaths++; + } + + public void addKill() { + kills++; + } + + public void addFinalKill() { + finalKills++; + } + +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java index 540cdf9d..171fa804 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java @@ -1,5 +1,6 @@ package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; +import com.mojang.blaze3d.platform.GlStateManager; import io.github.solclient.client.mod.Mod; import io.github.solclient.client.mod.hud.HudElement; import io.github.solclient.client.util.data.Colour; @@ -25,12 +26,18 @@ public class GameLogDisplay implements HudElement { new Message(-1, "☠ §bA1") ); private Position position = new Position(100, 100); + private int maxNameLength = 1; public GameLogDisplay(BedwarsMod mod) { this.mod = mod; this.mc = MinecraftClient.getInstance(); } + public void gameStart(int maxNameLength) { + this.messages.clear(); + this.maxNameLength = maxNameLength; + } + @Override public void setPosition(Position position) { this.position = position; @@ -66,13 +73,16 @@ public int getFadeSeconds() { @Override public void render(Position position, boolean editMode) { + GlStateManager.enableBlend(); + GlStateManager.blendFuncSeparate(770, 771, 1, 0); int tick = mc.inGameHud.getTicks(); int y = -200; + boolean chatFocused = mc.inGameHud.getChatHud().isChatFocused(); for (Message message : (editMode ? EDIT_MESSAGES : messages)) { y += 9; int color = -1; int tickAlive = (tick - message.tickCreated); - if (!editMode && tickAlive > 20 * getSecondsBeforeFade()) { + if (!chatFocused && !editMode && tickAlive > 20 * getSecondsBeforeFade()) { if (tickAlive > 20 * getSecondsBeforeFade() + getFadeSeconds()) { // Stop rendering break; @@ -83,6 +93,7 @@ public void render(Position position, boolean editMode) { } mc.textRenderer.draw(message.content, position.getX(), position.getY() - y, color); } + GlStateManager.disableBlend(); } @Override @@ -107,12 +118,33 @@ public void push(String content) { } } - public void died(BedwarsPlayer player, @Nullable BedwarsPlayer killer, boolean finaled) { + public String died(BedwarsPlayer player, @Nullable BedwarsPlayer killer, boolean finaled) { + String time = "§7" + mod.getGame().get().getFormattedTime() + " "; if (killer == null) { - push(new LiteralText("☠ " + player.getColoredTeamNumber())); + return time + getPlayerFormatted(player) + " §7/death/"; } else { - push(new LiteralText("☠ " + player.getColoredTeamNumber() + "§7 // " + killer.getColoredTeamNumber())); + if (finaled && killer.getStats() != null) { + return time + getPlayerFormatted(player) + " §6§n/FINAL/§r " + getPlayerFormatted(killer) + " §b#" + killer.getStats().getFinalKills(); + } else { + return time + getPlayerFormatted(player) + " §7/death/ " + getPlayerFormatted(killer); + } + } + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + private String format(String name) { + if (name.length() >= maxNameLength) { + return name; + } + int dif = maxNameLength - name.length(); + StringBuilder nameBuilder = new StringBuilder(name); + for (int i = 0; i < dif; i++) { + nameBuilder.append(" "); } + return nameBuilder.toString(); } @Value diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/LobbyStatsHud.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java similarity index 88% rename from wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/LobbyStatsHud.java rename to wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java index 29080ee4..11011c68 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/LobbyStatsHud.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java @@ -1,4 +1,4 @@ -package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.stats; import io.github.solclient.client.mod.Mod; import io.github.solclient.client.mod.hud.HudElement; diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java index d8faed59..6f4ef81d 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java @@ -7,7 +7,6 @@ public class BedwarsTeamUpgrades { public final TrapUpgrade trap = new TrapUpgrade(); - public final TeamUpgrade sharpness = new BinaryUpgrade( "sharpness", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords\\s*$"), 8, 4 @@ -19,7 +18,7 @@ public class BedwarsTeamUpgrades { ); public final TeamUpgrade healPool = new BinaryUpgrade( - "heal_pool", Pattern.compile("^(\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + "heal_pool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), 3, 1 ); diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java index 6374968a..315041a1 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java @@ -2,6 +2,8 @@ import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.LiteralText; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -21,6 +23,7 @@ public BinaryUpgrade(String name, Pattern regex, int foursPrice, int doublesPric } @Override protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(new LiteralText("Got an upgrade")); purchased = true; } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java index 1940efc1..252130cf 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java @@ -2,6 +2,8 @@ import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.LiteralText; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -21,6 +23,7 @@ public TieredUpgrade(String name, Pattern regex, int[] foursPrice, int[] doubles @Override protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(new LiteralText("Got an upgrade")); level += 1; } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java index 600e62dc..8a763ede 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java @@ -1,6 +1,8 @@ package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; +import net.minecraft.client.MinecraftClient; +import net.minecraft.text.LiteralText; import java.util.ArrayList; import java.util.List; @@ -26,10 +28,12 @@ public TrapUpgrade() { @Override protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { if (matcher.group(1).equals("off")) { + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(new LiteralText("Trap went off")); // Trap went off traps.remove(0); return; } + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(new LiteralText("Trap died")); traps.add(TrapType.getFuzzy(matcher.group(1))); } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/chat/ChatMod.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/chat/ChatMod.java index 32ed0c79..fcd068fd 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/chat/ChatMod.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/chat/ChatMod.java @@ -214,7 +214,7 @@ public void onReceiveChatMessage(ReceiveChatMessageEvent event) { return; } - String message = strip(event.message); + String message = strip(event.originalMessage); for (String word : filteredWords) { word = strip(word); diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAdditionsMod.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAdditionsMod.java index 5c7bc8a2..996214c8 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAdditionsMod.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAdditionsMod.java @@ -18,8 +18,6 @@ import io.github.solclient.client.packet.Popup; import io.github.solclient.client.util.*; import io.github.solclient.client.util.data.*; -import lombok.Getter; -import net.hypixel.api.HypixelAPI; import net.minecraft.item.ItemStack; import net.minecraft.text.*; import net.minecraft.text.ClickEvent.Action; @@ -236,10 +234,10 @@ public void onMessage(ReceiveChatMessageEvent event) { return; } - if (locrawTrigger.matcher(event.message).matches()) { + if (locrawTrigger.matcher(event.originalMessage).matches()) { try { event.cancelled = true; - locationData = new Gson().fromJson(event.message, HypixelLocationData.class); + locationData = new Gson().fromJson(event.originalMessage, HypixelLocationData.class); return; } catch (Throwable error) { logger.warn("Could not detect location", error); @@ -248,19 +246,19 @@ public void onMessage(ReceiveChatMessageEvent event) { if (hidegg) { for (Pattern pattern : hideggTriggers) { - if (pattern.matcher(event.message).matches()) { + if (pattern.matcher(event.originalMessage).matches()) { event.cancelled = true; return; } } } - if (hidegl && hideglTrigger.matcher(event.message).matches()) { + if (hidegl && hideglTrigger.matcher(event.originalMessage).matches()) { event.cancelled = true; return; } - if (hideChannelMessageTrigger.matcher(event.message).matches()) { + if (hideChannelMessageTrigger.matcher(event.originalMessage).matches()) { event.cancelled = true; return; } @@ -269,13 +267,13 @@ public void onMessage(ReceiveChatMessageEvent event) { return; } - if (event.actionBar && isHousing() && event.message.startsWith("Now playing:")) { + if (event.actionBar && isHousing() && event.originalMessage.startsWith("Now playing:")) { event.cancelled = true; return; } if (popupEvents) { - for (String line : event.message.split("\\n")) { + for (String line : event.originalMessage.split("\\n")) { Popup popup = HypixelPopupType.popupFromMessage(line); if (popup != null) { Client.INSTANCE.getPopups().add(popup); @@ -286,7 +284,7 @@ public void onMessage(ReceiveChatMessageEvent event) { if (autogg && !donegg) { for (Pattern pattern : autoggTriggers) { - if (pattern.matcher(event.message).matches()) { + if (pattern.matcher(event.originalMessage).matches()) { donegg = true; mc.player.sendChatMessage("/achat " + autoggMessage); return; @@ -294,12 +292,12 @@ public void onMessage(ReceiveChatMessageEvent event) { } } - if (autogl && !donegl && event.message.equals(autoglTrigger)) { + if (autogl && !donegl && event.originalMessage.equals(autoglTrigger)) { ticksUntilAutogl = 20; return; } - Matcher apiKeyMatcher = apiKeyMessageTrigger.matcher(event.message); + Matcher apiKeyMatcher = apiKeyMessageTrigger.matcher(event.originalMessage); if (apiKeyMatcher.matches()) { setApiKey(apiKeyMatcher.group(1)); } From 5ecbdd6956f1cba0d709675e839722348e77658a Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Thu, 9 Feb 2023 15:49:34 -0700 Subject: [PATCH 09/23] Refactor death messages --- .../hud/bedwarsoverlay/BedwarsDeathType.java | 20 + .../impl/hud/bedwarsoverlay/BedwarsGame.java | 361 ++++-------------- .../hud/bedwarsoverlay/BedwarsMessages.java | 282 ++++++++++++++ .../impl/hud/bedwarsoverlay/BedwarsMod.java | 2 +- .../hud/bedwarsoverlay/GameLogDisplay.java | 17 - .../bedwarsoverlay/upgrades/TeamUpgrade.java | 4 +- 6 files changed, 376 insertions(+), 310 deletions(-) create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java new file mode 100644 index 00000000..998ceeb5 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java @@ -0,0 +1,20 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +public enum BedwarsDeathType { + COMBAT("rekt"), + VOID("yeeted into void"), + PROJECTILE("shot"), + FALL("fall"), + GOLEM("golem moment"), + SELF_VOID("voided"), + SELF_UNKNOWN("died"), + ; + + @Getter + private final String inner; + +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index c8118d3e..820c3a81 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -14,246 +14,16 @@ import org.jetbrains.annotations.Nullable; import java.util.*; -import java.util.function.Consumer; import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; public class BedwarsGame { - private final static Pattern DISCONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) disconnected\\.$"); - private final static Pattern RECONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) reconnected\\.$"); - private final static Pattern FINAL_KILL = Pattern.compile("FINAL KILL!"); - private final static Pattern BED_DESTROY = Pattern.compile("^\\s*?BED DESTRUCTION > (\\w+) Bed"); - private final static Pattern TEAM_ELIMINATED = Pattern.compile("^\\s*?TEAM ELIMINATED > (\\w+) Team"); - - private final static Pattern GAME_END = Pattern.compile("^ +1st Killer - ?\\[?\\w*\\+*\\]? \\w+ - \\d+(?: Kills?)?$"); - - private final static Pattern[] DIED = { - Pattern.compile(formatPlaceholder("^{killed} fell into the void.(?: FINAL KILL!)?\\s*?")), - Pattern.compile(formatPlaceholder("^{killed} died.(?: FINAL KILL!)?\\s*?")) - }; - - private final static Pattern[] ANNOYING_MESSAGES = { - Pattern.compile("^You will respawn in \\d* seconds!$"), - Pattern.compile("^You purchased Wool$"), - Pattern.compile("^Cross-teaming is not allowed"), - Pattern.compile("^\\+\\d+ Coins!"), - Pattern.compile("^\\+\\d+ coins!"), - Pattern.compile("^Coins just earned DOUBLE"), - Pattern.compile("^\\+\\d+ Bed Wars Experience"), - Pattern.compile("^You have respawned"), - }; - - private final static Pattern[] BED_BREAK = { - Pattern.compile(formatPlaceholder("Bed was broken by {player}")), - Pattern.compile(formatPlaceholder("Bed was incinerated by {player}")), - Pattern.compile(formatPlaceholder("Bed was iced by {player}")), - Pattern.compile(formatPlaceholder("Bed had to raise the white flag to {player}")), - Pattern.compile(formatPlaceholder("Bed was dismantled by {player}")), - Pattern.compile(formatPlaceholder("Bed was deep fried by {player}")), - Pattern.compile(formatPlaceholder("Bed was ripped apart by {player}")), - Pattern.compile(formatPlaceholder("Bed was traded in for milk and cookies by {player}")), - Pattern.compile(formatPlaceholder("Bed was sacrificed by {player}")), - Pattern.compile(formatPlaceholder("Bed was gulped by {player}")), - Pattern.compile(formatPlaceholder("Bed was gulped by {player}")), - Pattern.compile(formatPlaceholder("Bed was squeaked apart by {player}")), - Pattern.compile(formatPlaceholder("Bed was stung by {player}")), - Pattern.compile(formatPlaceholder("Bed was impaled by {player}")), - Pattern.compile(formatPlaceholder("Bed be shot with cannon by {player}")), - Pattern.compile(formatPlaceholder("Bed got memed by {player}")), - Pattern.compile(formatPlaceholder("Bed was made into a snowman by {player}")), - Pattern.compile(formatPlaceholder("Bed was scrambled by {player}")), - Pattern.compile(formatPlaceholder("Bed was stuffed with tissue paper by {player}")), - Pattern.compile(formatPlaceholder("Bed was scrambled by {player}")), - Pattern.compile(formatPlaceholder("Bed was bed #{number} destroyed by {player}")), - Pattern.compile(formatPlaceholder("Bed was spooked by {player}")), - Pattern.compile(formatPlaceholder("Bed was dreadfully corrupted by {player}")), - Pattern.compile(formatPlaceholder("Bed was bed #{number} destroyed by {player}")), - Pattern.compile(formatPlaceholder("Bed exploded from a firework by {player}")), - Pattern.compile(formatPlaceholder("Bed was blasted to dust by {player}")), - Pattern.compile(formatPlaceholder("Bed was melted by {player}'s holiday spirit")), - Pattern.compile(formatPlaceholder("Bed was ripped to shreds by {player}")), - Pattern.compile(formatPlaceholder("Bed has left the game after seeing {player}")), - Pattern.compile(formatPlaceholder("Bed was spooked by {player}")), - Pattern.compile(formatPlaceholder("Bed was contaminated by {player}")), - Pattern.compile(formatPlaceholder("Bed was sold in a garage sale by {player}")), - }; - - private final static String[] KILLS = { - "{killed} was struck down by {player}.", - "{killed} was turned to dust by {player}.", - "{killed} was melted by {player}.", - "{killed} was turned to ash by {player}.", - "{killed} was fried by {player}'s Golem.", - "{killed} was filled full of lead by {player}.", - "{killed} met their end by {player}.", - "{killed} was killed with dynamite by {player}.", - "{killed} lost a drinking contest with {player}.", - "{killed} lost the draw to {player}'s Golem.", - "{killed} died in close combat to {player}.", - "{killed} fought to the edge with {player}.", - "{killed} fell to the great marksmanship of {player}.", - "{killed} stumbled off a ledge with help by {player}.", - "{killed} tangoed with {player}'s Golem.", - "{killed} was given the cold shoulder by {player}.", - "{killed} was hit off by a love bomb from {player}.", - "{killed} was struck with Cupid's arrow by {player}.", - "{killed} was out of the league of {player}.", - "{killed} was no match for {player}'s Golem.", - "{killed} was glazed in BBQ sauce by {player}.", - "{killed} slipped in BBQ sauce off the edge spilled by {player}.", - "{killed} was thrown chili powder at by {player}.", - "{killed} was not spicy enough for {player}.", - "{killed} was sliced up by {player}'s Golem.", - "{killed} was bitten by {player}.", - "{killed} howled into the void for {player}.", - "{killed} caught the ball thrown by {player}.", - "{killed} was distracted by a puppy placed by {player}.", - "{killed} played too rough with {player}'s Golem.", - "{killed} was wrapped into a gift by {player}.", - "{killed} hit the hard-wood floor because of {player}.", - "{killed} was put on the naughty list by {player}.", - "{killed} was pushed down a slope by {player}.", - "{killed} was turned to gingerbread by {player}'s Golem.", - "{killed} was hunted down by {player}.", - "{killed} stumbled on a trap set by {player}.", - "{killed} got skewered by {player}.", - "{killed} was thrown into a volcano by {player}.", - "{killed} was mauled by {player}'s Golem.", - "{killed} was oinked by {player}.", - "{killed} slipped into void for {player}.", - "{killed} got attacked by a carrot from {player}.", - "{killed} was distracted by a piglet from {player}.", - "{killed} was oinked by {player}'s Golem.", - "{killed} was chewed up by {player}.", - "{killed} was scared into the void by {player}.", - "{killed} stepped in a mouse trap placed by {player}.", - "{killed} was distracted by a rat dragging pizza from {player}.", - "{killed} squeaked around with {player}'s Golem.", - "{killed} was buzzed to death by {player}.", - "{killed} was bzzz'd into the void by {player}.", - "{killed} was startled by {player}.", - "{killed} was stung off the edge by {player}.", - "{killed} was bee'd by {player}'s Golem.", - "{killed} was trampled by {player}.", - "{killed} was back kicked into the void by {player}.", - "{killed} was impaled from a distance by {player}.", - "{killed} was headbutted off a cliff by {player}.", - "{killed} was trampled by {player}'s Golem.", - "{killed} be sent to Davy Jones' locker by {player}.", - "{killed} be cannonballed to death by {player}.", - "{killed} be shot and killed by {player}.", - "{killed} be killed with magic by {player}.", - "{killed} be killed with metal by {player}'s Golem.", - "{killed} got rekt by {player}.", - "{killed} took the L to {player}.", - "{killed} got smacked by {player}.", - "{killed} got roasted by {player}.", - "{killed} got bamboozled by {player}'s Golem.", - "{killed} was locked outside during a snow storm by {player}.", - "{killed} was pushed into a snowbank by {player}.", - "{killed} was hit with a snowball from {player}.", - "{killed} was shoved down an icy slope by {player}.", - "{killed} got snowed in by {player}'s Golem.", - "{killed} was painted pretty by {player}.", - "{killed} was deviled into the void by {player}.", - "{killed} slipped into a pan placed by {player}.", - "{killed} was flipped off the edge by {player}.", - "{killed} was made sunny side up by {player}'s Golem.", - "{killed} was wrapped up by {player}.", - "{killed} was tied into a bow by {player}.", - "{killed} was glued up by {player}.", - "{killed} tripped over a present placed by {player}.", - "{killed} was taped together by {player}'s Golem.", - "{killed} was stomped by {player}.", - "{killed} was {player}'s final #{number}.", - "{killed} was thrown down a pit by {player}.", - "{killed} was shot by {player}.", - "{killed} was thrown to the ground by {player}.", - "{killed} was outclassed by {player}'s Golem.", - "{killed} was spooked by {player}.", - "{killed} was spooked off the map by {player}.", - "{killed} was remotely spooked by {player}.", - "{killed} was totally spooked by {player}.", - "{killed} was spooked by {player}'s Golem.", - "{killed} was tragically backstabbed by {player}.", - "{killed} was heartlessly let go by {player}.", - "{killed}'s heart was pierced by {player}.", - "{killed} was delivered into nothingness by {player}.", - "{killed} was dismembered by {player}'s Golem.", - "{killed} was crushed by {player}.", - "{killed} was {player}'s final #5,794.", - "{killed} was dominated by {player}.", - "{killed} was assassinated by {player}.", - "{killed} was thrown off their high horse by {player}.", - "{killed} was degraded by {player}'s Golem.", - "{killed} was whacked with a party balloon by {player}.", - "{killed} was popped into the void by {player}.", - "{killed} was shot with a roman candle by {player}.", - "{killed} was launched like a firework by {player}.", - "{killed} was lit up by {player}'s Golem.", - "{killed} was crushed into moon dust by {player}.", - "{killed} was sent the wrong way by {player}.", - "{killed} was hit by an asteroid from {player}.", - "{killed} was blasted to the moon by {player}.", - "{killed} was blown up by {player}'s Golem.", - "{killed} was smothered in holiday cheer by {player}.", - "{killed} was banished into the ether by {player}'s holiday spirit.", - "{killed} was sniped by a missile of festivity by {player}.", - "{killed} was pushed by {player}'s holiday spirit.", - "{killed} was sung holiday tunes to by {player}'s Golem.", - "{killed} was ripped to shreds by {player}.", - "{killed} was charged by {player}.", - "{killed} was pounced on by {player}.", - "{killed} was ripped and thrown by {player}.", - "{killed} was ripped to shreds by {player}'s Golem.", - "{killed} was bested by {player}.", - "{killed} was {player}'s final #5,794.", - "{killed} was knocked into the void by {player}.", - "{killed} was shot by {player}.", - "{killed} was knocked off an edge by {player}.", - "{killed} was bested by {player}'s Golem.", - "{killed} had a small brain moment while fighting {player}.", - "{killed} was not able to block clutch against {player}.", - "{killed} got 360 no-scoped by {player}.", - "{killed} forgot how many blocks they had left while fighting {player}.", - "{killed} got absolutely destroyed by {player}'s Golem.", - "{killed} was too shy to meet {player}.", - "{killed} didn't distance themselves properly from {player}.", - "{killed} was coughed at by {player}.", - "{killed} tripped while trying to run away from {player}.", - "{killed} got too close to {player}'s Golem.", - "{killed} was yelled at by {player}.", - "{killed} was thrown off the lawn by {player}.", - "{killed} was accidentally spit on by {player}.", - "{killed} slipped on the fake teeth of {player}.", - "{killed} was chased away by {player}'s Golem.", - "{killed} was killed by {player}.", - "{killed} was knocked into the void by {player}." - }; - - private final static Pattern[] KILLS_COMPILED = new Pattern[KILLS.length]; - private BedwarsTeam won = null; private int wonTick = -1; - private int seconds = 0; private Text topBarText = new LiteralText(""); - private static String formatPlaceholder(String input) { - return input - .replace("{killed}", "(\\b[A-Za-z0-9_§]{3,16}\\b)") - .replace("{player}", "(\\b[A-Za-z0-9_§]{3,16}\\b)") - .replace("{number}", "[0-9,]+"); - } - - static { - for (int i = 0; i < KILLS.length; i++) { - String kill = KILLS[i]; - KILLS_COMPILED[i] = Pattern.compile(formatPlaceholder("^" + kill.replace(".", "\\.") + "(?: FINAL KILL!)?\\s*?")); - } - } private BedwarsPlayer me = null; @@ -341,12 +111,32 @@ private void debug(String message) { mc.inGameHud.getChatHud().addMessage(new LiteralText("§b§lINFO:§8 " + message)); } - private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, boolean finalDeath) { + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { player.died(); if (killer != null) { killer.killed(finalDeath); } - event.newMessage = mod.gameLog.died(player, killer, finalDeath); + event.newMessage = formatDeath(player, killer, type, finalDeath); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String time = "§7" + mod.getGame().get().getFormattedTime() + " "; + String inner = type.getInner(); + if (finalDeath) { + inner = "§6§b/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return time + playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + return time + playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); } public boolean isTeamEliminated(BedwarsTeam team) { @@ -355,52 +145,66 @@ public boolean isTeamEliminated(BedwarsTeam team) { public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { try { - if (matched(ANNOYING_MESSAGES, rawMessage).isPresent()) { + if (BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { event.cancelled = true; return; } - if (matched(DIED, rawMessage, m -> { - BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); - if (killed == null) { - debug("Player " + m.group(1) + " was not found"); - return; - } - died(event, killed, null, matched(FINAL_KILL, rawMessage).isPresent()); + if (BedwarsMessages.matched(BedwarsMessages.SELF_VOID, rawMessage, m -> { + died(m, rawMessage, event, BedwarsDeathType.SELF_VOID); })) { return; } - if (matched(KILLS_COMPILED, rawMessage, m -> { - BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); - BedwarsPlayer killer = getPlayer(m.group(2)).orElse(null); - if (killed == null) { - debug("Player " + m.group(1) + " was not found"); - return; - } - died(event, killed, killer, matched(FINAL_KILL, rawMessage).isPresent()); + if (BedwarsMessages.matched(BedwarsMessages.SELF_UNKNOWN, rawMessage, m -> { + died(m, rawMessage, event, BedwarsDeathType.SELF_UNKNOWN); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.COMBAT_KILL, rawMessage, m -> { + died(m, rawMessage, event, BedwarsDeathType.COMBAT); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.VOID_KILL, rawMessage, m -> { + died(m, rawMessage, event, BedwarsDeathType.VOID); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.PROJECTILE_KILL, rawMessage, m -> { + died(m, rawMessage, event, BedwarsDeathType.PROJECTILE); })) { return; } - if (matched(BED_DESTROY, rawMessage, m -> { - BedwarsPlayer player = matched(BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); + if (BedwarsMessages.matched(BedwarsMessages.FALL_KILL, rawMessage, m -> { + died(m, rawMessage, event, BedwarsDeathType.FALL); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.GOLEM_KILL, rawMessage, m -> { + died(m, rawMessage, event, BedwarsDeathType.GOLEM); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.BED_DESTROY, rawMessage, m -> { + BedwarsPlayer player = BedwarsMessages.matched(BedwarsMessages.BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); BedwarsTeam.fromName(m.group(1)).ifPresent(t -> bedDestroyed(t, player)); })) { return; } - if (matched(DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(this::disconnected))) { + if (BedwarsMessages.matched(BedwarsMessages.DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(this::disconnected))) { return; } - if (matched(RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(this::reconnected))) { + if (BedwarsMessages.matched(BedwarsMessages.RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(this::reconnected))) { return; } - if (matched(GAME_END, rawMessage, m -> { + if (BedwarsMessages.matched(BedwarsMessages.GAME_END, rawMessage, m -> { BedwarsTeam win = players.values().stream().filter(p -> !p.isFinalKilled()).findFirst().map(BedwarsPlayer::getTeam).orElse(null); this.won = win; this.wonTick = mc.inGameHud.getTicks() + 10; })) { return; } - if (matched(TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(this::teamEliminated))) { + if (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(this::teamEliminated))) { return; } upgrades.onMessage(rawMessage); @@ -409,6 +213,19 @@ public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { } } + private void died(Matcher m, String rawMessage, ReceiveChatMessageEvent event, BedwarsDeathType type) { + BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); + BedwarsPlayer killer = null; + if (type != BedwarsDeathType.SELF_UNKNOWN && type != BedwarsDeathType.SELF_VOID) { + killer = getPlayer(m.group(2)).orElse(null); + } + if (killed == null) { + debug("Player " + m.group(1) + " was not found"); + return; + } + died(event, killed, killer, type, BedwarsMessages.matched(BedwarsMessages.FINAL_KILL, rawMessage).isPresent()); + } + private void gameEnd(BedwarsTeam win) { if (me == null) { BedwarsMod.getInstance().gameEnd(); @@ -485,42 +302,6 @@ public void tick() { players.values().forEach(p -> p.tick(currentTick)); } - public static boolean matched(Pattern pattern, String input, Consumer consumer) { - Optional matcher = matched(pattern, input); - if (!matcher.isPresent()) { - return false; - } - consumer.accept(matcher.get()); - return true; - } - - public static boolean matched(Pattern[] pattern, String input, Consumer consumer) { - Optional matcher = matched(pattern, input); - if (!matcher.isPresent()) { - return false; - } - consumer.accept(matcher.get()); - return true; - } - - public static Optional matched(Pattern[] pattern, String input) { - for (Pattern p : pattern) { - Optional m = matched(p, input); - if (m.isPresent()) { - return m; - } - } - return Optional.empty(); - } - - public static Optional matched(Pattern pattern, String input) { - Matcher matcher = pattern.matcher(input); - if (matcher.find()) { - return Optional.of(matcher); - } - return Optional.empty(); - } - public void updateEntries(List entries) { // Update latencies and other information for entries entries.forEach(entry -> diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java new file mode 100644 index 00000000..4770cf9f --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java @@ -0,0 +1,282 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + +import java.util.Arrays; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class BedwarsMessages { + + public final static Pattern[] COMBAT_KILL = convert( + "{killed} was struck down by {player}.", + "{killed} was filled full of lead by {player}.", + "{killed} died in close combat to {player}.", + "{killed} was given the cold shoulder by {player}.", + "{killed} was glazed in BBQ sauce by {player}.", + "{killed} was bitten by {player}.", + "{killed} was wrapped into a gift by {player}.", + "{killed} was hunted down by {player}.", + "{killed} was oinked by {player}.", + "{killed} was chewed up by {player}.", + "{killed} was buzzed to death by {player}.", + "{killed} was trampled by {player}.", + "{killed} be sent to Davy Jones' locker by {player}.", + "{killed} got rekt by {player}.", + "{killed} was locked outside during a snow storm by {player}.", + "{killed} was painted pretty by {player}.", + "{killed} was wrapped up by {player}.", + "{killed} was stomped by {player}.", + "{killed} was {player}'s final #{number}", + "{killed} was spooked by {player}.", + "{killed} was tragically backstabbed by {player}.", + "{killed} was crushed by {player}.", + "{killed} was {player}'s final #{number}.", + "{killed} was whacked with a party balloon by {player}.", + "{killed} was crushed into moon dust by {player}.", + "{killed} was smothered in holiday cheer by {player}.", + "{killed} was ripped to shreds by {player}.", + "{killed} was bested by {player}.", + "{killed} was {player}'s final #{number}.", + "{killed} had a small brain moment while fighting {player}.", + "{killed} was too shy to meet {player}.", + "{killed} was yelled at by {player}.", + "{killed} was killed by {player}." + ); + + public final static Pattern[] VOID_KILL = convert( + "{killed} was turned to dust by {player}.", + "{killed} met their end by {player}.", + "{killed} fought to the edge with {player}.", + "{killed} was hit off by a love bomb from {player}.", + "{killed} slipped in BBQ sauce off the edge spilled by {player}.", + "{killed} howled into the void for {player}.", + "{killed} hit the hard-wood floor because of {player}.", + "{killed} stumbled on a trap set by {player}.", + "{killed} slipped into void for {player}.", + "{killed} was scared into the void by {player}.", + "{killed} was bzzz'd into the void by {player}.", + "{killed} was back kicked into the void by {player}.", + "{killed} be cannonballed to death by {player}.", + "{killed} took the L to {player}.", + "{killed} was pushed into a snowbank by {player}.", + "{killed} was deviled into the void by {player}.", + "{killed} was tied into a bow by {player}.", + "{killed} was thrown down a pit by {player}.", + "{killed} was spooked off the map by {player}.", + "{killed} was heartlessly let go by {player}.", + "{killed} was dominated by {player}.", + "{killed} was popped into the void by {player}.", + "{killed} was sent the wrong way by {player}.", + "{killed} was banished into the ether by {player}'s holiday spirit.", + "{killed} was charged by {player}.", + "{killed} was knocked into the void by {player}.", + "{killed} was not able to block clutch against {player}.", + "{killed} didn't distance themselves properly from {player}.", + "{killed} was thrown off the lawn by {player}.", + "{killed} was turned to dust by {player}." + ); + + public final static Pattern[] PROJECTILE_KILL = convert( + "{killed} was melted by {player}.", + "{killed} was killed with dynamite by {player}.", + "{killed} fell to the great marksmanship of {player}.", + "{killed} was struck with Cupid's arrow by {player}.", + "{killed} was thrown chili powder at by {player}.", + "{killed} caught the ball thrown by {player}.", + "{killed} was put on the naughty list by {player}.", + "{killed} got skewered by {player}.", + "{killed} got attacked by a carrot from {player}.", + "{killed} stepped in a mouse trap placed by {player}.", + "{killed} was startled by {player}.", + "{killed} was impaled from a distance by {player}.", + "{killed} be shot and killed by {player}.", + "{killed} got smacked by {player}.", + "{killed} was hit with a snowball from {player}.", + "{killed} slipped into a pan placed by {player}.", + "{killed} was glued up by {player}.", + "{killed} was shot by {player}.", + "{killed} was remotely spooked by {player}.", + "{killed}'s heart was pierced by {player}.", + "{killed} was assassinated by {player}.", + "{killed} was shot with a roman candle by {player}.", + "{killed} was hit by an asteroid from {player}.", + "{killed} was sniped by a missile of festivity by {player}.", + "{killed} was pounced on by {player}.", + "{killed} was shot by {player}.", + "{killed} got 360 no-scoped by {player}.", + "{killed} was coughed at by {player}.", + "{killed} was accidentally spit on by {player}." + ); + + public final static Pattern[] FALL_KILL = convert( + "{killed} was turned to ash by {player}.", + "{killed} lost a drinking contest with {player}.", + "{killed} stumbled off a ledge with help by {player}.", + "{killed} was out of the league of {player}.", + "{killed} was not spicy enough for {player}.", + "{killed} was distracted by a puppy placed by {player}.", + "{killed} was pushed down a slope by {player}.", + "{killed} was thrown into a volcano by {player}.", + "{killed} was distracted by a piglet from {player}.", + "{killed} was distracted by a rat dragging pizza from {player}.", + "{killed} was stung off the edge by {player}.", + "{killed} was headbutted off a cliff by {player}.", + "{killed} be killed with magic by {player}.", + "{killed} got roasted by {player}.", + "{killed} was shoved down an icy slope by {player}.", + "{killed} was flipped off the edge by {player}.", + "{killed} tripped over a present placed by {player}.", + "{killed} was thrown to the ground by {player}.", + "{killed} was totally spooked by {player}.", + "{killed} was delivered into nothingness by {player}.", + "{killed} was thrown off their high horse by {player}.", + "{killed} was launched like a firework by {player}.", + "{killed} was blasted to the moon by {player}.", + "{killed} was pushed by {player}'s holiday spirit.", + "{killed} was ripped and thrown by {player}.", + "{killed} was knocked off an edge by {player}.", + "{killed} forgot how many blocks they had left while fighting {player}.", + "{killed} tripped while trying to run away from {player}.", + "{killed} slipped on the fake teeth of {player}.", + "{killed} was knocked into the void by {player}." + ); + + public final static Pattern[] GOLEM_KILL = convert( + "{killed} was fried by {player}'s Golem.", + "{killed} lost the draw to {player}'s Golem.", + "{killed} tangoed with {player}'s Golem.", + "{killed} was no match for {player}'s Golem.", + "{killed} was sliced up by {player}'s Golem.", + "{killed} played too rough with {player}'s Golem.", + "{killed} was turned to gingerbread by {player}'s Golem.", + "{killed} was mauled by {player}'s Golem.", + "{killed} was oinked by {player}'s Golem.", + "{killed} squeaked around with {player}'s Golem.", + "{killed} was bee'd by {player}'s Golem.", + "{killed} was trampled by {player}'s Golem.", + "{killed} be killed with metal by {player}'s Golem.", + "{killed} got bamboozled by {player}'s Golem.", + "{killed} got snowed in by {player}'s Golem.", + "{killed} was made sunny side up by {player}'s Golem.", + "{killed} was taped together by {player}'s Golem.", + "{killed} was outclassed by {player}'s Golem.", + "{killed} was spooked by {player}'s Golem.", + "{killed} was dismembered by {player}'s Golem.", + "{killed} was degraded by {player}'s Golem.", + "{killed} was lit up by {player}'s Golem.", + "{killed} was blown up by {player}'s Golem.", + "{killed} was sung holiday tunes to by {player}'s Golem.", + "{killed} was ripped to shreds by {player}'s Golem.", + "{killed} was bested by {player}'s Golem.", + "{killed} got absolutely destroyed by {player}'s Golem.", + "{killed} got too close to {player}'s Golem.", + "{killed} was chased away by {player}'s Golem." + ); + + public final static Pattern[] BED_BREAK = { + Pattern.compile(formatPlaceholder("Bed was broken by {player}")), + Pattern.compile(formatPlaceholder("Bed was incinerated by {player}")), + Pattern.compile(formatPlaceholder("Bed was iced by {player}")), + Pattern.compile(formatPlaceholder("Bed had to raise the white flag to {player}")), + Pattern.compile(formatPlaceholder("Bed was dismantled by {player}")), + Pattern.compile(formatPlaceholder("Bed was deep fried by {player}")), + Pattern.compile(formatPlaceholder("Bed was ripped apart by {player}")), + Pattern.compile(formatPlaceholder("Bed was traded in for milk and cookies by {player}")), + Pattern.compile(formatPlaceholder("Bed was sacrificed by {player}")), + Pattern.compile(formatPlaceholder("Bed was gulped by {player}")), + Pattern.compile(formatPlaceholder("Bed was gulped by {player}")), + Pattern.compile(formatPlaceholder("Bed was squeaked apart by {player}")), + Pattern.compile(formatPlaceholder("Bed was stung by {player}")), + Pattern.compile(formatPlaceholder("Bed was impaled by {player}")), + Pattern.compile(formatPlaceholder("Bed be shot with cannon by {player}")), + Pattern.compile(formatPlaceholder("Bed got memed by {player}")), + Pattern.compile(formatPlaceholder("Bed was made into a snowman by {player}")), + Pattern.compile(formatPlaceholder("Bed was scrambled by {player}")), + Pattern.compile(formatPlaceholder("Bed was stuffed with tissue paper by {player}")), + Pattern.compile(formatPlaceholder("Bed was scrambled by {player}")), + Pattern.compile(formatPlaceholder("Bed was bed #{number} destroyed by {player}")), + Pattern.compile(formatPlaceholder("Bed was spooked by {player}")), + Pattern.compile(formatPlaceholder("Bed was dreadfully corrupted by {player}")), + Pattern.compile(formatPlaceholder("Bed was bed #{number} destroyed by {player}")), + Pattern.compile(formatPlaceholder("Bed exploded from a firework by {player}")), + Pattern.compile(formatPlaceholder("Bed was blasted to dust by {player}")), + Pattern.compile(formatPlaceholder("Bed was melted by {player}'s holiday spirit")), + Pattern.compile(formatPlaceholder("Bed was ripped to shreds by {player}")), + Pattern.compile(formatPlaceholder("Bed has left the game after seeing {player}")), + Pattern.compile(formatPlaceholder("Bed was spooked by {player}")), + Pattern.compile(formatPlaceholder("Bed was contaminated by {player}")), + Pattern.compile(formatPlaceholder("Bed was sold in a garage sale by {player}")), + }; + + public final static Pattern DISCONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) disconnected\\.$"); + public final static Pattern RECONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) reconnected\\.$"); + public final static Pattern FINAL_KILL = Pattern.compile("FINAL KILL!"); + public final static Pattern BED_DESTROY = Pattern.compile("^\\s*?BED DESTRUCTION > (\\w+) Bed"); + public final static Pattern TEAM_ELIMINATED = Pattern.compile("^\\s*?TEAM ELIMINATED > (\\w+) Team"); + + public final static Pattern GAME_END = Pattern.compile("^ +1st Killer - ?\\[?\\w*\\+*\\]? \\w+ - \\d+(?: Kills?)?$"); + + public final static Pattern SELF_VOID = Pattern.compile(formatPlaceholder("^{killed} fell into the void.(?: FINAL KILL!)?\\s*?")); + public final static Pattern SELF_UNKNOWN = Pattern.compile(formatPlaceholder("^{killed} died.(?: FINAL KILL!)?\\s*?")); + + public final static Pattern[] ANNOYING_MESSAGES = { + Pattern.compile("^You will respawn in \\d* seconds!$"), + Pattern.compile("^You purchased Wool$"), + Pattern.compile("^Cross-teaming is not allowed"), + Pattern.compile("^\\+\\d+ Coins!"), + Pattern.compile("^\\+\\d+ coins!"), + Pattern.compile("^Coins just earned DOUBLE"), + Pattern.compile("^\\+\\d+ Bed Wars Experience"), + Pattern.compile("^You have respawned"), + }; + + private static Pattern[] convert(String... input) { + return Arrays.stream(input).map(str -> Pattern.compile("^" + formatPlaceholder(str) + "(?: FINAL KILL!)?\\s*?")).toArray(Pattern[]::new); + } + + private static String formatPlaceholder(String input) { + return input + .replace("{killed}", "(\\b[A-Za-z0-9_§]{3,16}\\b)") + .replace("{player}", "(\\b[A-Za-z0-9_§]{3,16}\\b)") + .replace("{number}", "[0-9,]+"); + } + + public static boolean matched(Pattern pattern, String input, Consumer consumer) { + Optional matcher = matched(pattern, input); + if (!matcher.isPresent()) { + return false; + } + consumer.accept(matcher.get()); + return true; + } + + public static boolean matched(Pattern[] pattern, String input, Consumer consumer) { + Optional matcher = matched(pattern, input); + if (!matcher.isPresent()) { + return false; + } + consumer.accept(matcher.get()); + return true; + } + + public static Optional matched(Pattern[] pattern, String input) { + for (Pattern p : pattern) { + Optional m = matched(p, input); + if (m.isPresent()) { + return m; + } + } + return Optional.empty(); + } + + public static Optional matched(Pattern pattern, String input) { + Matcher matcher = pattern.matcher(input); + if (matcher.find()) { + return Optional.of(matcher); + } + return Optional.empty(); + } + + +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java index 5feb90e5..fe794061 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -41,7 +41,7 @@ public void onMessage(ReceiveChatMessageEvent event) { String rawMessage = event.originalMessage.replaceAll("§.", ""); if (currentGame != null) { currentGame.onChatMessage(rawMessage, event); - } else if (targetTick < 0 && BedwarsGame.matched(GAME_START, rawMessage).isPresent()) { + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { // Give time for Hypixel to sync targetTick = mc.inGameHud.getTicks() + 10; } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java index 171fa804..b0558bee 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java @@ -118,23 +118,6 @@ public void push(String content) { } } - public String died(BedwarsPlayer player, @Nullable BedwarsPlayer killer, boolean finaled) { - String time = "§7" + mod.getGame().get().getFormattedTime() + " "; - if (killer == null) { - return time + getPlayerFormatted(player) + " §7/death/"; - } else { - if (finaled && killer.getStats() != null) { - return time + getPlayerFormatted(player) + " §6§n/FINAL/§r " + getPlayerFormatted(killer) + " §b#" + killer.getStats().getFinalKills(); - } else { - return time + getPlayerFormatted(player) + " §7/death/ " + getPlayerFormatted(killer); - } - } - } - - private String getPlayerFormatted(BedwarsPlayer player) { - return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); - } - private String format(String name) { if (name.length() >= maxNameLength) { return name; diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java index cd35d622..53cf4566 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java @@ -1,6 +1,6 @@ package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; -import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsGame; +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMessages; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; import java.util.regex.Matcher; @@ -20,7 +20,7 @@ public TeamUpgrade(String name, Pattern[] pattern) { } public boolean match(String unformatedMessage) { - return BedwarsGame.matched(regex, unformatedMessage, matcher -> onMatch(this, matcher)); + return BedwarsMessages.matched(regex, unformatedMessage, matcher -> onMatch(this, matcher)); } protected abstract void onMatch(TeamUpgrade upgrade, Matcher matcher); From a753bb5b14f5dcc7c400fe3e89ea32f2fd350ad6 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Fri, 10 Feb 2023 20:50:51 -0700 Subject: [PATCH 10/23] Add Team Upgrades Overlay --- .../event/impl/ReceiveChatMessageEvent.java | 4 +- .../client/ClientPlayNetworkHandlerMixin.java | 6 +- .../client/mixin/mod/SCReplayModMixins.java | 2 +- .../hud/bedwarsoverlay/BedwarsDeathType.java | 35 ++++- .../impl/hud/bedwarsoverlay/BedwarsGame.java | 96 ++++++------ .../hud/bedwarsoverlay/BedwarsMessages.java | 3 + .../impl/hud/bedwarsoverlay/BedwarsMod.java | 43 ++++-- .../impl/hud/bedwarsoverlay/BedwarsTeam.java | 5 + .../hud/bedwarsoverlay/GameLogDisplay.java | 140 ------------------ .../bedwarsoverlay/TeamUpgradesOverlay.java | 84 +++++++++++ .../upgrades/BedwarsTeamUpgrades.java | 10 +- .../upgrades/BinaryUpgrade.java | 6 +- .../bedwarsoverlay/upgrades/TeamUpgrade.java | 13 +- .../upgrades/TieredUpgrade.java | 8 +- .../bedwarsoverlay/upgrades/TrapUpgrade.java | 35 ++++- .../assets/sol_client/lang/en_US.lang | 1 + .../textures/bedwars/dragonbuff_0.png | Bin 0 -> 291 bytes .../textures/bedwars/dragonbuff_1.png | Bin 0 -> 291 bytes .../sol_client/textures/bedwars/forge_0.png | Bin 0 -> 255 bytes .../sol_client/textures/bedwars/forge_1.png | Bin 0 -> 255 bytes .../sol_client/textures/bedwars/forge_2.png | Bin 0 -> 255 bytes .../sol_client/textures/bedwars/forge_3.png | Bin 0 -> 255 bytes .../sol_client/textures/bedwars/forge_4.png | Bin 0 -> 255 bytes .../sol_client/textures/bedwars/haste_0.png | Bin 0 -> 269 bytes .../sol_client/textures/bedwars/haste_1.png | Bin 0 -> 269 bytes .../sol_client/textures/bedwars/haste_2.png | Bin 0 -> 269 bytes .../textures/bedwars/healpool_0.png | Bin 0 -> 223 bytes .../textures/bedwars/healpool_1.png | Bin 0 -> 223 bytes .../sol_client/textures/bedwars/prot_0.png | Bin 0 -> 245 bytes .../sol_client/textures/bedwars/prot_1.png | Bin 0 -> 266 bytes .../sol_client/textures/bedwars/prot_2.png | Bin 0 -> 272 bytes .../sol_client/textures/bedwars/prot_3.png | Bin 0 -> 264 bytes .../sol_client/textures/bedwars/prot_4.png | Bin 0 -> 245 bytes .../sol_client/textures/bedwars/sharp_0.png | Bin 0 -> 255 bytes .../sol_client/textures/bedwars/sharp_1.png | Bin 0 -> 255 bytes .../textures/bedwars/trap/alarm.png | Bin 0 -> 293 bytes .../bedwars/trap/counteroffensive.png | Bin 0 -> 304 bytes .../textures/bedwars/trap/empty.png | Bin 0 -> 228 bytes .../textures/bedwars/trap/itsatrap.png | Bin 0 -> 312 bytes .../sol_client/textures/bedwars/trap/menu.png | Bin 0 -> 277 bytes .../textures/bedwars/trap/minerfatigue.png | Bin 0 -> 265 bytes 41 files changed, 257 insertions(+), 234 deletions(-) delete mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java create mode 100644 wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/dragonbuff_0.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/dragonbuff_1.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_0.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_1.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_2.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_3.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_4.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/haste_0.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/haste_1.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/haste_2.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/healpool_0.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/healpool_1.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_0.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_1.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_2.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_3.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_4.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/sharp_0.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/sharp_1.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/alarm.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/counteroffensive.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/empty.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/itsatrap.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/menu.png create mode 100644 wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/minerfatigue.png diff --git a/wrapper/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java b/wrapper/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java index 68678fce..4169d4bf 100644 --- a/wrapper/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java +++ b/wrapper/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java @@ -1,17 +1,19 @@ package io.github.solclient.client.event.impl; import lombok.RequiredArgsConstructor; +import net.minecraft.text.Text; @RequiredArgsConstructor public class ReceiveChatMessageEvent { public final boolean actionBar; public final String originalMessage; + public final Text formattedMessage; /** * Whether the event is fired from the replay mod. */ public final boolean replay; public boolean cancelled; - public String newMessage = null; + public Text newMessage = null; } diff --git a/wrapper/src/main/java/io/github/solclient/client/mixin/client/ClientPlayNetworkHandlerMixin.java b/wrapper/src/main/java/io/github/solclient/client/mixin/client/ClientPlayNetworkHandlerMixin.java index 8ecb8337..b54e1735 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mixin/client/ClientPlayNetworkHandlerMixin.java +++ b/wrapper/src/main/java/io/github/solclient/client/mixin/client/ClientPlayNetworkHandlerMixin.java @@ -39,10 +39,10 @@ public void handleEntityStatus(EntityStatusS2CPacket packet, CallbackInfo callba @Redirect(method = "onChatMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;)V")) public void handleChat(ChatHud instance, Text message) { - ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, Formatting.strip(message.asUnformattedString()), false); + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, Formatting.strip(message.asUnformattedString()), message, false); if (!Client.INSTANCE.getEvents().post(event).cancelled) { if (event.newMessage != null) { - instance.addMessage(new LiteralText(event.newMessage)); + instance.addMessage(event.newMessage); } else { instance.addMessage(message); } @@ -52,7 +52,7 @@ public void handleChat(ChatHud instance, Text message) { @Redirect(method = "onChatMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;setOverlayMessage(Lnet/minecraft/text/Text;Z)V")) public void handleActionBar(InGameHud instance, Text text, boolean tinted) { if (!Client.INSTANCE.getEvents().post( - new ReceiveChatMessageEvent(true, Formatting.strip(text.asUnformattedString()), false)).cancelled) { + new ReceiveChatMessageEvent(true, Formatting.strip(text.asUnformattedString()), text, false)).cancelled) { instance.setOverlayMessage(text, tinted); } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mixin/mod/SCReplayModMixins.java b/wrapper/src/main/java/io/github/solclient/client/mixin/mod/SCReplayModMixins.java index 2cceb3fa..8a8b3d0c 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mixin/mod/SCReplayModMixins.java +++ b/wrapper/src/main/java/io/github/solclient/client/mixin/mod/SCReplayModMixins.java @@ -280,7 +280,7 @@ public void handleChat(Packet packet, CallbackInfo callback) { .strip(((ChatMessageS2CPacket) packet).getMessage().asUnformattedString()); if (Client.INSTANCE.getEvents().post(new ReceiveChatMessageEvent( - ((ChatMessageS2CPacket) packet).getType() == 2, messageString, true)).cancelled) + ((ChatMessageS2CPacket) packet).getType() == 2, messageString, ((ChatMessageS2CPacket) packet).getMessage(), true)).cancelled) callback.cancel(); } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java index 998ceeb5..94088e20 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java @@ -3,18 +3,39 @@ import lombok.AllArgsConstructor; import lombok.Getter; +import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + @AllArgsConstructor public enum BedwarsDeathType { - COMBAT("rekt"), - VOID("yeeted into void"), - PROJECTILE("shot"), - FALL("fall"), - GOLEM("golem moment"), - SELF_VOID("voided"), - SELF_UNKNOWN("died"), + COMBAT("rekt", BedwarsMessages.COMBAT_KILL), + VOID("yeeted into void", BedwarsMessages.VOID_KILL), + PROJECTILE("shot", BedwarsMessages.PROJECTILE_KILL), + FALL("fall", BedwarsMessages.FALL_KILL), + GOLEM("golem moment", BedwarsMessages.GOLEM_KILL), + SELF_VOID("voided", new Pattern[]{BedwarsMessages.SELF_VOID}), + SELF_UNKNOWN("died", new Pattern[]{BedwarsMessages.SELF_UNKNOWN}), ; @Getter private final String inner; + @Getter + private final Pattern[] patterns; + + public static boolean getDeath(String rawMessage, BedwarsDeathMatch ifPresent) { + for (BedwarsDeathType type : values()) { + if (BedwarsMessages.matched(type.getPatterns(), rawMessage, m -> ifPresent.onMatch(type, m))) { + return true; + } + } + return false; + } + + public interface BedwarsDeathMatch { + + void onMatch(BedwarsDeathType type, Matcher matcher); + + } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index 820c3a81..de46a908 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -44,9 +44,9 @@ public BedwarsGame(BedwarsMod mod) { public void onStart() { debug("Game started"); + mod.upgradesOverlay.onStart(upgrades); players.clear(); Map> teamPlayers = new HashMap<>(); - int maxLength = 1; for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { String name = mc.inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); if (name.charAt(1) != ' ') { @@ -72,14 +72,12 @@ public void onStart() { for (int i = 0; i < value.size(); i++) { PlayerListEntry e = value.get(i); BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); - maxLength = Math.max(e.getProfile().getName().length(), maxLength); if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { me = p; } players.put(e.getProfile().getName(), p); } } - mod.gameLog.gameStart(maxLength); this.started = true; } @@ -116,23 +114,44 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if (killer != null) { killer.killed(finalDeath); } - event.newMessage = formatDeath(player, killer, type, finalDeath); + event.newMessage = new LiteralText(formatDeath(player, killer, type, finalDeath)); + } + + private String formatDisconnect(BedwarsPlayer disconnected) { + String playerFormatted = getPlayerFormatted(disconnected); + return playerFormatted + " §7§o/disconnected/"; + } + + private String formatReconnect(BedwarsPlayer reconnected) { + String playerFormatted = getPlayerFormatted(reconnected); + return playerFormatted + " §7§o/reconnected/"; + } + + private String formatEliminated(BedwarsTeam team) { + return "§6§l§oTEAM ELMINATED §8§l> " + team.getColorSection() + team.getName() + " Team §7/eliminated/ "; + } + + private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { + String playerFormatted = getPlayerFormatted(breaker); + return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted; } private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - String time = "§7" + mod.getGame().get().getFormattedTime() + " "; String inner = type.getInner(); if (finalDeath) { - inner = "§6§b/" + inner.toUpperCase(Locale.ROOT) + "/"; + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; } else { inner = "§7/" + inner + "/"; } String playerFormatted = getPlayerFormatted(player); if (killer == null) { - return time + playerFormatted + " " + inner; + return playerFormatted + " " + inner; } String killerFormatted = getPlayerFormatted(killer); - return time + playerFormatted + " " + inner + " " + killerFormatted; + if (finalDeath && killer.getStats() != null) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; } private String getPlayerFormatted(BedwarsPlayer player) { @@ -149,52 +168,22 @@ public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { event.cancelled = true; return; } - if (BedwarsMessages.matched(BedwarsMessages.SELF_VOID, rawMessage, m -> { - died(m, rawMessage, event, BedwarsDeathType.SELF_VOID); - })) { - return; - } - if (BedwarsMessages.matched(BedwarsMessages.SELF_UNKNOWN, rawMessage, m -> { - died(m, rawMessage, event, BedwarsDeathType.SELF_UNKNOWN); - })) { - return; - } - if (BedwarsMessages.matched(BedwarsMessages.COMBAT_KILL, rawMessage, m -> { - died(m, rawMessage, event, BedwarsDeathType.COMBAT); - })) { - return; - } - if (BedwarsMessages.matched(BedwarsMessages.VOID_KILL, rawMessage, m -> { - died(m, rawMessage, event, BedwarsDeathType.VOID); - })) { - return; - } - if (BedwarsMessages.matched(BedwarsMessages.PROJECTILE_KILL, rawMessage, m -> { - died(m, rawMessage, event, BedwarsDeathType.PROJECTILE); - })) { - return; - } - if (BedwarsMessages.matched(BedwarsMessages.FALL_KILL, rawMessage, m -> { - died(m, rawMessage, event, BedwarsDeathType.FALL); - })) { - return; - } - if (BedwarsMessages.matched(BedwarsMessages.GOLEM_KILL, rawMessage, m -> { - died(m, rawMessage, event, BedwarsDeathType.GOLEM); + if (BedwarsDeathType.getDeath(rawMessage, (type, m) -> { + died(m, rawMessage, event, type); })) { return; } if (BedwarsMessages.matched(BedwarsMessages.BED_DESTROY, rawMessage, m -> { BedwarsPlayer player = BedwarsMessages.matched(BedwarsMessages.BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); - BedwarsTeam.fromName(m.group(1)).ifPresent(t -> bedDestroyed(t, player)); - + BedwarsTeam team = BedwarsTeam.fromName(m.group(1)).orElse(me.getTeam()); + bedDestroyed(event, team, player); })) { return; } - if (BedwarsMessages.matched(BedwarsMessages.DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(this::disconnected))) { + if (BedwarsMessages.matched(BedwarsMessages.DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> disconnected(event, p)))) { return; } - if (BedwarsMessages.matched(BedwarsMessages.RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(this::reconnected))) { + if (BedwarsMessages.matched(BedwarsMessages.RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> reconnected(event, p)))) { return; } if (BedwarsMessages.matched(BedwarsMessages.GAME_END, rawMessage, m -> { @@ -204,7 +193,7 @@ public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { })) { return; } - if (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(this::teamEliminated))) { + if (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { return; } upgrades.onMessage(rawMessage); @@ -233,32 +222,37 @@ private void gameEnd(BedwarsTeam win) { } for (BedwarsPlayer p : players.values()) { - if (p.getStats() != null) { - mc.inGameHud.getChatHud().addMessage(new LiteralText(p.getProfile().getProfile().getName() + " - " + p.getStats().getWinstreak())); + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + mc.inGameHud.getChatHud().addMessage(new LiteralText(getPlayerFormatted(p) + " - " + p.getStats().getWinstreak())); } } BedwarsMod.getInstance().gameEnd(); } - private void teamEliminated(BedwarsTeam team) { + private void teamEliminated(ReceiveChatMessageEvent event, BedwarsTeam team) { // Make sure everyone is dead, just in case players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> { b.setBed(false); b.died(); }); + event.newMessage = new LiteralText(formatEliminated(team)); } - private void bedDestroyed(BedwarsTeam team, @Nullable BedwarsPlayer breaker) { + private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Nullable BedwarsPlayer breaker) { players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); + event.newMessage = new LiteralText(formatBed(team, breaker)); } - private void disconnected(BedwarsPlayer player) { + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { player.disconnected(); + event.newMessage = new LiteralText(formatDisconnect(player)); } - private void reconnected(BedwarsPlayer player) { + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { player.reconnected(); + event.newMessage = new LiteralText(formatDisconnect(player)); } public void onScoreboardRender(ScoreboardRenderEvent event) { diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java index 4770cf9f..377b978e 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java @@ -136,6 +136,7 @@ public class BedwarsMessages { "{killed} was pushed by {player}'s holiday spirit.", "{killed} was ripped and thrown by {player}.", "{killed} was knocked off an edge by {player}.", + "{killed} was knocked off a cliff by {player}.", "{killed} forgot how many blocks they had left while fighting {player}.", "{killed} tripped while trying to run away from {player}.", "{killed} slipped on the fake teeth of {player}.", @@ -207,6 +208,7 @@ public class BedwarsMessages { Pattern.compile(formatPlaceholder("Bed was spooked by {player}")), Pattern.compile(formatPlaceholder("Bed was contaminated by {player}")), Pattern.compile(formatPlaceholder("Bed was sold in a garage sale by {player}")), + Pattern.compile(formatPlaceholder("Bed was destroyed by {player}")), }; public final static Pattern DISCONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) disconnected\\.$"); @@ -222,6 +224,7 @@ public class BedwarsMessages { public final static Pattern[] ANNOYING_MESSAGES = { Pattern.compile("^You will respawn in \\d* seconds!$"), + Pattern.compile("^You will respawn in \\d* second!$"), Pattern.compile("^You purchased Wool$"), Pattern.compile("^Cross-teaming is not allowed"), Pattern.compile("^\\+\\d+ Coins!"), diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java index fe794061..691935f0 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -8,6 +8,8 @@ import io.github.solclient.client.mod.hud.HudElement; import io.github.solclient.client.mod.impl.SolClientMod; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.text.LiteralText; import java.util.*; @@ -28,11 +30,16 @@ public static BedwarsMod getInstance() { } protected BedwarsGame currentGame = null; - protected final GameLogDisplay gameLog; + protected final TeamUpgradesOverlay upgradesOverlay; private int targetTick = -1; private BedwarsMod() { - gameLog = new GameLogDisplay(this); + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + @Override + public String getDetail() { + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + " " + I18n.translate("sol_client.mod.screen.textues_by", "Sybillian"); } @EventHandler @@ -41,6 +48,15 @@ public void onMessage(ReceiveChatMessageEvent event) { String rawMessage = event.originalMessage.replaceAll("§.", ""); if (currentGame != null) { currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + " "; + if (!event.cancelled) { + // Add time to every message received in game + if (event.newMessage != null) { + event.newMessage = new LiteralText(time).append(event.newMessage); + } else { + event.newMessage = new LiteralText(time).append(event.formattedMessage); + } + } } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { // Give time for Hypixel to sync targetTick = mc.inGameHud.getTicks() + 10; @@ -59,15 +75,7 @@ public void onTick(PreTickEvent event) { mc.inGameHud.getPlayerListWidget().setHeader(null); currentGame.tick(); } else { - boolean ready = false; - for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { - String name = mc.inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); - if (name.charAt(1) == ' ') { - ready = true; - break; - } - } - if (ready) { + if (checkReady()) { currentGame.onStart(); } } @@ -79,9 +87,19 @@ public void onTick(PreTickEvent event) { } } + private boolean checkReady() { + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + @Override public List getHudElements() { - return Arrays.asList(gameLog); + return Arrays.asList(upgradesOverlay); } @Override @@ -106,6 +124,7 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { } public void gameEnd() { + upgradesOverlay.onEnd(); currentGame = null; } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java index 6fc9780f..e2035a62 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java @@ -4,6 +4,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; +import java.util.Locale; import java.util.Optional; @@ -47,4 +48,8 @@ public static Optional fromName(String name) { return Optional.empty(); } + public String getName() { + return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); + } + } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java deleted file mode 100644 index b0558bee..00000000 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/GameLogDisplay.java +++ /dev/null @@ -1,140 +0,0 @@ -package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; - -import com.mojang.blaze3d.platform.GlStateManager; -import io.github.solclient.client.mod.Mod; -import io.github.solclient.client.mod.hud.HudElement; -import io.github.solclient.client.util.data.Colour; -import io.github.solclient.client.util.data.Position; -import io.github.solclient.client.util.data.Rectangle; -import lombok.Value; -import net.minecraft.client.MinecraftClient; -import net.minecraft.text.LiteralText; -import net.minecraft.text.Text; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class GameLogDisplay implements HudElement { - - private final BedwarsMod mod; - private final MinecraftClient mc; - private final List messages = new ArrayList<>(); - private final static List EDIT_MESSAGES = Arrays.asList( - new Message(-1, "☠ §9B1§7 //§c R2"), - new Message(-1, "☠ §bA1") - ); - private Position position = new Position(100, 100); - private int maxNameLength = 1; - - public GameLogDisplay(BedwarsMod mod) { - this.mod = mod; - this.mc = MinecraftClient.getInstance(); - } - - public void gameStart(int maxNameLength) { - this.messages.clear(); - this.maxNameLength = maxNameLength; - } - - @Override - public void setPosition(Position position) { - this.position = position; - } - - @Override - public float getScale() { - return 1f; - } - - @Override - public Position getConfiguredPosition() { - return position; - } - - @Override - public boolean isVisible() { - return true; - } - - @Override - public Rectangle getBounds(Position position) { - return position.rectangle(100, 200); - } - - public int getSecondsBeforeFade() { - return 10; - } - - public int getFadeSeconds() { - return 3; - } - - @Override - public void render(Position position, boolean editMode) { - GlStateManager.enableBlend(); - GlStateManager.blendFuncSeparate(770, 771, 1, 0); - int tick = mc.inGameHud.getTicks(); - int y = -200; - boolean chatFocused = mc.inGameHud.getChatHud().isChatFocused(); - for (Message message : (editMode ? EDIT_MESSAGES : messages)) { - y += 9; - int color = -1; - int tickAlive = (tick - message.tickCreated); - if (!chatFocused && !editMode && tickAlive > 20 * getSecondsBeforeFade()) { - if (tickAlive > 20 * getSecondsBeforeFade() + getFadeSeconds()) { - // Stop rendering - break; - } - int tickFade = tickAlive - 20 * getSecondsBeforeFade(); - float alpha = 1 - (tickFade / (20f * getFadeSeconds())); - color = new Colour(255, 255, 255, (int) (alpha * 255)).getValue(); - } - mc.textRenderer.draw(message.content, position.getX(), position.getY() - y, color); - } - GlStateManager.disableBlend(); - } - - @Override - public Mod getMod() { - return mod; - } - - @Override - public boolean isShownInReplay() { - return false; - } - - public void push(Text content) { - push(content.asFormattedString()); - } - - public void push(String content) { - int tick = mc.inGameHud.getTicks(); - messages.add(0, new Message(tick, content)); - while (messages.size() > 300) { - messages.remove(300); - } - } - - private String format(String name) { - if (name.length() >= maxNameLength) { - return name; - } - int dif = maxNameLength - name.length(); - StringBuilder nameBuilder = new StringBuilder(name); - for (int i = 0; i < dif; i++) { - nameBuilder.append(" "); - } - return nameBuilder.toString(); - } - - @Value - public static class Message { - int tickCreated; - String content; - - } - -} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java new file mode 100644 index 00000000..45420f05 --- /dev/null +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java @@ -0,0 +1,84 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; + +import com.mojang.blaze3d.platform.GlStateManager; +import io.github.solclient.client.mod.Mod; +import io.github.solclient.client.mod.hud.HudElement; +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.BedwarsTeamUpgrades; +import io.github.solclient.client.util.data.Position; +import io.github.solclient.client.util.data.Rectangle; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.util.Identifier; + +public class TeamUpgradesOverlay implements HudElement { + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + + private Position position = new Position(100, 100); + + public TeamUpgradesOverlay(BedwarsMod mod) { + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + @Override + public float getScale() { + return 1; + } + + @Override + public Position getConfiguredPosition() { + return this.position; + } + + @Override + public void setPosition(Position position) { + this.position = position; + } + + @Override + public boolean isVisible() { + return true; + } + + @Override + public Rectangle getBounds(Position position) { + return position.rectangle(60, 20); + } + + @Override + public void render(Position position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + int x = position.getX() + 1; + int y = position.getY() + 2; + GlStateManager.color(1, 1, 1); + for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + mc.getTextureManager().bindTexture(new Identifier("sol_client", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(x, y, 0, 0, 16, 16, 16, 16); + x += 17; + } + } + + @Override + public Mod getMod() { + return mod; + } + + @Override + public boolean isShownInReplay() { + return false; + } +} diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java index 6f4ef81d..cf2cd37f 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java @@ -8,27 +8,27 @@ public class BedwarsTeamUpgrades { public final TrapUpgrade trap = new TrapUpgrade(); public final TeamUpgrade sharpness = new BinaryUpgrade( - "sharpness", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords\\s*$"), + "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords\\s*$"), 8, 4 ); public final TeamUpgrade dragonBuff = new BinaryUpgrade( - "dragon_buff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), 5, 5 ); public final TeamUpgrade healPool = new BinaryUpgrade( - "heal_pool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), 3, 1 ); public final TeamUpgrade protection = new TieredUpgrade( - "protection", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Protection .{1,2}\\s*$"), + "prot", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Reinforced Armor .{1,2}\\s*$"), new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16} ); public final TeamUpgrade maniacMiner = new TieredUpgrade( - "maniac_miner", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,2}\\s*$"), + "haste", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,2}\\s*$"), new int[]{2, 4}, new int[]{4, 6} ); diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java index 315041a1..0e75ce4a 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java @@ -23,10 +23,14 @@ public BinaryUpgrade(String name, Pattern regex, int foursPrice, int doublesPric } @Override protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(new LiteralText("Got an upgrade")); purchased = true; } + @Override + public String[] getTexture() { + return new String[]{name + "_" + (purchased ? "1" : "0")}; + } + @Override public int getPrice(BedwarsMode mode) { if (mode.getTeams().length == 8) { diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java index 53cf4566..332acb91 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java @@ -2,13 +2,15 @@ import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMessages; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; +import lombok.Getter; import java.util.regex.Matcher; import java.util.regex.Pattern; public abstract class TeamUpgrade { - private final String name; - private final Pattern[] regex; + @Getter + protected final String name; + protected final Pattern[] regex; public TeamUpgrade(String name, Pattern pattern) { this(name, new Pattern[]{pattern}); @@ -23,6 +25,13 @@ public boolean match(String unformatedMessage) { return BedwarsMessages.matched(regex, unformatedMessage, matcher -> onMatch(this, matcher)); } + public abstract String[] getTexture(); + + public boolean isMultiUpgrade() { + // Basically only trap + return false; + } + protected abstract void onMatch(TeamUpgrade upgrade, Matcher matcher); public abstract int getPrice(BedwarsMode mode); diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java index 252130cf..aaf56c34 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java @@ -2,8 +2,6 @@ import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; import lombok.Getter; -import net.minecraft.client.MinecraftClient; -import net.minecraft.text.LiteralText; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -21,9 +19,13 @@ public TieredUpgrade(String name, Pattern regex, int[] foursPrice, int[] doubles this.doublesPrice = doublesPrice; } + @Override + public String[] getTexture() { + return new String[]{name + "_" + level}; + } + @Override protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(new LiteralText("Got an upgrade")); level += 1; } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java index 8a763ede..856b72d7 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java @@ -1,8 +1,8 @@ package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; -import net.minecraft.client.MinecraftClient; -import net.minecraft.text.LiteralText; +import lombok.AllArgsConstructor; +import lombok.Getter; import java.util.ArrayList; import java.util.List; @@ -28,12 +28,10 @@ public TrapUpgrade() { @Override protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { if (matcher.group(1).equals("off")) { - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(new LiteralText("Trap went off")); // Trap went off traps.remove(0); return; } - MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(new LiteralText("Trap died")); traps.add(TrapType.getFuzzy(matcher.group(1))); } @@ -54,14 +52,35 @@ public int getPrice(BedwarsMode mode) { return 0; } + @Override + public String[] getTexture() { + if (traps.size() == 0) { + return new String[]{"trap/empty"}; + } + String[] trapTextures = new String[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = "trap/" + type.getTextureName(); + } + return trapTextures; + } + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor public enum TrapType { - ITS_A_TRAP, - COUNTER_OFFENSIVE, - ALARM, - MINER_FATIGUE + ITS_A_TRAP("itsatrap"), + COUNTER_OFFENSIVE("counteroffensive"), + ALARM("alarm"), + MINER_FATIGUE("minerfatigue") ; + @Getter + private final String textureName; + public static TrapType getFuzzy(String s) { s = s.toLowerCase(Locale.ROOT); if (s.contains("miner")) { diff --git a/wrapper/src/main/resources/assets/sol_client/lang/en_US.lang b/wrapper/src/main/resources/assets/sol_client/lang/en_US.lang index dcb244bb..0e327f31 100644 --- a/wrapper/src/main/resources/assets/sol_client/lang/en_US.lang +++ b/wrapper/src/main/resources/assets/sol_client/lang/en_US.lang @@ -471,6 +471,7 @@ sol_client.mod.screen.modified_from=, using code by %s sol_client.mod.screen.originally_by=, originally by %s sol_client.mod.screen.inspired_by=, inspired by %s sol_client.mod.screen.by=, by %s +sol_client.mod.screen.textures_by=, textures by %s sol_client.mod.screen.about=About Sol Client sol_client.mod.screen.license=Licensed under the GPL v3 license. diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/dragonbuff_0.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/dragonbuff_0.png new file mode 100644 index 0000000000000000000000000000000000000000..a9cf7905c71f0aaf52540aa540c79c7692d1149a GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}@0G|+7AbsxKxj%pY++~VN1gdW~NNsXpi4s+kUXbM_nb~yxY^vjx?SU%m zRMu`aeS5ZNI!CJCgF`kO(@Kt7H?KeN`@Z%c_MWe7Za31@rW~1agZW&~M+OfK_9rFl Setrkq%i!ti=d#Wzp$Pzjb8i9w literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/dragonbuff_1.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/dragonbuff_1.png new file mode 100644 index 0000000000000000000000000000000000000000..c9b22218179224ff6ac5a423fb0673d66a64d0e1 GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}@0G|+7Aiep<-JgH|P4(S9XYau~$DhTk*Y2Bo<@~0*kJ!|=vnrfpQvs?u z_3q;oAjMk}H67J$1B?d zRo1Dj-D>*wY|nI#RKEv@Y&NEq9JOvNS%G}T0G|+7AT1>&6&f09X=yoO!i0{Fj*S~P9yxO4*|TQ_1qDD^-p_J9K#IF0 z$S?Rm958tKGkyXJa~60+7BevL9RguSQ4OyKpkRQfi(`mJaOs&wz6J#j*T8rYf&c#x zIxgyrE-yaEy!mFB@f4=MrLq|g@&6a>kNwy1NjjiC=)g`B#kRUwPKIhf&IG}*LMeq+ hLhRqURof@sWaiw>qH4YD-%_C244$rjF6*2UngCNS%G}T0G|+7AZ=-BId|^d;^N{*j~<;qefs}A&;Q#>|36>6a^*^(Y?H~|zd(w+ zB*-uLKO8W4`7?e33Ud~CL>4nJ@ErnSMo|r~2B2Vor;B5VMsVqwM!p6G4%fhV5rO~z z4>~UDj4m%e$GrJwnDG>*zNNAm4)OmN?2rA|@JTwLJ?Owr6UDZ=SWbp&Kh6ZfutF(? iRYL6FxmDXI-DKw6&7x|(?B7zL*$kepelF{r5}E*ka9HX9 literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_2.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_2.png new file mode 100644 index 0000000000000000000000000000000000000000..c4d14eea361e12c71aecf68dbfc262fb7ec05e72 GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|+7Anjtuwta<4M~%?`_YqI81^l1q`F~sK|L2SMZ*l_4a(XQ=08-o~ zL4Lvi;ef%*pYan&w!kB@n1O-sFbFdq&tH)O6b$fmaSYK2Emd<;CZiH{T31p2F0(R5rsQ{{MpgvHu!ANe8qC9oT82*j5+I$x!XbnIITeD5bDU hi2XaaYWt*{%$&PfRIQi&TM9Ir!PC{xWt~$(695e-R{{V4 literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_3.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_3.png new file mode 100644 index 0000000000000000000000000000000000000000..8d6e083aa2db79e7b207731c1cecca79ad3bea8c GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|+7AkF5&rLtX5s6#5^e~SO3$p7;^|8Fb(|9r9SdXVgdSD8FOin}Dp zFZe$kFnIYhegX<}7I;J!GcfQS0%1l`4X*~EV1TEKV~9p@>6u2p1_ch+z<3dX|Njp< zF6xXfFFwb-`DU2$6sEqVvKbEX{}=3!{nzkGI-ou1z)lmzwz^nOhH5{~1i`REDTP%+ g?BBUn+b7**=G@JqYQ5~=QlQxkp00i_>zopr06#rb^8f$< literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_4.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/forge_4.png new file mode 100644 index 0000000000000000000000000000000000000000..c346b66aa482ef085327f1ebc6fafeba13dee15d GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|+7Ann4zwp~-DLrmy@T*RXg|Nrwm|8Fb(|9tU!M_ZumZY!yDAjMr0 zhBpuKmbYQ26Vq0A-CquO#XM$i@p_IZZ hA@=Xws_m0*GIQ=`QMF$7Zz<4h22WQ%mvv4FO#tapQ(yo9 literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/haste_0.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/haste_0.png new file mode 100644 index 0000000000000000000000000000000000000000..f10edaaf1e9587ff5502daeec69651c7b3b45590 GIT binary patch literal 269 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|+7Al=*BJA3x*ii!#i4Gm9EPYVl+z`#IbV`HGyw;8wB11YYOAiv=M zFu<_sjLvzWC})93WHAE+-vJP2%(~Xe2^387ba4#P2=+Y}DRe-AgZaXOE2sYI-(lc- z>U>fNS%G}H0G|+7AbsP;jkj;#Zr{G$UWq^3URl%5-XSu|Pe%+WmDZ!v2c)=4g8YL2 z!vMpkGdkyiqMQXDk;M!QdR{v8Ic zr_Lv(V-nID)-S)|bS$HbQ&6*ucZTcrxhBViZv^~fs8#b9HPBAyQu_Tn#_G2zXT-#t yPi{xN?>Zyceolm`Bz)P2ZtL^+i>%g8zsWA8!20`JmgHKXZ492SelF{r5}E)ebzcnt literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/haste_2.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/haste_2.png new file mode 100644 index 0000000000000000000000000000000000000000..23c562ad8057f1291b5ac1aabbe357a0bd343528 GIT binary patch literal 269 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|+7ApQS-*#Dm$Kei~?EAeOBD{I=>J48nL>4*WP9Om!g22xxlL4Lvi zVSr)N8J+V$QO*L7$YKTtzJnmlxMO1WTcBW)r;B5VMzHU>NTCA?9LyIMTsieu{|*D! zQ|FV?F$rl6>zChfI+oGJDX7`SJHz$*T$5wMHv;}K)T;T58fd3;DgFK(WA)pVGh*V+ yC$}TscbySzKPSRe629z1xApn^MOJI4-(;6kVEz3qOL8sHHU>{uKbLh*2~7ZP&0Z4# literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/healpool_0.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/healpool_0.png new file mode 100644 index 0000000000000000000000000000000000000000..efb9c84d9765ad42cdb8eaddef7885f3c938dcac GIT binary patch literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}f0G|+7ARQAEvvTFiDO096Iy#!0n*&8URaNc-DfW^ezu^C1z#!$#>;@F# zEbxddW?8eR=RK?hG4#}JL+(sPb{3NS%G}f0G|+7AbnX&>winjhn$>wQc|5FB0!Nq1%rAZ#aa)(=-}z%7@`qedd`uLL4kwWvHQ}0`$)qDoQ-ll*5a~0#s?zj zh%zV@GrjiN+IB*&?pgx>zMgs&1>L-D2~Vbr)jVO-6Ju%RcTiISn#JJh>gTe~DWM4f DeSNS%G}f0G|+7Ag!XJ(%07)6ci*PB68-;8KB6ijraP26njaKU+{l0V36`=b^{7= z7I;J!GcfQS0Aa?gYn_}x!7xu3#}JL++%w)n2NXD%FSIFqw=Xh$kZzT#_++Kc$CdRA z=VmfU6t_v%IPo2uvrGKR(kRAUo`r!E{MXqWjI4Cdzu3m~zQ&=x!ufiWsY7?n&{ literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_1.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_1.png new file mode 100644 index 0000000000000000000000000000000000000000..184eda3adcfdafaa0d4a7af42e3b9c726cfc83a0 GIT binary patch literal 266 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|+7Ag!XJ(%07)6ci*PB68-;8C_jnO>_%)r36AA}h#Sc6r7g3+EXjv*Ssxu?8^8Vop?1Ac}~{4IY& zz-sH`8Lo=!WqzKt@7Sa7;KI9mMVEL&;9;|LW;;tMpW_Ov1PeBOW!nCZ`_rBYOeIbx u9~L~++aN3Og>}kJX(OdOH`Ujq*cGm3+i+p_zHLBj7(8A5T-G@yGywq2;aBkh literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_2.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_2.png new file mode 100644 index 0000000000000000000000000000000000000000..559047b3fbfd15273688d5d29ffa12b350be1222 GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|+7Ag!ybtD>S}{Q9(9S9xDwpNNQvq@-j}P|*MX|ADgkU!K1LQrsm$ ze!)NyC}8mNXZ!>d<}C1tEM{Qf+YiEw7OcT4K*2;$7sn8d;M_BgTn7v|TrR#+x%KQH z`?|$KPAj_))Vr+zIph*^jv7d%V<(c$YWr?uPWW;+M|1h BUVQ)n literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_3.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_3.png new file mode 100644 index 0000000000000000000000000000000000000000..aaa5ce0f5b7539d3f59ee3f18f240c8da54007b5 GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|+7Ag!ybYyA4OTvxfIq~!nq|NHv-f`WoXL_~m6_bsp404c7LAirRs z6a+AAI-_$QD9Tyj5n0T@z_%ZS87)|YRe*xAo-U3d8o{||Bl!*}aIjq1w4>lZcX>+3 ztYtMEpYP23amBu4j;O+-w#bm9;t2tVL*_P|&0)EGP3Wpn!IM+mcV?J>n0oK`j6Y^` u4EWYqpAcU#!F)-GTFdV9Gj}G0AK_M3V3UYnvmR&<1B0ilpUXO@geCx&nOq+L literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_4.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/prot_4.png new file mode 100644 index 0000000000000000000000000000000000000000..d2715e825a12104e5cf8543b78d0459577c59ab6 GIT binary patch literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}f0G|+7Ag!ybYyA4OTvxfIq~!nq|A8WZ5}xb3(?_cadn70%b2RE@=3R-1^u b>8fC~$Y-%A=5sLv+Q8uH>gTe~DWM4fAN@>y literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/sharp_0.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/sharp_0.png new file mode 100644 index 0000000000000000000000000000000000000000..1662e97d7807fd8d20280556c12c20a96e0164cd GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|+7Ag!jR*4x`#US2LHCT4AI9TXI#qod>C;2~#!}uA>tW8|34Ho_77wx$uxkvWSG?BlX>VL@` hD9qd3&3(zG&c2I7;ngCA2SBqKJYD@<);T3K0RSoxPVN8z literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/sharp_1.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/sharp_1.png new file mode 100644 index 0000000000000000000000000000000000000000..880201af22bfe019274cbd1153262e63bd6e626d GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|+7AkAlQX8iiJ_VG0wstTgXp>kd2o@SyMesUUe+(6j_2eQ8dDejUW zzu^CHz~JT2_z5V?S>O>_3^d{}2s0kfUy%Y74DfVu4ABUVJ>$rCK!L+0aHI0pJO2-` z28yI7ev0pKU8kzBh$Un`%dM|0?|C;fhw(F%S(~_68!YNS%G}50G|+7AZ?hOBIjZ1*W8vmyY}>-yIY?`bsUZ=T;nE|f zGiFF|0x7HJ{XC+)o?&903B#&eAq=uS8Y~w-{`Jk)JW+ST>m$>_ z6Lmokc+)=f9S%EWlKtS~9GPXm-TZ>4X|l6E{4@R2p|%3{2XCZ3LiKNS{$T#HnbT`Q T^NJ-vTNylE{an^LB{Ts5!%J^S literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/counteroffensive.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/counteroffensive.png new file mode 100644 index 0000000000000000000000000000000000000000..1ec03a522baaaefa7a15b0960999a27b3448f364 GIT binary patch literal 304 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|&0G|+7ARQ18kerm{D=yq^VVtI_c<9ifSFc`K^Kz{X@>SsgDO~$g_A`*; zDGBlm{*M3*Lif*|1B!DNctjR6Fz_7)VaDV6D^h@hwVp1HAsWH1{oH(q6?mMzKdXP= z|Nf1EnfKHSrw=dmS6+Snx1Qj^$^$MTyiY!s^>a+zqBX(rn@_NJD95(6sZmlN8y*RC zJ+uxt5xwjpXthD`K!V4!*xi8)bC1gl7+bfMZ($d`R?{2!qsLz0hlcOE*j{_)g^AB) g&)Dq@&)a4HVgdW%{pk!LK!-4Ry85}Sb4q9e00W0@g#Z8m literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/empty.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/empty.png new file mode 100644 index 0000000000000000000000000000000000000000..5029b747549447126e87add037193c1d62b7c076 GIT binary patch literal 228 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G~10G|+7AZ=-B>Fn%mVqyYhH!PYK0Hjz;g8YL20|CSDZG0euI14-?iy0XB z4ude`@%$AjKtW$m7sn8d;M9IcJ_bb&=G3?U@9z=GGQGt;laYrnW?_earBD L)z4*}Q$iB}?`uPC literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/itsatrap.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/itsatrap.png new file mode 100644 index 0000000000000000000000000000000000000000..3d79a94a8bc592a20ce2419c841dac555d907390 GIT binary patch literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|m0G|+7Abo;`MMBN;KO5Vu-P`{IL6l}_S&^cmVnBAr^XJbOELb2Uqp72# zGeJlQsCf5{qsxGlKuM5aFi0^HV0fS$D+!e2EbxddW?*t}9QIwKZ%?sxQcm5Hve>)kCp kYEQFGNUxQ(sB}ESYpTX&;D2SOAkYB}p00i_>zopr0H0lQD*ylh literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/menu.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..4786a83f242aa7548498c9e58ccbdbc72ace7056 GIT binary patch literal 277 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|&0G|+7AT1#w;o{m3j{AwzY z;wcI83;vG)3_|zModb$<7I;J!GcfQS24TkI`72U@f=Qk(jv*Ssp*@Uz2NXD%bzhWx z`u~63q77>~J*!2!{<8dLNDSNK@Ji|8g6|udm%MdJRkmVzG*5od_J&K>Mg5wkW8N~w zHZ7a@Jy_1Q>;k(Ar{n(RjE-F=W}H@Ne71A7LYUrW_EowZOO`A&zXP<5!PC{xWt~$( F69A-FVb1^n literal 0 HcmV?d00001 diff --git a/wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/minerfatigue.png b/wrapper/src/main/resources/assets/sol_client/textures/bedwars/trap/minerfatigue.png new file mode 100644 index 0000000000000000000000000000000000000000..3eb866b7794f8a5078f2f9e340fa1f71a464c454 GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}%0G|+7AZ=(CcKX8CwOgL#mCQ~^ZfNb^ARuZ26koUf?{Of-SrX(I{2vM! zg8eImK!ODxk;M!Qe1}1p@p%4<6rf;|r;B5VMsRFzG~WROj>A$MQ-05{$h>;otUl4( zVKuYMRbGQe>4bA0udNRlDgEGHvcD<))8 Date: Wed, 19 Apr 2023 15:47:35 -0600 Subject: [PATCH 11/23] Timings and stats --- .../client/mixin/mod/BedwarsMixins.java | 11 +++ .../impl/hud/bedwarsoverlay/BedwarsGame.java | 81 ++++++++++++++++++- .../hud/bedwarsoverlay/BedwarsMessages.java | 1 + .../bedwarsoverlay/BedwarsPlayerStats.java | 3 + .../bedwarsoverlay/TeamUpgradesOverlay.java | 24 +++++- .../upgrades/BedwarsTeamUpgrades.java | 4 +- .../upgrades/BinaryUpgrade.java | 9 ++- .../bedwarsoverlay/upgrades/TeamUpgrade.java | 1 + .../upgrades/TieredUpgrade.java | 5 ++ .../bedwarsoverlay/upgrades/TrapUpgrade.java | 5 ++ .../client/mod/impl/hud/chat/ChatMod.java | 2 +- 11 files changed, 135 insertions(+), 11 deletions(-) diff --git a/wrapper/src/main/java/io/github/solclient/client/mixin/mod/BedwarsMixins.java b/wrapper/src/main/java/io/github/solclient/client/mixin/mod/BedwarsMixins.java index 25ed61ac..4978d30f 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mixin/mod/BedwarsMixins.java +++ b/wrapper/src/main/java/io/github/solclient/client/mixin/mod/BedwarsMixins.java @@ -23,6 +23,8 @@ public static class PlayerListHudMixin { @Shadow private Text header; + @Shadow private Text footer; + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) public void getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { if (!BedwarsMod.getInstance().isEnabled()) { @@ -60,6 +62,15 @@ public void changeHeader(Text header, CallbackInfo ci) { ci.cancel(); } + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void changeFooter(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } + } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index de46a908..c59fe196 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -11,7 +11,6 @@ import net.minecraft.scoreboard.Team; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.regex.Matcher; @@ -19,10 +18,23 @@ public class BedwarsGame { + private static final int DIAMOND_START = 30; + private static final int DIAMOND_1 = 30; + private static final int DIAMOND_2 = 23; + private static final int DIAMOND_3 = 16; + private static final int EMERALD_START = 30; + private static final int EMERALD_1 = 65; + private static final int EMERALD_2 = 50; + private static final int EMERALD_3 = 35; + + private int diamondsTimer = DIAMOND_START; + private int emeraldsTimer = EMERALD_START; + private BedwarsTeam won = null; private int wonTick = -1; private int seconds = 0; private Text topBarText = new LiteralText(""); + private Text bottomBarText = new LiteralText(""); private BedwarsPlayer me = null; @@ -85,10 +97,18 @@ public Text getTopBarText() { return topBarText; } + public Text getBottomBarText() { + return bottomBarText; + } + private String calculateTopBarText() { return getFormattedTime(); } + private String calculateBottomBarText() { + return "§bDiamonds - " + diamondsTimer + " §8| " + "§aEmeralds - " + emeraldsTimer; + } + public String getFormattedTime() { int minute = seconds / 60; int second = seconds % 60; @@ -133,7 +153,8 @@ private String formatEliminated(BedwarsTeam team) { private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { String playerFormatted = getPlayerFormatted(breaker); - return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted; + return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted + + (breaker.getStats() == null ? "" : " §6" + breaker.getStats().getBedsBroken()); } private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { @@ -241,6 +262,9 @@ private void teamEliminated(ReceiveChatMessageEvent event, BedwarsTeam team) { private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Nullable BedwarsPlayer breaker) { players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); + if (breaker != null && breaker.getStats() != null) { + breaker.getStats().addBed(); + } event.newMessage = new LiteralText(formatBed(team, breaker)); } @@ -282,9 +306,60 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { if (this.seconds % 60 != target) { // Update seconds while (this.seconds % 60 != target) { - this.seconds++; + updateClock(); } topBarText = new LiteralText(calculateTopBarText()); + bottomBarText = new LiteralText(calculateBottomBarText()); + } + } + + private int getDiamondTimerTier(int tier) { + if (tier <= 1) { + return DIAMOND_1; + } + if (tier == 2) { + return DIAMOND_2; + } + return DIAMOND_3; + } + + private int getEmeraldTier(int tier) { + if (tier <= 1) { + return EMERALD_1; + } + if (tier == 2) { + return EMERALD_2; + } + return EMERALD_3; + } + + private void updateClock() { + // This just straight up doesn't work. I think it's because hypixel doesn't follow strict timings + // Also the math on this is just wrong somewhere + this.seconds++; + int minutes = seconds / 60; + int diamondTier = Math.min((minutes + 6) / 12 + 1, 3); + int emeraldTier = Math.min(minutes / 12 + 1, 3); + diamondsTimer--; + emeraldsTimer--; + if (seconds % 60 == 0) { + if (minutes < 24 && minutes % 6 == 0) { + if ((minutes % 12) / 6 == 1) { + // Diamonds + diamondsTimer = 0; + } else { + // Emeralds + emeraldsTimer = 0; + } + } + } + if (diamondsTimer <= 0) { + int secondsTillUpgrade = (((minutes) / 12 + 1)) * 12 * 60 - 6 * 60 - seconds; + diamondsTimer = Math.min(getDiamondTimerTier(diamondTier), secondsTillUpgrade); + } + if (emeraldsTimer <= 0) { + int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; + emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java index 377b978e..9b38bbf5 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java @@ -232,6 +232,7 @@ public class BedwarsMessages { Pattern.compile("^Coins just earned DOUBLE"), Pattern.compile("^\\+\\d+ Bed Wars Experience"), Pattern.compile("^You have respawned"), + Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), }; private static Pattern[] convert(String... input) { diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java index a7b19403..d1dc8f69 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java @@ -93,4 +93,7 @@ public void addFinalKill() { finalKills++; } + public void addBed() { + bedsBroken++; + } } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java index 45420f05..efbc81ab 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java @@ -4,6 +4,8 @@ import io.github.solclient.client.mod.Mod; import io.github.solclient.client.mod.hud.HudElement; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.BedwarsTeamUpgrades; +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.TeamUpgrade; +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.TrapUpgrade; import io.github.solclient.client.util.data.Position; import io.github.solclient.client.util.data.Rectangle; import net.minecraft.client.MinecraftClient; @@ -54,7 +56,7 @@ public boolean isVisible() { @Override public Rectangle getBounds(Position position) { - return position.rectangle(60, 20); + return position.rectangle(60, 40); } @Override @@ -65,6 +67,26 @@ public void render(Position position, boolean editMode) { int x = position.getX() + 1; int y = position.getY() + 2; GlStateManager.color(1, 1, 1); + boolean normalUpgrades = false; + if (upgrades != null) { + for (TeamUpgrade u : upgrades.upgrades) { + if (!u.isPurchased()) { + continue; + } + if (u instanceof TrapUpgrade) { + continue; + } + String texture = u.getTexture()[0]; + mc.getTextureManager().bindTexture(new Identifier("sol_client", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(x, y, 0, 0, 16, 16, 16, 16); + x += 17; + normalUpgrades = true; + } + } + x = position.getX() + 1; + if (normalUpgrades) { + y += 17; + } for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { mc.getTextureManager().bindTexture(new Identifier("sol_client", "textures/bedwars/" + texture + ".png")); DrawableHelper.drawTexture(x, y, 0, 0, 16, 16, 16, 16); diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java index cf2cd37f..49e7d649 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java @@ -8,7 +8,7 @@ public class BedwarsTeamUpgrades { public final TrapUpgrade trap = new TrapUpgrade(); public final TeamUpgrade sharpness = new BinaryUpgrade( - "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords\\s*$"), + "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords"), 8, 4 ); @@ -37,7 +37,7 @@ public class BedwarsTeamUpgrades { new int[]{2, 4}, new int[]{4, 6} ); - private final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; + public final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; public BedwarsTeamUpgrades() { diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java index 0e75ce4a..f112f88a 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java @@ -1,16 +1,12 @@ package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; -import lombok.Getter; -import net.minecraft.client.MinecraftClient; -import net.minecraft.text.LiteralText; import java.util.regex.Matcher; import java.util.regex.Pattern; public class BinaryUpgrade extends TeamUpgrade { - @Getter private boolean purchased = false; private final int foursPrice; @@ -31,6 +27,11 @@ public String[] getTexture() { return new String[]{name + "_" + (purchased ? "1" : "0")}; } + @Override + public boolean isPurchased() { + return purchased; + } + @Override public int getPrice(BedwarsMode mode) { if (mode.getTeams().length == 8) { diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java index 332acb91..4d63e357 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java @@ -37,5 +37,6 @@ public boolean isMultiUpgrade() { public abstract int getPrice(BedwarsMode mode); + public abstract boolean isPurchased(); } diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java index aaf56c34..309c383b 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java @@ -24,6 +24,11 @@ public String[] getTexture() { return new String[]{name + "_" + level}; } + @Override + public boolean isPurchased() { + return level > 0; + } + @Override protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { level += 1; diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java index 856b72d7..8645569a 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java @@ -52,6 +52,11 @@ public int getPrice(BedwarsMode mode) { return 0; } + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + @Override public String[] getTexture() { if (traps.size() == 0) { diff --git a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/chat/ChatMod.java b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/chat/ChatMod.java index fcd068fd..18bb5920 100644 --- a/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/chat/ChatMod.java +++ b/wrapper/src/main/java/io/github/solclient/client/mod/impl/hud/chat/ChatMod.java @@ -66,7 +66,7 @@ public class ChatMod extends SolClientHudMod { public boolean colours = true; @Expose @Option - @Slider(min = 40, max = 320, step = 1) + @Slider(min = 40, max = 500, step = 1) public float width = 320; @Expose @Option From e44159daa7fbedee4dbce9abbd676850aaec18c0 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 20 Apr 2023 19:04:35 +0100 Subject: [PATCH 12/23] Licenses The project is still licensed the same way, I just finally did licensing as intended I think :P --- .../event/impl/ReceiveChatMessageEvent.java | 18 ++++++++++++++++++ .../hud/bedwarsoverlay/BedwarsDeathType.java | 18 ++++++++++++++++++ .../impl/hud/bedwarsoverlay/BedwarsGame.java | 18 ++++++++++++++++++ .../hud/bedwarsoverlay/BedwarsMessages.java | 18 ++++++++++++++++++ .../impl/hud/bedwarsoverlay/BedwarsMod.java | 18 ++++++++++++++++++ .../impl/hud/bedwarsoverlay/BedwarsMode.java | 18 ++++++++++++++++++ .../impl/hud/bedwarsoverlay/BedwarsPlayer.java | 18 ++++++++++++++++++ .../hud/bedwarsoverlay/BedwarsPlayerStats.java | 18 ++++++++++++++++++ .../impl/hud/bedwarsoverlay/BedwarsTeam.java | 18 ++++++++++++++++++ .../bedwarsoverlay/TeamUpgradesOverlay.java | 18 ++++++++++++++++++ .../mixins/PlayerListHudMixin.java | 18 ++++++++++++++++++ .../bedwarsoverlay/stats/LobbyStatsHud.java | 18 ++++++++++++++++++ .../upgrades/BedwarsTeamUpgrades.java | 18 ++++++++++++++++++ .../bedwarsoverlay/upgrades/BinaryUpgrade.java | 18 ++++++++++++++++++ .../bedwarsoverlay/upgrades/TeamUpgrade.java | 18 ++++++++++++++++++ .../bedwarsoverlay/upgrades/TieredUpgrade.java | 18 ++++++++++++++++++ .../bedwarsoverlay/upgrades/TrapUpgrade.java | 18 ++++++++++++++++++ .../impl/hypixeladditions/HypixelAPICache.java | 18 ++++++++++++++++++ 18 files changed, 324 insertions(+) diff --git a/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java b/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java index 4169d4bf..38cb8c2d 100644 --- a/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java +++ b/src/main/java/io/github/solclient/client/event/impl/ReceiveChatMessageEvent.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.event.impl; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java index 94088e20..5e2c9cd7 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import lombok.AllArgsConstructor; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index 70c78c84..dd6744a5 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import io.github.solclient.client.event.impl.ReceiveChatMessageEvent; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java index 9b38bbf5..c088605d 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import java.util.Arrays; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java index 7635c96d..5fb77d46 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import io.github.solclient.client.event.EventHandler; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java index fb7be1b0..2bdc29d2 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import lombok.Getter; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java index fe39a035..cda04a98 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java index d1dc8f69..54381664 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import com.google.gson.JsonElement; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java index e2035a62..5683a4e2 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java index efbc81ab..2a4801d9 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import com.mojang.blaze3d.platform.GlStateManager; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java index 38f8d1ff..7a43564b 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.mixins; import java.util.List; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java index 11011c68..7ea0b06a 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.stats; import io.github.solclient.client.mod.Mod; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java index 49e7d649..618b0740 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java index f112f88a..c5f503fe 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java index 4d63e357..f8410789 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMessages; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java index 309c383b..a0ed727d 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java index 8645569a..bf13a96c 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java b/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java index 589a2ed2..6e46cabc 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hypixeladditions; import io.github.solclient.client.util.ApacheHttpClient; From 1de6a92752394de8378d028f7044a5521441bdb0 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 20 Apr 2023 19:09:01 +0100 Subject: [PATCH 13/23] Language stuff! --- .../client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java | 2 +- src/main/resources/assets/sol_client/lang/en_US.lang | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java index 5fb77d46..e5fcbf04 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -53,7 +53,7 @@ public BedwarsMod() { @Override public String getDetail() { - return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + " " + I18n.translate("sol_client.mod.screen.textues_by", "Sybillian"); + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); } @Override diff --git a/src/main/resources/assets/sol_client/lang/en_US.lang b/src/main/resources/assets/sol_client/lang/en_US.lang index c14e8509..f28300b0 100644 --- a/src/main/resources/assets/sol_client/lang/en_US.lang +++ b/src/main/resources/assets/sol_client/lang/en_US.lang @@ -349,6 +349,10 @@ sol_client.mod.hypixel_util.option.autoglMessage=GL message sol_client.mod.hypixel_util.option.hidegl=Hide GL messages sol_client.mod.hypixel_util.option.levelhead=Show player levels +sol_client.mod.bedwars.name=Bedwars +sol_client.mod.bedwars.description=Various improvements and hud for bedwars. + + sol_client.mod.tnt_timer.name=TNT Timer sol_client.mod.tnt_timer.description=Display the explosion time of TNT. @@ -487,7 +491,7 @@ sol_client.mod.screen.modified_from=, using code by %s sol_client.mod.screen.originally_by=, originally by %s sol_client.mod.screen.inspired_by=, inspired by %s sol_client.mod.screen.by=, by %s -sol_client.mod.screen.textures_by=, textures by %s +sol_client.mod.screen.textures_by=; textures by %s sol_client.mod.screen.about=About Sol Client sol_client.mod.screen.license=Licensed under the GPL v3 license. From f9fc77f7e0a873c0c05d6a7b8ae5f38d70b520c2 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Mon, 24 Apr 2023 08:57:10 -0600 Subject: [PATCH 14/23] Saving certain elements and fixing windows moment --- .../io/github/solclient/client/SolClient.java | 6 +- .../io/github/solclient/client/mod/Mod.java | 4 ++ .../impl/hud/bedwarsoverlay/BedwarsGame.java | 47 ++++++++------ .../impl/hud/bedwarsoverlay/BedwarsMod.java | 63 +++++++++++++------ .../hud/bedwarsoverlay/BedwarsPlayer.java | 38 +++++------ .../bedwarsoverlay/TeamUpgradesOverlay.java | 54 ++++++++++------ .../upgrades/BedwarsTeamUpgrades.java | 40 ++++++------ .../client/mod/option/impl/FieldOptions.java | 2 +- .../io/github/solclient/wrapper/JarIndex.java | 2 +- 9 files changed, 156 insertions(+), 100 deletions(-) diff --git a/src/main/java/io/github/solclient/client/SolClient.java b/src/main/java/io/github/solclient/client/SolClient.java index e8353364..147dd29d 100644 --- a/src/main/java/io/github/solclient/client/SolClient.java +++ b/src/main/java/io/github/solclient/client/SolClient.java @@ -253,8 +253,10 @@ private void prepare(ModInfo info) { private static Gson getGson(Mod mod) { GsonBuilder builder = new GsonBuilder(); - if (mod != null) - builder.registerTypeAdapter(mod.getClass(), (InstanceCreator) (type) -> mod); + if (mod != null) { + builder.registerTypeAdapter(mod.getClass(), (InstanceCreator) (type) -> mod); + mod.registerOtherTypeAdapters(builder); + } return builder.excludeFieldsWithoutExposeAnnotation().create(); } diff --git a/src/main/java/io/github/solclient/client/mod/Mod.java b/src/main/java/io/github/solclient/client/mod/Mod.java index 78b62d65..0dce8214 100644 --- a/src/main/java/io/github/solclient/client/mod/Mod.java +++ b/src/main/java/io/github/solclient/client/mod/Mod.java @@ -337,6 +337,10 @@ public void setPinned(boolean pinned) { } } + public void registerOtherTypeAdapters(GsonBuilder builder) { + + } + void notifyUnpin() { pinned = false; } diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index dd6744a5..ac591ee4 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import io.github.solclient.client.event.impl.ReceiveChatMessageEvent; @@ -262,9 +262,18 @@ private void gameEnd(BedwarsTeam win) { return; } + mc.inGameHud.getChatHud().addMessage( + new LiteralText("§8§m----------[§7Winstreaks§8]----------") + ); for (BedwarsPlayer p : players.values()) { if (p.getStats() != null && p.getStats().getWinstreak() > 0) { - mc.inGameHud.getChatHud().addMessage(new LiteralText(getPlayerFormatted(p) + " - " + p.getStats().getWinstreak())); + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + new LiteralText( + getPlayerFormatted(p) + "§8: §7" + before + " §8→ §" + (winner ? "a" : "c") + after + )); } } diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java index e5fcbf04..1dc9693b 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -1,30 +1,34 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; +import com.google.gson.GsonBuilder; +import com.google.gson.InstanceCreator; +import com.google.gson.annotations.Expose; import io.github.solclient.client.event.EventHandler; import io.github.solclient.client.event.impl.PreTickEvent; import io.github.solclient.client.event.impl.ReceiveChatMessageEvent; import io.github.solclient.client.event.impl.ScoreboardRenderEvent; -import io.github.solclient.client.mod.ModCategory; +import io.github.solclient.client.event.impl.WorldLoadEvent; import io.github.solclient.client.mod.hud.HudElement; import io.github.solclient.client.mod.impl.*; +import io.github.solclient.client.mod.option.ModOption; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.resource.language.I18n; import net.minecraft.text.LiteralText; @@ -42,8 +46,9 @@ public final class BedwarsMod extends StandardMod { }; public static BedwarsMod instance; - protected BedwarsGame currentGame = null; + + @Expose protected final TeamUpgradesOverlay upgradesOverlay; private int targetTick = -1; @@ -51,6 +56,13 @@ public BedwarsMod() { upgradesOverlay = new TeamUpgradesOverlay(this); } + @Override + protected List> createOptions() { + List> options = super.createOptions(); + options.addAll(upgradesOverlay.createOptions()); + return options; + } + @Override public String getDetail() { return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); @@ -62,6 +74,13 @@ public void init() { instance = this; } + @EventHandler + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + @EventHandler public void onMessage(ReceiveChatMessageEvent event) { // Remove formatting @@ -138,4 +157,8 @@ public void gameEnd() { currentGame = null; } + @Override + public void registerOtherTypeAdapters(GsonBuilder builder) { + builder.registerTypeAdapter(TeamUpgradesOverlay.class, (InstanceCreator) (type) -> upgradesOverlay); + } } diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java index cda04a98..93574a2d 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; @@ -83,7 +83,7 @@ public void updateListEntry(PlayerListEntry entry) { } public boolean isFinalKilled() { - return tickAlive < 0 && !bed && !alive; + return tickAlive < 0 && !bed && !alive || (!bed && isDisconnected()); } public void tick(int currentTick) { diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java index 2a4801d9..f61beb2f 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java @@ -1,35 +1,42 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; +import com.google.gson.annotations.Expose; import com.mojang.blaze3d.platform.GlStateManager; import io.github.solclient.client.mod.Mod; import io.github.solclient.client.mod.hud.HudElement; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.BedwarsTeamUpgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.TeamUpgrade; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.TrapUpgrade; +import io.github.solclient.client.mod.option.ModOption; +import io.github.solclient.client.mod.option.annotation.Option; +import io.github.solclient.client.mod.option.impl.FieldOptions; import io.github.solclient.client.util.data.Position; import io.github.solclient.client.util.data.Rectangle; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.util.Identifier; +import java.util.ArrayList; +import java.util.List; + public class TeamUpgradesOverlay implements HudElement { private BedwarsTeamUpgrades upgrades = null; @@ -37,6 +44,7 @@ public class TeamUpgradesOverlay implements HudElement { private final MinecraftClient mc; private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + @Expose private Position position = new Position(100, 100); public TeamUpgradesOverlay(BedwarsMod mod) { @@ -77,6 +85,16 @@ public Rectangle getBounds(Position position) { return position.rectangle(60, 40); } + public List> createOptions() { + List> options = new ArrayList<>(); + try { + FieldOptions.visit(mod, this.getClass(), options::add); + } catch (IllegalAccessException error) { + throw new AssertionError(error); + } + return options; + } + @Override public void render(Position position, boolean editMode) { if (upgrades == null && !editMode) { diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java index 618b0740..3fcc4d5c 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BedwarsTeamUpgrades.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; @@ -41,12 +41,12 @@ public class BedwarsTeamUpgrades { ); public final TeamUpgrade protection = new TieredUpgrade( - "prot", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Reinforced Armor .{1,2}\\s*$"), + "prot", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Reinforced Armor .{1,3}\\s*$"), new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16} ); public final TeamUpgrade maniacMiner = new TieredUpgrade( - "haste", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,2}\\s*$"), + "haste", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,3}\\s*$"), new int[]{2, 4}, new int[]{4, 6} ); diff --git a/src/main/java/io/github/solclient/client/mod/option/impl/FieldOptions.java b/src/main/java/io/github/solclient/client/mod/option/impl/FieldOptions.java index a1295bf9..abf52818 100644 --- a/src/main/java/io/github/solclient/client/mod/option/impl/FieldOptions.java +++ b/src/main/java/io/github/solclient/client/mod/option/impl/FieldOptions.java @@ -46,7 +46,7 @@ public void visit(Mod mod, Consumer> visitor) throws IllegalAccessE visit(mod, mod.getClass(), visitor); } - private void visit(Mod mod, Class clazz, Consumer> visitor) + public void visit(Mod mod, Class clazz, Consumer> visitor) throws IllegalAccessException { if (clazz == null) return; diff --git a/src/main/java/io/github/solclient/wrapper/JarIndex.java b/src/main/java/io/github/solclient/wrapper/JarIndex.java index bd5ed752..127cabc2 100644 --- a/src/main/java/io/github/solclient/wrapper/JarIndex.java +++ b/src/main/java/io/github/solclient/wrapper/JarIndex.java @@ -56,7 +56,7 @@ private void populate(Consumer consumer) throws IOException, URISyntaxEx if (Files.isDirectory(entry)) return; - consumer.accept(root.relativize(entry).toString()); + consumer.accept(root.relativize(entry).toString().replace("\\", "/")); }); } else { URLConnection connection = resource.openConnection(); From afac0736bd3d2fbbf8828e39ecc1e97fecafc22d Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Mon, 24 Apr 2023 09:15:16 -0600 Subject: [PATCH 15/23] Adding scale and enabled option for team upgrades --- .../bedwarsoverlay/TeamUpgradesOverlay.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java index f61beb2f..31c3b3e8 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java @@ -26,8 +26,11 @@ import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.TeamUpgrade; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.TrapUpgrade; import io.github.solclient.client.mod.option.ModOption; +import io.github.solclient.client.mod.option.ModOptionStorage; import io.github.solclient.client.mod.option.annotation.Option; import io.github.solclient.client.mod.option.impl.FieldOptions; +import io.github.solclient.client.mod.option.impl.SliderOption; +import io.github.solclient.client.mod.option.impl.ToggleOption; import io.github.solclient.client.util.data.Position; import io.github.solclient.client.util.data.Rectangle; import net.minecraft.client.MinecraftClient; @@ -36,17 +39,26 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; public class TeamUpgradesOverlay implements HudElement { + private final static String TRANSLATION_KEY = "bedwars.teamupgrades"; + private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final MinecraftClient mc; private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + @Expose + private boolean enabled = true; + @Expose private Position position = new Position(100, 100); + @Expose + private float scale = 100; + public TeamUpgradesOverlay(BedwarsMod mod) { this.mod = mod; this.mc = MinecraftClient.getInstance(); @@ -62,7 +74,7 @@ public void onEnd() { @Override public float getScale() { - return 1; + return scale / 100; } @Override @@ -77,7 +89,7 @@ public void setPosition(Position position) { @Override public boolean isVisible() { - return true; + return enabled; } @Override @@ -87,6 +99,19 @@ public Rectangle getBounds(Position position) { public List> createOptions() { List> options = new ArrayList<>(); + options.add(new ToggleOption( + TRANSLATION_KEY + ".enabled", + ModOptionStorage.of(boolean.class, () -> enabled, (value) -> { + if (enabled != value) { + enabled = value; + } + }) + )); + options.add( + new SliderOption(TRANSLATION_KEY + ".option.scale", + ModOptionStorage.of(Number.class, () -> scale, (value) -> scale = value.floatValue()), + Optional.of("sol_client.slider.percent"), 50, 150, 1 + )); try { FieldOptions.visit(mod, this.getClass(), options::add); } catch (IllegalAccessException error) { From e2c164b69c88577bc6b8e418d04790d3352f5ea8 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Mon, 24 Apr 2023 14:47:07 -0600 Subject: [PATCH 16/23] More configuration and seconds until respawn --- .../impl/hud/bedwarsoverlay/BedwarsGame.java | 22 +++++--- .../impl/hud/bedwarsoverlay/BedwarsMod.java | 17 ++++++- .../bedwarsoverlay/TeamUpgradesOverlay.java | 2 +- .../mixins/PlayerListHudMixin.java | 51 +++++++++++++++++++ 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index ac591ee4..6361fccb 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -154,7 +154,9 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if (killer != null) { killer.killed(finalDeath); } - event.newMessage = new LiteralText(formatDeath(player, killer, type, finalDeath)); + if (mod.overrideMessages) { + event.newMessage = new LiteralText(formatDeath(player, killer, type, finalDeath)); + } } private String formatDisconnect(BedwarsPlayer disconnected) { @@ -205,7 +207,7 @@ public boolean isTeamEliminated(BedwarsTeam team) { public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { try { - if (BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + if (mod.removeAnnoyingMessages && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { event.cancelled = true; return; } @@ -286,7 +288,9 @@ private void teamEliminated(ReceiveChatMessageEvent event, BedwarsTeam team) { b.setBed(false); b.died(); }); - event.newMessage = new LiteralText(formatEliminated(team)); + if (mod.overrideMessages) { + event.newMessage = new LiteralText(formatEliminated(team)); + } } private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Nullable BedwarsPlayer breaker) { @@ -294,18 +298,24 @@ private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Null if (breaker != null && breaker.getStats() != null) { breaker.getStats().addBed(); } - event.newMessage = new LiteralText(formatBed(team, breaker)); + if (mod.overrideMessages) { + event.newMessage = new LiteralText(formatBed(team, breaker)); + } } private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { player.disconnected(); - event.newMessage = new LiteralText(formatDisconnect(player)); + if (mod.overrideMessages) { + event.newMessage = new LiteralText(formatDisconnect(player)); + } } private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { player.reconnected(); - event.newMessage = new LiteralText(formatDisconnect(player)); + if (mod.overrideMessages) { + event.newMessage = new LiteralText(formatReconnect(player)); + } } public void onScoreboardRender(ScoreboardRenderEvent event) { diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java index 1dc9693b..662c48a7 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -29,6 +29,8 @@ import io.github.solclient.client.mod.hud.HudElement; import io.github.solclient.client.mod.impl.*; import io.github.solclient.client.mod.option.ModOption; +import io.github.solclient.client.mod.option.annotation.AbstractTranslationKey; +import io.github.solclient.client.mod.option.annotation.Option; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.resource.language.I18n; import net.minecraft.text.LiteralText; @@ -37,6 +39,7 @@ import java.util.*; import java.util.regex.Pattern; +@AbstractTranslationKey("sol_client.mod.bedwars") public final class BedwarsMod extends StandardMod { private final static Pattern[] GAME_START = { @@ -50,6 +53,18 @@ public final class BedwarsMod extends StandardMod { @Expose protected final TeamUpgradesOverlay upgradesOverlay; + + @Expose + @Option + protected boolean removeAnnoyingMessages = true; + + @Expose + @Option + protected boolean showChatTime = true; + + @Expose + @Option + protected boolean overrideMessages = true; private int targetTick = -1; public BedwarsMod() { @@ -88,7 +103,7 @@ public void onMessage(ReceiveChatMessageEvent event) { if (currentGame != null) { currentGame.onChatMessage(rawMessage, event); String time = "§7" + currentGame.getFormattedTime() + " "; - if (!event.cancelled) { + if (!event.cancelled && showChatTime) { // Add time to every message received in game if (event.newMessage != null) { event.newMessage = new LiteralText(time).append(event.newMessage); diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java index 31c3b3e8..dd2e6c41 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/TeamUpgradesOverlay.java @@ -51,7 +51,7 @@ public class TeamUpgradesOverlay implements HudElement { private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; @Expose - private boolean enabled = true; + private boolean enabled = false; @Expose private Position position = new Position(100, 100); diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java index 7a43564b..7cc8aff6 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java @@ -20,6 +20,9 @@ import java.util.List; +import io.github.solclient.client.util.data.Colour; +import net.minecraft.client.MinecraftClient; +import net.minecraft.scoreboard.ScoreboardObjective; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.*; @@ -36,6 +39,54 @@ public class PlayerListHudMixin { @Shadow private Text footer; + @Shadow @Final private MinecraftClient client; + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value="INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Ljava/lang/String;FFI)I", ordinal=1 + ), + cancellable = true + ) + public void renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, PlayerListEntry playerEntry, CallbackInfo ci + ) { + if (!BedwarsMod.instance.isEnabled()) { + return; + } + BedwarsGame game = BedwarsMod.instance.getGame().orElse(null); + if (game == null) { + return; + } + BedwarsPlayer bedwarsPlayer = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + if (bedwarsPlayer == null) { + return; + } + ci.cancel(); + String render; + int color = 16777215; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - this.client.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.2f", secondsTillLive) + "s"; + } else { + int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); + color = new Colour(50,205,50).lerp(new Colour(215, 0, 64), 1 - (health / 20f)).getValue(); + render = String.valueOf(health); + } + // Health + this.client.textRenderer.drawWithShadow( + render, + (float)(endX - this.client.textRenderer.getStringWidth(render)), + (float) y, + color + ); + + } + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) public void getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { if (!BedwarsMod.instance.isEnabled()) { From b975f137e225781b1b615dfab566b44b3d28fe39 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Mon, 24 Apr 2023 16:59:10 -0600 Subject: [PATCH 17/23] Paper doll --- .../mod/impl/core/mixins/EntityMixin.java | 1 + .../client/mod/impl/hud/PaperDollMod.java | 121 ++++++++++++++++++ .../assets/sol_client/lang/en_US.lang | 5 + src/main/resources/standard-mods.json | 5 + 4 files changed, 132 insertions(+) create mode 100644 src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java diff --git a/src/main/java/io/github/solclient/client/mod/impl/core/mixins/EntityMixin.java b/src/main/java/io/github/solclient/client/mod/impl/core/mixins/EntityMixin.java index d0a3b243..a66526c1 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/core/mixins/EntityMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/core/mixins/EntityMixin.java @@ -23,6 +23,7 @@ import io.github.solclient.client.culling.Cullable; import lombok.*; import net.minecraft.entity.Entity; +import org.spongepowered.asm.mixin.injection.Inject; @Mixin(Entity.class) public abstract class EntityMixin implements Cullable { diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java b/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java new file mode 100644 index 00000000..6983c12d --- /dev/null +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java @@ -0,0 +1,121 @@ +package io.github.solclient.client.mod.impl.hud; + +import com.google.gson.annotations.Expose; +import com.mojang.blaze3d.platform.GLX; +import com.mojang.blaze3d.platform.GlStateManager; +import io.github.solclient.client.event.EventHandler; +import io.github.solclient.client.event.impl.PlayerHeadRotateEvent; +import io.github.solclient.client.event.impl.PreTickEvent; +import io.github.solclient.client.mod.impl.SolClientHudMod; +import io.github.solclient.client.mod.option.ModOption; +import io.github.solclient.client.mod.option.ModOptionStorage; +import io.github.solclient.client.mod.option.annotation.AbstractTranslationKey; +import io.github.solclient.client.mod.option.annotation.Option; +import io.github.solclient.client.mod.option.impl.SliderOption; +import io.github.solclient.client.util.MinecraftUtils; +import io.github.solclient.client.util.data.Position; +import io.github.solclient.client.util.data.Rectangle; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.DiffuseLighting; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.resource.language.I18n; + +import java.util.List; +import java.util.Optional; + +// Originally from KronHUD +// Added here by DarkKronicle :) +// https://github.com/DarkKronicle/KronHUD/blob/master/src/main/java/io/github/darkkronicle/kronhud/gui/hud/PlayerHud.java +@AbstractTranslationKey("sol_client.mod.paperdoll") +public class PaperDollMod extends SolClientHudMod { + + @Expose + @Option + private boolean dynamicRotation = true; + + @Expose + private float rotation = 0; + + private float lastYawOffset = 0; + private float yawOffset = 0; + + @Override + public Rectangle getBounds(Position position) { + return new Rectangle(position.getX(), position.getY(), 62, 94); + } + + @Override + public String getDetail() { + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle"); // maybe also add original creator + } + + @Override + protected List> createOptions() { + List> options = super.createOptions(); + Optional format = Optional.empty(); + options.add( + new SliderOption( + "sol_client.mod.paperdoll.option.rotation", + ModOptionStorage.of(Number.class, () -> rotation, (value) -> rotation = value.floatValue()), + format, 0, 360, 1 + ) + ); + return options; + } + + public void renderPlayer(double x, double y, float delta) { + if (mc.player == null) { + return; + } + + float deltaYaw = mc.player.prevYaw + (mc.player.yaw - mc.player.prevYaw) * delta; + if (dynamicRotation) { + deltaYaw -= (lastYawOffset + ((yawOffset - lastYawOffset) * delta)); + } + + GlStateManager.enableColorMaterial(); + GlStateManager.pushMatrix(); + GlStateManager.translate((float) x, (float) y, 500.0F); + GlStateManager.scale((float) (-40), (float) 40, (float) 40); + GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); + + GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F); + DiffuseLighting.enableNormally(); + GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(deltaYaw + rotation, 0.0F, 1.0F, 0.0F); + + EntityRenderDispatcher entityRenderDispatcher = MinecraftClient.getInstance().getEntityRenderManager(); + entityRenderDispatcher.setYaw(0); + entityRenderDispatcher.setRenderShadows(false); + entityRenderDispatcher.render(mc.player, 0.0, 0.0, 0.0, 0.0F, MinecraftUtils.getTickDelta()); + entityRenderDispatcher.setRenderShadows(true); + + GlStateManager.popMatrix(); + DiffuseLighting.disable(); + GlStateManager.disableRescaleNormal(); + GlStateManager.activeTexture(GLX.lightmapTextureUnit); + GlStateManager.disableTexture(); + GlStateManager.activeTexture(GLX.textureUnit); + + } + + @EventHandler + public void onPlayerRotate(PlayerHeadRotateEvent event) { + if (event.yaw == 0 && event.pitch == 0) { + return; + } + yawOffset += (event.yaw * .15) / 2; + } + + @Override + public void render(Position position, boolean editMode) { + renderPlayer(position.getX() + 31, position.getY() + 86, MinecraftUtils.getTickDelta()); + } + + @EventHandler + public void onTick(PreTickEvent event) { + lastYawOffset = yawOffset; + yawOffset *= .93f; + } + +} diff --git a/src/main/resources/assets/sol_client/lang/en_US.lang b/src/main/resources/assets/sol_client/lang/en_US.lang index 9c3bbd64..00e220c0 100644 --- a/src/main/resources/assets/sol_client/lang/en_US.lang +++ b/src/main/resources/assets/sol_client/lang/en_US.lang @@ -479,6 +479,11 @@ sol_client.mod.discord_integration.option.speakingColour=Speaking colour sol_client.mod.discord_integration.multiplayer=Multiplayer: %s +sol_client.mod.paperdoll.name=Paper Doll +sol_client.mod.paperdoll.description=Renders a small version of you on screen. +sol_client.mod.paperdoll.option.dynamicRotation=Dynamic Rotation +sol_client.mod.paperdoll.option.rotation=Rotation Offset + sol_client.mod.screen.title=Modules sol_client.mod.screen.search=Type to search sol_client.mod.screen.apply_to_all=Apply to All diff --git a/src/main/resources/standard-mods.json b/src/main/resources/standard-mods.json index b5cf2e09..d90622ad 100644 --- a/src/main/resources/standard-mods.json +++ b/src/main/resources/standard-mods.json @@ -96,6 +96,11 @@ "main": "hud.PotionEffectsMod", "category": "hud" }, + { + "id": "paperdoll", + "main": "hud.PaperDollMod", + "category": "hud" + }, { "id": "armour", "main": "hud.armour.ArmourMod", From e9623892bc5a0892ce24583d11c5b682b44b18f0 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Mon, 24 Apr 2023 17:01:32 -0600 Subject: [PATCH 18/23] Remove unnecessary import --- .../solclient/client/mod/impl/core/mixins/EntityMixin.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/io/github/solclient/client/mod/impl/core/mixins/EntityMixin.java b/src/main/java/io/github/solclient/client/mod/impl/core/mixins/EntityMixin.java index a66526c1..d0a3b243 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/core/mixins/EntityMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/core/mixins/EntityMixin.java @@ -23,7 +23,6 @@ import io.github.solclient.client.culling.Cullable; import lombok.*; import net.minecraft.entity.Entity; -import org.spongepowered.asm.mixin.injection.Inject; @Mixin(Entity.class) public abstract class EntityMixin implements Cullable { From b9acbf9f20c72c57cc9e48452775519da01df9d5 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Wed, 26 Apr 2023 12:21:33 -0600 Subject: [PATCH 19/23] Adding a lot more options and more stat displays --- .../client/mod/impl/hud/PaperDollMod.java | 3 + .../impl/hud/bedwarsoverlay/BedwarsGame.java | 34 +++++++- .../impl/hud/bedwarsoverlay/BedwarsMod.java | 55 +++++++++++++ .../bedwarsoverlay/BedwarsPlayerStats.java | 49 +++++++----- .../bedwarsoverlay/mixins/InGameHudMixin.java | 42 ++++++++++ .../mixins/PlayerEntityMixin.java | 26 +++++++ .../mixins/PlayerListHudMixin.java | 78 ++++++++++++++++++- .../mixins/PlayerEntityRendererMixin.java | 19 +++-- 8 files changed, 274 insertions(+), 32 deletions(-) create mode 100644 src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/InGameHudMixin.java create mode 100644 src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerEntityMixin.java diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java b/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java index 6983c12d..b9314e59 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java @@ -73,6 +73,8 @@ public void renderPlayer(double x, double y, float delta) { deltaYaw -= (lastYawOffset + ((yawOffset - lastYawOffset) * delta)); } + GlStateManager.enableLighting(); + GlStateManager.color(1, 1, 1, 1); GlStateManager.enableColorMaterial(); GlStateManager.pushMatrix(); GlStateManager.translate((float) x, (float) y, 500.0F); @@ -83,6 +85,7 @@ public void renderPlayer(double x, double y, float delta) { DiffuseLighting.enableNormally(); GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(deltaYaw + rotation, 0.0F, 1.0F, 0.0F); + GlStateManager.translate(0.0F, 0.0F, 0.0F); EntityRenderDispatcher entityRenderDispatcher = MinecraftClient.getInstance().getEntityRenderManager(); entityRenderDispatcher.setYaw(0); diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index 6361fccb..ee39ac6f 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -23,6 +23,7 @@ import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades.BedwarsTeamUpgrades; import lombok.Getter; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.scoreboard.ScoreboardPlayerScore; @@ -59,8 +60,8 @@ public class BedwarsGame { private BedwarsPlayer me = null; - // Use a treemap here for the O(log(n)) time - private final Map players = new TreeMap<>(); + private final Map players = new HashMap<>(16); + private final Map playersById = new HashMap<>(16); private final MinecraftClient mc; @Getter private boolean started = false; @@ -75,9 +76,9 @@ public BedwarsGame(BedwarsMod mod) { } public void onStart() { - debug("Game started"); mod.upgradesOverlay.onStart(upgrades); players.clear(); + playersById.clear(); Map> teamPlayers = new HashMap<>(); for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { String name = mc.inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); @@ -108,6 +109,7 @@ public void onStart() { me = p; } players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); } } this.started = true; @@ -141,6 +143,10 @@ public String getFormattedTime() { return time; } + public Optional getPlayer(UUID uuid) { + return Optional.ofNullable(playersById.getOrDefault(uuid, null)); + } + public Optional getPlayer(String name) { return Optional.ofNullable(players.getOrDefault(name, null)); } @@ -274,7 +280,7 @@ private void gameEnd(BedwarsTeam win) { int after = winner ? before + 1 : 0; mc.inGameHud.getChatHud().addMessage( new LiteralText( - getPlayerFormatted(p) + "§8: §7" + before + " §8→ §" + (winner ? "a" : "c") + after + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after )); } } @@ -425,4 +431,24 @@ public List getTabPlayerList(List original) { }).map(BedwarsPlayer::getProfile).collect(Collectors.toList()); } + public BedwarsPlayer getSelf() { + return me; + } + + public String getLevelHead(AbstractClientPlayerEntity entity) { + BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); + if (player == null) { + return null; + } + BedwarsPlayerStats stats = player.getStats(); + if (stats == null) { + return null; + } + if (seconds / 5 % 2 == 0) { + return String.format("FKDR %.2f", stats.getFKDR()); + } else { + return String.format("BBLR %.2f", stats.getBBLR()); + } + } + } diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java index 662c48a7..03430741 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMod.java @@ -33,11 +33,16 @@ import io.github.solclient.client.mod.option.annotation.Option; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.resource.language.I18n; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; import net.minecraft.text.LiteralText; +import net.minecraft.util.Formatting; import java.util.*; import java.util.regex.Pattern; +import java.util.stream.Collectors; @AbstractTranslationKey("sol_client.mod.bedwars") public final class BedwarsMod extends StandardMod { @@ -49,6 +54,23 @@ public final class BedwarsMod extends StandardMod { }; public static BedwarsMod instance; + + @Expose + @Option + public boolean hardcoreHearts = true; + + @Expose + @Option + public boolean showHunger = false; + + @Expose + @Option + public boolean displayArmor = true; + + @Expose + @Option + public boolean bedwarsLevelHead = true; + protected BedwarsGame currentGame = null; @Expose @@ -58,6 +80,10 @@ public final class BedwarsMod extends StandardMod { @Option protected boolean removeAnnoyingMessages = true; + @Expose + @Option + private boolean tabRenderLatencyIcon = false; + @Expose @Option protected boolean showChatTime = true; @@ -66,6 +92,7 @@ public final class BedwarsMod extends StandardMod { @Option protected boolean overrideMessages = true; private int targetTick = -1; + private boolean waiting = false; public BedwarsMod() { upgradesOverlay = new TeamUpgradesOverlay(this); @@ -96,6 +123,13 @@ public void onWorldLoad(WorldLoadEvent event) { } } + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + @EventHandler public void onMessage(ReceiveChatMessageEvent event) { // Remove formatting @@ -124,6 +158,7 @@ public Optional getGame() { @EventHandler public void onTick(PreTickEvent event) { if (currentGame != null) { + waiting = false; if (currentGame.isStarted()) { // Trigger setting the header mc.inGameHud.getPlayerListWidget().setHeader(null); @@ -163,8 +198,23 @@ public boolean inGame() { @EventHandler public void onScoreboardRender(ScoreboardRenderEvent event) { if (inGame()) { + waiting = false; currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.objective.getDisplayName()).contains("BED WARS")) { + return; } + Scoreboard scoreboard = event.objective.getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.objective); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, score.getPlayerName())).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); } public void gameEnd() { @@ -176,4 +226,9 @@ public void gameEnd() { public void registerOtherTypeAdapters(GsonBuilder builder) { builder.registerTypeAdapter(TeamUpgradesOverlay.class, (InstanceCreator) (type) -> upgradesOverlay); } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon; + } + } diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java index 54381664..8195213f 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import com.google.gson.JsonElement; @@ -73,7 +73,7 @@ public static BedwarsPlayerStats fromAPI(PlayerReply.Player player) { return new BedwarsPlayerStats(finalKills, finalDeaths, bedsBroken, deaths, kills, losses, wins, winstreak); } - private static int getAsIntElse(JsonObject obj, String key, int other) { + public static int getAsIntElse(JsonObject obj, String key, int other) { if (obj.has(key)) { try { return obj.get(key).getAsInt(); @@ -84,7 +84,7 @@ private static int getAsIntElse(JsonObject obj, String key, int other) { return other; } - private static JsonObject getObjectSafe(JsonObject object, String key) { + public static JsonObject getObjectSafe(JsonObject object, String key) { if (!object.has(key)) { return null; } @@ -114,4 +114,13 @@ public void addFinalKill() { public void addBed() { bedsBroken++; } + + public float getFKDR() { + return (float) finalKills / finalDeaths; + } + + public float getBBLR() { + return (float) bedsBroken / losses; + } + } diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/InGameHudMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/InGameHudMixin.java new file mode 100644 index 00000000..b4f9bc38 --- /dev/null +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/InGameHudMixin.java @@ -0,0 +1,42 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.mixins; + +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMod; +import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.entity.Entity; +import net.minecraft.entity.vehicle.MinecartEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(InGameHud.class) +public class InGameHudMixin { + + private static final Entity noHungerEntityTM = new MinecartEntity(null); + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value="STORE" + ), + ordinal = 18 + ) + public int displayHardcoreHearts(int offset) { + boolean hardcore = BedwarsMod.instance.isEnabled() && BedwarsMod.instance.inGame() && BedwarsMod.instance.hardcoreHearts && !BedwarsMod.instance.getGame().get().getSelf().isBed(); + return hardcore ? 5 : 0; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value="STORE" + ), + ordinal = 0 + ) + public Entity dontHunger(Entity normal) { + if (normal == null && BedwarsMod.instance.isEnabled() && BedwarsMod.instance.inGame() && !BedwarsMod.instance.showHunger) { + return noHungerEntityTM; + } + return normal; + } + +} diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerEntityMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerEntityMixin.java new file mode 100644 index 00000000..8e9fd86f --- /dev/null +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerEntityMixin.java @@ -0,0 +1,26 @@ +package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.mixins; + +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMod; +import net.minecraft.entity.player.PlayerEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(PlayerEntity.class) +public class PlayerEntityMixin { + + @Inject( + method = "getArmorProtectionValue", + at = @At( + "HEAD" + ), + cancellable = true + ) + public void disableArmor(CallbackInfoReturnable ci) { + if (BedwarsMod.instance.isEnabled() && BedwarsMod.instance.inGame() && !BedwarsMod.instance.displayArmor) { + ci.setReturnValue(0); + } + } + +} diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java index 7cc8aff6..f4e7b89d 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java @@ -19,9 +19,15 @@ package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.mixins; import java.util.List; +import java.util.Optional; +import com.google.gson.JsonObject; +import io.github.solclient.client.mod.impl.hypixeladditions.HypixelAPICache; import io.github.solclient.client.util.data.Colour; +import net.hypixel.api.reply.PlayerReply; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.scoreboard.Scoreboard; import net.minecraft.scoreboard.ScoreboardObjective; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.*; @@ -41,6 +47,53 @@ public class PlayerListHudMixin { @Shadow @Final private MinecraftClient client; + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void renderWithoutObjective( + int width, Scoreboard scoreboard, ScoreboardObjective playerListScoreboardObjective, CallbackInfo ci, + ClientPlayNetworkHandler clientPlayNetworkHandler, List list, int i, int j, int l, int m, int k, boolean bl, int n, int o, + int p, int q, int r, List list2, int t, int u, int s, int v, int y, PlayerListEntry playerListEntry2 + ) { + if (!BedwarsMod.instance.isEnabled() || !BedwarsMod.instance.isWaiting()) { + return; + } + Optional playerStatsOpt = HypixelAPICache.getInstance().getPlayerFromCache(playerListEntry2.getProfile().getId()); + if (!playerStatsOpt.isPresent()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + JsonObject playerStats = playerStatsOpt.get().getRaw().get("stats").getAsJsonObject(); + JsonObject stats = BedwarsPlayerStats.getObjectSafe(playerStats, "Bedwars"); + if (stats == null) { + return; + } + String render = String.format("%.2f", (float) (BedwarsPlayerStats.getAsIntElse(stats, "final_kills_bedwars", 1)) / BedwarsPlayerStats.getAsIntElse(stats, "final_deaths_bedwars", 1)); + this.client.textRenderer.drawWithShadow( + render, + (float)(endX - this.client.textRenderer.getStringWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderLatencyIcon", + at = @At("HEAD"), + cancellable = true + ) + public void cancelLatencyIcon(int width, int x, int y, PlayerListEntry playerEntry, CallbackInfo ci) { + if (BedwarsMod.instance.isEnabled() && BedwarsMod.instance.blockLatencyIcon() && (BedwarsMod.instance.isWaiting() || BedwarsMod.instance.inGame())) { + ci.cancel(); + } + } + @Inject( method = "renderScoreboardObjective", at = @At( @@ -54,6 +107,7 @@ public void renderCustomScoreboardObjective( if (!BedwarsMod.instance.isEnabled()) { return; } + BedwarsGame game = BedwarsMod.instance.getGame().orElse(null); if (game == null) { return; @@ -64,17 +118,18 @@ public void renderCustomScoreboardObjective( } ci.cancel(); String render; - int color = 16777215; + int color; if (!bedwarsPlayer.isAlive()) { if (bedwarsPlayer.isDisconnected()) { return; } int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - this.client.inGameHud.getTicks()); float secondsTillLive = tickTillLive / 20f; - render = String.format("%.2f", secondsTillLive) + "s"; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Colour(200, 200, 200).getValue(); } else { int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); - color = new Colour(50,205,50).lerp(new Colour(215, 0, 64), 1 - (health / 20f)).getValue(); + color = new Colour(255,255,255).lerp(new Colour(215, 0, 64), 1 - (health / 20f)).getValue(); render = String.valueOf(health); } // Health @@ -87,6 +142,23 @@ public void renderCustomScoreboardObjective( } + @ModifyVariable( + method = "render", + at = @At( + value="STORE" + ), + ordinal = 7 + ) + public int changeWidth(int value) { + if (BedwarsMod.instance.isEnabled() && BedwarsMod.instance.blockLatencyIcon() && (BedwarsMod.instance.isWaiting() || BedwarsMod.instance.inGame())) { + value -= 9; + } + if (BedwarsMod.instance.isEnabled() && BedwarsMod.instance.isWaiting()) { + value += 20; + } + return value; + } + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) public void getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { if (!BedwarsMod.instance.isEnabled()) { diff --git a/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/mixins/PlayerEntityRendererMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/mixins/PlayerEntityRendererMixin.java index f26785eb..1665d7b5 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/mixins/PlayerEntityRendererMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/mixins/PlayerEntityRendererMixin.java @@ -18,6 +18,7 @@ package io.github.solclient.client.mod.impl.hypixeladditions.mixins; +import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMod; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -38,14 +39,22 @@ protected PlayerEntityRendererMixin(EntityRenderDispatcher dispatcher) { @Inject(method = "method_10209(Lnet/minecraft/client/network/AbstractClientPlayerEntity;DDDLjava/lang/String;FD)V", at = @At("RETURN")) public void renderLevelhead(AbstractClientPlayerEntity entityIn, double x, double y, double z, String str, float p_177069_9_, double p_177069_10_, CallbackInfo callback) { - if (HypixelAdditionsMod.isEffective()) { + if (BedwarsMod.instance.isEnabled() && BedwarsMod.instance.inGame() && BedwarsMod.instance.bedwarsLevelHead) { + String levelhead = BedwarsMod.instance.getGame().get().getLevelHead(entityIn); + if (levelhead != null) { + renderLabelIfPresent(entityIn, Formatting.GRAY + levelhead, x, + y + (getFontRenderer().fontHeight * 1.15F * p_177069_9_), z, 64 + ); + } + } else if (HypixelAdditionsMod.isEffective()) { String levelhead = HypixelAdditionsMod.instance.getLevelhead( entityIn == MinecraftClient.getInstance().player, entityIn.getName().asFormattedString(), entityIn.getUuid()); - - if (levelhead != null) - renderLabelIfPresent(entityIn, Formatting.AQUA + "Level: " + Formatting.YELLOW + levelhead, x, - y + (getFontRenderer().fontHeight * 1.15F * p_177069_9_), z, 64); + if (levelhead != null) { + renderLabelIfPresent(entityIn, Formatting.AQUA + "Level: " + Formatting.YELLOW + levelhead, x, + y + (getFontRenderer().fontHeight * 1.15F * p_177069_9_), z, 64 + ); + } } } From 4c492331e8cd7b6a135298d000dbdd88da688b90 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Wed, 26 Apr 2023 14:20:39 -0600 Subject: [PATCH 20/23] Remove game specific stats from before/during game --- .../impl/hud/bedwarsoverlay/BedwarsGame.java | 37 +++++++++++++---- .../hud/bedwarsoverlay/BedwarsPlayer.java | 3 +- .../bedwarsoverlay/BedwarsPlayerStats.java | 41 ++++++++++++++++++- .../mixins/PlayerListHudMixin.java | 11 +---- 4 files changed, 71 insertions(+), 21 deletions(-) diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java index ee39ac6f..338be7e2 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsGame.java @@ -176,13 +176,38 @@ private String formatReconnect(BedwarsPlayer reconnected) { } private String formatEliminated(BedwarsTeam team) { - return "§6§l§oTEAM ELMINATED §8§l> " + team.getColorSection() + team.getName() + " Team §7/eliminated/ "; + StringBuilder message = new StringBuilder( + "§6§l§oTEAM ELIMINATED §8§l> " + team.getColorSection() + team.getName() + " Team §7/eliminated/ "); + for (BedwarsPlayer p : players.values().stream() + .filter(b -> b.getTeam() == team) + .sorted(Comparator.comparingInt(BedwarsPlayer::getNumber)) + .collect(Collectors.toList())) + { + BedwarsPlayerStats stats = p.getStats(); + if (stats == null) { + continue; + } + message.append("\n") + .append("§b") + .append(stats.getStars()) + .append(" ") + .append(p.getColoredName()) + .append("§7 Beds: §f") + .append(stats.getBedsBroken()) + .append("§7 Finals: §f") + .append(stats.getFinalKills()) + .append("§7 FKDR: §f") + .append(String.format("%.2f", stats.getFKDR())) + .append("§7 BBLR: §f") + .append(String.format("%.2f", stats.getBBLR())); + } + return message.toString(); } private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { String playerFormatted = getPlayerFormatted(breaker); return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted + - (breaker.getStats() == null ? "" : " §6" + breaker.getStats().getBedsBroken()); + (breaker.getStats() == null || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); } private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { @@ -197,7 +222,7 @@ private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, return playerFormatted + " " + inner; } String killerFormatted = getPlayerFormatted(killer); - if (finalDeath && killer.getStats() != null) { + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { killerFormatted += " §6" + killer.getStats().getFinalKills(); } return playerFormatted + " " + inner + " " + killerFormatted; @@ -444,11 +469,7 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { if (stats == null) { return null; } - if (seconds / 5 % 2 == 0) { - return String.format("FKDR %.2f", stats.getFKDR()); - } else { - return String.format("BBLR %.2f", stats.getBBLR()); - } + return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); } } diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java index 93574a2d..29adb9bb 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java @@ -157,9 +157,8 @@ public void killed(boolean finalKill) { if (stats != null) { if (finalKill) { stats.addFinalKill(); - } else { - stats.addKill(); } + stats.addKill(); } } } diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java index 8195213f..8e93d38b 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java @@ -40,15 +40,42 @@ public class BedwarsPlayerStats { @Getter private int kills; @Getter + private int gameFinalKills; + @Getter + private int gameFinalDeaths; + @Getter + private int gameBedsBroken; + @Getter + private int gameDeaths; + @Getter + private int gameKills; + @Getter private final int losses; @Getter private final int wins; @Getter private final int winstreak; + @Getter + private final int stars; public static BedwarsPlayerStats generateFake() { - return new BedwarsPlayerStats(0, 0, 0, 0, 0, 0, 0, 0); + return new BedwarsPlayerStats( + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1 + ); } @Nullable @@ -70,7 +97,12 @@ public static BedwarsPlayerStats fromAPI(PlayerReply.Player player) { int losses = getAsIntElse(bedwars, "losses_bedwars", 0); int wins = getAsIntElse(bedwars, "wins_bedwars", 0); int winstreak = getAsIntElse(bedwars, "winstreak", 0); - return new BedwarsPlayerStats(finalKills, finalDeaths, bedsBroken, deaths, kills, losses, wins, winstreak); + JsonObject achievements = getObjectSafe(stats, "achievements"); + int stars = 1; + if (achievements != null) { + stars = getAsIntElse(achievements, "bedwars_level", 1); + } + return new BedwarsPlayerStats(finalKills, finalDeaths, bedsBroken, deaths, kills, 0, 0, 0, 0, 0, losses, wins, winstreak, stars); } public static int getAsIntElse(JsonObject obj, String key, int other) { @@ -97,22 +129,27 @@ public static JsonObject getObjectSafe(JsonObject object, String key) { public void addDeath() { deaths++; + gameDeaths++; } public void addFinalDeath() { finalDeaths++; + gameFinalDeaths++; } public void addKill() { kills++; + gameKills++; } public void addFinalKill() { finalKills++; + gameFinalKills++; } public void addBed() { bedsBroken++; + gameBedsBroken++; } public float getFKDR() { diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java index f4e7b89d..b90fb3f7 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java @@ -23,6 +23,7 @@ import com.google.gson.JsonObject; import io.github.solclient.client.mod.impl.hypixeladditions.HypixelAPICache; +import io.github.solclient.client.mod.impl.hypixeladditions.HypixelAdditionsMod; import io.github.solclient.client.util.data.Colour; import net.hypixel.api.reply.PlayerReply; import net.minecraft.client.MinecraftClient; @@ -64,17 +65,9 @@ public void renderWithoutObjective( return; } Optional playerStatsOpt = HypixelAPICache.getInstance().getPlayerFromCache(playerListEntry2.getProfile().getId()); - if (!playerStatsOpt.isPresent()) { - return; - } int startX = v + i + 1; int endX = startX + n; - JsonObject playerStats = playerStatsOpt.get().getRaw().get("stats").getAsJsonObject(); - JsonObject stats = BedwarsPlayerStats.getObjectSafe(playerStats, "Bedwars"); - if (stats == null) { - return; - } - String render = String.format("%.2f", (float) (BedwarsPlayerStats.getAsIntElse(stats, "final_kills_bedwars", 1)) / BedwarsPlayerStats.getAsIntElse(stats, "final_deaths_bedwars", 1)); + String render = HypixelAdditionsMod.instance.getLevelhead(false, playerListEntry2.getDisplayName().asFormattedString(), playerListEntry2.getProfile().getId()); this.client.textRenderer.drawWithShadow( render, (float)(endX - this.client.textRenderer.getStringWidth(render)) + 20, From dd6f7d717d670a7803fa3de018aedac44c16b0ca Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Thu, 27 Apr 2023 09:37:38 -0600 Subject: [PATCH 21/23] Remove unnecessary line --- .../mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java index b90fb3f7..b34dbe94 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java @@ -64,7 +64,6 @@ public void renderWithoutObjective( if (!BedwarsMod.instance.isEnabled() || !BedwarsMod.instance.isWaiting()) { return; } - Optional playerStatsOpt = HypixelAPICache.getInstance().getPlayerFromCache(playerListEntry2.getProfile().getId()); int startX = v + i + 1; int endX = startX + n; String render = HypixelAdditionsMod.instance.getLevelhead(false, playerListEntry2.getDisplayName().asFormattedString(), playerListEntry2.getProfile().getId()); From 1e55f40c8f7dd5a287548836df55e8f899479874 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Thu, 27 Apr 2023 09:39:52 -0600 Subject: [PATCH 22/23] Licensing --- .../client/mod/impl/hud/PaperDollMod.java | 18 ++++++++++ .../hud/bedwarsoverlay/BedwarsDeathType.java | 36 +++++++++---------- .../hud/bedwarsoverlay/BedwarsMessages.java | 36 +++++++++---------- .../impl/hud/bedwarsoverlay/BedwarsMode.java | 36 +++++++++---------- .../impl/hud/bedwarsoverlay/BedwarsTeam.java | 36 +++++++++---------- .../bedwarsoverlay/mixins/InGameHudMixin.java | 18 ++++++++++ .../mixins/PlayerEntityMixin.java | 18 ++++++++++ .../bedwarsoverlay/stats/LobbyStatsHud.java | 36 +++++++++---------- .../upgrades/BinaryUpgrade.java | 36 +++++++++---------- .../bedwarsoverlay/upgrades/TeamUpgrade.java | 36 +++++++++---------- .../upgrades/TieredUpgrade.java | 36 +++++++++---------- .../bedwarsoverlay/upgrades/TrapUpgrade.java | 36 +++++++++---------- .../hypixeladditions/HypixelAPICache.java | 36 +++++++++---------- 13 files changed, 234 insertions(+), 180 deletions(-) diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java b/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java index b9314e59..e4fb3a89 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud; import com.google.gson.annotations.Expose; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java index 5e2c9cd7..fde69f58 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsDeathType.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import lombok.AllArgsConstructor; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java index c088605d..565e4345 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMessages.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import java.util.Arrays; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java index 2bdc29d2..114adcc5 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsMode.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; import lombok.Getter; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java index 5683a4e2..ee6f29dc 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsTeam.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/InGameHudMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/InGameHudMixin.java index b4f9bc38..73e2fb3f 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/InGameHudMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/InGameHudMixin.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.mixins; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMod; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerEntityMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerEntityMixin.java index 8e9fd86f..6a313224 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerEntityMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerEntityMixin.java @@ -1,3 +1,21 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.mixins; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMod; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java index 7ea0b06a..98cce546 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/stats/LobbyStatsHud.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.stats; import io.github.solclient.client.mod.Mod; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java index c5f503fe..ac226f0c 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/BinaryUpgrade.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java index f8410789..e50c3cff 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TeamUpgrade.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMessages; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java index a0ed727d..d0c2ff19 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TieredUpgrade.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java index bf13a96c..da48edfd 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/upgrades/TrapUpgrade.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hud.bedwarsoverlay.upgrades; import io.github.solclient.client.mod.impl.hud.bedwarsoverlay.BedwarsMode; diff --git a/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java b/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java index 6e46cabc..a6fe4d52 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hypixeladditions/HypixelAPICache.java @@ -1,21 +1,21 @@ -/* - * Sol Client - an open source Minecraft client - * Copyright (C) 2021-2023 TheKodeToad and Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package io.github.solclient.client.mod.impl.hypixeladditions; import io.github.solclient.client.util.ApacheHttpClient; From 1e5ce1002fd14c23fcc32926a09c1bb6a08025c4 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Mon, 1 May 2023 10:51:11 -0600 Subject: [PATCH 23/23] Fix star display --- .../mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java | 6 +++++- .../impl/hud/bedwarsoverlay/BedwarsPlayerStats.java | 2 +- .../hud/bedwarsoverlay/mixins/PlayerListHudMixin.java | 11 ++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java index 29adb9bb..4cd5d4b1 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayer.java @@ -98,7 +98,11 @@ public void tick(int currentTick) { stats = BedwarsPlayerStats.generateFake(); return; } - stats = BedwarsPlayerStats.fromAPI(player); + try { + stats = BedwarsPlayerStats.fromAPI(player); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(); + } }); } } diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java index 8e93d38b..2e4cb3ea 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/BedwarsPlayerStats.java @@ -97,7 +97,7 @@ public static BedwarsPlayerStats fromAPI(PlayerReply.Player player) { int losses = getAsIntElse(bedwars, "losses_bedwars", 0); int wins = getAsIntElse(bedwars, "wins_bedwars", 0); int winstreak = getAsIntElse(bedwars, "winstreak", 0); - JsonObject achievements = getObjectSafe(stats, "achievements"); + JsonObject achievements = getObjectSafe(player.getRaw().getAsJsonObject(), "achievements"); int stars = 1; if (achievements != null) { stars = getAsIntElse(achievements, "bedwars_level", 1); diff --git a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java index b34dbe94..aa4eeb5d 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java +++ b/src/main/java/io/github/solclient/client/mod/impl/hud/bedwarsoverlay/mixins/PlayerListHudMixin.java @@ -66,7 +66,16 @@ public void renderWithoutObjective( } int startX = v + i + 1; int endX = startX + n; - String render = HypixelAdditionsMod.instance.getLevelhead(false, playerListEntry2.getDisplayName().asFormattedString(), playerListEntry2.getProfile().getId()); + String render; + try { + render = HypixelAdditionsMod.instance.getLevelhead( + false, playerListEntry2.getProfile().getName(), playerListEntry2.getProfile().getId()); + } catch (Exception e) { + return; + } + if (render == null) { + return; + } this.client.textRenderer.drawWithShadow( render, (float)(endX - this.client.textRenderer.getStringWidth(render)) + 20,