From 6ef2c56dc5213bb5f3601ad813412d9ee2065d11 Mon Sep 17 00:00:00 2001 From: moehreag Date: Sat, 1 Jul 2023 00:01:54 +0200 Subject: [PATCH 01/41] port https://github.com/Sol-Client/client/pull/136 --- 1.8.9/build.gradle | 7 +- .../axolotlclient/mixin/ChatHudMixin.java | 26 +- .../mixin/EntityRendererMixin.java | 53 +- .../mixin/GameMenuScreenMixin.java | 4 +- .../axolotlclient/mixin/InGameHudMixin.java | 40 +- .../mixin/MinecraftClientMixin.java | 6 + .../mixin/PlayerEntityMixin.java | 14 + .../mixin/PlayerListHudMixin.java | 176 ++++++- .../axolotlclient/modules/auth/Auth.java | 2 + .../axolotlclient/modules/hud/HudManager.java | 2 + .../modules/hypixel/HypixelMods.java | 2 + .../modules/hypixel/autoboop/AutoBoop.java | 20 +- .../modules/hypixel/autogg/AutoGG.java | 11 +- .../modules/hypixel/autotip/AutoTip.java | 16 +- .../hypixel/bedwars/BedwarsDeathType.java | 62 +++ .../modules/hypixel/bedwars/BedwarsGame.java | 478 ++++++++++++++++++ .../hypixel/bedwars/BedwarsMessages.java | 308 +++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 223 ++++++++ .../modules/hypixel/bedwars/BedwarsMode.java | 43 ++ .../hypixel/bedwars/BedwarsPlayer.java | 156 ++++++ .../hypixel/bedwars/BedwarsPlayerStats.java | 167 ++++++ .../modules/hypixel/bedwars/BedwarsTeam.java | 77 +++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 110 ++++ .../hypixel/bedwars/stats/LobbyStatsHud.java | 127 +++++ .../bedwars/upgrades/BedwarsTeamUpgrades.java | 76 +++ .../bedwars/upgrades/BinaryUpgrade.java | 65 +++ .../hypixel/bedwars/upgrades/TeamUpgrade.java | 64 +++ .../bedwars/upgrades/TieredUpgrade.java | 73 +++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 125 +++++ .../io/github/axolotlclient/util/Hooks.java | 19 + .../events/impl/ReceiveChatMessageEvent.java | 40 ++ .../events/impl/ScoreboardRenderEvent.java | 38 ++ .../util/events/impl/WorldLoadEvent.java | 33 ++ common/build.gradle | 1 + .../hypixel/HypixelAbstractionLayer.java | 22 + .../util/events/types/CancellableEvent.java | 13 + .../textures/bedwars/dragonbuff_0.png | Bin 0 -> 291 bytes .../textures/bedwars/dragonbuff_1.png | Bin 0 -> 291 bytes .../textures/bedwars/forge_0.png | Bin 0 -> 255 bytes .../textures/bedwars/forge_1.png | Bin 0 -> 255 bytes .../textures/bedwars/forge_2.png | Bin 0 -> 255 bytes .../textures/bedwars/forge_3.png | Bin 0 -> 255 bytes .../textures/bedwars/forge_4.png | Bin 0 -> 255 bytes .../textures/bedwars/haste_0.png | Bin 0 -> 269 bytes .../textures/bedwars/haste_1.png | Bin 0 -> 269 bytes .../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 .../axolotlclient/textures/bedwars/note.txt | 1 + .../axolotlclient/textures/bedwars/prot_0.png | Bin 0 -> 245 bytes .../axolotlclient/textures/bedwars/prot_1.png | Bin 0 -> 266 bytes .../axolotlclient/textures/bedwars/prot_2.png | Bin 0 -> 272 bytes .../axolotlclient/textures/bedwars/prot_3.png | Bin 0 -> 264 bytes .../axolotlclient/textures/bedwars/prot_4.png | Bin 0 -> 245 bytes .../textures/bedwars/sharp_0.png | Bin 0 -> 255 bytes .../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 .../textures/bedwars/trap/menu.png | Bin 0 -> 277 bytes .../textures/bedwars/trap/minerfatigue.png | Bin 0 -> 265 bytes gradle.properties | 2 +- 63 files changed, 2643 insertions(+), 59 deletions(-) create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java create mode 100644 common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/dragonbuff_0.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/dragonbuff_1.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_0.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_1.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_2.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_3.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_4.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_0.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_1.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_2.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/healpool_0.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/healpool_1.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/note.txt create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_0.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_1.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_2.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_3.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_4.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/sharp_0.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/sharp_1.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/alarm.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/counteroffensive.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/empty.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/itsatrap.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/menu.png create mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/minerfatigue.png diff --git a/1.8.9/build.gradle b/1.8.9/build.gradle index 7e92e5f9b..186cdd62f 100644 --- a/1.8.9/build.gradle +++ b/1.8.9/build.gradle @@ -32,12 +32,7 @@ dependencies { mappings "net.legacyfabric:yarn:${project.mappings_18}" modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader}" - - annotationProcessor "org.ow2.asm:asm:${project.asmVersion}" - annotationProcessor "org.ow2.asm:asm-analysis:${project.asmVersion}" - annotationProcessor "org.ow2.asm:asm-commons:${project.asmVersion}" - annotationProcessor "org.ow2.asm:asm-tree:${project.asmVersion}" - annotationProcessor "org.ow2.asm:asm-util:${project.asmVersion}" + modImplementation("net.fabricmc:dev-launch-injector:0.2.1+build.8") modImplementation "io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}" include "io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}" diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index 66fe75ffd..48427d8f7 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,19 +22,17 @@ package io.github.axolotlclient.mixin; -import java.util.List; - import io.github.axolotlclient.modules.hud.HudManager; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.Hooks; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatHudLine; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -42,6 +40,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.List; + @Mixin(ChatHud.class) public abstract class ChatHudMixin { @@ -51,14 +51,24 @@ public abstract class ChatHudMixin { @Inject(method = "addMessage(Lnet/minecraft/text/Text;IIZ)V", at = @At("HEAD"), cancellable = true) public void axolotlclient$autoGG(Text message, int messageId, int timestamp, boolean bl, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - if (AutoTip.getInstance().onChatMessage(message)) { + if(message == null){ ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;IIZ)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message){ + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, Formatting.strip(message.asFormattedString()), message); + Hooks.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if(event.isCancelled()){ + return null; + } else if(event.getNewMessage() != null){ + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;info(Ljava/lang/String;)V"), remap = false) public String axolotlclient$noNamesInLogIfHidden(String message) { return axolotlclient$editChat(new LiteralText(message)).asUnformattedString(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 586f5dfbc..b9ccdf137 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -26,6 +26,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.freelook.Perspective; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.util.Util; import net.minecraft.client.MinecraftClient; @@ -75,29 +76,18 @@ public abstract class EntityRendererMixin { public void axolotlclient$addLevel(T entity, String string, double d, double e, double f, int i, CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (Util.currentServerAddressContains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String levelhead = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (levelhead != null) { + axolotlclient$drawLevelHead(levelhead); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() && string.contains(entity.getName().asFormattedString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); - float x = textRenderer.getStringWidth(text) / 2F; - int y = string.contains("deadmau5") ? -20 : -10; - - if (LevelHead.getInstance().background.get()) { - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); - GlStateManager.disableTexture(); - bufferBuilder.begin(7, VertexFormats.POSITION_COLOR); - bufferBuilder.vertex(-x - 1, -1 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); - bufferBuilder.vertex(-x - 1, 8 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); - bufferBuilder.vertex(x + 1, 8 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); - bufferBuilder.vertex(x + 1, -1 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); - tessellator.draw(); - GlStateManager.enableTexture(); - } - - textRenderer.draw(text, -x, y, LevelHead.getInstance().textColor.get().getAsInt(), - AxolotlClient.CONFIG.useShadows.get()); + axolotlclient$drawLevelHead(text); } else if (!HypixelAbstractionLayer.hasValidAPIKey()) { HypixelAbstractionLayer.loadApiKey(); } @@ -105,6 +95,29 @@ public abstract class EntityRendererMixin { } } + private void axolotlclient$drawLevelHead(String text){ + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + + float x = textRenderer.getStringWidth(text) / 2F; + int y = text.contains("deadmau5") ? -20 : -10; + + if (LevelHead.getInstance().background.get()) { + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder bufferBuilder = tessellator.getBuffer(); + GlStateManager.disableTexture(); + bufferBuilder.begin(7, VertexFormats.POSITION_COLOR); + bufferBuilder.vertex(-x - 1, -1 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); + bufferBuilder.vertex(-x - 1, 8 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); + bufferBuilder.vertex(x + 1, 8 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); + bufferBuilder.vertex(x + 1, -1 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); + tessellator.draw(); + GlStateManager.enableTexture(); + } + + textRenderer.draw(text, -x, y, LevelHead.getInstance().textColor.get().getAsInt(), + AxolotlClient.CONFIG.useShadows.get()); + } + @Redirect(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/BufferBuilder;vertex(DDD)Lnet/minecraft/client/render/BufferBuilder;")) public BufferBuilder axolotlclient$noBg(BufferBuilder instance, double d, double e, double f) { if (AxolotlClient.CONFIG.nametagBackground.get()) { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java index 85e9e6004..9994e2581 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java @@ -77,9 +77,9 @@ public abstract class GameMenuScreenMixin extends Screen { if (axolotlclient$hasModMenu()) return; - if ((MinecraftClient.getInstance().getServer() != null + if (!MinecraftClient.getInstance().isInSingleplayer() && ((MinecraftClient.getInstance().getServer() != null && MinecraftClient.getInstance().getServer().isPublished()) - || MinecraftClient.getInstance().getCurrentServerEntry() != null) { + || MinecraftClient.getInstance().getCurrentServerEntry() != null)) { args.set(0, 20); args.set(5, I18n.translate("title_short")); } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index d4c8ce833..6702ab937 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -25,17 +25,17 @@ import com.mojang.blaze3d.platform.GlStateManager; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.Window; +import net.minecraft.entity.Entity; +import net.minecraft.entity.vehicle.MinecartEntity; import net.minecraft.scoreboard.ScoreboardObjective; 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.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -159,4 +159,36 @@ public abstract class InGameHudMixin { } return instance.getWidth(); } + + private static final Entity axolotlclient$noHungerEntityTM = new MinecartEntity(null); + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value="STORE" + ), + ordinal = 18 + ) + public int axolotlclient$displayHardcoreHearts(int offset) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 5 : 0; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value="STORE" + ), + ordinal = 0 + ) + public Entity axolotlclient$dontHunger(Entity normal) { + if (normal == null && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return axolotlclient$noHungerEntityTM; + } + return normal; + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index a281afed3..1bff6b2fd 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -30,6 +30,7 @@ import io.github.axolotlclient.util.Hooks; import io.github.axolotlclient.util.NetworkHelper; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; @@ -82,6 +83,11 @@ protected MinecraftClientMixin(TextureManager textureManager) { public void axolotlclient$noWorldGC() { } + @Inject(method = "connect(Lnet/minecraft/client/world/ClientWorld;Ljava/lang/String;)V", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld clientWorld, String string, CallbackInfo ci){ + Hooks.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(clientWorld)); + } + /** * @author moehreag * @reason Customize Window title for use in AxolotlClient diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 2b1f3ce62..e01fb0765 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,6 +25,7 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.client.particle.ParticleType; @@ -83,4 +84,17 @@ public PlayerEntityMixin(World world) { comboHud.onEntityDamage(this); } } + + @Inject( + method = "getArmorProtectionValue", + at = @At( + "HEAD" + ), + cancellable = true + ) + public void axolotlclient$disableArmor(CallbackInfoReturnable ci) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + ci.setReturnValue(0); + } + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 611e0f5a2..1d9283086 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,31 +22,43 @@ package io.github.axolotlclient.mixin; +import java.util.List; import java.util.UUID; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.network.ClientConnection; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin extends DrawableHelper { - MinecraftClient client = MinecraftClient.getInstance(); + @Shadow @Final + private final MinecraftClient client = MinecraftClient.getInstance(); @Shadow private Text header; @Shadow @@ -135,7 +147,167 @@ public abstract class PlayerListHudMixin extends DrawableHelper { } @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getPlayerByUuid(Ljava/util/UUID;)Lnet/minecraft/entity/player/PlayerEntity;")) - private UUID makeStuff(UUID par1) { + private UUID axolotlclient$makeStuff(UUID par1) { return Tablist.getInstance().alwaysShowHeadLayer.get() ? MinecraftClient.getInstance().player.getUuid() : par1; } + + @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 axolotlclient$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.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if(playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())){ + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + 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 axolotlclient$cancelLatencyIcon(int width, int x, int y, PlayerListEntry playerEntry, CallbackInfo ci) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } + } + + @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 axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, PlayerListEntry playerEntry, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().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; + 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("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); + color = Color.blend(new Color(255,255,255), new Color(215, 0, 64), (int) (1 - (health / 20f)*100)).getAsInt(); + render = String.valueOf(health); + } + // Health + this.client.textRenderer.drawWithShadow( + render, + (float)(endX - this.client.textRenderer.getStringWidth(render)), + (float) y, + color + ); + + } + + @ModifyVariable( + method = "render", + at = @At( + value="STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$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;", remap = false)) + public List axolotlclient$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 axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/auth/Auth.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/auth/Auth.java index de347f454..b65e106f8 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/auth/Auth.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/auth/Auth.java @@ -86,6 +86,8 @@ protected void login(MSAccount account) { Runnable runnable = () -> { try { ((MinecraftClientAccessor) client).setSession(new Session(account.getName(), account.getUuid(), account.getAuthToken(), Session.AccountType.MOJANG.name())); + client.getSessionProperties().clear(); + client.getSessionProperties(); save(); current = account; Notifications.getInstance().addStatus(I18n.translate("auth.notif.title"), I18n.translate("auth.notif.login.successful", current.getName())); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 4a67615ff..df3a66940 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -37,6 +37,7 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.legacyfabric.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; @@ -98,6 +99,7 @@ public void init() { add(new ComboHud()); add(new PlayerHud()); add(new ChatHud()); + add(BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); refreshAllBounds(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 4afa2c98d..dae95aa0f 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -33,6 +33,7 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 3fa55a4f4..bc23fd052 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -22,12 +22,14 @@ package io.github.axolotlclient.modules.hypixel.autoboop; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.Hooks; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; -import net.minecraft.text.Text; public class AutoBoop implements AbstractHypixelMod { @@ -40,6 +42,7 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); + Hooks.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -47,13 +50,16 @@ public OptionCategory getCategory() { return cat; } - public void onMessage(Text message) { - if (enabled.get() && message.asUnformattedString().contains("Friend >") - && message.asUnformattedString().contains("joined.")) { - String player = message.asUnformattedString().substring(message.asFormattedString().indexOf(">"), - message.asUnformattedString().lastIndexOf(" ")); + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage().trim(); + if (enabled.get() && message.contains("Friend >") + && message.contains("joined.")) { + System.out.println(message); + String player = message.substring(message.indexOf("Friend >"), + message.lastIndexOf(" ")); + System.out.println(player); Util.sendChatMessage("/boop " + player); - System.out.println("Booped " + player); + AxolotlClient.LOGGER.info("Booped " + player); } } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index 6c250b217..97a0177c2 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -31,7 +31,9 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.Hooks; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; @@ -88,6 +90,8 @@ public void init() { category.add(onBWP); category.add(onPVPL); category.add(onMMC); + + Hooks.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -158,7 +162,8 @@ private List addToList(String... strings) { return Arrays.stream(strings).collect(Collectors.toList()); } - public void onMessage(Text message) { + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage(); if (client.getCurrentServerEntry() != null) { serverMap.keySet().forEach(s -> { if (serverMap.get(s).get() && client.getCurrentServerEntry().address.contains(s)) { @@ -176,10 +181,10 @@ public void onMessage(Text message) { } } - private void processChat(Text messageReceived, List options, String messageToSend) { + private void processChat(String messageReceived, List options, String messageToSend) { if (System.currentTimeMillis() - this.lastTime > 3000 && options != null) { for (String s : options) { - if (messageReceived.asUnformattedString().contains(s)) { + if (messageReceived.contains(s)) { Util.sendChatMessage(messageToSend); this.lastTime = System.currentTimeMillis(); return; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 5a3fbae7c..86437371f 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,15 +22,16 @@ package io.github.axolotlclient.modules.hypixel.autotip; -import java.util.regex.Pattern; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.Hooks; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; + +import java.util.regex.Pattern; public class AutoTip implements AbstractHypixelMod { @@ -52,6 +53,8 @@ public class AutoTip implements AbstractHypixelMod { public void init() { category.add(enabled, hideMessages); init = true; + + Hooks.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); } @Override @@ -77,8 +80,9 @@ public boolean tickable() { return true; } - public boolean onChatMessage(Text text) { - return enabled.get() && hideMessages.get() && - (messagePattern.matcher(text.asUnformattedString()).matches() || tippedPattern.matcher(text.asUnformattedString()).matches()); + public void onChatMessage(ReceiveChatMessageEvent event) { + event.setCancelled(enabled.get() && hideMessages.get() && + (messagePattern.matcher(event.getOriginalMessage()).matches() || + tippedPattern.matcher(event.getOriginalMessage()).matches())); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java new file mode 100644 index 000000000..c7e31cd32 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -0,0 +1,62 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@AllArgsConstructor +public enum BedwarsDeathType { + 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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..79701d49f --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,478 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +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; +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; +import java.util.stream.Collectors; + +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; + + private final Map players = new HashMap<>(16); + private final Map playersById = new HashMap<>(16); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + 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("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + 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); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + 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; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + 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)); + } + + 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, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(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) { + 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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + 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 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(p -> disconnected(event, p)))) { + return; + } + 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 -> { + 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + 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(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + new LiteralText("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + 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 + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + 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(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatEliminated(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(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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) { + 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) && (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); + } + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + 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()); + } + + 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; + } + return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + } + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java new file mode 100644 index 000000000..16a6ed379 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -0,0 +1,308 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +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} 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}.", + "{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}")), + Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), + 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"), + Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), + }; + + 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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..ff26c7e10 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,223 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +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.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + 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*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + public String getDetail() { + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, + tabRenderLatencyIcon, showChatTime, overrideMessages); + + instance = this; + + Hooks.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Hooks.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Hooks.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled(){ + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getOriginalMessage().replaceAll("§.", ""); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(new LiteralText(time).append(event.getNewMessage())); + } else { + event.setNewMessage(new LiteralText(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListWidget().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name){ + return "bedwars."+name; + } + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java new file mode 100644 index 000000000..cf30d660e --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java @@ -0,0 +1,43 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..af9da0085 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,156 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + + +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; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + 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) { + this.team = team; + this.profile = profile; + 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(); + } + + 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 || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + 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; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + 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(); + } + stats.addKill(); + } + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java new file mode 100644 index 000000000..de7dcd218 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -0,0 +1,167 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import lombok.AllArgsConstructor; +import lombok.Getter; +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 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, + 0, + 0, + 0, + 0, + 0, + 1 + ); + } + + @Nullable + public static BedwarsPlayerStats fromAPI(String uuid) { + JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); + JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject();//getObjectSafe(player.getRaw().getAsJsonObject(), "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) { + if (obj.has(key)) { + try { + return obj.get(key).getAsInt(); + } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { + // Not actually an int + } + } + return other; + } + + public 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++; + gameDeaths++; + } + + public void addFinalDeath() { + finalDeaths++; + gameFinalDeaths++; + } + + public void addKill() { + kills++; + gameKills++; + } + + public void addFinalKill() { + finalKills++; + gameFinalKills++; + } + + public void addBed() { + bedsBroken++; + gameBedsBroken++; + } + + public float getFKDR() { + return (float) finalKills / finalDeaths; + } + + public float getBBLR() { + return (float) bedsBroken / losses; + } + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java new file mode 100644 index 000000000..45777cebe --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Locale; +import java.util.Optional; + + +@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'), + ; + + @Getter + private final char code; + + @Getter + private final char prefix; + + public String getColorSection() { + return "§" + code; + } + + public static Optional fromPrefix(char prefix) { + for (BedwarsTeam t : values()) { + if (t.getPrefix() == prefix) { + return Optional.of(t); + } + } + 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(); + } + + public String getName() { + return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); + } + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..59e56b5bd --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,110 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.mojang.blaze3d.platform.GlStateManager; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.util.Identifier; + +import java.util.List; + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient","bedwars_teamupgrades"); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + public void drawOverlay(DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + int x = position.x() + 1; + int y = position.y() + 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; + texture = u.getTexture()[0]; + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(x, y, 0, 0, 16, 16, 16, 16); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(x, y, 0, 0, 16, 16, 16, 16); + x += 17; + } + } + + @Override + public void renderComponent(float delta) { + drawOverlay(getPos(), false); + } + + @Override + public void renderPlaceholderComponent(float delta) { + drawOverlay(getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java new file mode 100644 index 000000000..077a86294 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java @@ -0,0 +1,127 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.stats; + +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hud.gui.component.HudEntry; +import net.minecraft.util.Identifier; + +import java.util.List; + + +public class LobbyStatsHud implements HudEntry { + + public LobbyStatsHud() { + + } + + public void update() { + + } + + @Override + public void setX(int x) { + + } + + @Override + public float getScale() { + return 0; + } + + @Override + public int getRawX() { + return 0; + } + + @Override + public int getRawY() { + return 0; + } + + @Override + public void setY(int y) { + + } + + @Override + public int getWidth() { + return 0; + } + + @Override + public int getHeight() { + return 0; + } + + @Override + public void setHeight(int height) { + + } + + @Override + public void setWidth(int width) { + + } + + @Override + public List> getConfigurationOptions() { + return null; + } + + @Override + public OptionCategory getOptionsAsCategory() { + return null; + } + + @Override + public boolean isEnabled() { + return false; + } + + @Override + public void setEnabled(boolean value) { + + } + + @Override + public void render(float delta) { + + } + + @Override + public void renderPlaceholder(float delta) { + + } + + @Override + public void setHovered(boolean hovered) { + + } + + @Override + public Identifier getId() { + return null; + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..7e6a8a7df --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,76 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +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"), + 8, 4 + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5 + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1 + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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,3}\\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} + ); + + public 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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java new file mode 100644 index 000000000..4f305b133 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class BinaryUpgrade extends TeamUpgrade { + + 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 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) { + return doublesPrice; + } + return foursPrice; + } + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java new file mode 100644 index 000000000..b5dd4bb6d --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -0,0 +1,64 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public abstract class TeamUpgrade { + @Getter + protected final String name; + protected 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 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); + + + public abstract boolean isPurchased(); +} + diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java new file mode 100644 index 000000000..4bc10a05d --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -0,0 +1,73 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.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 + 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; + } + + 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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..5b78f5e40 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,125 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 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("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")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.8.9/src/main/java/io/github/axolotlclient/util/Hooks.java index 08c847ae1..f379a433b 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/Hooks.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/Hooks.java @@ -22,10 +22,15 @@ package io.github.axolotlclient.util; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.legacyfabric.fabric.api.event.Event; import net.legacyfabric.fabric.api.event.EventFactory; import net.minecraft.client.option.KeyBinding; +import java.util.Arrays; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -60,6 +65,20 @@ public class Hooks { } })); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent(){ + return EventFactory + .createArrayBacked(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } + public interface MouseInputCallback { void onMouseButton(int button); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..9771d77f8 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,40 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import net.minecraft.text.Text; + +@RequiredArgsConstructor +@Getter @Setter +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..f02d1858d --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import net.minecraft.scoreboard.ScoreboardObjective; + +import java.awt.*; + +@RequiredArgsConstructor +@Getter +public class ScoreboardRenderEvent extends CancellableEvent { + + private final Window window; + private final ScoreboardObjective objective; +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..742e55c90 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import net.minecraft.client.world.ClientWorld; + +@RequiredArgsConstructor @Getter +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/common/build.gradle b/common/build.gradle index 18b8a52e9..3a52dfba4 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -41,6 +41,7 @@ dependencies { compileOnly("org.apache.httpcomponents:httpclient:4.3.3") compileOnly("com.google.code.gson:gson:2.2.4") compileOnly("commons-io:commons-io:2.4") + compileOnly("org.apache.commons:commons-lang3:3.3.2") shadow(implementation("net.hypixel:hypixel-api-core:4.1") { exclude group: "com.google.code.gson", module: "gson" diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java index 0c47a91f2..3be664d49 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java @@ -32,6 +32,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.util.ThreadExecuter; import net.hypixel.api.HypixelAPI; @@ -62,6 +64,13 @@ public static boolean hasValidAPIKey() { return validApiKey; } + public static JsonElement getPlayerProperty(String uuid, String stat){ + if(loadPlayerDataIfAbsent(uuid)){ + return getPlayer(uuid).getProperty(stat); + } + return new JsonObject(); + } + public static int getPlayerLevel(String uuid, String mode) { if (api == null) { loadApiKey(); @@ -85,6 +94,19 @@ public static int getPlayerLevel(String uuid, String mode) { return 0; } + private static PlayerReply.Player getPlayer(String uuid){ + if (api == null) { + loadApiKey(); + } + if (loadPlayerDataIfAbsent(uuid)) { + try { + return cachedPlayerData.get(uuid).get(1, TimeUnit.MICROSECONDS).getPlayer(); + } catch (TimeoutException | InterruptedException | ExecutionException ignored) { + } + } + return null; + } + public static void loadApiKey() { String API_KEY = keySupplier.get(); if (API_KEY == null) { diff --git a/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java b/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java new file mode 100644 index 000000000..80ea1beec --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java @@ -0,0 +1,13 @@ +package io.github.axolotlclient.util.events.types; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +@RequiredArgsConstructor +public class CancellableEvent { + + @Getter @Setter + private boolean cancelled; + +} diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/dragonbuff_0.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/dragonbuff_1.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_2.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_3.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_4.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_0.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_2.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/healpool_0.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_1.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_2.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_3.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_4.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/sharp_0.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/sharp_1.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/counteroffensive.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/empty.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/itsatrap.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/menu.png b/common/src/main/resources/assets/axolotlclient/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/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/minerfatigue.png b/common/src/main/resources/assets/axolotlclient/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: Tue, 4 Jul 2023 13:07:44 +0200 Subject: [PATCH 02/41] remove unnecessary old code --- .../modules/hypixel/bedwars/BedwarsPlayerStats.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java index de7dcd218..ab5b8fc17 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -101,12 +101,12 @@ public static BedwarsPlayerStats fromAPI(String uuid) { int losses = getAsIntElse(bedwars, "losses_bedwars", 0); int wins = getAsIntElse(bedwars, "wins_bedwars", 0); int winstreak = getAsIntElse(bedwars, "winstreak", 0); - JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject();//getObjectSafe(player.getRaw().getAsJsonObject(), "achievements"); + JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); 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); + 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) { From dc941de3e2de3ace2c9cb664b2ef9382b0e514c4 Mon Sep 17 00:00:00 2001 From: moehreag Date: Tue, 4 Jul 2023 16:04:58 +0200 Subject: [PATCH 03/41] move class --- .../io/github/axolotlclient/mixin/ChatHudMixin.java | 4 ++-- .../io/github/axolotlclient/mixin/EntityMixin.java | 4 ++-- .../github/axolotlclient/mixin/KeyBindingMixin.java | 6 +++--- .../axolotlclient/mixin/MinecraftClientMixin.java | 6 +++--- .../modules/hud/gui/hud/KeystrokeHud.java | 6 +++--- .../modules/hud/gui/hud/PlayerHud.java | 4 ++-- .../modules/hud/gui/hud/simple/CPSHud.java | 6 +++--- .../modules/hypixel/autoboop/AutoBoop.java | 4 ++-- .../modules/hypixel/autogg/AutoGG.java | 5 ++--- .../modules/hypixel/autotip/AutoTip.java | 4 ++-- .../modules/hypixel/bedwars/BedwarsMod.java | 8 ++++---- .../util/{Hooks.java => events/Events.java} | 13 ++++--------- 12 files changed, 32 insertions(+), 38 deletions(-) rename 1.8.9/src/main/java/io/github/axolotlclient/util/{Hooks.java => events/Events.java} (93%) diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index 48427d8f7..874f7f2a3 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -24,7 +24,7 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.Util; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.DrawableHelper; @@ -60,7 +60,7 @@ public abstract class ChatHudMixin { @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;IIZ)V", at = @At("HEAD"), argsOnly = true) private Text axolotlclient$onChatMessage(Text message){ ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, Formatting.strip(message.asFormattedString()), message); - Hooks.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); if(event.isCancelled()){ return null; } else if(event.getNewMessage() != null){ diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index 46d8c2d38..42f4b9cfe 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -22,7 +22,7 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -51,6 +51,6 @@ public abstract class EntityMixin { pitch = (float) ((double) prevPitch - (double) pitch * 0.15); yaw = (float) ((double) prevYaw + (double) yaw * 0.15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java index d83cc8096..dde54459e 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java @@ -22,7 +22,7 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; import net.minecraft.util.collection.IntObjectStorage; @@ -49,7 +49,7 @@ public abstract class KeyBindingMixin { @Inject(method = "setKeyPressed", at = @At(value = "FIELD", target = "Lnet/minecraft/client/option/KeyBinding;pressed:Z")) private static void axolotlclient$onPress(int keyCode, boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress(KEY_MAP.get(keyCode)); + Events.KEYBIND_PRESS.invoker().onPress(KEY_MAP.get(keyCode)); } } @@ -68,6 +68,6 @@ public abstract class KeyBindingMixin { @Inject(method = "setCode", at = @At("RETURN")) public void axolotlclient$boundKeySet(int code, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(code); + Events.KEYBIND_CHANGE.invoker().setBoundKey(code); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 1bff6b2fd..5f0e18b4a 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,7 +27,7 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.NetworkHelper; import io.github.axolotlclient.util.Util; import io.github.axolotlclient.util.events.impl.WorldLoadEvent; @@ -85,7 +85,7 @@ protected MinecraftClientMixin(TextureManager textureManager) { @Inject(method = "connect(Lnet/minecraft/client/world/ClientWorld;Ljava/lang/String;)V", at = @At("HEAD")) private void axolotlclient$onWorldLoad(ClientWorld clientWorld, String string, CallbackInfo ci){ - Hooks.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(clientWorld)); + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(clientWorld)); } /** @@ -161,7 +161,7 @@ protected MinecraftClientMixin(TextureManager textureManager) { @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getTime()J", ordinal = 0)) public void axolotlclient$onMouseButton(CallbackInfo ci) { if (Mouse.getEventButtonState()) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(Mouse.getEventButton()); + Events.MOUSE_INPUT.invoker().onMouseButton(Mouse.getEventButton()); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index e388664b4..1ee13f4c9 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -36,7 +36,7 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.Util; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.GameOptions; @@ -89,8 +89,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 83f258d32..91b8e6108 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -30,7 +30,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import lombok.Getter; import net.minecraft.block.material.Material; import net.minecraft.client.render.DiffuseLighting; @@ -61,7 +61,7 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 5c81e5932..55625f6d9 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -28,7 +28,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.client.MinecraftClient; import net.minecraft.util.Identifier; @@ -48,7 +48,7 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register(button -> { + Events.MOUSE_INPUT.register(button -> { if (!fromKeybindings.get()) { if (button == 0) { ClickList.LEFT.click(); @@ -57,7 +57,7 @@ public CPSHud() { } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEYBIND_PRESS.register((key) -> { if (fromKeybindings.get()) { if (key.equals(client.options.attackKey)) { ClickList.LEFT.click(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index bc23fd052..2b809219c 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -26,7 +26,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.Util; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; @@ -42,7 +42,7 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); - Hooks.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index 97a0177c2..0dbaffd14 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -31,12 +31,11 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.Util; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; /** * Based on DragonEggBedrockBreaking's AutoGG Mod @@ -91,7 +90,7 @@ public void init() { category.add(onPVPL); category.add(onMMC); - Hooks.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 86437371f..2b8fe8364 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -25,7 +25,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.Util; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; @@ -54,7 +54,7 @@ public void init() { category.add(enabled, hideMessages); init = true; - Hooks.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); } @Override diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index ff26c7e10..3edb91c90 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -25,7 +25,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import io.github.axolotlclient.util.events.impl.WorldLoadEvent; @@ -105,9 +105,9 @@ public void init() { instance = this; - Hooks.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); - Hooks.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); - Hooks.WORLD_LOAD_EVENT.register(this::onWorldLoad); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); } public boolean isEnabled(){ diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java similarity index 93% rename from 1.8.9/src/main/java/io/github/axolotlclient/util/Hooks.java rename to 1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java index f379a433b..00bb659fb 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/Hooks.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -20,7 +20,7 @@ * For more information, see the LICENSE file. */ -package io.github.axolotlclient.util; +package io.github.axolotlclient.util.events; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -31,14 +31,7 @@ import java.util.Arrays; -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { +public class Events { public static final Event MOUSE_INPUT = EventFactory.createArrayBacked(MouseInputCallback.class, listeners -> (button -> { @@ -79,6 +72,8 @@ public interface EventCallback { void invoke(T parameters); } + // TODO migrate all of these to the system above + public interface MouseInputCallback { void onMouseButton(int button); From 0ca8f50c0fe8beaa23544e2c75217251c1532d5c Mon Sep 17 00:00:00 2001 From: moehreag Date: Thu, 6 Jul 2023 23:09:01 +0200 Subject: [PATCH 04/41] restore functionality --- 1.8.9/build.gradle | 5 ++++- .../github/axolotlclient/mixin/ChatHudMixin.java | 12 +++++------- .../axolotlclient/mixin/PlayerListHudMixin.java | 15 +++++++++------ .../modules/hypixel/bedwars/BedwarsDeathType.java | 5 +++++ .../modules/hypixel/bedwars/BedwarsGame.java | 5 +++++ .../modules/hypixel/bedwars/BedwarsMessages.java | 5 +++++ .../modules/hypixel/bedwars/BedwarsMod.java | 11 ++++++++--- .../modules/hypixel/bedwars/BedwarsMode.java | 4 ++++ .../modules/hypixel/bedwars/BedwarsPlayer.java | 5 +++++ .../hypixel/bedwars/BedwarsPlayerStats.java | 4 ++++ .../modules/hypixel/bedwars/BedwarsTeam.java | 5 ++++- .../hypixel/bedwars/TeamUpgradesOverlay.java | 5 +++++ .../hypixel/bedwars/stats/LobbyStatsHud.java | 4 ++++ .../bedwars/upgrades/BedwarsTeamUpgrades.java | 5 +++++ .../hypixel/bedwars/upgrades/BinaryUpgrade.java | 5 +++++ .../hypixel/bedwars/upgrades/TeamUpgrade.java | 6 ++++++ .../hypixel/bedwars/upgrades/TieredUpgrade.java | 5 +++++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 5 +++++ gradle.properties | 2 +- 19 files changed, 94 insertions(+), 19 deletions(-) diff --git a/1.8.9/build.gradle b/1.8.9/build.gradle index 186cdd62f..9167d19b1 100644 --- a/1.8.9/build.gradle +++ b/1.8.9/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'io.github.juuxel.loom-quiltflower' version '1.8.+' - id "fabric-loom" version "1.0-SNAPSHOT" + id "fabric-loom" version "1.0.+" } group = maven_group @@ -36,6 +36,9 @@ dependencies { modImplementation "io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}" include "io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}" + modImplementation "io.github.axolotlclient.AxolotlClient-config:AxolotlClientConfig-common:${project.config}" + + modImplementation "net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${project.lfapi}+${project.minecraft_18}" modCompileOnlyApi(files("libs/legacy-modmenu-1.2.0+1.8.9-dev.jar")) diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index 874f7f2a3..0304d3009 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -24,15 +24,14 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; -import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatHudLine; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -import net.minecraft.util.Formatting; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -49,17 +48,16 @@ public abstract class ChatHudMixin { @Final private List visibleMessages; - @Inject(method = "addMessage(Lnet/minecraft/text/Text;IIZ)V", at = @At("HEAD"), cancellable = true) - public void axolotlclient$autoGG(Text message, int messageId, int timestamp, boolean bl, CallbackInfo ci) { - + @Inject(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;IIZ)V"), cancellable = true) + public void axolotlclient$autoGG(Text message, int messageId, CallbackInfo ci) { if(message == null){ ci.cancel(); } } - @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;IIZ)V", at = @At("HEAD"), argsOnly = true) + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At("HEAD"), argsOnly = true) private Text axolotlclient$onChatMessage(Text message){ - ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, Formatting.strip(message.asFormattedString()), message); + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.asUnformattedString(), message); Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); if(event.isCancelled()){ return null; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 1d9283086..e0db8603f 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -48,6 +48,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -57,13 +58,15 @@ @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin extends DrawableHelper { - @Shadow @Final + @Final + @Shadow private final MinecraftClient client = MinecraftClient.getInstance(); @Shadow private Text header; @Shadow private Text footer; - private PlayerListEntry playerListEntry; + @Unique + private PlayerListEntry axolotlclient$playerListEntry; @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) public void axolotlclient$nickHider(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { @@ -78,13 +81,13 @@ public abstract class PlayerListHudMixin extends DrawableHelper { @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Ljava/lang/String;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { - playerListEntry = playerEntry; + axolotlclient$playerListEntry = playerEntry; return playerEntry; } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;getStringWidth(Ljava/lang/String;)I", ordinal = 0)) public int axolotlclient$moveName(TextRenderer instance, String text) { - if (AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(playerListEntry.getProfile().getId())) + if (AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$playerListEntry.getProfile().getId())) return instance.getStringWidth(text) + 10; return instance.getStringWidth(text); } @@ -94,7 +97,7 @@ public abstract class PlayerListHudMixin extends DrawableHelper { float x = args.get(1); float y = args.get(2); if (AxolotlClient.CONFIG.showBadges.get() - && AxolotlClient.isUsingClient(playerListEntry.getProfile().getId())) { + && AxolotlClient.isUsingClient(axolotlclient$playerListEntry.getProfile().getId())) { client.getTextureManager().bindTexture(AxolotlClient.badgeIcon); DrawableHelper.drawTexture((int) x, (int) y, 0, 0, 8, 8, 8, 8); args.set(1, x + 10); @@ -106,7 +109,7 @@ public abstract class PlayerListHudMixin extends DrawableHelper { float x = args.get(1); float y = args.get(2); if (AxolotlClient.CONFIG.showBadges.get() - && AxolotlClient.isUsingClient(playerListEntry.getProfile().getId())) { + && AxolotlClient.isUsingClient(axolotlclient$playerListEntry.getProfile().getId())) { client.getTextureManager().bindTexture(AxolotlClient.badgeIcon); DrawableHelper.drawTexture((int) x, (int) y, 0, 0, 8, 8, 8, 8); args.set(1, x + 10); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java index c7e31cd32..b777db1dd 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -28,6 +28,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * + * @author DarkKronicle + */ + @AllArgsConstructor public enum BedwarsDeathType { COMBAT("rekt", BedwarsMessages.COMBAT_KILL), diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 79701d49f..878a9bf72 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -40,6 +40,11 @@ import java.util.regex.Matcher; import java.util.stream.Collectors; +/** + * + * @author DarkKronicle + */ + public class BedwarsGame { private static final int DIAMOND_START = 30; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java index 16a6ed379..8cd1bf1e6 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -28,6 +28,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * + * @author DarkKronicle + */ + public class BedwarsMessages { public final static Pattern[] COMBAT_KILL = convert( diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 3edb91c90..acf1ae8ed 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -129,10 +129,10 @@ public boolean isWaiting() { public void onMessage(ReceiveChatMessageEvent event) { // Remove formatting - String rawMessage = event.getOriginalMessage().replaceAll("§.", ""); + String rawMessage = event.getFormattedMessage().asUnformattedString(); if (currentGame != null) { currentGame.onChatMessage(rawMessage, event); - String time = "§7" + currentGame.getFormattedTime() + " "; + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; if (!event.isCancelled() && showChatTime.get()) { // Add time to every message received in game if (event.getNewMessage() != null) { @@ -151,7 +151,12 @@ public Optional getGame() { return currentGame == null ? Optional.empty() : Optional.of(currentGame); } - @Override + @Override + public boolean tickable() { + return true; + } + + @Override public void tick() { if (currentGame != null) { waiting = false; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java index cf30d660e..bc14cf87a 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java @@ -24,6 +24,10 @@ import lombok.Getter; +/** + * + * @author DarkKronicle + */ public enum BedwarsMode { SOLO(BedwarsTeam.values()), diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java index af9da0085..821912aff 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -28,6 +28,11 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.PlayerListEntry; +/** + * + * @author DarkKronicle + */ + @Data public class BedwarsPlayer { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java index ab5b8fc17..cd52b42fb 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -29,6 +29,10 @@ import lombok.Getter; import org.jetbrains.annotations.Nullable; +/** + * + * @author DarkKronicle + */ @AllArgsConstructor public class BedwarsPlayerStats { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java index 45777cebe..8ee555af7 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java @@ -22,13 +22,16 @@ package io.github.axolotlclient.modules.hypixel.bedwars; - import lombok.AllArgsConstructor; import lombok.Getter; import java.util.Locale; import java.util.Optional; +/** + * + * @author DarkKronicle + */ @AllArgsConstructor public enum BedwarsTeam { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 59e56b5bd..1baa2fb14 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -35,6 +35,11 @@ import java.util.List; +/** + * + * @author DarkKronicle + */ + public class TeamUpgradesOverlay extends BoxHudEntry { public final static Identifier ID = new Identifier("axolotlclient","bedwars_teamupgrades"); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java index 077a86294..c1aa4614a 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java @@ -29,6 +29,10 @@ import java.util.List; +/** + * + * @author DarkKronicle + */ public class LobbyStatsHud implements HudEntry { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java index 7e6a8a7df..1bfe244fb 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -25,6 +25,11 @@ import java.util.regex.Pattern; +/** + * + * @author DarkKronicle + */ + public class BedwarsTeamUpgrades { public final TrapUpgrade trap = new TrapUpgrade(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java index 4f305b133..493a9d5a4 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -27,6 +27,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * + * @author DarkKronicle + */ + public class BinaryUpgrade extends TeamUpgrade { private boolean purchased = false; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java index b5dd4bb6d..46321d239 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -29,6 +29,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * + * @author DarkKronicle + */ + + public abstract class TeamUpgrade { @Getter protected final String name; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java index 4bc10a05d..38021adca 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -28,6 +28,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * + * @author DarkKronicle + */ + public class TieredUpgrade extends TeamUpgrade { private final int[] doublesPrice; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 5b78f5e40..98d67818f 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -32,6 +32,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * + * @author DarkKronicle + */ + public class TrapUpgrade extends TeamUpgrade { private final static Pattern[] REGEX = { diff --git a/gradle.properties b/gradle.properties index c42973502..cece4e89c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ fabric.loom.multiProjectOptimisation=true axolotlclient.modules.all=true # Mod Properties -version=3.0.4-darkkronicle-bedwars-overlay +version=3.0.4-darkkronicle-bedwars-overlay-beta.2 maven_group=io.github.axolotlclient archives_base_name=AxolotlClient minecraft_1192=1.19.2 From d28ced65c1bacf2c5f740969f23840d587d7b079 Mon Sep 17 00:00:00 2001 From: moehreag Date: Thu, 6 Jul 2023 23:13:28 +0200 Subject: [PATCH 05/41] apply license header --- .../util/events/types/CancellableEvent.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java b/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java index 80ea1beec..0fdb3a809 100644 --- a/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java +++ b/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.types; import lombok.Getter; From 1307e1e0fcc9eab08760334efedffc0b91903057 Mon Sep 17 00:00:00 2001 From: moehreag Date: Fri, 7 Jul 2023 22:30:17 +0200 Subject: [PATCH 06/41] fix some bugs, add translations This should now make the PR be in the same state as the original PR --- .../mixin/EntityRendererMixin.java | 5 +- .../axolotlclient/mixin/InGameHudMixin.java | 6 +- .../mixin/PlayerListHudMixin.java | 21 ++-- .../modules/hypixel/bedwars/BedwarsGame.java | 21 ++-- .../hypixel/bedwars/TeamUpgradesOverlay.java | 12 ++- .../hypixel/bedwars/stats/LobbyStatsHud.java | 93 ++---------------- .../events/impl/ScoreboardRenderEvent.java | 3 +- .../assets/axolotlclient/lang/en_us.json | 14 ++- .../textures/bedwars/trap/menu.png | Bin 277 -> 0 bytes 9 files changed, 51 insertions(+), 124 deletions(-) delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/menu.png diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index b9ccdf137..279b73f74 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -74,7 +74,7 @@ public abstract class EntityRendererMixin { @Inject(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Ljava/lang/String;III)I", ordinal = 1)) public void axolotlclient$addLevel(T entity, String string, double d, double e, double f, int i, CallbackInfo ci) { - if (entity instanceof AbstractClientPlayerEntity) { + if (entity instanceof AbstractClientPlayerEntity && string.contains(entity.getName().asFormattedString())) { if (Util.currentServerAddressContains("hypixel.net")) { if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && @@ -83,8 +83,7 @@ public abstract class EntityRendererMixin { if (levelhead != null) { axolotlclient$drawLevelHead(levelhead); } - } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.contains(entity.getName().asFormattedString())) { + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); axolotlclient$drawLevelHead(text); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 6702ab937..66c9d42f2 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -26,6 +26,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; @@ -50,7 +52,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardObjective", at = @At("HEAD"), cancellable = true) public void axolotlclient$customScoreBoard(ScoreboardObjective objective, Window window, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(window, objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index e0db8603f..95f4527ec 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.mixin; -import java.util.List; -import java.util.UUID; - import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; @@ -55,6 +52,9 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; +import java.util.List; +import java.util.UUID; + @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin extends DrawableHelper { @@ -118,7 +118,9 @@ public abstract class PlayerListHudMixin extends DrawableHelper { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(width, x, y, entry)) { ci.cancel(); } } @@ -192,17 +194,6 @@ public abstract class PlayerListHudMixin extends DrawableHelper { ); } - @Inject( - method = "renderLatencyIcon", - at = @At("HEAD"), - cancellable = true - ) - public void axolotlclient$cancelLatencyIcon(int width, int x, int y, PlayerListEntry playerEntry, CallbackInfo ci) { - if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { - ci.cancel(); - } - } - @Inject( method = "renderScoreboardObjective", at = @At( diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 878a9bf72..3eab4921e 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -65,7 +65,6 @@ public class BedwarsGame { private Text topBarText = new LiteralText(""); private Text bottomBarText = new LiteralText(""); - private BedwarsPlayer me = null; private final Map players = new HashMap<>(16); @@ -391,15 +390,15 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { } } - private int getDiamondTimerTier(int tier) { - if (tier <= 1) { - return DIAMOND_1; - } - if (tier == 2) { - return DIAMOND_2; - } - return DIAMOND_3; - } + private int getDiamondTier(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) { @@ -431,7 +430,7 @@ private void updateClock() { } if (diamondsTimer <= 0) { int secondsTillUpgrade = (((minutes) / 12 + 1)) * 12 * 60 - 6 * 60 - seconds; - diamondsTimer = Math.min(getDiamondTimerTier(diamondTier), secondsTillUpgrade); + diamondsTimer = Math.min(getDiamondTier(diamondTier), secondsTillUpgrade); } if (emeraldsTimer <= 0) { int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 1baa2fb14..733f0f5e0 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -23,7 +23,6 @@ package io.github.axolotlclient.modules.hypixel.bedwars; import com.mojang.blaze3d.platform.GlStateManager; -import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; @@ -33,8 +32,6 @@ import net.minecraft.client.gui.DrawableHelper; import net.minecraft.util.Identifier; -import java.util.List; - /** * * @author DarkKronicle @@ -67,8 +64,11 @@ public void drawOverlay(DrawPosition position, boolean editMode) { if (upgrades == null && !editMode) { return; } + int x = position.x() + 1; int y = position.y() + 2; + GlStateManager.enableAlphaTest(); + GlStateManager.enableBlend(); GlStateManager.color(1, 1, 1); boolean normalUpgrades = false; if (upgrades != null) { @@ -100,7 +100,11 @@ public void drawOverlay(DrawPosition position, boolean editMode) { @Override public void renderComponent(float delta) { - drawOverlay(getPos(), false); + if (mod.isWaiting()) { + + } else { + drawOverlay(getPos(), false); + } } @Override diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java index c1aa4614a..895b8f5d5 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java @@ -22,110 +22,31 @@ package io.github.axolotlclient.modules.hypixel.bedwars.stats; -import io.github.axolotlclient.AxolotlClientConfig.options.Option; -import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; -import io.github.axolotlclient.modules.hud.gui.component.HudEntry; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import net.minecraft.util.Identifier; -import java.util.List; - /** - * * @author DarkKronicle */ -public class LobbyStatsHud implements HudEntry { - - public LobbyStatsHud() { - - } - - public void update() { - - } - - @Override - public void setX(int x) { - - } - - @Override - public float getScale() { - return 0; - } - - @Override - public int getRawX() { - return 0; - } - - @Override - public int getRawY() { - return 0; - } - - @Override - public void setY(int y) { - - } +public class LobbyStatsHud extends BoxHudEntry { - @Override - public int getWidth() { - return 0; + public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { + super(width, height, backgroundAllowed); } @Override - public int getHeight() { - return 0; - } - - @Override - public void setHeight(int height) { - - } - - @Override - public void setWidth(int width) { - - } - - @Override - public List> getConfigurationOptions() { - return null; - } - - @Override - public OptionCategory getOptionsAsCategory() { + public Identifier getId() { return null; } @Override - public boolean isEnabled() { - return false; - } - - @Override - public void setEnabled(boolean value) { + public void renderComponent(float delta) { } @Override - public void render(float delta) { + public void renderPlaceholderComponent(float delta) { } - - @Override - public void renderPlaceholder(float delta) { - - } - - @Override - public void setHovered(boolean hovered) { - - } - - @Override - public Identifier getId() { - return null; - } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java index f02d1858d..27617eff3 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -25,10 +25,9 @@ import io.github.axolotlclient.util.events.types.CancellableEvent; import lombok.Getter; import lombok.RequiredArgsConstructor; +import net.minecraft.client.util.Window; import net.minecraft.scoreboard.ScoreboardObjective; -import java.awt.*; - @RequiredArgsConstructor @Getter public class ScoreboardRenderEvent extends CancellableEvent { diff --git a/common/src/main/resources/assets/axolotlclient/lang/en_us.json b/common/src/main/resources/assets/axolotlclient/lang/en_us.json index 03acc1e9b..8306b7d71 100644 --- a/common/src/main/resources/assets/axolotlclient/lang/en_us.json +++ b/common/src/main/resources/assets/axolotlclient/lang/en_us.json @@ -49,7 +49,7 @@ "allocated": "Allocated", "alwaysCrit": "Always Show", "alwaysCrit.tooltip": "Whether to always emit these particles when hitting.", - "alwaysShowHatLayer": "Always show Hat Layer", + "alwaysShowHeadLayer": "Always show Hat Layer", "anchorpoint": "Anchorpoint", "applyBlend": "Apply Blending", "armorhud": "Armor HUD", @@ -374,5 +374,15 @@ "zoomScrollStep": "Scroll Step", "zoomScrolling": "Zoom Scrolling", "zoomScrolling.tooltip": "Whether to allow scrolling to modify the zoom factor.", - "zoomSpeed": "Animation Speed" + "zoomSpeed": "Animation Speed", + "bedwars": "Bedwars", + "bedwars.hardcoreHearts": "Hardcore Hearts", + "bedwars.showHunger": "Show Hunger Bar", + "bedwars.displayArmor": "Display Armor", + "bedwars.bedwarsLevelHead": "Bedwars Level Head", + "bedwars.removeAnnoyingMessages": "Remove Annoying Messages", + "bedwars.tabRenderLatencyIcon": "Render Tablist Latency Icon", + "bedwars.showChatTime": "Show Chat Time", + "bedwars.overrideMessages": "Override Messages", + "bedwars_teamupgrades": "Bedwars Team Upgrades HUD" } diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/menu.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/menu.png deleted file mode 100644 index 4786a83f242aa7548498c9e58ccbdbc72ace7056..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 From f3f14f39fa5332e7b27183484f4700cc11a43fe7 Mon Sep 17 00:00:00 2001 From: moehreag Date: Sat, 8 Jul 2023 02:48:36 +0200 Subject: [PATCH 07/41] fully migrate to new Event system --- .../axolotlclient/mixin/EntityMixin.java | 5 +- .../axolotlclient/mixin/KeyBindMixin.java | 8 +- .../axolotlclient/mixin/MouseMixin.java | 5 +- .../modules/hud/gui/hud/KeystrokeHud.java | 26 +++--- .../modules/hud/gui/hud/PlayerHud.java | 13 +-- .../modules/hud/gui/hud/simple/CPSHud.java | 20 ++--- .../io/github/axolotlclient/util/Hooks.java | 81 ------------------- .../axolotlclient/util/events/Events.java | 50 ++++++++++++ .../util/events/impl/KeyBindChangeEvent.java | 11 +++ .../util/events/impl/KeyPressEvent.java | 9 +++ .../util/events/impl/MouseInputEvent.java | 10 +++ .../impl/PlayerDirectionChangeEvent.java | 10 +++ .../events/impl/ReceiveChatMessageEvent.java | 39 +++++++++ .../events/impl/ScoreboardRenderEvent.java | 37 +++++++++ .../util/events/impl/WorldLoadEvent.java | 32 ++++++++ .../axolotlclient/mixin/EntityMixin.java | 5 +- .../axolotlclient/mixin/KeyBindMixin.java | 8 +- .../axolotlclient/mixin/MouseMixin.java | 5 +- .../modules/hud/gui/hud/KeystrokeHud.java | 21 ++--- .../modules/hud/gui/hud/PlayerHud.java | 13 +-- .../modules/hud/gui/hud/simple/CPSHud.java | 20 ++--- .../io/github/axolotlclient/util/Hooks.java | 81 ------------------- .../axolotlclient/util/events/Events.java | 50 ++++++++++++ .../util/events/impl/KeyBindChangeEvent.java | 11 +++ .../util/events/impl/KeyPressEvent.java | 10 +++ .../util/events/impl/MouseInputEvent.java | 10 +++ .../impl/PlayerDirectionChangeEvent.java | 10 +++ .../events/impl/ReceiveChatMessageEvent.java | 39 +++++++++ .../events/impl/ScoreboardRenderEvent.java | 37 +++++++++ .../util/events/impl/WorldLoadEvent.java | 32 ++++++++ .../axolotlclient/mixin/EntityMixin.java | 5 +- .../axolotlclient/mixin/KeyBindMixin.java | 8 +- .../axolotlclient/mixin/MouseMixin.java | 5 +- .../modules/hud/gui/hud/KeystrokeHud.java | 21 ++--- .../modules/hud/gui/hud/PlayerHud.java | 13 +-- .../modules/hud/gui/hud/simple/CPSHud.java | 20 ++--- .../io/github/axolotlclient/util/Hooks.java | 80 ------------------ .../axolotlclient/util/events/Events.java | 49 +++++++++++ .../util/events/impl/KeyBindChangeEvent.java | 11 +++ .../util/events/impl/KeyPressEvent.java | 9 +++ .../util/events/impl/MouseInputEvent.java | 10 +++ .../impl/PlayerDirectionChangeEvent.java | 10 +++ .../events/impl/ReceiveChatMessageEvent.java | 39 +++++++++ .../events/impl/ScoreboardRenderEvent.java | 37 +++++++++ .../util/events/impl/WorldLoadEvent.java | 32 ++++++++ .../axolotlclient/mixin/EntityMixin.java | 5 +- .../axolotlclient/mixin/KeyBindMixin.java | 8 +- .../axolotlclient/mixin/MouseMixin.java | 5 +- .../modules/hud/gui/hud/KeystrokeHud.java | 21 ++--- .../modules/hud/gui/hud/PlayerHud.java | 13 +-- .../modules/hud/gui/hud/simple/CPSHud.java | 20 ++--- .../io/github/axolotlclient/util/Hooks.java | 80 ------------------ .../axolotlclient/util/events/Events.java | 49 +++++++++++ .../util/events/impl/KeyBindChangeEvent.java | 11 +++ .../util/events/impl/KeyPressEvent.java | 9 +++ .../util/events/impl/MouseInputEvent.java | 10 +++ .../impl/PlayerDirectionChangeEvent.java | 10 +++ .../events/impl/ReceiveChatMessageEvent.java | 39 +++++++++ .../events/impl/ScoreboardRenderEvent.java | 37 +++++++++ .../util/events/impl/WorldLoadEvent.java | 32 ++++++++ .../axolotlclient/mixin/EntityMixin.java | 5 +- .../axolotlclient/mixin/KeyBindMixin.java | 8 +- .../axolotlclient/mixin/MouseMixin.java | 5 +- .../modules/hud/gui/hud/KeystrokeHud.java | 21 ++--- .../modules/hud/gui/hud/PlayerHud.java | 13 +-- .../modules/hud/gui/hud/simple/CPSHud.java | 20 ++--- .../io/github/axolotlclient/util/Hooks.java | 80 ------------------ .../axolotlclient/util/events/Events.java | 49 +++++++++++ .../util/events/impl/KeyBindChangeEvent.java | 11 +++ .../util/events/impl/KeyPressEvent.java | 9 +++ .../util/events/impl/MouseInputEvent.java | 10 +++ .../impl/PlayerDirectionChangeEvent.java | 10 +++ .../events/impl/ReceiveChatMessageEvent.java | 39 +++++++++ .../events/impl/ScoreboardRenderEvent.java | 37 +++++++++ .../util/events/impl/WorldLoadEvent.java | 32 ++++++++ .../axolotlclient/mixin/EntityMixin.java | 5 +- .../axolotlclient/mixin/KeyBindMixin.java | 8 +- .../axolotlclient/mixin/MouseMixin.java | 5 +- .../modules/hud/gui/hud/KeystrokeHud.java | 13 +-- .../modules/hud/gui/hud/PlayerHud.java | 9 ++- .../modules/hud/gui/hud/simple/CPSHud.java | 14 ++-- .../io/github/axolotlclient/util/Hooks.java | 80 ------------------ .../axolotlclient/util/events/Events.java | 49 +++++++++++ .../util/events/impl/KeyBindChangeEvent.java | 11 +++ .../util/events/impl/KeyPressEvent.java | 9 +++ .../util/events/impl/MouseInputEvent.java | 10 +++ .../impl/PlayerDirectionChangeEvent.java | 10 +++ .../events/impl/ReceiveChatMessageEvent.java | 39 +++++++++ .../events/impl/ScoreboardRenderEvent.java | 37 +++++++++ .../util/events/impl/WorldLoadEvent.java | 32 ++++++++ .../axolotlclient/mixin/EntityMixin.java | 3 +- .../axolotlclient/mixin/KeyBindingMixin.java | 6 +- .../mixin/MinecraftClientMixin.java | 5 +- .../modules/hud/gui/hud/KeystrokeHud.java | 17 ++-- .../modules/hud/gui/hud/PlayerHud.java | 9 ++- .../modules/hud/gui/hud/simple/CPSHud.java | 10 ++- .../axolotlclient/util/events/Events.java | 56 ++----------- .../util/events/impl/KeyBindChangeEvent.java | 10 +++ .../util/events/impl/KeyPressEvent.java | 9 +++ .../util/events/impl/MouseInputEvent.java | 9 +++ .../impl/PlayerDirectionChangeEvent.java | 10 +++ .../events/impl/ReceiveChatMessageEvent.java | 9 +-- .../events/impl/ScoreboardRenderEvent.java | 8 +- .../util/events/impl/WorldLoadEvent.java | 5 +- .../util/events/types/CancellableEvent.java | 9 +-- 105 files changed, 1495 insertions(+), 766 deletions(-) delete mode 100644 1.16.5/src/main/java/io/github/axolotlclient/util/Hooks.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/util/Hooks.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/util/Hooks.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/util/Hooks.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java delete mode 100644 1.19.4/src/main/java/io/github/axolotlclient/util/Hooks.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java delete mode 100644 1.20/src/main/java/io/github/axolotlclient/util/Hooks.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/util/events/Events.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index cc07df4d9..f5efca90f 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index c36ecc90b..34f3a2cdf 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -22,7 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; import org.spongepowered.asm.mixin.Mixin; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBinding) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBinding) ((Object) this))); } } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index 02e659956..0d35dc75b 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;setKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index de12acbff..9c00079ed 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,10 +22,6 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption; @@ -35,7 +31,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; @@ -45,6 +42,10 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); @@ -232,11 +233,6 @@ public void renderPlaceholderComponent(MatrixStack matrices, float delta) { renderComponent(matrices, delta); } - @Override - public boolean movable() { - return true; - } - @Override public boolean tickable() { return true; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 1c1f569e5..edf227a6d 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,14 +22,13 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.List; - import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -42,6 +41,8 @@ import net.minecraft.util.math.Quaternion; import net.minecraft.util.math.Vec3f; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -65,11 +66,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index e05125d6f..3dcc576e8 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; +import java.util.ArrayList; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register((event) -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { if (fromKeybindings.get()) { - if (key.equals(client.options.keyAttack)) { + if (event.getKey().equals(client.options.keyAttack)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.keyUse)) { + } else if (event.getKey().equals(client.options.keyUse)) { ClickList.RIGHT.click(); } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.16.5/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index 44f025fce..000000000 --- a/1.16.5/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.util; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = EventFactory.createArrayBacked(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = EventFactory.createArrayBacked(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = EventFactory.createArrayBacked(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = EventFactory - .createArrayBacked(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBinding binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..a620accb9 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events; + +import io.github.axolotlclient.util.events.impl.*; +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +import java.util.Arrays; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent(){ + return EventFactory + .createArrayBacked(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..921d99b69 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,11 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.util.InputUtil; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..82ac1580c --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,9 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBinding; +@Data +public class KeyPressEvent { + + private final KeyBinding key; +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..e4f053df1 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..fe2d88b4f --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..8db148f79 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.client.util.Window; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final Window window; + private final ScoreboardObjective objective; +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index cc07df4d9..f5efca90f 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index 1e5103a9b..a51a7996b 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -22,7 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.options.KeyBinding; import net.minecraft.client.util.InputUtil; import org.spongepowered.asm.mixin.Mixin; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBinding) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBinding) (Object) this)); } } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index d76331887..1a70efe47 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/options/KeyBinding;setKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 655ab83fc..414cb4635 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,10 +22,6 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption; @@ -35,7 +31,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.options.KeyBinding; import net.minecraft.client.util.InputUtil; @@ -45,6 +42,10 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index c5a6e890a..2c1a8ebae 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,14 +22,13 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.List; - import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -42,6 +41,8 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Quaternion; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -65,11 +66,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index e05125d6f..3dcc576e8 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; +import java.util.ArrayList; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register((event) -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { if (fromKeybindings.get()) { - if (key.equals(client.options.keyAttack)) { + if (event.getKey().equals(client.options.keyAttack)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.keyUse)) { + } else if (event.getKey().equals(client.options.keyUse)) { ClickList.RIGHT.click(); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index 52e90af02..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.util; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.client.options.KeyBinding; -import net.minecraft.client.util.InputUtil; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = EventFactory.createArrayBacked(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = EventFactory.createArrayBacked(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = EventFactory.createArrayBacked(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = EventFactory - .createArrayBacked(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBinding binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..a620accb9 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events; + +import io.github.axolotlclient.util.events.impl.*; +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +import java.util.Arrays; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent(){ + return EventFactory + .createArrayBacked(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..921d99b69 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,11 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.util.InputUtil; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..9e544c505 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.options.KeyBinding; + +@Data +public class KeyPressEvent { + + private final KeyBinding key; +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..e4f053df1 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..fe2d88b4f --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..8db148f79 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.client.util.Window; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final Window window; + private final ScoreboardObjective objective; +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index ee7520b6e..e13f9b3f0 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index bae9a75ca..16bbd5622 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -23,7 +23,9 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.platform.InputUtil; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.option.KeyBind; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBind) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBind) ((Object) this))); } } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index 49c1cc4bb..8b962b876 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBind;setKeyPressed(Lcom/mojang/blaze3d/platform/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 332f2e0d6..47018ceea 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,10 +22,6 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -36,7 +32,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBind; import net.minecraft.client.util.math.MatrixStack; @@ -45,6 +42,10 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index bd36207a0..e987bc934 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,15 +22,14 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.List; - import com.mojang.blaze3d.lighting.DiffuseLighting; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -42,6 +41,8 @@ import net.minecraft.util.math.Quaternion; import net.minecraft.util.math.Vec3f; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -65,11 +66,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 19bcca2d6..ee170a3ad 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; +import java.util.ArrayList; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register(event -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { if (fromKeybindings.get()) { - if (key.equals(client.options.attackKey)) { + if (event.getKey().equals(client.options.attackKey)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.useKey)) { + } else if (event.getKey().equals(client.options.useKey)) { ClickList.RIGHT.click(); } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.19.2/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index b35c4ab5d..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.util; - -import com.mojang.blaze3d.platform.InputUtil; -import net.minecraft.client.option.KeyBind; -import org.quiltmc.qsl.base.api.event.Event; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = Event.create(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = Event.create(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = Event.create(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = Event - .create(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBind binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..0d0c8b8cd --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events; + +import io.github.axolotlclient.util.events.impl.*; +import org.quiltmc.qsl.base.api.event.Event; + +import java.util.Arrays; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent(){ + return Event + .create(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..7d5eaa95f --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,11 @@ +package io.github.axolotlclient.util.events.impl; + +import com.mojang.blaze3d.platform.InputUtil; +import lombok.Data; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..c5d356bab --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,9 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBind; +@Data +public class KeyPressEvent { + + private final KeyBind key; +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..e4f053df1 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..fe2d88b4f --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..38fa3e231 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import com.mojang.blaze3d.glfw.Window; +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final Window window; + private final ScoreboardObjective objective; +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index ee7520b6e..e13f9b3f0 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index bae9a75ca..16bbd5622 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -23,7 +23,9 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.platform.InputUtil; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.option.KeyBind; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBind) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBind) ((Object) this))); } } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index 49c1cc4bb..8b962b876 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBind;setKeyPressed(Lcom/mojang/blaze3d/platform/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 332f2e0d6..47018ceea 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,10 +22,6 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -36,7 +32,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBind; import net.minecraft.client.util.math.MatrixStack; @@ -45,6 +42,10 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index b1f15db8b..2ff4d84ba 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,15 +22,14 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.List; - import com.mojang.blaze3d.lighting.DiffuseLighting; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -43,6 +42,8 @@ import org.joml.Quaternionf; import org.joml.Vector3f; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -66,11 +67,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 19bcca2d6..ee170a3ad 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; +import java.util.ArrayList; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register(event -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { if (fromKeybindings.get()) { - if (key.equals(client.options.attackKey)) { + if (event.getKey().equals(client.options.attackKey)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.useKey)) { + } else if (event.getKey().equals(client.options.useKey)) { ClickList.RIGHT.click(); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.19.3/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index b35c4ab5d..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.util; - -import com.mojang.blaze3d.platform.InputUtil; -import net.minecraft.client.option.KeyBind; -import org.quiltmc.qsl.base.api.event.Event; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = Event.create(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = Event.create(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = Event.create(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = Event - .create(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBind binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..0d0c8b8cd --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events; + +import io.github.axolotlclient.util.events.impl.*; +import org.quiltmc.qsl.base.api.event.Event; + +import java.util.Arrays; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent(){ + return Event + .create(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..7d5eaa95f --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,11 @@ +package io.github.axolotlclient.util.events.impl; + +import com.mojang.blaze3d.platform.InputUtil; +import lombok.Data; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..c5d356bab --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,9 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBind; +@Data +public class KeyPressEvent { + + private final KeyBind key; +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..e4f053df1 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..fe2d88b4f --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..38fa3e231 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import com.mojang.blaze3d.glfw.Window; +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final Window window; + private final ScoreboardObjective objective; +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index ee7520b6e..e13f9b3f0 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index bae9a75ca..16bbd5622 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -23,7 +23,9 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.platform.InputUtil; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.option.KeyBind; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBind) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBind) ((Object) this))); } } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index 49c1cc4bb..8b962b876 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBind;setKeyPressed(Lcom/mojang/blaze3d/platform/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 332f2e0d6..47018ceea 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,10 +22,6 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -36,7 +32,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBind; import net.minecraft.client.util.math.MatrixStack; @@ -45,6 +42,10 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index b1f15db8b..2ff4d84ba 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,15 +22,14 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.List; - import com.mojang.blaze3d.lighting.DiffuseLighting; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -43,6 +42,8 @@ import org.joml.Quaternionf; import org.joml.Vector3f; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -66,11 +67,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 19bcca2d6..ee170a3ad 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; +import java.util.ArrayList; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register(event -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { if (fromKeybindings.get()) { - if (key.equals(client.options.attackKey)) { + if (event.getKey().equals(client.options.attackKey)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.useKey)) { + } else if (event.getKey().equals(client.options.useKey)) { ClickList.RIGHT.click(); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.19.4/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index b35c4ab5d..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.util; - -import com.mojang.blaze3d.platform.InputUtil; -import net.minecraft.client.option.KeyBind; -import org.quiltmc.qsl.base.api.event.Event; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = Event.create(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = Event.create(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = Event.create(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = Event - .create(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBind binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..0d0c8b8cd --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events; + +import io.github.axolotlclient.util.events.impl.*; +import org.quiltmc.qsl.base.api.event.Event; + +import java.util.Arrays; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent(){ + return Event + .create(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..7d5eaa95f --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,11 @@ +package io.github.axolotlclient.util.events.impl; + +import com.mojang.blaze3d.platform.InputUtil; +import lombok.Data; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..c5d356bab --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,9 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBind; +@Data +public class KeyPressEvent { + + private final KeyBind key; +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..e4f053df1 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..fe2d88b4f --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..38fa3e231 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import com.mojang.blaze3d.glfw.Window; +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final Window window; + private final ScoreboardObjective objective; +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index ee7520b6e..e13f9b3f0 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index bae9a75ca..16bbd5622 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -23,7 +23,9 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.platform.InputUtil; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.option.KeyBind; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBind) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBind) ((Object) this))); } } } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index 49c1cc4bb..8b962b876 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBind;setKeyPressed(Lcom/mojang/blaze3d/platform/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index ae8e75bb0..f1fec27a4 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -32,7 +32,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.option.KeyBind; @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 0c84e10e6..18dcfb5f9 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -28,7 +28,8 @@ import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; @@ -67,11 +68,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index adadc0844..690926ccd 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -25,7 +25,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register(event -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register(event -> { if (fromKeybindings.get()) { - if (key.equals(client.options.attackKey)) { + if (event.getKey().equals(client.options.attackKey)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.useKey)) { + } else if (event.getKey().equals(client.options.useKey)) { ClickList.RIGHT.click(); } } diff --git a/1.20/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.20/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index b35c4ab5d..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.util; - -import com.mojang.blaze3d.platform.InputUtil; -import net.minecraft.client.option.KeyBind; -import org.quiltmc.qsl.base.api.event.Event; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = Event.create(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = Event.create(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = Event.create(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = Event - .create(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBind binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.20/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..0d0c8b8cd --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events; + +import io.github.axolotlclient.util.events.impl.*; +import org.quiltmc.qsl.base.api.event.Event; + +import java.util.Arrays; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent(){ + return Event + .create(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..7d5eaa95f --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,11 @@ +package io.github.axolotlclient.util.events.impl; + +import com.mojang.blaze3d.platform.InputUtil; +import lombok.Data; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..c5d356bab --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,9 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBind; +@Data +public class KeyPressEvent { + + private final KeyBind key; +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..e4f053df1 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..fe2d88b4f --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..38fa3e231 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import com.mojang.blaze3d.glfw.Window; +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final Window window; + private final ScoreboardObjective objective; +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index 42f4b9cfe..037f191a3 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -23,6 +23,7 @@ package io.github.axolotlclient.mixin; import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -51,6 +52,6 @@ public abstract class EntityMixin { pitch = (float) ((double) prevPitch - (double) pitch * 0.15); yaw = (float) ((double) prevYaw + (double) yaw * 0.15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Events.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java index dde54459e..ccc5abf2f 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java @@ -23,6 +23,8 @@ package io.github.axolotlclient.mixin; import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; import net.minecraft.util.collection.IntObjectStorage; @@ -49,7 +51,7 @@ public abstract class KeyBindingMixin { @Inject(method = "setKeyPressed", at = @At(value = "FIELD", target = "Lnet/minecraft/client/option/KeyBinding;pressed:Z")) private static void axolotlclient$onPress(int keyCode, boolean pressed, CallbackInfo ci) { if (pressed) { - Events.KEYBIND_PRESS.invoker().onPress(KEY_MAP.get(keyCode)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent(KEY_MAP.get(keyCode))); } } @@ -68,6 +70,6 @@ public abstract class KeyBindingMixin { @Inject(method = "setCode", at = @At("RETURN")) public void axolotlclient$boundKeySet(int code, CallbackInfo ci) { - Events.KEYBIND_CHANGE.invoker().setBoundKey(code); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(code)); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 5f0e18b4a..c651dd152 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,9 +27,10 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.NetworkHelper; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; @@ -161,7 +162,7 @@ protected MinecraftClientMixin(TextureManager textureManager) { @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getTime()J", ordinal = 0)) public void axolotlclient$onMouseButton(CallbackInfo ci) { if (Mouse.getEventButtonState()) { - Events.MOUSE_INPUT.invoker().onMouseButton(Mouse.getEventButton()); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(Mouse.getEventButton())); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 1ee13f4c9..18bda862e 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,10 +22,6 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - import com.mojang.blaze3d.platform.GlStateManager; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -36,14 +32,19 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.GameOptions; import net.minecraft.client.option.KeyBinding; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -131,12 +132,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 91b8e6108..29b996159 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,8 +22,6 @@ package io.github.axolotlclient.modules.hud.gui.hud; -import java.util.List; - import com.mojang.blaze3d.platform.GLX; import com.mojang.blaze3d.platform.GlStateManager; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -31,6 +29,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.block.material.Material; import net.minecraft.client.render.DiffuseLighting; @@ -38,6 +37,8 @@ import net.minecraft.entity.player.ClientPlayerEntity; import net.minecraft.util.Identifier; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -64,8 +65,8 @@ public PlayerHud() { Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 55625f6d9..161afe589 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,16 +22,17 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; import io.github.axolotlclient.util.events.Events; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.option.KeyBinding; import net.minecraft.util.Identifier; +import java.util.ArrayList; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -57,7 +58,8 @@ public CPSHud() { } } }); - Events.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { + KeyBinding key = event.getKey(); if (fromKeybindings.get()) { if (key.equals(client.options.attackKey)) { ClickList.LEFT.click(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java index 00bb659fb..551e09025 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -22,42 +22,18 @@ package io.github.axolotlclient.util.events; -import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; -import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; -import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import io.github.axolotlclient.util.events.impl.*; import net.legacyfabric.fabric.api.event.Event; import net.legacyfabric.fabric.api.event.EventFactory; -import net.minecraft.client.option.KeyBinding; import java.util.Arrays; public class Events { - public static final Event MOUSE_INPUT = EventFactory.createArrayBacked(MouseInputCallback.class, - listeners -> (button -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(button); - } - })); - public static final Event KEYBIND_CHANGE = EventFactory.createArrayBacked(ChangeBind.class, - listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = EventFactory.createArrayBacked(OnPress.class, - listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = EventFactory - .createArrayBacked(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); public static final Event> WORLD_LOAD_EVENT = createEvent(); @@ -71,26 +47,4 @@ private static Event> createEvent(){ public interface EventCallback { void invoke(T parameters); } - - // TODO migrate all of these to the system above - - public interface MouseInputCallback { - - void onMouseButton(int button); - } - - public interface ChangeBind { - - void setBoundKey(int boundKey); - } - - public interface OnPress { - - void onPress(KeyBinding binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..522473f9a --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class KeyBindChangeEvent { + + private final int boundKey; + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..82ac1580c --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,9 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBinding; +@Data +public class KeyPressEvent { + + private final KeyBinding key; +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..bcb118b5c --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,9 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final int button; +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..fe2d88b4f --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,10 @@ +package io.github.axolotlclient.util.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java index 9771d77f8..ba3746d79 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -23,13 +23,12 @@ package io.github.axolotlclient.util.events.impl; import io.github.axolotlclient.util.events.types.CancellableEvent; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.Setter; +import lombok.Data; +import lombok.EqualsAndHashCode; import net.minecraft.text.Text; -@RequiredArgsConstructor -@Getter @Setter +@EqualsAndHashCode(callSuper = true) +@Data public class ReceiveChatMessageEvent extends CancellableEvent { private final boolean actionBar; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java index 27617eff3..8db148f79 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -23,13 +23,13 @@ package io.github.axolotlclient.util.events.impl; import io.github.axolotlclient.util.events.types.CancellableEvent; -import lombok.Getter; -import lombok.RequiredArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; import net.minecraft.client.util.Window; import net.minecraft.scoreboard.ScoreboardObjective; -@RequiredArgsConstructor -@Getter +@EqualsAndHashCode(callSuper = true) +@Data public class ScoreboardRenderEvent extends CancellableEvent { private final Window window; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java index 742e55c90..872d370dd 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -22,11 +22,10 @@ package io.github.axolotlclient.util.events.impl; -import lombok.Getter; -import lombok.RequiredArgsConstructor; +import lombok.Data; import net.minecraft.client.world.ClientWorld; -@RequiredArgsConstructor @Getter +@Data public class WorldLoadEvent { private final ClientWorld world; diff --git a/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java b/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java index 0fdb3a809..d0efce3e4 100644 --- a/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java +++ b/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java @@ -22,14 +22,11 @@ package io.github.axolotlclient.util.events.types; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.Setter; +import lombok.Data; -@RequiredArgsConstructor -public class CancellableEvent { +@Data +public abstract class CancellableEvent { - @Getter @Setter private boolean cancelled; } From 94efe3f4b9e854ccf00c4db6367d021ae638ee92 Mon Sep 17 00:00:00 2001 From: moehreag Date: Sat, 8 Jul 2023 15:40:45 +0200 Subject: [PATCH 08/41] port to the other versions some mixins might have issues, needs testing --- .../axolotlclient/mixin/ChatHudMixin.java | 27 +- .../mixin/EntityRendererMixin.java | 23 +- .../axolotlclient/mixin/InGameHudMixin.java | 41 +- .../mixin/MinecraftClientMixin.java | 8 + .../mixin/PlayerEntityMixin.java | 14 +- .../mixin/PlayerListHudMixin.java | 177 ++++++- .../modules/hypixel/autoboop/AutoBoop.java | 14 +- .../modules/hypixel/autogg/AutoGG.java | 27 +- .../modules/hypixel/autotip/AutoTip.java | 15 +- .../hypixel/bedwars/BedwarsDeathType.java | 66 +++ .../modules/hypixel/bedwars/BedwarsGame.java | 480 ++++++++++++++++++ .../hypixel/bedwars/BedwarsMessages.java | 312 ++++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 228 +++++++++ .../modules/hypixel/bedwars/BedwarsMode.java | 45 ++ .../hypixel/bedwars/BedwarsPlayer.java | 160 ++++++ .../hypixel/bedwars/BedwarsPlayerStats.java | 170 +++++++ .../modules/hypixel/bedwars/BedwarsTeam.java | 79 +++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 119 +++++ .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ++ .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 +++ .../bedwars/upgrades/BinaryUpgrade.java | 70 +++ .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 +++ .../bedwars/upgrades/TieredUpgrade.java | 77 +++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 +++++ .../events/impl/ScoreboardRenderEvent.java | 2 - .../axolotlclient/mixin/ChatHudMixin.java | 27 +- .../mixin/EntityRendererMixin.java | 23 +- .../axolotlclient/mixin/InGameHudMixin.java | 41 +- .../mixin/MinecraftClientMixin.java | 8 + .../mixin/PlayerEntityMixin.java | 14 +- .../mixin/PlayerListHudMixin.java | 189 ++++++- .../modules/hypixel/HypixelMods.java | 8 +- .../modules/hypixel/autoboop/AutoBoop.java | 13 +- .../modules/hypixel/autogg/AutoGG.java | 27 +- .../modules/hypixel/autotip/AutoTip.java | 17 +- .../hypixel/bedwars/BedwarsDeathType.java | 66 +++ .../modules/hypixel/bedwars/BedwarsGame.java | 480 ++++++++++++++++++ .../hypixel/bedwars/BedwarsMessages.java | 312 ++++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 228 +++++++++ .../modules/hypixel/bedwars/BedwarsMode.java | 45 ++ .../hypixel/bedwars/BedwarsPlayer.java | 160 ++++++ .../hypixel/bedwars/BedwarsPlayerStats.java | 170 +++++++ .../modules/hypixel/bedwars/BedwarsTeam.java | 79 +++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 119 +++++ .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ++ .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 +++ .../bedwars/upgrades/BinaryUpgrade.java | 70 +++ .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 +++ .../bedwars/upgrades/TieredUpgrade.java | 77 +++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 +++++ .../events/impl/ScoreboardRenderEvent.java | 2 - .../axolotlclient/mixin/ChatHudMixin.java | 25 +- .../mixin/EntityRendererMixin.java | 23 +- .../axolotlclient/mixin/InGameHudMixin.java | 41 +- .../mixin/MinecraftClientMixin.java | 8 + .../mixin/PlayerEntityMixin.java | 14 +- .../mixin/PlayerListHudMixin.java | 177 ++++++- .../hypixel/bedwars/BedwarsDeathType.java | 66 +++ .../modules/hypixel/bedwars/BedwarsGame.java | 479 +++++++++++++++++ .../hypixel/bedwars/BedwarsMessages.java | 312 ++++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 227 +++++++++ .../modules/hypixel/bedwars/BedwarsMode.java | 45 ++ .../hypixel/bedwars/BedwarsPlayer.java | 160 ++++++ .../hypixel/bedwars/BedwarsPlayerStats.java | 170 +++++++ .../modules/hypixel/bedwars/BedwarsTeam.java | 79 +++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 118 +++++ .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ++ .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 +++ .../bedwars/upgrades/BinaryUpgrade.java | 70 +++ .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 +++ .../bedwars/upgrades/TieredUpgrade.java | 77 +++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 +++++ .../events/impl/ScoreboardRenderEvent.java | 2 - .../axolotlclient/mixin/ChatHudMixin.java | 25 +- .../mixin/EntityRendererMixin.java | 23 +- .../axolotlclient/mixin/InGameHudMixin.java | 41 +- .../mixin/MinecraftClientMixin.java | 8 + .../mixin/PlayerEntityMixin.java | 14 +- .../mixin/PlayerListHudMixin.java | 176 ++++++- .../modules/hypixel/autoboop/AutoBoop.java | 13 +- .../modules/hypixel/autogg/AutoGG.java | 25 +- .../modules/hypixel/autotip/AutoTip.java | 16 +- .../hypixel/bedwars/BedwarsDeathType.java | 66 +++ .../modules/hypixel/bedwars/BedwarsGame.java | 479 +++++++++++++++++ .../hypixel/bedwars/BedwarsMessages.java | 312 ++++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 227 +++++++++ .../modules/hypixel/bedwars/BedwarsMode.java | 45 ++ .../hypixel/bedwars/BedwarsPlayer.java | 160 ++++++ .../hypixel/bedwars/BedwarsPlayerStats.java | 170 +++++++ .../modules/hypixel/bedwars/BedwarsTeam.java | 79 +++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 118 +++++ .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ++ .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 +++ .../bedwars/upgrades/BinaryUpgrade.java | 70 +++ .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 +++ .../bedwars/upgrades/TieredUpgrade.java | 77 +++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 +++++ .../events/impl/ScoreboardRenderEvent.java | 2 - .../axolotlclient/mixin/ChatHudMixin.java | 25 +- .../mixin/EntityRendererMixin.java | 23 +- .../axolotlclient/mixin/InGameHudMixin.java | 41 +- .../mixin/MinecraftClientMixin.java | 8 + .../mixin/PlayerEntityMixin.java | 14 +- .../mixin/PlayerListHudMixin.java | 176 ++++++- .../modules/hypixel/autoboop/AutoBoop.java | 13 +- .../modules/hypixel/autogg/AutoGG.java | 25 +- .../modules/hypixel/autotip/AutoTip.java | 14 +- .../hypixel/bedwars/BedwarsDeathType.java | 66 +++ .../modules/hypixel/bedwars/BedwarsGame.java | 479 +++++++++++++++++ .../hypixel/bedwars/BedwarsMessages.java | 312 ++++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 227 +++++++++ .../modules/hypixel/bedwars/BedwarsMode.java | 45 ++ .../hypixel/bedwars/BedwarsPlayer.java | 160 ++++++ .../hypixel/bedwars/BedwarsPlayerStats.java | 170 +++++++ .../modules/hypixel/bedwars/BedwarsTeam.java | 79 +++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 118 +++++ .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ++ .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 +++ .../bedwars/upgrades/BinaryUpgrade.java | 70 +++ .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 +++ .../bedwars/upgrades/TieredUpgrade.java | 77 +++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 +++++ .../events/impl/ScoreboardRenderEvent.java | 2 - .../axolotlclient/mixin/ChatHudMixin.java | 25 +- .../mixin/EntityRendererMixin.java | 23 +- .../axolotlclient/mixin/InGameHudMixin.java | 41 +- .../mixin/MinecraftClientMixin.java | 8 + .../mixin/PlayerEntityMixin.java | 14 +- .../mixin/PlayerListHudMixin.java | 189 ++++++- .../hypixel/bedwars/BedwarsDeathType.java | 66 +++ .../modules/hypixel/bedwars/BedwarsGame.java | 479 +++++++++++++++++ .../hypixel/bedwars/BedwarsMessages.java | 312 ++++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 227 +++++++++ .../modules/hypixel/bedwars/BedwarsMode.java | 45 ++ .../hypixel/bedwars/BedwarsPlayer.java | 160 ++++++ .../hypixel/bedwars/BedwarsPlayerStats.java | 170 +++++++ .../modules/hypixel/bedwars/BedwarsTeam.java | 79 +++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 118 +++++ .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ++ .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 +++ .../bedwars/upgrades/BinaryUpgrade.java | 70 +++ .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 +++ .../bedwars/upgrades/TieredUpgrade.java | 77 +++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 +++++ .../events/impl/ScoreboardRenderEvent.java | 2 - .../axolotlclient/mixin/InGameHudMixin.java | 2 +- .../mixin/PlayerListHudMixin.java | 21 +- 147 files changed, 14551 insertions(+), 275 deletions(-) create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java create mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index f4a36a2c1..967b301c2 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,31 +22,40 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.text.Text; 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.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true) - public void axolotlclient$autoThings(Text message, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + @Inject(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;IIZ)V"), cancellable = true) + public void axolotlclient$autoThings(Text message, int messageId, CallbackInfo ci) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;I)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 4ba4aa7e0..8a2b52100 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, false, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9af2bd244..a4f55dc6c 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -28,6 +28,9 @@ import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; @@ -38,10 +41,7 @@ import org.jetbrains.annotations.Nullable; 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.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +89,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +189,33 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), + ordinal = 18 + ) + public int axolotlclient$displayHardcoreHearts(int offset) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 5 : offset; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 20 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 4afc08eac..dd3e7539f 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -26,11 +26,14 @@ import io.github.axolotlclient.modules.blur.MenuBlur; import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -83,4 +86,9 @@ public abstract class MinecraftClientMixin { private void axolotlclient$noModdedSigns(CallbackInfoReturnable cir) { cir.setReturnValue(false); } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 0465c0aae..7a1797145 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -25,12 +25,19 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.render.entity.PlayerModelPart; import net.minecraft.client.util.math.MatrixStack; @@ -42,14 +49,16 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; 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.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.List; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -75,6 +84,10 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text applyGameModeFormatting(PlayerListEntry par1, MutableText par2); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { profile = playerEntry.getProfile(); @@ -115,7 +128,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { ci.cancel(); } } @@ -150,4 +165,156 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$alwaysShowHeadLayer(PlayerEntity instance, PlayerModelPart modelPart) { return Tablist.getInstance().alwaysShowHeadLayer.get() || instance.isPartVisible(modelPart); } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, 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.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.client.textRenderer.drawWithShadow(matrixStack, + render, + (float) (endX - this.client.textRenderer.getWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Ljava/lang/String;FFI)I", + ordinal = 1 + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, + PlayerListEntry playerEntry, MatrixStack matrices, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().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; + 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("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + this.client.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - this.client.textRenderer.getWidth(render)), + (float) y, + color + ); + + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$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;", remap = false)) + public List axolotlclient$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 axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 2cb1c7255..4bcf3761d 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -26,8 +26,9 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; -import net.minecraft.text.Text; // Based on https://github.com/VeryHolyCheeeese/AutoBoop/blob/main/src/main/java/autoboop/AutoBoop.java public class AutoBoop implements AbstractHypixelMod { @@ -41,6 +42,8 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -48,10 +51,11 @@ public OptionCategory getCategory() { return cat; } - public void onMessage(Text message) { - if (enabled.get() && message.getString().contains("Friend >") && message.getString().contains("joined.")) { - String player = message.getString().substring(message.getString().indexOf(">"), - message.getString().lastIndexOf(" ")); + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage(); + if (enabled.get() && message.contains("Friend >") && message.contains("joined.")) { + String player = message.substring(message.indexOf(">"), + message.lastIndexOf(" ")); Util.sendChatMessage("/boop " + player); } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index f9c18e6aa..083799dfe 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -22,19 +22,20 @@ package io.github.axolotlclient.modules.hypixel.autogg; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.stream.Collectors; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; /** * Based on DragonEggBedrockBreaking's AutoGG Mod @@ -88,6 +89,8 @@ public void init() { category.add(onBWP); category.add(onPVPL); category.add(onMMC); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -158,28 +161,28 @@ private List addToList(String... strings) { return Arrays.stream(strings).collect(Collectors.toList()); } - public void onMessage(Text message) { + public void onMessage(ReceiveChatMessageEvent event) { if (client.getCurrentServerEntry() != null) { serverMap.keySet().forEach(s -> { if (serverMap.get(s).get() && client.getCurrentServerEntry().address.contains(s)) { if (gf.get()) { - processChat(message, gfStrings.get(s), gfString.get()); + processChat(event.getOriginalMessage(), gfStrings.get(s), gfString.get()); } if (gg.get()) { - processChat(message, ggStrings.get(s), ggString.get()); + processChat(event.getOriginalMessage(), ggStrings.get(s), ggString.get()); } if (glhf.get()) { - processChat(message, glhfStrings.get(s), glhfString.get()); + processChat(event.getOriginalMessage(), glhfStrings.get(s), glhfString.get()); } } }); } } - private void processChat(Text messageReceived, List options, String messageToSend) { + private void processChat(String messageReceived, List options, String messageToSend) { if (System.currentTimeMillis() - this.lastTime > 3000 && options != null) { for (String s : options) { - if (messageReceived.getString().contains(s)) { + if (messageReceived.contains(s)) { Util.sendChatMessage(messageToSend); this.lastTime = System.currentTimeMillis(); return; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 23c9956e7..3d2f4a1f8 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,15 +22,16 @@ package io.github.axolotlclient.modules.hypixel.autotip; -import java.util.regex.Pattern; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; + +import java.util.regex.Pattern; public class AutoTip implements AbstractHypixelMod { @@ -52,6 +53,8 @@ public class AutoTip implements AbstractHypixelMod { @Override public void init() { category.add(enabled, hideMessages); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); init = true; } @@ -80,8 +83,8 @@ public boolean tickable() { return true; } - public boolean onChatMessage(Text text) { - return enabled.get() && hideMessages.get() && (messagePattern.matcher(text.getString()).matches() - || tippedPattern.matcher(text.getString()).matches()); + public void onChatMessage(ReceiveChatMessageEvent event) { + event.setCancelled(enabled.get() && hideMessages.get() && (messagePattern.matcher(event.getOriginalMessage()).matches() + || tippedPattern.matcher(event.getOriginalMessage()).matches())); } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java new file mode 100644 index 000000000..ef3f5bb2f --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +@AllArgsConstructor +public enum BedwarsDeathType { + 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/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..f6311d361 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,480 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +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; +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; +import java.util.stream.Collectors; + +/** + * @author DarkKronicle + */ + +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; + + private final Map players = new HashMap<>(16); + private final Map playersById = new HashMap<>(16); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + 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); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + 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; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + 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)); + } + + 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, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(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) { + 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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + 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 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(p -> disconnected(event, p)))) { + return; + } + 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 -> { + 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + 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(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + new LiteralText("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + 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 + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + 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(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatEliminated(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(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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, new LiteralText(score.getPlayerName())).getString(); + 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) { + updateClock(); + } + topBarText = new LiteralText(calculateTopBarText()); + bottomBarText = new LiteralText(calculateBottomBarText()); + } + } + + private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); + } + if (emeraldsTimer <= 0) { + int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; + emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); + } + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + 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()); + } + + 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; + } + return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + } + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java new file mode 100644 index 000000000..afdaaa861 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -0,0 +1,312 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import java.util.Arrays; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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} 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}.", + "{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}")), + Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), + 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"), + Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), + }; + + 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/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..cd9b01cad --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,228 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +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.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + 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*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + public String getDetail() { + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, + tabRenderLatencyIcon, showChatTime, overrideMessages); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(new LiteralText(time).append(event.getNewMessage())); + } else { + event.setNewMessage(new LiteralText(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListHud().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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, new LiteralText(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java new file mode 100644 index 000000000..511145cc4 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..c092237ca --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + 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) { + this.team = team; + this.profile = profile; + 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(); + } + + 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 || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + 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; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + 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(); + } + stats.addKill(); + } + } +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java new file mode 100644 index 000000000..337a46afd --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -0,0 +1,170 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +@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 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, + 0, + 0, + 0, + 0, + 0, + 1 + ); + } + + @Nullable + public static BedwarsPlayerStats fromAPI(String uuid) { + JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); + JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); + 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) { + if (obj.has(key)) { + try { + return obj.get(key).getAsInt(); + } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { + // Not actually an int + } + } + return other; + } + + public 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++; + gameDeaths++; + } + + public void addFinalDeath() { + finalDeaths++; + gameFinalDeaths++; + } + + public void addKill() { + kills++; + gameKills++; + } + + public void addFinalKill() { + finalKills++; + gameFinalKills++; + } + + public void addBed() { + bedsBroken++; + gameBedsBroken++; + } + + public float getFKDR() { + return (float) finalKills / finalDeaths; + } + + public float getBBLR() { + return (float) bedsBroken / losses; + } + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java new file mode 100644 index 000000000..f71318188 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java @@ -0,0 +1,79 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Locale; +import java.util.Optional; + +/** + * @author DarkKronicle + */ + +@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'), + ; + + @Getter + private final char code; + + @Getter + private final char prefix; + + public String getColorSection() { + return "§" + code; + } + + public static Optional fromPrefix(char prefix) { + for (BedwarsTeam t : values()) { + if (t.getPrefix() == prefix) { + return Optional.of(t); + } + } + 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(); + } + + public String getName() { + return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); + } + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..86885fa6e --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,119 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.mojang.blaze3d.platform.GlStateManager; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + GlStateManager.enableAlphaTest(); + GlStateManager.enableBlend(); + GlStateManager.color4f(1, 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; + texture = u.getTexture()[0]; + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + if (mod.isWaiting()) { + + } else { + drawOverlay(stack, getPos(), false); + } + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java new file mode 100644 index 000000000..2053d498a --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.stats; + +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class LobbyStatsHud extends BoxHudEntry { + + public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { + super(width, height, backgroundAllowed); + } + + @Override + public void renderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public void renderPlaceholderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public Identifier getId() { + return null; + } +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..156a7f31d --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4 + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5 + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1 + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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,3}\\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} + ); + + public 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/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java new file mode 100644 index 000000000..bfd8eabda --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BinaryUpgrade extends TeamUpgrade { + + 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 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) { + return doublesPrice; + } + return foursPrice; + } + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java new file mode 100644 index 000000000..78126e8cd --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + + +public abstract class TeamUpgrade { + @Getter + protected final String name; + protected 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 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); + + + public abstract boolean isPurchased(); +} + diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java new file mode 100644 index 000000000..a1bda0577 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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 + 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; + } + + 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/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..4c56947f1 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,129 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 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("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")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java index 8db148f79..2b813be85 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -25,13 +25,11 @@ import io.github.axolotlclient.util.events.types.CancellableEvent; import lombok.Data; import lombok.EqualsAndHashCode; -import net.minecraft.client.util.Window; import net.minecraft.scoreboard.ScoreboardObjective; @EqualsAndHashCode(callSuper = true) @Data public class ScoreboardRenderEvent extends CancellableEvent { - private final Window window; private final ScoreboardObjective objective; } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index f4a36a2c1..967b301c2 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,31 +22,40 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.text.Text; 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.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true) - public void axolotlclient$autoThings(Text message, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + @Inject(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;IIZ)V"), cancellable = true) + public void axolotlclient$autoThings(Text message, int messageId, CallbackInfo ci) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;I)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 4ba4aa7e0..8a2b52100 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, false, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9af2bd244..a4f55dc6c 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -28,6 +28,9 @@ import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; @@ -38,10 +41,7 @@ import org.jetbrains.annotations.Nullable; 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.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +89,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +189,33 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), + ordinal = 18 + ) + public int axolotlclient$displayHardcoreHearts(int offset) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 5 : offset; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 20 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 4afc08eac..dd3e7539f 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -26,11 +26,14 @@ import io.github.axolotlclient.modules.blur.MenuBlur; import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -83,4 +86,9 @@ public abstract class MinecraftClientMixin { private void axolotlclient$noModdedSigns(CallbackInfoReturnable cir) { cir.setReturnValue(false); } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index e60d70c11..6786c9efe 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -25,12 +25,19 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.render.entity.PlayerModelPart; import net.minecraft.client.util.math.MatrixStack; @@ -42,14 +49,17 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; 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.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.List; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -59,7 +69,8 @@ public abstract class PlayerListHudMixin { @Shadow private Text footer; - private GameProfile profile; + @Unique + private GameProfile axolotlclient$profile; @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) public void axolotlclient$nickHider(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { @@ -76,22 +87,26 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text method_27538(PlayerListEntry par1, MutableText par2); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { - profile = playerEntry.getProfile(); + axolotlclient$profile = playerEntry.getProfile(); return playerEntry; } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;getWidth(Lnet/minecraft/text/StringVisitable;)I")) public int axolotlclient$moveName(TextRenderer instance, StringVisitable text) { - if (profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(profile.getId())) + if (axolotlclient$profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$profile.getId())) return instance.getWidth(text) + 10; return instance.getWidth(text); } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/text/Text;FFI)I")) public int axolotlclient$moveName2(TextRenderer instance, MatrixStack matrices, Text text, float x, float y, int color) { - if (profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(profile.getId())) { + if (axolotlclient$profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$profile.getId())) { MinecraftClient.getInstance().getTextureManager().bindTexture(AxolotlClient.badgeIcon); RenderSystem.color4f(1, 1, 1, 1); @@ -99,7 +114,7 @@ public abstract class PlayerListHudMixin { x += 9; } - profile = null; + axolotlclient$profile = null; return instance.drawWithShadow(matrices, text, x, y, color); } @@ -116,7 +131,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { ci.cancel(); } } @@ -151,4 +168,156 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$alwaysShowHeadLayer(PlayerEntity instance, PlayerModelPart modelPart) { return Tablist.getInstance().alwaysShowHeadLayer.get() || instance.isPartVisible(modelPart); } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, 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.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.client.textRenderer.drawWithShadow(matrixStack, + render, + (float) (endX - this.client.textRenderer.getWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Ljava/lang/String;FFI)I", + ordinal = 1 + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, + PlayerListEntry playerEntry, MatrixStack matrices, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().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; + 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("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + this.client.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - this.client.textRenderer.getWidth(render)), + (float) y, + color + ); + + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$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;", remap = false)) + public List axolotlclient$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 axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 660692581..2fb578396 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hypixel; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -33,10 +30,14 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; +import java.util.ArrayList; +import java.util.List; + public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 2cb1c7255..a500fa8f7 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -26,8 +26,9 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; -import net.minecraft.text.Text; // Based on https://github.com/VeryHolyCheeeese/AutoBoop/blob/main/src/main/java/autoboop/AutoBoop.java public class AutoBoop implements AbstractHypixelMod { @@ -41,6 +42,7 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -48,10 +50,11 @@ public OptionCategory getCategory() { return cat; } - public void onMessage(Text message) { - if (enabled.get() && message.getString().contains("Friend >") && message.getString().contains("joined.")) { - String player = message.getString().substring(message.getString().indexOf(">"), - message.getString().lastIndexOf(" ")); + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage(); + if (enabled.get() && message.contains("Friend >") && message.contains("joined.")) { + String player = message.substring(message.indexOf(">"), + message.lastIndexOf(" ")); Util.sendChatMessage("/boop " + player); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index f9c18e6aa..083799dfe 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -22,19 +22,20 @@ package io.github.axolotlclient.modules.hypixel.autogg; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.stream.Collectors; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; /** * Based on DragonEggBedrockBreaking's AutoGG Mod @@ -88,6 +89,8 @@ public void init() { category.add(onBWP); category.add(onPVPL); category.add(onMMC); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -158,28 +161,28 @@ private List addToList(String... strings) { return Arrays.stream(strings).collect(Collectors.toList()); } - public void onMessage(Text message) { + public void onMessage(ReceiveChatMessageEvent event) { if (client.getCurrentServerEntry() != null) { serverMap.keySet().forEach(s -> { if (serverMap.get(s).get() && client.getCurrentServerEntry().address.contains(s)) { if (gf.get()) { - processChat(message, gfStrings.get(s), gfString.get()); + processChat(event.getOriginalMessage(), gfStrings.get(s), gfString.get()); } if (gg.get()) { - processChat(message, ggStrings.get(s), ggString.get()); + processChat(event.getOriginalMessage(), ggStrings.get(s), ggString.get()); } if (glhf.get()) { - processChat(message, glhfStrings.get(s), glhfString.get()); + processChat(event.getOriginalMessage(), glhfStrings.get(s), glhfString.get()); } } }); } } - private void processChat(Text messageReceived, List options, String messageToSend) { + private void processChat(String messageReceived, List options, String messageToSend) { if (System.currentTimeMillis() - this.lastTime > 3000 && options != null) { for (String s : options) { - if (messageReceived.getString().contains(s)) { + if (messageReceived.contains(s)) { Util.sendChatMessage(messageToSend); this.lastTime = System.currentTimeMillis(); return; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 23c9956e7..7ee9561c1 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,15 +22,16 @@ package io.github.axolotlclient.modules.hypixel.autotip; -import java.util.regex.Pattern; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; + +import java.util.regex.Pattern; public class AutoTip implements AbstractHypixelMod { @@ -53,6 +54,8 @@ public class AutoTip implements AbstractHypixelMod { public void init() { category.add(enabled, hideMessages); init = true; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); } @Override @@ -65,7 +68,7 @@ public void tick() { if (init) { if (System.currentTimeMillis() - lastTime > 1200000 && MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel") + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") && enabled.get()) { if (MinecraftClient.getInstance().player != null) { Util.sendChatMessage("/tip all"); @@ -80,8 +83,8 @@ public boolean tickable() { return true; } - public boolean onChatMessage(Text text) { - return enabled.get() && hideMessages.get() && (messagePattern.matcher(text.getString()).matches() - || tippedPattern.matcher(text.getString()).matches()); + public void onChatMessage(ReceiveChatMessageEvent event) { + event.setCancelled(enabled.get() && hideMessages.get() && (messagePattern.matcher(event.getOriginalMessage()).matches() + || tippedPattern.matcher(event.getOriginalMessage()).matches())); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java new file mode 100644 index 000000000..ef3f5bb2f --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +@AllArgsConstructor +public enum BedwarsDeathType { + 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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..37ba575dc --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,480 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +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; +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; +import java.util.stream.Collectors; + +/** + * @author DarkKronicle + */ + +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; + + private final Map players = new HashMap<>(16); + private final Map playersById = new HashMap<>(16); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + 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).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + 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); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + 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; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + 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)); + } + + 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, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(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) { + 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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + 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 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(p -> disconnected(event, p)))) { + return; + } + 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 -> { + 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + 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(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + new LiteralText("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + 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 + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + 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(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatEliminated(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(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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.modifyText(team, new LiteralText(score.getPlayerName())).getString(); + 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) { + updateClock(); + } + topBarText = new LiteralText(calculateTopBarText()); + bottomBarText = new LiteralText(calculateBottomBarText()); + } + } + + private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); + } + if (emeraldsTimer <= 0) { + int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; + emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); + } + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + 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()); + } + + 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; + } + return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + } + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java new file mode 100644 index 000000000..afdaaa861 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -0,0 +1,312 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import java.util.Arrays; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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} 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}.", + "{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}")), + Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), + 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"), + Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), + }; + + 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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..b2fb4561d --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,228 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +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.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + 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*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + public String getDetail() { + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, + tabRenderLatencyIcon, showChatTime, overrideMessages); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(new LiteralText(time).append(event.getNewMessage())); + } else { + event.setNewMessage(new LiteralText(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListWidget().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListWidget().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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.modifyText(team, new LiteralText(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java new file mode 100644 index 000000000..511145cc4 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..c092237ca --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + 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) { + this.team = team; + this.profile = profile; + 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(); + } + + 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 || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + 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; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + 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(); + } + stats.addKill(); + } + } +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java new file mode 100644 index 000000000..337a46afd --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -0,0 +1,170 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +@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 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, + 0, + 0, + 0, + 0, + 0, + 1 + ); + } + + @Nullable + public static BedwarsPlayerStats fromAPI(String uuid) { + JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); + JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); + 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) { + if (obj.has(key)) { + try { + return obj.get(key).getAsInt(); + } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { + // Not actually an int + } + } + return other; + } + + public 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++; + gameDeaths++; + } + + public void addFinalDeath() { + finalDeaths++; + gameFinalDeaths++; + } + + public void addKill() { + kills++; + gameKills++; + } + + public void addFinalKill() { + finalKills++; + gameFinalKills++; + } + + public void addBed() { + bedsBroken++; + gameBedsBroken++; + } + + public float getFKDR() { + return (float) finalKills / finalDeaths; + } + + public float getBBLR() { + return (float) bedsBroken / losses; + } + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java new file mode 100644 index 000000000..f71318188 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java @@ -0,0 +1,79 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Locale; +import java.util.Optional; + +/** + * @author DarkKronicle + */ + +@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'), + ; + + @Getter + private final char code; + + @Getter + private final char prefix; + + public String getColorSection() { + return "§" + code; + } + + public static Optional fromPrefix(char prefix) { + for (BedwarsTeam t : values()) { + if (t.getPrefix() == prefix) { + return Optional.of(t); + } + } + 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(); + } + + public String getName() { + return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); + } + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..86885fa6e --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,119 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.mojang.blaze3d.platform.GlStateManager; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + GlStateManager.enableAlphaTest(); + GlStateManager.enableBlend(); + GlStateManager.color4f(1, 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; + texture = u.getTexture()[0]; + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + if (mod.isWaiting()) { + + } else { + drawOverlay(stack, getPos(), false); + } + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java new file mode 100644 index 000000000..2053d498a --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.stats; + +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class LobbyStatsHud extends BoxHudEntry { + + public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { + super(width, height, backgroundAllowed); + } + + @Override + public void renderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public void renderPlaceholderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public Identifier getId() { + return null; + } +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..156a7f31d --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4 + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5 + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1 + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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,3}\\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} + ); + + public 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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java new file mode 100644 index 000000000..bfd8eabda --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BinaryUpgrade extends TeamUpgrade { + + 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 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) { + return doublesPrice; + } + return foursPrice; + } + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java new file mode 100644 index 000000000..78126e8cd --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + + +public abstract class TeamUpgrade { + @Getter + protected final String name; + protected 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 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); + + + public abstract boolean isPurchased(); +} + diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java new file mode 100644 index 000000000..a1bda0577 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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 + 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; + } + + 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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..4c56947f1 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,129 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 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("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")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java index 8db148f79..2b813be85 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -25,13 +25,11 @@ import io.github.axolotlclient.util.events.types.CancellableEvent; import lombok.Data; import lombok.EqualsAndHashCode; -import net.minecraft.client.util.Window; import net.minecraft.scoreboard.ScoreboardObjective; @EqualsAndHashCode(callSuper = true) @Data public class ScoreboardRenderEvent extends CancellableEvent { - private final Window window; private final ScoreboardObjective objective; } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index df6ce02af..6995afe20 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,10 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatMessageTag; import net.minecraft.network.chat.MessageSignature; @@ -34,21 +33,31 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), cancellable = true) public void axolotlclient$autoThings(Text message, MessageSignature signature, ChatMessageTag tag, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 4ba4aa7e0..8a2b52100 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, false, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9af2bd244..6e252457c 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -28,6 +28,9 @@ import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; @@ -38,10 +41,7 @@ import org.jetbrains.annotations.Nullable; 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.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +89,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +189,33 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderHealthBar", + at = @At( + value = "STORE" + ), + ordinal = 13 + ) + public int axolotlclient$displayHardcoreHearts(int v) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return (hardcore ? 9 * 5 : v); + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 22 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 9f53f46fa..be9243592 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,10 +27,13 @@ import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import net.minecraft.resource.ResourceType; import org.quiltmc.loader.api.QuiltLoader; import org.quiltmc.qsl.resource.loader.api.ResourceLoader; @@ -82,4 +85,9 @@ public abstract class MinecraftClientMixin { MenuBlur.getInstance().onScreenOpen(); } } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 0f3d70692..c0a8ebe7f 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -25,12 +25,19 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.ClientConnection; @@ -39,14 +46,16 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; 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.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.List; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -72,6 +81,10 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text applyGameModeFormatting(PlayerListEntry entry, MutableText name); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { profile = playerEntry.getProfile(); @@ -112,7 +125,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { ci.cancel(); } } @@ -147,4 +162,156 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$renderHatLayer(boolean drawHat) { return Tablist.getInstance().alwaysShowHeadLayer.get() || drawHat; } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, 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.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.client.textRenderer.drawWithShadow(matrixStack, + render, + (float) (endX - this.client.textRenderer.getWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Ljava/lang/String;FFI)I", + ordinal = 1 + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, + PlayerListEntry playerEntry, MatrixStack matrices, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().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; + 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("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + this.client.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - this.client.textRenderer.getWidth(render)), + (float) y, + color + ); + + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$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;", remap = false)) + public List axolotlclient$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 axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java new file mode 100644 index 000000000..ef3f5bb2f --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +@AllArgsConstructor +public enum BedwarsDeathType { + 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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..fa2baff1f --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,479 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +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; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.Text; +import org.jetbrains.annotations.Nullable; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +/** + * @author DarkKronicle + */ + +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 = Text.empty(); + private Text bottomBarText = Text.empty(); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(16); + private final Map playersById = new HashMap<>(16); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + 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); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + 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; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + 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)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(Text.literal("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(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) { + 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)) + .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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + 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 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(p -> disconnected(event, p)))) { + return; + } + 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 -> { + 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + 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(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + Text.literal("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + Text.literal( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + 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(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatEliminated(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(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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, Text.literal(score.getPlayerName())).getString(); + 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) { + updateClock(); + } + topBarText = Text.literal(calculateTopBarText()); + bottomBarText = Text.literal(calculateBottomBarText()); + } + } + + private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); + } + if (emeraldsTimer <= 0) { + int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; + emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); + } + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + 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()); + } + + 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; + } + return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + } + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java new file mode 100644 index 000000000..afdaaa861 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -0,0 +1,312 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import java.util.Arrays; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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} 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}.", + "{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}")), + Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), + 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"), + Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), + }; + + 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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..437fc348f --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,227 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +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.Text; +import net.minecraft.util.Formatting; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + 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*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + public String getDetail() { + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, + tabRenderLatencyIcon, showChatTime, overrideMessages); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(Text.literal(time).append(event.getNewMessage())); + } else { + event.setNewMessage(Text.literal(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListHud().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .toList(); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, Text.literal(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java new file mode 100644 index 000000000..511145cc4 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..c092237ca --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + 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) { + this.team = team; + this.profile = profile; + 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(); + } + + 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 || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + 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; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + 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(); + } + stats.addKill(); + } + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java new file mode 100644 index 000000000..337a46afd --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -0,0 +1,170 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +@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 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, + 0, + 0, + 0, + 0, + 0, + 1 + ); + } + + @Nullable + public static BedwarsPlayerStats fromAPI(String uuid) { + JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); + JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); + 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) { + if (obj.has(key)) { + try { + return obj.get(key).getAsInt(); + } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { + // Not actually an int + } + } + return other; + } + + public 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++; + gameDeaths++; + } + + public void addFinalDeath() { + finalDeaths++; + gameFinalDeaths++; + } + + public void addKill() { + kills++; + gameKills++; + } + + public void addFinalKill() { + finalKills++; + gameFinalKills++; + } + + public void addBed() { + bedsBroken++; + gameBedsBroken++; + } + + public float getFKDR() { + return (float) finalKills / finalDeaths; + } + + public float getBBLR() { + return (float) bedsBroken / losses; + } + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java new file mode 100644 index 000000000..f71318188 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java @@ -0,0 +1,79 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Locale; +import java.util.Optional; + +/** + * @author DarkKronicle + */ + +@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'), + ; + + @Getter + private final char code; + + @Getter + private final char prefix; + + public String getColorSection() { + return "§" + code; + } + + public static Optional fromPrefix(char prefix) { + for (BedwarsTeam t : values()) { + if (t.getPrefix() == prefix) { + return Optional.of(t); + } + } + 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(); + } + + public String getName() { + return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); + } + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..efac1d64d --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,118 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + RenderSystem.enableBlend(); + RenderSystem.setShaderColor(1, 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; + texture = u.getTexture()[0]; + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + if (mod.isWaiting()) { + + } else { + drawOverlay(stack, getPos(), false); + } + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java new file mode 100644 index 000000000..2053d498a --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.stats; + +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class LobbyStatsHud extends BoxHudEntry { + + public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { + super(width, height, backgroundAllowed); + } + + @Override + public void renderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public void renderPlaceholderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public Identifier getId() { + return null; + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..156a7f31d --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4 + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5 + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1 + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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,3}\\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} + ); + + public 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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java new file mode 100644 index 000000000..bfd8eabda --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BinaryUpgrade extends TeamUpgrade { + + 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 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) { + return doublesPrice; + } + return foursPrice; + } + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java new file mode 100644 index 000000000..78126e8cd --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + + +public abstract class TeamUpgrade { + @Getter + protected final String name; + protected 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 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); + + + public abstract boolean isPurchased(); +} + diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java new file mode 100644 index 000000000..a1bda0577 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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 + 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; + } + + 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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..4c56947f1 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,129 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 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("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")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java index 38fa3e231..2b813be85 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -22,7 +22,6 @@ package io.github.axolotlclient.util.events.impl; -import com.mojang.blaze3d.glfw.Window; import io.github.axolotlclient.util.events.types.CancellableEvent; import lombok.Data; import lombok.EqualsAndHashCode; @@ -32,6 +31,5 @@ @Data public class ScoreboardRenderEvent extends CancellableEvent { - private final Window window; private final ScoreboardObjective objective; } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index f75f75615..098118c15 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,10 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatMessageTag; import net.minecraft.network.message.MessageSignature; @@ -34,21 +33,31 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), cancellable = true) public void axolotlclient$autoThings(Text message, MessageSignature signature, ChatMessageTag tag, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 1d5bf7103..89c0f641b 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, false, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9af2bd244..9b9f53f94 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -28,6 +28,9 @@ import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; @@ -38,10 +41,7 @@ import org.jetbrains.annotations.Nullable; 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.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +89,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +189,33 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderHealthBar", + at = @At( + value = "STORE" + ), + ordinal = 13 + ) + public int axolotlclient$displayHardcoreHearts(int v) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 9 * 5 : v; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 22 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 9f53f46fa..be9243592 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,10 +27,13 @@ import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import net.minecraft.resource.ResourceType; import org.quiltmc.loader.api.QuiltLoader; import org.quiltmc.qsl.resource.loader.api.ResourceLoader; @@ -82,4 +85,9 @@ public abstract class MinecraftClientMixin { MenuBlur.getInstance().onScreenOpen(); } } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 0f3d70692..11b1a4915 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -25,12 +25,19 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.ClientConnection; @@ -39,14 +46,16 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; 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.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.List; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -72,6 +81,10 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text applyGameModeFormatting(PlayerListEntry entry, MutableText name); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { profile = playerEntry.getProfile(); @@ -112,7 +125,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { ci.cancel(); } } @@ -147,4 +162,155 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$renderHatLayer(boolean drawHat) { return Tablist.getInstance().alwaysShowHeadLayer.get() || drawHat; } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, 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.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.client.textRenderer.drawWithShadow(matrixStack, + render, + (float) (endX - this.client.textRenderer.getWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Ljava/lang/String;FFI)I" + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, + PlayerListEntry playerEntry, MatrixStack matrices, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().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; + 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("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + this.client.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - this.client.textRenderer.getWidth(render)), + (float) y, + color + ); + + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$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 = "Ljava/util/stream/Stream;toList()Ljava/util/List;", remap = false)) + public List axolotlclient$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 axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 2cb1c7255..a500fa8f7 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -26,8 +26,9 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; -import net.minecraft.text.Text; // Based on https://github.com/VeryHolyCheeeese/AutoBoop/blob/main/src/main/java/autoboop/AutoBoop.java public class AutoBoop implements AbstractHypixelMod { @@ -41,6 +42,7 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -48,10 +50,11 @@ public OptionCategory getCategory() { return cat; } - public void onMessage(Text message) { - if (enabled.get() && message.getString().contains("Friend >") && message.getString().contains("joined.")) { - String player = message.getString().substring(message.getString().indexOf(">"), - message.getString().lastIndexOf(" ")); + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage(); + if (enabled.get() && message.contains("Friend >") && message.contains("joined.")) { + String player = message.substring(message.indexOf(">"), + message.lastIndexOf(" ")); Util.sendChatMessage("/boop " + player); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index b5d93e47f..ddf958773 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -22,18 +22,19 @@ package io.github.axolotlclient.modules.hypixel.autogg; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; /** * Based on DragonEggBedrockBreaking's AutoGG Mod @@ -87,6 +88,8 @@ public void init() { category.add(onBWP); category.add(onPVPL); category.add(onMMC); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -157,28 +160,28 @@ private List addToList(String... strings) { return Arrays.stream(strings).toList(); } - public void onMessage(Text message) { + public void onMessage(ReceiveChatMessageEvent event) { if (client.getCurrentServerEntry() != null) { serverMap.keySet().forEach(s -> { if (serverMap.get(s).get() && client.getCurrentServerEntry().address.contains(s)) { if (gf.get()) { - processChat(message, gfStrings.get(s), gfString.get()); + processChat(event.getOriginalMessage(), gfStrings.get(s), gfString.get()); } if (gg.get()) { - processChat(message, ggStrings.get(s), ggString.get()); + processChat(event.getOriginalMessage(), ggStrings.get(s), ggString.get()); } if (glhf.get()) { - processChat(message, glhfStrings.get(s), glhfString.get()); + processChat(event.getOriginalMessage(), glhfStrings.get(s), glhfString.get()); } } }); } } - private void processChat(Text messageReceived, List options, String messageToSend) { + private void processChat(String messageReceived, List options, String messageToSend) { if (System.currentTimeMillis() - this.lastTime > 3000 && options != null) { for (String s : options) { - if (messageReceived.getString().contains(s)) { + if (messageReceived.contains(s)) { Util.sendChatMessage(messageToSend); this.lastTime = System.currentTimeMillis(); return; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 23c9956e7..06350af80 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,15 +22,16 @@ package io.github.axolotlclient.modules.hypixel.autotip; -import java.util.regex.Pattern; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; + +import java.util.regex.Pattern; public class AutoTip implements AbstractHypixelMod { @@ -52,6 +53,9 @@ public class AutoTip implements AbstractHypixelMod { @Override public void init() { category.add(enabled, hideMessages); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); + init = true; } @@ -80,8 +84,8 @@ public boolean tickable() { return true; } - public boolean onChatMessage(Text text) { - return enabled.get() && hideMessages.get() && (messagePattern.matcher(text.getString()).matches() - || tippedPattern.matcher(text.getString()).matches()); + public void onChatMessage(ReceiveChatMessageEvent event) { + event.setCancelled(enabled.get() && hideMessages.get() && (messagePattern.matcher(event.getOriginalMessage()).matches() + || tippedPattern.matcher(event.getOriginalMessage()).matches())); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java new file mode 100644 index 000000000..ef3f5bb2f --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +@AllArgsConstructor +public enum BedwarsDeathType { + 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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..fa2baff1f --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,479 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +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; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.Text; +import org.jetbrains.annotations.Nullable; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +/** + * @author DarkKronicle + */ + +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 = Text.empty(); + private Text bottomBarText = Text.empty(); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(16); + private final Map playersById = new HashMap<>(16); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + 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); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + 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; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + 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)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(Text.literal("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(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) { + 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)) + .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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + 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 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(p -> disconnected(event, p)))) { + return; + } + 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 -> { + 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + 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(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + Text.literal("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + Text.literal( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + 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(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatEliminated(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(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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, Text.literal(score.getPlayerName())).getString(); + 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) { + updateClock(); + } + topBarText = Text.literal(calculateTopBarText()); + bottomBarText = Text.literal(calculateBottomBarText()); + } + } + + private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); + } + if (emeraldsTimer <= 0) { + int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; + emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); + } + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + 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()); + } + + 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; + } + return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + } + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java new file mode 100644 index 000000000..afdaaa861 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -0,0 +1,312 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import java.util.Arrays; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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} 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}.", + "{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}")), + Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), + 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"), + Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), + }; + + 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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..437fc348f --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,227 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +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.Text; +import net.minecraft.util.Formatting; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + 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*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + public String getDetail() { + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, + tabRenderLatencyIcon, showChatTime, overrideMessages); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(Text.literal(time).append(event.getNewMessage())); + } else { + event.setNewMessage(Text.literal(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListHud().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .toList(); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, Text.literal(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java new file mode 100644 index 000000000..511145cc4 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..c092237ca --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + 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) { + this.team = team; + this.profile = profile; + 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(); + } + + 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 || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + 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; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + 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(); + } + stats.addKill(); + } + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java new file mode 100644 index 000000000..337a46afd --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -0,0 +1,170 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +@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 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, + 0, + 0, + 0, + 0, + 0, + 1 + ); + } + + @Nullable + public static BedwarsPlayerStats fromAPI(String uuid) { + JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); + JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); + 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) { + if (obj.has(key)) { + try { + return obj.get(key).getAsInt(); + } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { + // Not actually an int + } + } + return other; + } + + public 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++; + gameDeaths++; + } + + public void addFinalDeath() { + finalDeaths++; + gameFinalDeaths++; + } + + public void addKill() { + kills++; + gameKills++; + } + + public void addFinalKill() { + finalKills++; + gameFinalKills++; + } + + public void addBed() { + bedsBroken++; + gameBedsBroken++; + } + + public float getFKDR() { + return (float) finalKills / finalDeaths; + } + + public float getBBLR() { + return (float) bedsBroken / losses; + } + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java new file mode 100644 index 000000000..f71318188 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java @@ -0,0 +1,79 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Locale; +import java.util.Optional; + +/** + * @author DarkKronicle + */ + +@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'), + ; + + @Getter + private final char code; + + @Getter + private final char prefix; + + public String getColorSection() { + return "§" + code; + } + + public static Optional fromPrefix(char prefix) { + for (BedwarsTeam t : values()) { + if (t.getPrefix() == prefix) { + return Optional.of(t); + } + } + 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(); + } + + public String getName() { + return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); + } + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..efac1d64d --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,118 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + RenderSystem.enableBlend(); + RenderSystem.setShaderColor(1, 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; + texture = u.getTexture()[0]; + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + if (mod.isWaiting()) { + + } else { + drawOverlay(stack, getPos(), false); + } + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java new file mode 100644 index 000000000..2053d498a --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.stats; + +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class LobbyStatsHud extends BoxHudEntry { + + public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { + super(width, height, backgroundAllowed); + } + + @Override + public void renderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public void renderPlaceholderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public Identifier getId() { + return null; + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..156a7f31d --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4 + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5 + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1 + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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,3}\\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} + ); + + public 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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java new file mode 100644 index 000000000..bfd8eabda --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BinaryUpgrade extends TeamUpgrade { + + 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 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) { + return doublesPrice; + } + return foursPrice; + } + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java new file mode 100644 index 000000000..78126e8cd --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + + +public abstract class TeamUpgrade { + @Getter + protected final String name; + protected 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 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); + + + public abstract boolean isPurchased(); +} + diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java new file mode 100644 index 000000000..a1bda0577 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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 + 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; + } + + 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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..4c56947f1 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,129 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 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("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")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java index 38fa3e231..2b813be85 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -22,7 +22,6 @@ package io.github.axolotlclient.util.events.impl; -import com.mojang.blaze3d.glfw.Window; import io.github.axolotlclient.util.events.types.CancellableEvent; import lombok.Data; import lombok.EqualsAndHashCode; @@ -32,6 +31,5 @@ @Data public class ScoreboardRenderEvent extends CancellableEvent { - private final Window window; private final ScoreboardObjective objective; } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index f75f75615..098118c15 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,10 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatMessageTag; import net.minecraft.network.message.MessageSignature; @@ -34,21 +33,31 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), cancellable = true) public void axolotlclient$autoThings(Text message, MessageSignature signature, ChatMessageTag tag, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 00c3a054a..bba7200e1 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, TextRenderer.TextLayerType.NORMAL, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9af2bd244..9b9f53f94 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -28,6 +28,9 @@ import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; @@ -38,10 +41,7 @@ import org.jetbrains.annotations.Nullable; 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.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +89,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +189,33 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderHealthBar", + at = @At( + value = "STORE" + ), + ordinal = 13 + ) + public int axolotlclient$displayHardcoreHearts(int v) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 9 * 5 : v; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 22 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 9f53f46fa..be9243592 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,10 +27,13 @@ import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import net.minecraft.resource.ResourceType; import org.quiltmc.loader.api.QuiltLoader; import org.quiltmc.qsl.resource.loader.api.ResourceLoader; @@ -82,4 +85,9 @@ public abstract class MinecraftClientMixin { MenuBlur.getInstance().onScreenOpen(); } } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 0f3d70692..b15611db3 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -25,12 +25,19 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.ClientConnection; @@ -39,14 +46,16 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; 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.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.List; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -72,6 +81,10 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text applyGameModeFormatting(PlayerListEntry entry, MutableText name); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { profile = playerEntry.getProfile(); @@ -112,7 +125,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { ci.cancel(); } } @@ -147,4 +162,155 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$renderHatLayer(boolean drawHat) { return Tablist.getInstance().alwaysShowHeadLayer.get() || drawHat; } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, 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.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.client.textRenderer.drawWithShadow(matrixStack, + render, + (float) (endX - this.client.textRenderer.getWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Ljava/lang/String;FFI)I" + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, + PlayerListEntry playerEntry, MatrixStack matrices, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().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; + 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("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + this.client.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - this.client.textRenderer.getWidth(render)), + (float) y, + color + ); + + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$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 = "method_48213", at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/stream/Stream;toList()Ljava/util/List;", remap = false)) + public List axolotlclient$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 axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 2cb1c7255..a500fa8f7 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -26,8 +26,9 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; -import net.minecraft.text.Text; // Based on https://github.com/VeryHolyCheeeese/AutoBoop/blob/main/src/main/java/autoboop/AutoBoop.java public class AutoBoop implements AbstractHypixelMod { @@ -41,6 +42,7 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -48,10 +50,11 @@ public OptionCategory getCategory() { return cat; } - public void onMessage(Text message) { - if (enabled.get() && message.getString().contains("Friend >") && message.getString().contains("joined.")) { - String player = message.getString().substring(message.getString().indexOf(">"), - message.getString().lastIndexOf(" ")); + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage(); + if (enabled.get() && message.contains("Friend >") && message.contains("joined.")) { + String player = message.substring(message.indexOf(">"), + message.lastIndexOf(" ")); Util.sendChatMessage("/boop " + player); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index b5d93e47f..ddf958773 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -22,18 +22,19 @@ package io.github.axolotlclient.modules.hypixel.autogg; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; /** * Based on DragonEggBedrockBreaking's AutoGG Mod @@ -87,6 +88,8 @@ public void init() { category.add(onBWP); category.add(onPVPL); category.add(onMMC); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -157,28 +160,28 @@ private List addToList(String... strings) { return Arrays.stream(strings).toList(); } - public void onMessage(Text message) { + public void onMessage(ReceiveChatMessageEvent event) { if (client.getCurrentServerEntry() != null) { serverMap.keySet().forEach(s -> { if (serverMap.get(s).get() && client.getCurrentServerEntry().address.contains(s)) { if (gf.get()) { - processChat(message, gfStrings.get(s), gfString.get()); + processChat(event.getOriginalMessage(), gfStrings.get(s), gfString.get()); } if (gg.get()) { - processChat(message, ggStrings.get(s), ggString.get()); + processChat(event.getOriginalMessage(), ggStrings.get(s), ggString.get()); } if (glhf.get()) { - processChat(message, glhfStrings.get(s), glhfString.get()); + processChat(event.getOriginalMessage(), glhfStrings.get(s), glhfString.get()); } } }); } } - private void processChat(Text messageReceived, List options, String messageToSend) { + private void processChat(String messageReceived, List options, String messageToSend) { if (System.currentTimeMillis() - this.lastTime > 3000 && options != null) { for (String s : options) { - if (messageReceived.getString().contains(s)) { + if (messageReceived.contains(s)) { Util.sendChatMessage(messageToSend); this.lastTime = System.currentTimeMillis(); return; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 23c9956e7..095c74a84 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,15 +22,16 @@ package io.github.axolotlclient.modules.hypixel.autotip; -import java.util.regex.Pattern; - import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; + +import java.util.regex.Pattern; public class AutoTip implements AbstractHypixelMod { @@ -52,6 +53,7 @@ public class AutoTip implements AbstractHypixelMod { @Override public void init() { category.add(enabled, hideMessages); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); init = true; } @@ -80,8 +82,8 @@ public boolean tickable() { return true; } - public boolean onChatMessage(Text text) { - return enabled.get() && hideMessages.get() && (messagePattern.matcher(text.getString()).matches() - || tippedPattern.matcher(text.getString()).matches()); + public void onChatMessage(ReceiveChatMessageEvent event) { + event.setCancelled(enabled.get() && hideMessages.get() && (messagePattern.matcher(event.getOriginalMessage()).matches() + || tippedPattern.matcher(event.getOriginalMessage()).matches())); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java new file mode 100644 index 000000000..76945484a --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +@AllArgsConstructor +public enum BedwarsDeathType { + 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/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..fa2baff1f --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,479 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +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; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.Text; +import org.jetbrains.annotations.Nullable; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +/** + * @author DarkKronicle + */ + +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 = Text.empty(); + private Text bottomBarText = Text.empty(); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(16); + private final Map playersById = new HashMap<>(16); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + 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); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + 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; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + 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)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(Text.literal("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(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) { + 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)) + .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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + 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 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(p -> disconnected(event, p)))) { + return; + } + 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 -> { + 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + 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(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + Text.literal("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + Text.literal( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + 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(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatEliminated(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(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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, Text.literal(score.getPlayerName())).getString(); + 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) { + updateClock(); + } + topBarText = Text.literal(calculateTopBarText()); + bottomBarText = Text.literal(calculateBottomBarText()); + } + } + + private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); + } + if (emeraldsTimer <= 0) { + int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; + emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); + } + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + 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()); + } + + 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; + } + return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + } + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java new file mode 100644 index 000000000..6698b8dd0 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -0,0 +1,312 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import java.util.Arrays; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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} 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}.", + "{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}")), + Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), + 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"), + Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), + }; + + 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/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..437fc348f --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,227 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +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.Text; +import net.minecraft.util.Formatting; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + 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*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + public String getDetail() { + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, + tabRenderLatencyIcon, showChatTime, overrideMessages); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(Text.literal(time).append(event.getNewMessage())); + } else { + event.setNewMessage(Text.literal(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListHud().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .toList(); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, Text.literal(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java new file mode 100644 index 000000000..511145cc4 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..c092237ca --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + 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) { + this.team = team; + this.profile = profile; + 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(); + } + + 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 || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + 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; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + 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(); + } + stats.addKill(); + } + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java new file mode 100644 index 000000000..337a46afd --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -0,0 +1,170 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +@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 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, + 0, + 0, + 0, + 0, + 0, + 1 + ); + } + + @Nullable + public static BedwarsPlayerStats fromAPI(String uuid) { + JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); + JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); + 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) { + if (obj.has(key)) { + try { + return obj.get(key).getAsInt(); + } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { + // Not actually an int + } + } + return other; + } + + public 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++; + gameDeaths++; + } + + public void addFinalDeath() { + finalDeaths++; + gameFinalDeaths++; + } + + public void addKill() { + kills++; + gameKills++; + } + + public void addFinalKill() { + finalKills++; + gameFinalKills++; + } + + public void addBed() { + bedsBroken++; + gameBedsBroken++; + } + + public float getFKDR() { + return (float) finalKills / finalDeaths; + } + + public float getBBLR() { + return (float) bedsBroken / losses; + } + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java new file mode 100644 index 000000000..f71318188 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java @@ -0,0 +1,79 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Locale; +import java.util.Optional; + +/** + * @author DarkKronicle + */ + +@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'), + ; + + @Getter + private final char code; + + @Getter + private final char prefix; + + public String getColorSection() { + return "§" + code; + } + + public static Optional fromPrefix(char prefix) { + for (BedwarsTeam t : values()) { + if (t.getPrefix() == prefix) { + return Optional.of(t); + } + } + 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(); + } + + public String getName() { + return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); + } + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..efac1d64d --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,118 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + RenderSystem.enableBlend(); + RenderSystem.setShaderColor(1, 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; + texture = u.getTexture()[0]; + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + if (mod.isWaiting()) { + + } else { + drawOverlay(stack, getPos(), false); + } + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java new file mode 100644 index 000000000..2053d498a --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.stats; + +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class LobbyStatsHud extends BoxHudEntry { + + public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { + super(width, height, backgroundAllowed); + } + + @Override + public void renderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public void renderPlaceholderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public Identifier getId() { + return null; + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..c0d4b90d0 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4 + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5 + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1 + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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,3}\\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} + ); + + public 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/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java new file mode 100644 index 000000000..28e0fa76b --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BinaryUpgrade extends TeamUpgrade { + + 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 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) { + return doublesPrice; + } + return foursPrice; + } + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java new file mode 100644 index 000000000..b2aec9401 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + + +public abstract class TeamUpgrade { + @Getter + protected final String name; + protected 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 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); + + + public abstract boolean isPurchased(); +} + diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java new file mode 100644 index 000000000..f7ba59f93 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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 + 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; + } + + 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/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..c2f4a9359 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,129 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 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("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")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java index 38fa3e231..2b813be85 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -22,7 +22,6 @@ package io.github.axolotlclient.util.events.impl; -import com.mojang.blaze3d.glfw.Window; import io.github.axolotlclient.util.events.types.CancellableEvent; import lombok.Data; import lombok.EqualsAndHashCode; @@ -32,6 +31,5 @@ @Data public class ScoreboardRenderEvent extends CancellableEvent { - private final Window window; private final ScoreboardObjective objective; } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index f75f75615..098118c15 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,10 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatMessageTag; import net.minecraft.network.message.MessageSignature; @@ -34,21 +33,31 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), cancellable = true) public void axolotlclient$autoThings(Text message, MessageSignature signature, ChatMessageTag tag, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 57809e3ec..8acec63f5 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, TextRenderer.TextLayerType.NORMAL, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 4617f87de..fa328728f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -28,6 +28,9 @@ import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.GuiGraphics; @@ -38,10 +41,7 @@ import org.jetbrains.annotations.Nullable; 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.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +89,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(GuiGraphics graphics, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +189,33 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderHealthBar", + at = @At( + value = "STORE" + ), + ordinal = 13 + ) + public int axolotlclient$displayHardcoreHearts(int v) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 9 * 5 : v; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 22 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 9f53f46fa..be9243592 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,10 +27,13 @@ import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import net.minecraft.resource.ResourceType; import org.quiltmc.loader.api.QuiltLoader; import org.quiltmc.qsl.resource.loader.api.ResourceLoader; @@ -82,4 +85,9 @@ public abstract class MinecraftClientMixin { MenuBlur.getInstance().onScreenOpen(); } } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 06d88edbf..82b72a876 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -25,12 +25,19 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.network.ClientConnection; import net.minecraft.scoreboard.Scoreboard; @@ -38,14 +45,19 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Final; 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.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.List; +import java.util.UUID; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -54,7 +66,8 @@ public abstract class PlayerListHudMixin { private Text header; @Shadow private Text footer; - private GameProfile profile; + @Unique + private GameProfile axolotlclient$profile; @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) public void axolotlclient$nickHider(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { @@ -71,29 +84,33 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text applyGameModeFormatting(PlayerListEntry entry, MutableText name); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { - profile = playerEntry.getProfile(); + axolotlclient$profile = playerEntry.getProfile(); return playerEntry; } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;getWidth(Lnet/minecraft/text/StringVisitable;)I")) public int axolotlclient$moveName(TextRenderer instance, StringVisitable text) { - if (profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(profile.getId())) + if (axolotlclient$profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$profile.getId())) return instance.getWidth(text) + 10; return instance.getWidth(text); } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;drawShadowedText(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)I")) public int axolotlclient$moveName2(GuiGraphics instance, TextRenderer renderer, Text text, int x, int y, int color) { - if (profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(profile.getId())) { + if (axolotlclient$profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$profile.getId())) { RenderSystem.setShaderColor(1, 1, 1, 1); instance.drawTexture(AxolotlClient.badgeIcon, x, y, 8, 8, 0, 0, 8, 8, 8, 8); x += 9; } - profile = null; + axolotlclient$profile = null; return instance.drawShadowedText(renderer, text, x, y, color); } @@ -110,7 +127,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(GuiGraphics graphics, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(graphics, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(graphics, width, x, y, entry)) { ci.cancel(); } } @@ -145,4 +164,154 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$renderHatLayer(boolean drawHat) { return Tablist.getInstance().alwaysShowHeadLayer.get() || drawHat; } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/gui/GuiGraphics;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + GuiGraphics graphics, int scaledWindowWidth, Scoreboard scoreboard, @Nullable ScoreboardObjective objective, 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.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + graphics.drawShadowedText(client.textRenderer, + render, + (endX - this.client.textRenderer.getWidth(render)) + 20, + y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/GuiGraphics;drawShadowedText(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)I" + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, UUID uuid, GuiGraphics graphics, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null) { + return; + } + BedwarsPlayer bedwarsPlayer = game.getPlayer(player).orElse(null); + if (bedwarsPlayer == null) { + return; + } + ci.cancel(); + String render; + 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("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + graphics.drawShadowedText(client.textRenderer, + render, + (endX - this.client.textRenderer.getWidth(render)), + y, + color + ); + + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$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 = "getVisibleEntries", at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/stream/Stream;toList()Ljava/util/List;", remap = false)) + public List axolotlclient$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 axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java new file mode 100644 index 000000000..76945484a --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +@AllArgsConstructor +public enum BedwarsDeathType { + 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/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..8eafaf2ad --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,479 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +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; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.Text; +import org.jetbrains.annotations.Nullable; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +/** + * @author DarkKronicle + */ + +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 = Text.empty(); + private Text bottomBarText = Text.empty(); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(16); + private final Map playersById = new HashMap<>(16); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + 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); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + 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; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + 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)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(Text.literal("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(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) { + 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)) + .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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + 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 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(p -> disconnected(event, p)))) { + return; + } + 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 -> { + 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + 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(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + Text.literal("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + Text.literal( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + 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(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatEliminated(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(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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, Text.literal(score.getPlayerName())).getString(); + 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) { + updateClock(); + } + topBarText = Text.literal(calculateTopBarText()); + bottomBarText = Text.literal(calculateBottomBarText()); + } + } + + private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); + } + if (emeraldsTimer <= 0) { + int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; + emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); + } + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + 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()); + } + + 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; + } + return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + } + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java new file mode 100644 index 000000000..6698b8dd0 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -0,0 +1,312 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import java.util.Arrays; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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} 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}.", + "{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}")), + Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), + 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"), + Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), + }; + + 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/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..437fc348f --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,227 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +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.Text; +import net.minecraft.util.Formatting; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + 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*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + public String getDetail() { + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, + tabRenderLatencyIcon, showChatTime, overrideMessages); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(Text.literal(time).append(event.getNewMessage())); + } else { + event.setNewMessage(Text.literal(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListHud().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .toList(); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, Text.literal(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java new file mode 100644 index 000000000..6a6ebafb9 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..27865c880 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + 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) { + this.team = team; + this.profile = profile; + 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(); + } + + 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 || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + 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; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + 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(); + } + stats.addKill(); + } + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java new file mode 100644 index 000000000..ab5d906db --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -0,0 +1,170 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +@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 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, + 0, + 0, + 0, + 0, + 0, + 1 + ); + } + + @Nullable + public static BedwarsPlayerStats fromAPI(String uuid) { + JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); + JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); + 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) { + if (obj.has(key)) { + try { + return obj.get(key).getAsInt(); + } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { + // Not actually an int + } + } + return other; + } + + public 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++; + gameDeaths++; + } + + public void addFinalDeath() { + finalDeaths++; + gameFinalDeaths++; + } + + public void addKill() { + kills++; + gameKills++; + } + + public void addFinalKill() { + finalKills++; + gameFinalKills++; + } + + public void addBed() { + bedsBroken++; + gameBedsBroken++; + } + + public float getFKDR() { + return (float) finalKills / finalDeaths; + } + + public float getBBLR() { + return (float) bedsBroken / losses; + } + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java new file mode 100644 index 000000000..035e42430 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java @@ -0,0 +1,79 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Locale; +import java.util.Optional; + +/** + * @author DarkKronicle + */ + +@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'), + ; + + @Getter + private final char code; + + @Getter + private final char prefix; + + public String getColorSection() { + return "§" + code; + } + + public static Optional fromPrefix(char prefix) { + for (BedwarsTeam t : values()) { + if (t.getPrefix() == prefix) { + return Optional.of(t); + } + } + 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(); + } + + public String getName() { + return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); + } + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..efac1d64d --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,118 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars; + +import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + RenderSystem.enableBlend(); + RenderSystem.setShaderColor(1, 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; + texture = u.getTexture()[0]; + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + if (mod.isWaiting()) { + + } else { + drawOverlay(stack, getPos(), false); + } + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java new file mode 100644 index 000000000..2053d498a --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.stats; + +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class LobbyStatsHud extends BoxHudEntry { + + public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { + super(width, height, backgroundAllowed); + } + + @Override + public void renderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public void renderPlaceholderComponent(MatrixStack matrices, float delta) { + + } + + @Override + public Identifier getId() { + return null; + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..c0d4b90d0 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4 + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5 + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1 + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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,3}\\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} + ); + + public 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/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java new file mode 100644 index 000000000..28e0fa76b --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BinaryUpgrade extends TeamUpgrade { + + 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 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) { + return doublesPrice; + } + return foursPrice; + } + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java new file mode 100644 index 000000000..b2aec9401 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + + +public abstract class TeamUpgrade { + @Getter + protected final String name; + protected 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 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); + + + public abstract boolean isPurchased(); +} + diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java new file mode 100644 index 000000000..f7ba59f93 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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 + 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; + } + + 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/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..c2f4a9359 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,129 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 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("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")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java index 38fa3e231..2b813be85 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -22,7 +22,6 @@ package io.github.axolotlclient.util.events.impl; -import com.mojang.blaze3d.glfw.Window; import io.github.axolotlclient.util.events.types.CancellableEvent; import lombok.Data; import lombok.EqualsAndHashCode; @@ -32,6 +31,5 @@ @Data public class ScoreboardRenderEvent extends CancellableEvent { - private final Window window; private final ScoreboardObjective objective; } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 66c9d42f2..6e3307bfe 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -177,7 +177,7 @@ public abstract class InGameHudMixin { boolean hardcore = BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); - return hardcore ? 5 : 0; + return hardcore ? 5 : offset; } @ModifyVariable( diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 95f4527ec..89e16c5fe 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -42,7 +42,6 @@ import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -57,10 +56,8 @@ @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin extends DrawableHelper { - - @Final - @Shadow - private final MinecraftClient client = MinecraftClient.getInstance(); + @Unique + private final MinecraftClient axolotlclient$client = MinecraftClient.getInstance(); @Shadow private Text header; @Shadow @@ -98,7 +95,7 @@ public abstract class PlayerListHudMixin extends DrawableHelper { float y = args.get(2); if (AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$playerListEntry.getProfile().getId())) { - client.getTextureManager().bindTexture(AxolotlClient.badgeIcon); + axolotlclient$client.getTextureManager().bindTexture(AxolotlClient.badgeIcon); DrawableHelper.drawTexture((int) x, (int) y, 0, 0, 8, 8, 8, 8); args.set(1, x + 10); } @@ -110,7 +107,7 @@ public abstract class PlayerListHudMixin extends DrawableHelper { float y = args.get(2); if (AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$playerListEntry.getProfile().getId())) { - client.getTextureManager().bindTexture(AxolotlClient.badgeIcon); + axolotlclient$client.getTextureManager().bindTexture(AxolotlClient.badgeIcon); DrawableHelper.drawTexture((int) x, (int) y, 0, 0, 8, 8, 8, 8); args.set(1, x + 10); } @@ -186,9 +183,9 @@ public abstract class PlayerListHudMixin extends DrawableHelper { } catch (Exception e) { return; } - this.client.textRenderer.drawWithShadow( + this.axolotlclient$client.textRenderer.drawWithShadow( render, - (float)(endX - this.client.textRenderer.getStringWidth(render)) + 20, + (float) (endX - this.axolotlclient$client.textRenderer.getStringWidth(render)) + 20, (float) y, -1 ); @@ -223,7 +220,7 @@ public abstract class PlayerListHudMixin extends DrawableHelper { if (bedwarsPlayer.isDisconnected()) { return; } - int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - this.client.inGameHud.getTicks()); + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - this.axolotlclient$client.inGameHud.getTicks()); float secondsTillLive = tickTillLive / 20f; render = String.format("%.1f", secondsTillLive) + "s"; color = new Color(200, 200, 200).getAsInt(); @@ -233,9 +230,9 @@ public abstract class PlayerListHudMixin extends DrawableHelper { render = String.valueOf(health); } // Health - this.client.textRenderer.drawWithShadow( + this.axolotlclient$client.textRenderer.drawWithShadow( render, - (float)(endX - this.client.textRenderer.getStringWidth(render)), + (float) (endX - this.axolotlclient$client.textRenderer.getStringWidth(render)), (float) y, color ); From f8cd917eb4c048d49024c722e18ee7ae332114a0 Mon Sep 17 00:00:00 2001 From: moehreag Date: Sat, 8 Jul 2023 19:07:38 +0200 Subject: [PATCH 09/41] remove timings code, fix some mixins --- .../mixin/PlayerListHudMixin.java | 2 +- .../modules/hypixel/bedwars/BedwarsGame.java | 59 +------------------ .../util/events/impl/KeyBindChangeEvent.java | 22 +++++++ .../util/events/impl/KeyPressEvent.java | 22 +++++++ .../util/events/impl/MouseInputEvent.java | 22 +++++++ .../impl/PlayerDirectionChangeEvent.java | 22 +++++++ .../modules/hypixel/bedwars/BedwarsGame.java | 59 +------------------ .../util/events/impl/KeyBindChangeEvent.java | 22 +++++++ .../util/events/impl/KeyPressEvent.java | 22 +++++++ .../util/events/impl/MouseInputEvent.java | 22 +++++++ .../impl/PlayerDirectionChangeEvent.java | 22 +++++++ .../axolotlclient/mixin/InGameHudMixin.java | 4 +- .../mixin/PlayerListHudMixin.java | 2 +- .../modules/hypixel/bedwars/BedwarsGame.java | 58 +----------------- .../hypixel/bedwars/TeamUpgradesOverlay.java | 4 +- .../util/events/impl/KeyBindChangeEvent.java | 22 +++++++ .../util/events/impl/KeyPressEvent.java | 22 +++++++ .../util/events/impl/MouseInputEvent.java | 22 +++++++ .../impl/PlayerDirectionChangeEvent.java | 22 +++++++ .../axolotlclient/mixin/InGameHudMixin.java | 4 +- .../mixin/PlayerListHudMixin.java | 2 +- .../modules/hypixel/bedwars/BedwarsGame.java | 58 +----------------- .../hypixel/bedwars/TeamUpgradesOverlay.java | 7 +-- .../util/events/impl/KeyBindChangeEvent.java | 22 +++++++ .../util/events/impl/KeyPressEvent.java | 22 +++++++ .../util/events/impl/MouseInputEvent.java | 22 +++++++ .../impl/PlayerDirectionChangeEvent.java | 22 +++++++ .../axolotlclient/mixin/InGameHudMixin.java | 4 +- .../mixin/PlayerListHudMixin.java | 2 +- .../modules/hypixel/bedwars/BedwarsGame.java | 59 +------------------ .../hypixel/bedwars/TeamUpgradesOverlay.java | 7 +-- .../util/events/impl/KeyBindChangeEvent.java | 22 +++++++ .../util/events/impl/KeyPressEvent.java | 22 +++++++ .../util/events/impl/MouseInputEvent.java | 22 +++++++ .../impl/PlayerDirectionChangeEvent.java | 22 +++++++ .../axolotlclient/mixin/InGameHudMixin.java | 2 +- .../mixin/PlayerListHudMixin.java | 7 +-- .../modules/hypixel/bedwars/BedwarsGame.java | 59 +------------------ .../hypixel/bedwars/TeamUpgradesOverlay.java | 15 ++--- .../hypixel/bedwars/stats/LobbyStatsHud.java | 6 +- .../util/events/impl/KeyBindChangeEvent.java | 22 +++++++ .../util/events/impl/KeyPressEvent.java | 22 +++++++ .../util/events/impl/MouseInputEvent.java | 22 +++++++ .../impl/PlayerDirectionChangeEvent.java | 22 +++++++ .../modules/hypixel/bedwars/BedwarsGame.java | 59 +------------------ .../util/events/impl/KeyBindChangeEvent.java | 22 +++++++ .../util/events/impl/KeyPressEvent.java | 22 +++++++ .../util/events/impl/MouseInputEvent.java | 22 +++++++ .../impl/PlayerDirectionChangeEvent.java | 22 +++++++ 49 files changed, 652 insertions(+), 443 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 7a1797145..768d7c5e1 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -177,7 +177,7 @@ public abstract class PlayerListHudMixin { public void axolotlclient$renderWithoutObjective( MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, 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 + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 ) { if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { return; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index f6311d361..98d1e03b7 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -45,19 +45,6 @@ */ 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; @@ -134,7 +121,7 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "§bDiamonds - " + diamondsTimer + " §8| " + "§aEmeralds - " + emeraldsTimer; + return ""; } public String getFormattedTime() { @@ -388,52 +375,8 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { } } - private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); - } - if (emeraldsTimer <= 0) { - int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; - emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); - } } public void tick() { diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java index 921d99b69..b8f450ddc 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index 82ac1580c..0ae92b634 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java index e4f053df1..1217f4d0d 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java index fe2d88b4f..460f7b4b2 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 37ba575dc..539037c96 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -45,19 +45,6 @@ */ 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; @@ -134,7 +121,7 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "§bDiamonds - " + diamondsTimer + " §8| " + "§aEmeralds - " + emeraldsTimer; + return ""; } public String getFormattedTime() { @@ -388,52 +375,8 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { } } - private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); - } - if (emeraldsTimer <= 0) { - int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; - emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); - } } public void tick() { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java index 921d99b69..b8f450ddc 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index 9e544c505..b36c489c9 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java index e4f053df1..1217f4d0d 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java index fe2d88b4f..460f7b4b2 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 6e252457c..db36e7cd8 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -195,7 +195,7 @@ public abstract class InGameHudMixin { at = @At( value = "STORE" ), - ordinal = 13 + ordinal = 7 ) public int axolotlclient$displayHardcoreHearts(int v) { boolean hardcore = BedwarsMod.getInstance().isEnabled() && @@ -208,7 +208,7 @@ public abstract class InGameHudMixin { method = "renderStatusBars", at = @At( value = "STORE" - ), ordinal = 22 + ), ordinal = 15 ) public int axolotlclient$dontHunger(int heartCount) { if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index c0a8ebe7f..0322f240f 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -174,7 +174,7 @@ public abstract class PlayerListHudMixin { public void axolotlclient$renderWithoutObjective( MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, 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 + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 ) { if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { return; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index fa2baff1f..10ee68962 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -45,18 +45,6 @@ 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; @@ -133,7 +121,7 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "§bDiamonds - " + diamondsTimer + " §8| " + "§aEmeralds - " + emeraldsTimer; + return ""; } public String getFormattedTime() { @@ -387,52 +375,8 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { } } - private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); - } - if (emeraldsTimer <= 0) { - int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; - emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); - } } public void tick() { diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index efac1d64d..0d7e64aa5 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -80,7 +80,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo } String texture; texture = u.getTexture()[0]; - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); x += 17; normalUpgrades = true; @@ -91,7 +91,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo y += 17; } for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); x += 17; } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java index 7d5eaa95f..72214c8aa 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import com.mojang.blaze3d.platform.InputUtil; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index c5d356bab..21a85dce0 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java index e4f053df1..1217f4d0d 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java index fe2d88b4f..460f7b4b2 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9b9f53f94..502b75076 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -195,7 +195,7 @@ public abstract class InGameHudMixin { at = @At( value = "STORE" ), - ordinal = 13 + ordinal = 7 ) public int axolotlclient$displayHardcoreHearts(int v) { boolean hardcore = BedwarsMod.getInstance().isEnabled() && @@ -208,7 +208,7 @@ public abstract class InGameHudMixin { method = "renderStatusBars", at = @At( value = "STORE" - ), ordinal = 22 + ), ordinal = 15 ) public int axolotlclient$dontHunger(int heartCount) { if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 11b1a4915..81282f52a 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -174,7 +174,7 @@ public abstract class PlayerListHudMixin { public void axolotlclient$renderWithoutObjective( MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, 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 + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 ) { if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { return; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index fa2baff1f..10ee68962 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -45,18 +45,6 @@ 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; @@ -133,7 +121,7 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "§bDiamonds - " + diamondsTimer + " §8| " + "§aEmeralds - " + emeraldsTimer; + return ""; } public String getFormattedTime() { @@ -387,52 +375,8 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { } } - private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); - } - if (emeraldsTimer <= 0) { - int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; - emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); - } } public void tick() { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index efac1d64d..cbcfcffc6 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -28,7 +28,6 @@ import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; @@ -43,13 +42,11 @@ public class TeamUpgradesOverlay extends BoxHudEntry { private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; - private final MinecraftClient mc; private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; public TeamUpgradesOverlay(BedwarsMod mod) { super(60, 40, true); this.mod = mod; - this.mc = MinecraftClient.getInstance(); } public void onStart(BedwarsTeamUpgrades newUpgrades) { @@ -80,7 +77,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo } String texture; texture = u.getTexture()[0]; - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); x += 17; normalUpgrades = true; @@ -91,7 +88,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo y += 17; } for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); x += 17; } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java index 7d5eaa95f..72214c8aa 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import com.mojang.blaze3d.platform.InputUtil; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index c5d356bab..21a85dce0 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java index e4f053df1..1217f4d0d 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java index fe2d88b4f..460f7b4b2 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9b9f53f94..502b75076 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -195,7 +195,7 @@ public abstract class InGameHudMixin { at = @At( value = "STORE" ), - ordinal = 13 + ordinal = 7 ) public int axolotlclient$displayHardcoreHearts(int v) { boolean hardcore = BedwarsMod.getInstance().isEnabled() && @@ -208,7 +208,7 @@ public abstract class InGameHudMixin { method = "renderStatusBars", at = @At( value = "STORE" - ), ordinal = 22 + ), ordinal = 15 ) public int axolotlclient$dontHunger(int heartCount) { if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index b15611db3..85d04fe6c 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -174,7 +174,7 @@ public abstract class PlayerListHudMixin { public void axolotlclient$renderWithoutObjective( MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, 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 + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 ) { if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { return; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index fa2baff1f..5209a582d 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -44,19 +44,6 @@ */ 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; @@ -133,7 +120,7 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "§bDiamonds - " + diamondsTimer + " §8| " + "§aEmeralds - " + emeraldsTimer; + return ""; } public String getFormattedTime() { @@ -387,52 +374,8 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { } } - private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); - } - if (emeraldsTimer <= 0) { - int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; - emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); - } } public void tick() { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index efac1d64d..cbcfcffc6 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -28,7 +28,6 @@ import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; @@ -43,13 +42,11 @@ public class TeamUpgradesOverlay extends BoxHudEntry { private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; - private final MinecraftClient mc; private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; public TeamUpgradesOverlay(BedwarsMod mod) { super(60, 40, true); this.mod = mod; - this.mc = MinecraftClient.getInstance(); } public void onStart(BedwarsTeamUpgrades newUpgrades) { @@ -80,7 +77,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo } String texture; texture = u.getTexture()[0]; - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); x += 17; normalUpgrades = true; @@ -91,7 +88,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo y += 17; } for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); + RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); x += 17; } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java index 7d5eaa95f..72214c8aa 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import com.mojang.blaze3d.platform.InputUtil; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index c5d356bab..21a85dce0 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java index e4f053df1..1217f4d0d 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java index fe2d88b4f..460f7b4b2 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index fa328728f..2fdd6a96e 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -208,7 +208,7 @@ public abstract class InGameHudMixin { method = "renderStatusBars", at = @At( value = "STORE" - ), ordinal = 22 + ), ordinal = 15 ) public int axolotlclient$dontHunger(int heartCount) { if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 82b72a876..9de52e48d 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -37,7 +37,6 @@ import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.hud.PlayerListHud; -import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.network.ClientConnection; import net.minecraft.scoreboard.Scoreboard; @@ -175,8 +174,8 @@ public abstract class PlayerListHudMixin { ) public void axolotlclient$renderWithoutObjective( GuiGraphics graphics, int scaledWindowWidth, Scoreboard scoreboard, @Nullable ScoreboardObjective objective, 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 + 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, int z, PlayerListEntry playerListEntry2 ) { if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { return; @@ -285,7 +284,7 @@ public abstract class PlayerListHudMixin { cir.setReturnValue(player.getTabListDisplay()); } - @ModifyVariable(method = "getVisibleEntries", at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/stream/Stream;toList()Ljava/util/List;", remap = false)) + @ModifyVariable(method = "render", at = @At(value = "STORE"), ordinal = 0) public List axolotlclient$overrideSortedPlayers(List original) { if (!BedwarsMod.getInstance().inGame()) { return original; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 8eafaf2ad..e4d0686d8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -44,19 +44,6 @@ */ 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; @@ -133,7 +120,7 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "§bDiamonds - " + diamondsTimer + " §8| " + "§aEmeralds - " + emeraldsTimer; + return ""; } public String getFormattedTime() { @@ -387,52 +374,8 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { } } - private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); - } - if (emeraldsTimer <= 0) { - int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; - emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); - } } public void tick() { diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index efac1d64d..ac3c49de3 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -29,8 +29,7 @@ import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.util.Identifier; /** @@ -60,7 +59,7 @@ public void onEnd() { upgrades = null; } - public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + public void drawOverlay(GuiGraphics graphics, DrawPosition position, boolean editMode) { if (upgrades == null && !editMode) { return; } @@ -80,8 +79,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo } String texture; texture = u.getTexture()[0]; - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + graphics.drawTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png"), x, y, 0, 0, 16, 16, 16, 16); x += 17; normalUpgrades = true; } @@ -91,14 +89,13 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo y += 17; } for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + graphics.drawTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png"), x, y, 0, 0, 16, 16, 16, 16); x += 17; } } @Override - public void renderComponent(MatrixStack stack, float delta) { + public void renderComponent(GuiGraphics stack, float delta) { if (mod.isWaiting()) { } else { @@ -107,7 +104,7 @@ public void renderComponent(MatrixStack stack, float delta) { } @Override - public void renderPlaceholderComponent(MatrixStack stack, float delta) { + public void renderPlaceholderComponent(GuiGraphics stack, float delta) { drawOverlay(stack, getPos(), true); } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java index 2053d498a..c956da4c3 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java @@ -23,7 +23,7 @@ package io.github.axolotlclient.modules.hypixel.bedwars.stats; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.util.Identifier; /** @@ -37,12 +37,12 @@ public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { } @Override - public void renderComponent(MatrixStack matrices, float delta) { + public void renderComponent(GuiGraphics graphics, float delta) { } @Override - public void renderPlaceholderComponent(MatrixStack matrices, float delta) { + public void renderPlaceholderComponent(GuiGraphics graphics, float delta) { } diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java index 7d5eaa95f..72214c8aa 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import com.mojang.blaze3d.platform.InputUtil; diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index c5d356bab..21a85dce0 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java index e4f053df1..1217f4d0d 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java index fe2d88b4f..460f7b4b2 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 3eab4921e..d324b84ca 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -46,19 +46,6 @@ */ 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; @@ -135,7 +122,7 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "§bDiamonds - " + diamondsTimer + " §8| " + "§aEmeralds - " + emeraldsTimer; + return ""; } public String getFormattedTime() { @@ -390,52 +377,8 @@ public void onScoreboardRender(ScoreboardRenderEvent event) { } } - private int getDiamondTier(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) && (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(getDiamondTier(diamondTier), secondsTillUpgrade); - } - if (emeraldsTimer <= 0) { - int secondsTillUpgrade = ((minutes / 12 + 1)) * 12 * 60 - seconds; - emeraldsTimer = Math.min(getEmeraldTier(emeraldTier), secondsTillUpgrade); - } } public void tick() { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java index 522473f9a..e1b32934f 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index 82ac1580c..0ae92b634 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java index bcb118b5c..9c154f310 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java index fe2d88b4f..460f7b4b2 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.util.events.impl; import lombok.Data; From 0ec51df380f41d41e4020f95a0ff7e0a7a112709 Mon Sep 17 00:00:00 2001 From: moehreag Date: Sat, 8 Jul 2023 19:50:19 +0200 Subject: [PATCH 10/41] oversaw this --- .../axolotlclient/modules/hud/gui/hud/simple/CPSHud.java | 6 +++--- gradle.properties | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 161afe589..d69c39c74 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -49,11 +49,11 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Events.MOUSE_INPUT.register(button -> { + Events.MOUSE_INPUT.register(event -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } diff --git a/gradle.properties b/gradle.properties index cece4e89c..a55efb436 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ fabric.loom.multiProjectOptimisation=true axolotlclient.modules.all=true # Mod Properties -version=3.0.4-darkkronicle-bedwars-overlay-beta.2 +version=3.0.4-darkkronicle-bedwars-overlay-beta.3 maven_group=io.github.axolotlclient archives_base_name=AxolotlClient minecraft_1192=1.19.2 From e7ef3d26e78d53e630604576a43c434bc109a62a Mon Sep 17 00:00:00 2001 From: moehreag Date: Sat, 8 Jul 2023 20:59:29 +0200 Subject: [PATCH 11/41] fix more bugs --- .../io/github/axolotlclient/modules/hud/HudManager.java | 8 +++++--- .../axolotlclient/modules/hypixel/HypixelMods.java | 8 +++++--- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../github/axolotlclient/mixin/PlayerListHudMixin.java | 2 +- .../io/github/axolotlclient/modules/hud/HudManager.java | 8 +++++--- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../io/github/axolotlclient/modules/hud/HudManager.java | 8 +++++--- .../axolotlclient/modules/hypixel/HypixelMods.java | 8 +++++--- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../github/axolotlclient/mixin/PlayerListHudMixin.java | 6 +++--- .../io/github/axolotlclient/modules/hud/HudManager.java | 9 ++++++--- .../axolotlclient/modules/hypixel/HypixelMods.java | 8 +++++--- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../io/github/axolotlclient/modules/hud/HudManager.java | 8 +++++--- .../axolotlclient/modules/hypixel/HypixelMods.java | 8 +++++--- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../io/github/axolotlclient/modules/hud/HudManager.java | 2 ++ .../axolotlclient/modules/hypixel/HypixelMods.java | 2 ++ .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../io/github/axolotlclient/modules/hud/HudManager.java | 8 ++++---- .../axolotlclient/modules/hud/gui/AbstractHudEntry.java | 8 +++----- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../main/resources/assets/axolotlclient/lang/en_us.json | 2 +- 23 files changed, 69 insertions(+), 41 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 42bb33d65..f1eafbc4e 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hud; -import java.util.*; -import java.util.stream.Collectors; - import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -38,12 +35,16 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; import org.lwjgl.glfw.GLFW; +import java.util.*; +import java.util.stream.Collectors; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -100,6 +101,7 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 660692581..2fb578396 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hypixel; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -33,10 +30,14 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; +import java.util.ArrayList; +import java.util.List; + public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index cd9b01cad..fbbcd6f46 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -102,6 +102,7 @@ public String getDetail() { public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 6786c9efe..6fabee67d 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -180,7 +180,7 @@ public abstract class PlayerListHudMixin { public void axolotlclient$renderWithoutObjective( MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, 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 + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 ) { if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { return; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 5a80ea675..1beffdd52 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hud; -import java.util.*; -import java.util.stream.Collectors; - import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -38,12 +35,16 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.options.KeyBinding; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; import org.lwjgl.glfw.GLFW; +import java.util.*; +import java.util.stream.Collectors; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -100,6 +101,7 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index b2fb4561d..eaf9a608e 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -102,6 +102,7 @@ public String getDetail() { public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 37b523884..d8f4e46e4 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hud; -import java.util.*; -import java.util.stream.Collectors; - import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; @@ -39,11 +36,15 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBind; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; +import java.util.*; +import java.util.stream.Collectors; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -100,6 +101,7 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 660692581..2fb578396 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hypixel; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -33,10 +30,14 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; +import java.util.ArrayList; +import java.util.List; + public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 437fc348f..643571217 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -101,6 +101,7 @@ public String getDetail() { public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 81282f52a..b7cade9e5 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -56,6 +56,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.util.List; +import java.util.UUID; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -210,8 +211,7 @@ public abstract class PlayerListHudMixin { cancellable = true ) private void axolotlclient$renderCustomScoreboardObjective( - ScoreboardObjective objective, int y, String player, int startX, int endX, - PlayerListEntry playerEntry, MatrixStack matrices, CallbackInfo ci + ScoreboardObjective objective, int y, String player, int startX, int endX, UUID uuid, MatrixStack matrices, CallbackInfo ci ) { if (!BedwarsMod.getInstance().isEnabled()) { return; @@ -221,7 +221,7 @@ public abstract class PlayerListHudMixin { if (game == null) { return; } - BedwarsPlayer bedwarsPlayer = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + BedwarsPlayer bedwarsPlayer = game.getPlayer(player).orElse(null); if (bedwarsPlayer == null) { return; } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 8c6e755f1..9b520da5a 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hud; -import java.util.*; -import java.util.stream.Collectors; - import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; @@ -39,10 +36,14 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; +import java.util.*; +import java.util.stream.Collectors; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -98,6 +99,8 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); + entries.values().forEach(HudEntry::init); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 660692581..2fb578396 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hypixel; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -33,10 +30,14 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; +import java.util.ArrayList; +import java.util.List; + public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 437fc348f..643571217 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -101,6 +101,7 @@ public String getDetail() { public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index c051d28b4..42f3ffeac 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hud; -import java.util.*; -import java.util.stream.Collectors; - import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; @@ -39,10 +36,14 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; +import java.util.*; +import java.util.stream.Collectors; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -98,6 +99,7 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 660692581..2fb578396 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hypixel; -import java.util.ArrayList; -import java.util.List; - import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -33,10 +30,14 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; +import java.util.ArrayList; +import java.util.List; + public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 437fc348f..643571217 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -101,6 +101,7 @@ public String getDetail() { public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 16ccbcea9..779a35599 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -36,6 +36,7 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.util.Identifier; @@ -99,6 +100,7 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 18623adbb..2fb578396 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -30,6 +30,7 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 437fc348f..643571217 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -101,6 +101,7 @@ public String getDetail() { public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index df3a66940..e51f48dac 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hud; -import java.util.*; -import java.util.stream.Collectors; - import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.AbstractModule; @@ -44,6 +41,9 @@ import net.minecraft.util.Identifier; import org.lwjgl.input.Keyboard; +import java.util.*; +import java.util.stream.Collectors; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -99,7 +99,7 @@ public void init() { add(new ComboHud()); add(new PlayerHud()); add(new ChatHud()); - add(BedwarsMod.getInstance().getUpgradesOverlay()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); refreshAllBounds(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java index ff726bd64..7dbb6ce31 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java @@ -22,9 +22,6 @@ package io.github.axolotlclient.modules.hud.gui; -import java.util.ArrayList; -import java.util.List; - import com.mojang.blaze3d.platform.GlStateManager; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -42,6 +39,9 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.util.math.MathHelper; +import java.util.ArrayList; +import java.util.List; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -257,6 +257,4 @@ public void setEnabled(boolean value) { enabled.set(value); } - public void init() { - } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index acf1ae8ed..3b77a37a6 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -102,6 +102,7 @@ public String getDetail() { public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/common/src/main/resources/assets/axolotlclient/lang/en_us.json b/common/src/main/resources/assets/axolotlclient/lang/en_us.json index 8306b7d71..49335528a 100644 --- a/common/src/main/resources/assets/axolotlclient/lang/en_us.json +++ b/common/src/main/resources/assets/axolotlclient/lang/en_us.json @@ -384,5 +384,5 @@ "bedwars.tabRenderLatencyIcon": "Render Tablist Latency Icon", "bedwars.showChatTime": "Show Chat Time", "bedwars.overrideMessages": "Override Messages", - "bedwars_teamupgrades": "Bedwars Team Upgrades HUD" + "bedwars_teamupgrades": "Team Upgrades HUD" } From b910240a3fe2bc5a3422f5918cd3954d6482923d Mon Sep 17 00:00:00 2001 From: moehreag Date: Sun, 9 Jul 2023 15:47:18 +0200 Subject: [PATCH 12/41] add more customisation options - move common stuff to the common module --- .../hypixel/bedwars/BedwarsDeathType.java | 66 ---- .../modules/hypixel/bedwars/BedwarsGame.java | 3 +- .../hypixel/bedwars/BedwarsMessages.java | 312 ----------------- .../modules/hypixel/bedwars/BedwarsMod.java | 9 +- .../modules/hypixel/bedwars/BedwarsMode.java | 45 --- .../hypixel/bedwars/BedwarsPlayerStats.java | 170 ---------- .../modules/hypixel/bedwars/BedwarsTeam.java | 79 ----- .../hypixel/bedwars/BedwarsDeathType.java | 66 ---- .../modules/hypixel/bedwars/BedwarsGame.java | 3 +- .../hypixel/bedwars/BedwarsMessages.java | 312 ----------------- .../modules/hypixel/bedwars/BedwarsMod.java | 9 +- .../modules/hypixel/bedwars/BedwarsMode.java | 45 --- .../hypixel/bedwars/BedwarsPlayerStats.java | 170 ---------- .../modules/hypixel/bedwars/BedwarsTeam.java | 79 ----- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 ----- .../bedwars/upgrades/BinaryUpgrade.java | 70 ---- .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 ---- .../bedwars/upgrades/TieredUpgrade.java | 77 ----- .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 -------- .../hypixel/bedwars/BedwarsDeathType.java | 66 ---- .../modules/hypixel/bedwars/BedwarsGame.java | 3 +- .../hypixel/bedwars/BedwarsMessages.java | 312 ----------------- .../modules/hypixel/bedwars/BedwarsMod.java | 9 +- .../modules/hypixel/bedwars/BedwarsMode.java | 45 --- .../hypixel/bedwars/BedwarsPlayerStats.java | 170 ---------- .../modules/hypixel/bedwars/BedwarsTeam.java | 79 ----- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 ----- .../bedwars/upgrades/BinaryUpgrade.java | 70 ---- .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 ---- .../bedwars/upgrades/TieredUpgrade.java | 77 ----- .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 -------- .../hypixel/bedwars/BedwarsDeathType.java | 66 ---- .../modules/hypixel/bedwars/BedwarsGame.java | 3 +- .../hypixel/bedwars/BedwarsMessages.java | 312 ----------------- .../modules/hypixel/bedwars/BedwarsMod.java | 9 +- .../modules/hypixel/bedwars/BedwarsMode.java | 45 --- .../hypixel/bedwars/BedwarsPlayerStats.java | 170 ---------- .../modules/hypixel/bedwars/BedwarsTeam.java | 79 ----- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 ----- .../bedwars/upgrades/BinaryUpgrade.java | 70 ---- .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 ---- .../bedwars/upgrades/TieredUpgrade.java | 77 ----- .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 -------- .../modules/hypixel/bedwars/BedwarsGame.java | 3 +- .../modules/hypixel/bedwars/BedwarsMod.java | 9 +- .../modules/hypixel/bedwars/BedwarsMode.java | 45 --- .../hypixel/bedwars/BedwarsPlayerStats.java | 170 ---------- .../modules/hypixel/bedwars/BedwarsTeam.java | 79 ----- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 ----- .../bedwars/upgrades/BinaryUpgrade.java | 70 ---- .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 ---- .../bedwars/upgrades/TieredUpgrade.java | 77 ----- .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 -------- .../hypixel/bedwars/BedwarsDeathType.java | 66 ---- .../modules/hypixel/bedwars/BedwarsGame.java | 21 +- .../hypixel/bedwars/BedwarsMessages.java | 312 ----------------- .../modules/hypixel/bedwars/BedwarsMod.java | 9 +- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 80 ----- .../bedwars/upgrades/BinaryUpgrade.java | 70 ---- .../hypixel/bedwars/upgrades/TeamUpgrade.java | 69 ---- .../bedwars/upgrades/TieredUpgrade.java | 77 ----- .../hypixel/bedwars/upgrades/TrapUpgrade.java | 129 -------- .../hypixel/bedwars/BedwarsDeathType.java | 67 ---- .../modules/hypixel/bedwars/BedwarsGame.java | 21 +- .../hypixel/bedwars/BedwarsMessages.java | 313 ------------------ .../modules/hypixel/bedwars/BedwarsMod.java | 16 +- .../modules/hypixel/bedwars/BedwarsMode.java | 47 --- .../hypixel/bedwars/BedwarsPlayerStats.java | 171 ---------- .../modules/hypixel/bedwars/BedwarsTeam.java | 80 ----- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 81 ----- .../bedwars/upgrades/BinaryUpgrade.java | 70 ---- .../hypixel/bedwars/upgrades/TeamUpgrade.java | 70 ---- .../bedwars/upgrades/TieredUpgrade.java | 78 ----- .../hypixel/bedwars/upgrades/TrapUpgrade.java | 130 -------- CHANGELOG.md | 5 + common/build.gradle | 1 + .../hypixel/bedwars/BedwarsDeathType.java | 0 .../hypixel/bedwars/BedwarsLevelHeadMode.java | 43 +++ .../hypixel/bedwars/BedwarsMessages.java | 0 .../modules/hypixel/bedwars/BedwarsMode.java | 0 .../hypixel/bedwars/BedwarsPlayerStats.java | 0 .../modules/hypixel/bedwars/BedwarsTeam.java | 0 .../bedwars/upgrades/BedwarsTeamUpgrades.java | 0 .../bedwars/upgrades/BinaryUpgrade.java | 0 .../hypixel/bedwars/upgrades/TeamUpgrade.java | 0 .../bedwars/upgrades/TieredUpgrade.java | 0 .../hypixel/bedwars/upgrades/TrapUpgrade.java | 0 .../assets/axolotlclient/lang/en_us.json | 17 +- gradle.properties | 2 +- 89 files changed, 150 insertions(+), 6637 deletions(-) delete mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java delete mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java delete mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java delete mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java delete mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java delete mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java delete mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java delete mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java delete mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java delete mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java delete mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java delete mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java delete mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java delete mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java delete mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java delete mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java delete mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java delete mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java delete mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java delete mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java rename {1.19.4 => common}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java (100%) create mode 100644 common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java rename {1.19.4 => common}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java (100%) rename {1.20 => common}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java (100%) rename {1.20 => common}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java (100%) rename {1.20 => common}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java (100%) rename {1.16.5 => common}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java (100%) rename {1.16.5 => common}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java (100%) rename {1.16.5 => common}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java (100%) rename {1.16.5 => common}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java (100%) rename {1.16.5 => common}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java (100%) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java deleted file mode 100644 index ef3f5bb2f..000000000 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -@AllArgsConstructor -public enum BedwarsDeathType { - 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/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 98d1e03b7..76b0cb2e2 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -417,7 +417,8 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { if (stats == null) { return null; } - return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java deleted file mode 100644 index afdaaa861..000000000 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import java.util.Arrays; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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} 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}.", - "{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}")), - Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), - 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"), - Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), - }; - - 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/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index fbbcd6f46..4601c287a 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -23,6 +23,7 @@ package io.github.axolotlclient.modules.hypixel.bedwars; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.events.Events; @@ -72,6 +73,10 @@ public class BedwarsMod implements AbstractHypixelMod { public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + protected BedwarsGame currentGame = null; @@ -100,8 +105,8 @@ public String getDetail() { @Override public void init() { - category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, - tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java deleted file mode 100644 index 511145cc4..000000000 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.Getter; - -/** - * @author DarkKronicle - */ - -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/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java deleted file mode 100644 index 337a46afd..000000000 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.jetbrains.annotations.Nullable; - -/** - * @author DarkKronicle - */ - -@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 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, - 0, - 0, - 0, - 0, - 0, - 1 - ); - } - - @Nullable - public static BedwarsPlayerStats fromAPI(String uuid) { - JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); - JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); - 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) { - if (obj.has(key)) { - try { - return obj.get(key).getAsInt(); - } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { - // Not actually an int - } - } - return other; - } - - public 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++; - gameDeaths++; - } - - public void addFinalDeath() { - finalDeaths++; - gameFinalDeaths++; - } - - public void addKill() { - kills++; - gameKills++; - } - - public void addFinalKill() { - finalKills++; - gameFinalKills++; - } - - public void addBed() { - bedsBroken++; - gameBedsBroken++; - } - - public float getFKDR() { - return (float) finalKills / finalDeaths; - } - - public float getBBLR() { - return (float) bedsBroken / losses; - } - -} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java deleted file mode 100644 index f71318188..000000000 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Locale; -import java.util.Optional; - -/** - * @author DarkKronicle - */ - -@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'), - ; - - @Getter - private final char code; - - @Getter - private final char prefix; - - public String getColorSection() { - return "§" + code; - } - - public static Optional fromPrefix(char prefix) { - for (BedwarsTeam t : values()) { - if (t.getPrefix() == prefix) { - return Optional.of(t); - } - } - 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(); - } - - public String getName() { - return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); - } - -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java deleted file mode 100644 index ef3f5bb2f..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -@AllArgsConstructor -public enum BedwarsDeathType { - 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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 539037c96..c8affb592 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -417,7 +417,8 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { if (stats == null) { return null; } - return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java deleted file mode 100644 index afdaaa861..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import java.util.Arrays; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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} 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}.", - "{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}")), - Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), - 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"), - Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), - }; - - 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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index eaf9a608e..f4a8b5275 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -23,6 +23,7 @@ package io.github.axolotlclient.modules.hypixel.bedwars; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.events.Events; @@ -72,6 +73,10 @@ public class BedwarsMod implements AbstractHypixelMod { public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + protected BedwarsGame currentGame = null; @@ -100,8 +105,8 @@ public String getDetail() { @Override public void init() { - category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, - tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java deleted file mode 100644 index 511145cc4..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.Getter; - -/** - * @author DarkKronicle - */ - -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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java deleted file mode 100644 index 337a46afd..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.jetbrains.annotations.Nullable; - -/** - * @author DarkKronicle - */ - -@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 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, - 0, - 0, - 0, - 0, - 0, - 1 - ); - } - - @Nullable - public static BedwarsPlayerStats fromAPI(String uuid) { - JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); - JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); - 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) { - if (obj.has(key)) { - try { - return obj.get(key).getAsInt(); - } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { - // Not actually an int - } - } - return other; - } - - public 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++; - gameDeaths++; - } - - public void addFinalDeath() { - finalDeaths++; - gameFinalDeaths++; - } - - public void addKill() { - kills++; - gameKills++; - } - - public void addFinalKill() { - finalKills++; - gameFinalKills++; - } - - public void addBed() { - bedsBroken++; - gameBedsBroken++; - } - - public float getFKDR() { - return (float) finalKills / finalDeaths; - } - - public float getBBLR() { - return (float) bedsBroken / losses; - } - -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java deleted file mode 100644 index f71318188..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Locale; -import java.util.Optional; - -/** - * @author DarkKronicle - */ - -@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'), - ; - - @Getter - private final char code; - - @Getter - private final char prefix; - - public String getColorSection() { - return "§" + code; - } - - public static Optional fromPrefix(char prefix) { - for (BedwarsTeam t : values()) { - if (t.getPrefix() == prefix) { - return Optional.of(t); - } - } - 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(); - } - - public String getName() { - return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); - } - -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java deleted file mode 100644 index 156a7f31d..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - - -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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"), - 8, 4 - ); - - public final TeamUpgrade dragonBuff = new BinaryUpgrade( - "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), - 5, 5 - ); - - public final TeamUpgrade healPool = new BinaryUpgrade( - "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), - 3, 1 - ); - - public final TeamUpgrade protection = new TieredUpgrade( - "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,3}\\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} - ); - - public 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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java deleted file mode 100644 index bfd8eabda..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -public class BinaryUpgrade extends TeamUpgrade { - - 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 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) { - return doublesPrice; - } - return foursPrice; - } - -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java deleted file mode 100644 index 78126e8cd..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - - -public abstract class TeamUpgrade { - @Getter - protected final String name; - protected 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 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); - - - public abstract boolean isPurchased(); -} - diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java deleted file mode 100644 index a1bda0577..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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 - 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; - } - - 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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java deleted file mode 100644 index 4c56947f1..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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; - } - - @Override - public boolean isPurchased() { - return traps.size() > 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("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")) { - return MINER_FATIGUE; - } - if (s.contains("alarm")) { - return ALARM; - } - if (s.contains("counter")) { - return COUNTER_OFFENSIVE; - } - return ITS_A_TRAP; - } - } -} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java deleted file mode 100644 index ef3f5bb2f..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -@AllArgsConstructor -public enum BedwarsDeathType { - 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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 10ee68962..317bbc2fe 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -417,7 +417,8 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { if (stats == null) { return null; } - return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java deleted file mode 100644 index afdaaa861..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import java.util.Arrays; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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} 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}.", - "{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}")), - Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), - 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"), - Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), - }; - - 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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 643571217..272c0c276 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -23,6 +23,7 @@ package io.github.axolotlclient.modules.hypixel.bedwars; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.events.Events; @@ -71,6 +72,10 @@ public class BedwarsMod implements AbstractHypixelMod { public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + protected BedwarsGame currentGame = null; @@ -99,8 +104,8 @@ public String getDetail() { @Override public void init() { - category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, - tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java deleted file mode 100644 index 511145cc4..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.Getter; - -/** - * @author DarkKronicle - */ - -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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java deleted file mode 100644 index 337a46afd..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.jetbrains.annotations.Nullable; - -/** - * @author DarkKronicle - */ - -@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 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, - 0, - 0, - 0, - 0, - 0, - 1 - ); - } - - @Nullable - public static BedwarsPlayerStats fromAPI(String uuid) { - JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); - JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); - 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) { - if (obj.has(key)) { - try { - return obj.get(key).getAsInt(); - } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { - // Not actually an int - } - } - return other; - } - - public 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++; - gameDeaths++; - } - - public void addFinalDeath() { - finalDeaths++; - gameFinalDeaths++; - } - - public void addKill() { - kills++; - gameKills++; - } - - public void addFinalKill() { - finalKills++; - gameFinalKills++; - } - - public void addBed() { - bedsBroken++; - gameBedsBroken++; - } - - public float getFKDR() { - return (float) finalKills / finalDeaths; - } - - public float getBBLR() { - return (float) bedsBroken / losses; - } - -} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java deleted file mode 100644 index f71318188..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Locale; -import java.util.Optional; - -/** - * @author DarkKronicle - */ - -@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'), - ; - - @Getter - private final char code; - - @Getter - private final char prefix; - - public String getColorSection() { - return "§" + code; - } - - public static Optional fromPrefix(char prefix) { - for (BedwarsTeam t : values()) { - if (t.getPrefix() == prefix) { - return Optional.of(t); - } - } - 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(); - } - - public String getName() { - return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); - } - -} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java deleted file mode 100644 index 156a7f31d..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - - -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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"), - 8, 4 - ); - - public final TeamUpgrade dragonBuff = new BinaryUpgrade( - "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), - 5, 5 - ); - - public final TeamUpgrade healPool = new BinaryUpgrade( - "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), - 3, 1 - ); - - public final TeamUpgrade protection = new TieredUpgrade( - "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,3}\\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} - ); - - public 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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java deleted file mode 100644 index bfd8eabda..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -public class BinaryUpgrade extends TeamUpgrade { - - 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 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) { - return doublesPrice; - } - return foursPrice; - } - -} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java deleted file mode 100644 index 78126e8cd..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - - -public abstract class TeamUpgrade { - @Getter - protected final String name; - protected 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 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); - - - public abstract boolean isPurchased(); -} - diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java deleted file mode 100644 index a1bda0577..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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 - 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; - } - - 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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java deleted file mode 100644 index 4c56947f1..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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; - } - - @Override - public boolean isPurchased() { - return traps.size() > 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("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")) { - return MINER_FATIGUE; - } - if (s.contains("alarm")) { - return ALARM; - } - if (s.contains("counter")) { - return COUNTER_OFFENSIVE; - } - return ITS_A_TRAP; - } - } -} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java deleted file mode 100644 index ef3f5bb2f..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -@AllArgsConstructor -public enum BedwarsDeathType { - 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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 10ee68962..317bbc2fe 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -417,7 +417,8 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { if (stats == null) { return null; } - return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java deleted file mode 100644 index afdaaa861..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import java.util.Arrays; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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} 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}.", - "{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}")), - Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), - 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"), - Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), - }; - - 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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 643571217..272c0c276 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -23,6 +23,7 @@ package io.github.axolotlclient.modules.hypixel.bedwars; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.events.Events; @@ -71,6 +72,10 @@ public class BedwarsMod implements AbstractHypixelMod { public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + protected BedwarsGame currentGame = null; @@ -99,8 +104,8 @@ public String getDetail() { @Override public void init() { - category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, - tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java deleted file mode 100644 index 511145cc4..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.Getter; - -/** - * @author DarkKronicle - */ - -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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java deleted file mode 100644 index 337a46afd..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.jetbrains.annotations.Nullable; - -/** - * @author DarkKronicle - */ - -@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 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, - 0, - 0, - 0, - 0, - 0, - 1 - ); - } - - @Nullable - public static BedwarsPlayerStats fromAPI(String uuid) { - JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); - JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); - 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) { - if (obj.has(key)) { - try { - return obj.get(key).getAsInt(); - } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { - // Not actually an int - } - } - return other; - } - - public 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++; - gameDeaths++; - } - - public void addFinalDeath() { - finalDeaths++; - gameFinalDeaths++; - } - - public void addKill() { - kills++; - gameKills++; - } - - public void addFinalKill() { - finalKills++; - gameFinalKills++; - } - - public void addBed() { - bedsBroken++; - gameBedsBroken++; - } - - public float getFKDR() { - return (float) finalKills / finalDeaths; - } - - public float getBBLR() { - return (float) bedsBroken / losses; - } - -} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java deleted file mode 100644 index f71318188..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Locale; -import java.util.Optional; - -/** - * @author DarkKronicle - */ - -@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'), - ; - - @Getter - private final char code; - - @Getter - private final char prefix; - - public String getColorSection() { - return "§" + code; - } - - public static Optional fromPrefix(char prefix) { - for (BedwarsTeam t : values()) { - if (t.getPrefix() == prefix) { - return Optional.of(t); - } - } - 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(); - } - - public String getName() { - return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); - } - -} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java deleted file mode 100644 index 156a7f31d..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - - -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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"), - 8, 4 - ); - - public final TeamUpgrade dragonBuff = new BinaryUpgrade( - "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), - 5, 5 - ); - - public final TeamUpgrade healPool = new BinaryUpgrade( - "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), - 3, 1 - ); - - public final TeamUpgrade protection = new TieredUpgrade( - "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,3}\\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} - ); - - public 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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java deleted file mode 100644 index bfd8eabda..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -public class BinaryUpgrade extends TeamUpgrade { - - 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 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) { - return doublesPrice; - } - return foursPrice; - } - -} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java deleted file mode 100644 index 78126e8cd..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - - -public abstract class TeamUpgrade { - @Getter - protected final String name; - protected 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 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); - - - public abstract boolean isPurchased(); -} - diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java deleted file mode 100644 index a1bda0577..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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 - 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; - } - - 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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java deleted file mode 100644 index 4c56947f1..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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; - } - - @Override - public boolean isPurchased() { - return traps.size() > 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("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")) { - return MINER_FATIGUE; - } - if (s.contains("alarm")) { - return ALARM; - } - if (s.contains("counter")) { - return COUNTER_OFFENSIVE; - } - return ITS_A_TRAP; - } - } -} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 5209a582d..1d78941b6 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -416,7 +416,8 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { if (stats == null) { return null; } - return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 643571217..272c0c276 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -23,6 +23,7 @@ package io.github.axolotlclient.modules.hypixel.bedwars; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.events.Events; @@ -71,6 +72,10 @@ public class BedwarsMod implements AbstractHypixelMod { public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + protected BedwarsGame currentGame = null; @@ -99,8 +104,8 @@ public String getDetail() { @Override public void init() { - category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, - tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java deleted file mode 100644 index 511145cc4..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.Getter; - -/** - * @author DarkKronicle - */ - -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/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java deleted file mode 100644 index 337a46afd..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.jetbrains.annotations.Nullable; - -/** - * @author DarkKronicle - */ - -@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 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, - 0, - 0, - 0, - 0, - 0, - 1 - ); - } - - @Nullable - public static BedwarsPlayerStats fromAPI(String uuid) { - JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); - JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); - 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) { - if (obj.has(key)) { - try { - return obj.get(key).getAsInt(); - } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { - // Not actually an int - } - } - return other; - } - - public 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++; - gameDeaths++; - } - - public void addFinalDeath() { - finalDeaths++; - gameFinalDeaths++; - } - - public void addKill() { - kills++; - gameKills++; - } - - public void addFinalKill() { - finalKills++; - gameFinalKills++; - } - - public void addBed() { - bedsBroken++; - gameBedsBroken++; - } - - public float getFKDR() { - return (float) finalKills / finalDeaths; - } - - public float getBBLR() { - return (float) bedsBroken / losses; - } - -} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java deleted file mode 100644 index f71318188..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Locale; -import java.util.Optional; - -/** - * @author DarkKronicle - */ - -@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'), - ; - - @Getter - private final char code; - - @Getter - private final char prefix; - - public String getColorSection() { - return "§" + code; - } - - public static Optional fromPrefix(char prefix) { - for (BedwarsTeam t : values()) { - if (t.getPrefix() == prefix) { - return Optional.of(t); - } - } - 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(); - } - - public String getName() { - return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); - } - -} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java deleted file mode 100644 index c0d4b90d0..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - - -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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"), - 8, 4 - ); - - public final TeamUpgrade dragonBuff = new BinaryUpgrade( - "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), - 5, 5 - ); - - public final TeamUpgrade healPool = new BinaryUpgrade( - "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), - 3, 1 - ); - - public final TeamUpgrade protection = new TieredUpgrade( - "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,3}\\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} - ); - - public 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/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java deleted file mode 100644 index 28e0fa76b..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -public class BinaryUpgrade extends TeamUpgrade { - - 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 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) { - return doublesPrice; - } - return foursPrice; - } - -} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java deleted file mode 100644 index b2aec9401..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - - -public abstract class TeamUpgrade { - @Getter - protected final String name; - protected 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 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); - - - public abstract boolean isPurchased(); -} - diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java deleted file mode 100644 index f7ba59f93..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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 - 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; - } - - 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/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java deleted file mode 100644 index c2f4a9359..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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; - } - - @Override - public boolean isPurchased() { - return traps.size() > 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("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")) { - return MINER_FATIGUE; - } - if (s.contains("alarm")) { - return ALARM; - } - if (s.contains("counter")) { - return COUNTER_OFFENSIVE; - } - return ITS_A_TRAP; - } - } -} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java deleted file mode 100644 index 76945484a..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -@AllArgsConstructor -public enum BedwarsDeathType { - 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/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index e4d0686d8..0a4fdc368 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -408,15 +408,16 @@ public BedwarsPlayer getSelf() { } 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; - } - return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); - } + BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); + if (player == null) { + return null; + } + BedwarsPlayerStats stats = player.getStats(); + if (stats == null) { + return null; + } + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java deleted file mode 100644 index 6698b8dd0..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import java.util.Arrays; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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} 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}.", - "{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}")), - Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), - 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"), - Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), - }; - - 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/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 643571217..272c0c276 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -23,6 +23,7 @@ package io.github.axolotlclient.modules.hypixel.bedwars; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.events.Events; @@ -71,6 +72,10 @@ public class BedwarsMod implements AbstractHypixelMod { public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + protected BedwarsGame currentGame = null; @@ -99,8 +104,8 @@ public String getDetail() { @Override public void init() { - category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, - tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); instance = this; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java deleted file mode 100644 index c0d4b90d0..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - - -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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"), - 8, 4 - ); - - public final TeamUpgrade dragonBuff = new BinaryUpgrade( - "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), - 5, 5 - ); - - public final TeamUpgrade healPool = new BinaryUpgrade( - "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), - 3, 1 - ); - - public final TeamUpgrade protection = new TieredUpgrade( - "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,3}\\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} - ); - - public 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/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java deleted file mode 100644 index 28e0fa76b..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -public class BinaryUpgrade extends TeamUpgrade { - - 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 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) { - return doublesPrice; - } - return foursPrice; - } - -} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java deleted file mode 100644 index b2aec9401..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - - -public abstract class TeamUpgrade { - @Getter - protected final String name; - protected 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 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); - - - public abstract boolean isPurchased(); -} - diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java deleted file mode 100644 index f7ba59f93..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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 - 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; - } - - 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/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java deleted file mode 100644 index c2f4a9359..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author DarkKronicle - */ - -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; - } - - @Override - public boolean isPurchased() { - return traps.size() > 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("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")) { - return MINER_FATIGUE; - } - if (s.contains("alarm")) { - return ALARM; - } - if (s.contains("counter")) { - return COUNTER_OFFENSIVE; - } - return ITS_A_TRAP; - } - } -} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java deleted file mode 100644 index b777db1dd..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author DarkKronicle - */ - -@AllArgsConstructor -public enum BedwarsDeathType { - 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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index d324b84ca..96a793859 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -411,15 +411,16 @@ public BedwarsPlayer getSelf() { } 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; - } - return "§7Kills: §f" + stats.getGameKills() + " §7Deaths: §f" + stats.getGameDeaths(); - } + BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); + if (player == null) { + return null; + } + BedwarsPlayerStats stats = player.getStats(); + if (stats == null) { + return null; + } + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java deleted file mode 100644 index 8cd1bf1e6..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import java.util.Arrays; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author DarkKronicle - */ - -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} 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}.", - "{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}")), - Pattern.compile(formatPlaceholder("Bed was destroyed 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 will respawn in \\d* second!$"), - 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"), - Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), - }; - - 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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 3b77a37a6..f44b425d6 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -23,6 +23,7 @@ package io.github.axolotlclient.modules.hypixel.bedwars; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.events.Events; @@ -72,11 +73,14 @@ public class BedwarsMod implements AbstractHypixelMod { public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); - protected BedwarsGame currentGame = null; + protected BedwarsGame currentGame = null; @Getter - protected final TeamUpgradesOverlay upgradesOverlay; + protected final TeamUpgradesOverlay upgradesOverlay; protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); @@ -100,16 +104,16 @@ public String getDetail() { @Override public void init() { - category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, removeAnnoyingMessages, - tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); - instance = this; + instance = this; Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); - } + } public boolean isEnabled(){ return enabled.get(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java deleted file mode 100644 index bc14cf87a..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.Getter; - -/** - * - * @author DarkKronicle - */ - -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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java deleted file mode 100644 index cd52b42fb..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.jetbrains.annotations.Nullable; - -/** - * - * @author DarkKronicle - */ - -@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 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, - 0, - 0, - 0, - 0, - 0, - 1 - ); - } - - @Nullable - public static BedwarsPlayerStats fromAPI(String uuid) { - JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); - JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); - 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) { - if (obj.has(key)) { - try { - return obj.get(key).getAsInt(); - } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { - // Not actually an int - } - } - return other; - } - - public 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++; - gameDeaths++; - } - - public void addFinalDeath() { - finalDeaths++; - gameFinalDeaths++; - } - - public void addKill() { - kills++; - gameKills++; - } - - public void addFinalKill() { - finalKills++; - gameFinalKills++; - } - - public void addBed() { - bedsBroken++; - gameBedsBroken++; - } - - public float getFKDR() { - return (float) finalKills / finalDeaths; - } - - public float getBBLR() { - return (float) bedsBroken / losses; - } - -} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java deleted file mode 100644 index 8ee555af7..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Locale; -import java.util.Optional; - -/** - * - * @author DarkKronicle - */ - -@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'), - ; - - @Getter - private final char code; - - @Getter - private final char prefix; - - public String getColorSection() { - return "§" + code; - } - - public static Optional fromPrefix(char prefix) { - for (BedwarsTeam t : values()) { - if (t.getPrefix() == prefix) { - return Optional.of(t); - } - } - 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(); - } - - public String getName() { - return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); - } - -} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java deleted file mode 100644 index 1bfe244fb..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - - -import java.util.regex.Pattern; - -/** - * - * @author DarkKronicle - */ - -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"), - 8, 4 - ); - - public final TeamUpgrade dragonBuff = new BinaryUpgrade( - "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), - 5, 5 - ); - - public final TeamUpgrade healPool = new BinaryUpgrade( - "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), - 3, 1 - ); - - public final TeamUpgrade protection = new TieredUpgrade( - "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,3}\\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} - ); - - public 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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java deleted file mode 100644 index 493a9d5a4..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author DarkKronicle - */ - -public class BinaryUpgrade extends TeamUpgrade { - - 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 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) { - return doublesPrice; - } - return foursPrice; - } - -} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java deleted file mode 100644 index 46321d239..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author DarkKronicle - */ - - -public abstract class TeamUpgrade { - @Getter - protected final String name; - protected 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 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); - - - public abstract boolean isPurchased(); -} - diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java deleted file mode 100644 index 38021adca..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author DarkKronicle - */ - -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 - 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; - } - - 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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java deleted file mode 100644 index 98d67818f..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; - -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author DarkKronicle - */ - -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; - } - - @Override - public boolean isPurchased() { - return traps.size() > 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("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")) { - return MINER_FATIGUE; - } - if (s.contains("alarm")) { - return ALARM; - } - if (s.contains("counter")) { - return COUNTER_OFFENSIVE; - } - return ITS_A_TRAP; - } - } -} diff --git a/CHANGELOG.md b/CHANGELOG.md index f5dadbeb2..68ce35542 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,3 +127,8 @@ - update to 1.20 - update Chinese translations (HowardZHY) - fix a reach hud bug on 1.8.9 + +### 3.0.4 + +- add DarkKronicle's Bedwars Overlay +- fix the controls screen crashing in 1.8.9 diff --git a/common/build.gradle b/common/build.gradle index 3a52dfba4..8bb8eaf9c 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -32,6 +32,7 @@ repositories { } dependencies { + implementation 'org.jetbrains:annotations:24.0.0' // take the oldest version just to build against compileOnly("io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}") diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java similarity index 100% rename from 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java rename to common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java new file mode 100644 index 000000000..7a3c97a0f --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java @@ -0,0 +1,43 @@ +package io.github.axolotlclient.modules.hypixel.bedwars; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.function.Function; + +public enum BedwarsLevelHeadMode { + FINAL_KILLS(stats -> "§7Final Kills (Total): §f" + stats.getFinalKills()), + FINAL_DEATHS(stats -> "§7Final Deaths (Total): §f" + stats.getFinalDeaths()), + BEDS_BROKEN(stats -> "§7Beds Broken (Total): §f" + stats.getBedsBroken()), + GAME_KILLS_GAME_DEATHS(stats -> "§7Kills (Game): §f" + stats.getGameKills() + " §7Deaths (Game): §f" + stats.getGameDeaths()), + KILLS(stats -> "§7Kills (Total): §f" + stats.getKills()), + DEATHS(stats -> "§7Deaths (Total): §f" + stats.getDeaths()), + GAME_FINAL_KILLS(stats -> "§7Final Kills (Game): §f" + stats.getGameFinalKills()), + GAME_BEDS_BROKEN(stats -> "§7Beds Broken (Game): §f" + stats.getGameBedsBroken()), + GAME_DEATHS(stats -> "§7Deaths (Game): §f" + stats.getGameDeaths()), + GAME_KILLS(stats -> "§7Kills (Game): §f" + stats.getGameKills()), + LOSSES(stats -> "§7Losses: §f" + stats.getLosses()), + WINS(stats -> "§7Wins: §f" + stats.getWins()), + WINSTREAK(stats -> "§7Winstreak: §f" + stats.getWinstreak()), + STARS(stats -> "§7Stars: §f" + stats.getStars()); + + private final Function titleSupplier; + + BedwarsLevelHeadMode(Function titleSupplier) { + this.titleSupplier = titleSupplier; + } + + public String apply(BedwarsPlayerStats stats) { + return titleSupplier.apply(stats); + } + + private static final HashMap modes; + + static { + modes = new HashMap<>(); + Arrays.stream(values()).forEach(m -> modes.put(m.toString(), m)); + } + + public static BedwarsLevelHeadMode get(String mode) { + return modes.getOrDefault(mode, null); + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java similarity index 100% rename from 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java rename to common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java similarity index 100% rename from 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java rename to common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java similarity index 100% rename from 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java rename to common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java similarity index 100% rename from 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java rename to common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java similarity index 100% rename from 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java rename to common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java similarity index 100% rename from 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java rename to common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java similarity index 100% rename from 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java rename to common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java similarity index 100% rename from 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java rename to common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java similarity index 100% rename from 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java rename to common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java diff --git a/common/src/main/resources/assets/axolotlclient/lang/en_us.json b/common/src/main/resources/assets/axolotlclient/lang/en_us.json index 49335528a..d53bce3fe 100644 --- a/common/src/main/resources/assets/axolotlclient/lang/en_us.json +++ b/common/src/main/resources/assets/axolotlclient/lang/en_us.json @@ -384,5 +384,20 @@ "bedwars.tabRenderLatencyIcon": "Render Tablist Latency Icon", "bedwars.showChatTime": "Show Chat Time", "bedwars.overrideMessages": "Override Messages", - "bedwars_teamupgrades": "Team Upgrades HUD" + "bedwars_teamupgrades": "Team Upgrades HUD", + "bedwars.bedwarsLevelHeadMode": "LevelHead Mode", + "FINAL_KILLS": "Final Kills (Total)", + "FINAL_DEATHS": "Final Deaths (Total)", + "BEDS_BROKEN": "Beds Broken (Totak)", + "GAME_KILLS_GAME_DEATHS": "Kills (Game)/Deaths (Game)", + "KILLS": "Kills (Total)", + "DEATHS": "Deaths (Total)", + "GAME_FINAL_KILLS": "Final Kills (Game)", + "GAME_BEDS_BROKEN": "Beds Broken (Game)", + "GAME_DEATHS": "Deaths (Game)", + "GAME_KILLS": "Kills (Game)", + "LOSSES": "Losses", + "WINS": "Wins", + "WINSTREAK": "Winstreak", + "STARS": "Stars" } diff --git a/gradle.properties b/gradle.properties index a55efb436..39b74ba5a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ fabric.loom.multiProjectOptimisation=true axolotlclient.modules.all=true # Mod Properties -version=3.0.4-darkkronicle-bedwars-overlay-beta.3 +version=3.0.4-darkkronicle-bedwars-overlay-beta.4 maven_group=io.github.axolotlclient archives_base_name=AxolotlClient minecraft_1192=1.19.2 From f46dacef24046b45207ab2e6a60b7b408ff097f0 Mon Sep 17 00:00:00 2001 From: moehreag Date: Sun, 9 Jul 2023 16:36:34 +0200 Subject: [PATCH 13/41] format a lot of things - put the top 3 killers in the bottom of the player list --- .../mixin/PlayerListHudMixin.java | 4 +- .../axolotlclient/modules/hud/HudManager.java | 7 +- .../modules/hud/gui/hud/KeystrokeHud.java | 8 +- .../modules/hud/gui/hud/PlayerHud.java | 4 +- .../modules/hud/gui/hud/simple/CPSHud.java | 6 +- .../modules/hypixel/HypixelMods.java | 6 +- .../modules/hypixel/autogg/AutoGG.java | 10 +- .../modules/hypixel/autotip/AutoTip.java | 4 +- .../modules/hypixel/bedwars/BedwarsGame.java | 13 +- .../modules/hypixel/bedwars/BedwarsMod.java | 12 +- .../axolotlclient/modules/rpc/DiscordRPC.java | 5 +- .../axolotlclient/util/events/Events.java | 6 +- .../util/events/impl/KeyPressEvent.java | 1 + .../mixin/PlayerListHudMixin.java | 4 +- .../axolotlclient/modules/hud/HudManager.java | 7 +- .../modules/hud/gui/hud/KeystrokeHud.java | 8 +- .../modules/hud/gui/hud/PlayerHud.java | 4 +- .../modules/hud/gui/hud/simple/CPSHud.java | 6 +- .../modules/hypixel/HypixelMods.java | 6 +- .../modules/hypixel/autogg/AutoGG.java | 10 +- .../modules/hypixel/autotip/AutoTip.java | 4 +- .../modules/hypixel/bedwars/BedwarsGame.java | 13 +- .../modules/hypixel/bedwars/BedwarsMod.java | 12 +- .../axolotlclient/modules/rpc/DiscordRPC.java | 5 +- .../axolotlclient/util/events/Events.java | 6 +- .../mixin/PlayerListHudMixin.java | 4 +- .../axolotlclient/modules/hud/HudManager.java | 7 +- .../modules/hud/gui/hud/KeystrokeHud.java | 8 +- .../modules/hud/gui/hud/PlayerHud.java | 4 +- .../modules/hud/gui/hud/simple/CPSHud.java | 6 +- .../hud/gui/hud/vanilla/CrosshairHud.java | 4 +- .../modules/hud/util/RenderUtil.java | 4 +- .../modules/hypixel/HypixelMods.java | 6 +- .../modules/hypixel/bedwars/BedwarsGame.java | 13 +- .../modules/hypixel/bedwars/BedwarsMod.java | 10 +- .../axolotlclient/modules/rpc/DiscordRPC.java | 5 +- .../axolotlclient/util/events/Events.java | 6 +- .../util/events/impl/KeyPressEvent.java | 1 + .../mixin/PlayerListHudMixin.java | 6 +- .../axolotlclient/modules/hud/HudManager.java | 7 +- .../modules/hud/gui/hud/KeystrokeHud.java | 8 +- .../modules/hud/gui/hud/PlayerHud.java | 4 +- .../modules/hud/gui/hud/simple/CPSHud.java | 6 +- .../hud/gui/hud/vanilla/CrosshairHud.java | 4 +- .../modules/hud/util/RenderUtil.java | 4 +- .../modules/hypixel/HypixelMods.java | 6 +- .../modules/hypixel/autogg/AutoGG.java | 8 +- .../modules/hypixel/autotip/AutoTip.java | 4 +- .../modules/hypixel/bedwars/BedwarsGame.java | 13 +- .../modules/hypixel/bedwars/BedwarsMod.java | 10 +- .../axolotlclient/modules/rpc/DiscordRPC.java | 3 +- .../axolotlclient/util/events/Events.java | 6 +- .../util/events/impl/KeyPressEvent.java | 1 + .../mixin/PlayerListHudMixin.java | 4 +- .../axolotlclient/modules/hud/HudManager.java | 7 +- .../modules/hud/gui/hud/KeystrokeHud.java | 8 +- .../modules/hud/gui/hud/PlayerHud.java | 4 +- .../modules/hud/gui/hud/simple/CPSHud.java | 6 +- .../hud/gui/hud/vanilla/CrosshairHud.java | 4 +- .../modules/hud/util/RenderUtil.java | 4 +- .../modules/hypixel/HypixelMods.java | 6 +- .../modules/hypixel/autogg/AutoGG.java | 8 +- .../modules/hypixel/autotip/AutoTip.java | 4 +- .../modules/hypixel/bedwars/BedwarsGame.java | 13 +- .../modules/hypixel/bedwars/BedwarsMod.java | 10 +- .../axolotlclient/modules/rpc/DiscordRPC.java | 3 +- .../axolotlclient/util/events/Events.java | 6 +- .../util/events/impl/KeyPressEvent.java | 1 + .../github/axolotlclient/AxolotlClient.java | 10 +- .../config/AxolotlClientConfig.java | 6 +- .../config/screen/CreditsScreen.java | 8 +- .../mixin/BossBarHudAccessor.java | 6 +- .../mixin/GameMenuScreenMixin.java | 6 +- .../mixin/ParticleManagerMixin.java | 8 +- .../mixin/PlayerListHudMixin.java | 6 +- .../mixin/ReloadableResourceManagerMixin.java | 10 +- .../mixin/ScreenshotRecorderMixin.java | 6 +- .../mixin/ShaderEffectAccessor.java | 4 +- .../mixin/SplashOverlayMixin.java | 4 +- .../axolotlclient/modules/ModuleLoader.java | 8 +- .../modules/auth/AccountsListWidget.java | 4 +- .../modules/auth/AddOfflineScreen.java | 4 +- .../axolotlclient/modules/auth/Auth.java | 10 +- .../axolotlclient/modules/blur/MenuBlur.java | 4 +- .../modules/blur/MotionBlur.java | 4 +- .../modules/hud/HudEditScreen.java | 8 +- .../axolotlclient/modules/hud/HudManager.java | 6 +- .../modules/hud/gui/AbstractHudEntry.java | 6 +- .../hud/gui/component/Configurable.java | 4 +- .../modules/hud/gui/entry/BoxHudEntry.java | 4 +- .../hud/gui/entry/SimpleTextHudEntry.java | 4 +- .../modules/hud/gui/entry/TextHudEntry.java | 4 +- .../modules/hud/gui/hud/CompassHud.java | 4 +- .../modules/hud/gui/hud/CoordsHud.java | 8 +- .../modules/hud/gui/hud/KeystrokeHud.java | 8 +- .../modules/hud/gui/hud/MemoryHud.java | 4 +- .../modules/hud/gui/hud/PackDisplayHud.java | 12 +- .../modules/hud/gui/hud/PlayerHud.java | 4 +- .../modules/hud/gui/hud/PotionsHud.java | 6 +- .../modules/hud/gui/hud/item/ArmorHud.java | 4 +- .../modules/hud/gui/hud/item/ArrowHud.java | 4 +- .../hud/gui/hud/item/ItemUpdateHud.java | 8 +- .../modules/hud/gui/hud/simple/CPSHud.java | 6 +- .../hud/gui/hud/simple/IRLTimeHud.java | 10 +- .../modules/hud/gui/hud/simple/PingHud.java | 4 +- .../modules/hud/gui/hud/simple/ReachHud.java | 8 +- .../modules/hud/gui/hud/simple/SpeedHud.java | 8 +- .../modules/hud/gui/hud/simple/TPSHud.java | 6 +- .../hud/gui/hud/simple/ToggleSprintHud.java | 16 +- .../hud/gui/hud/vanilla/ActionBarHud.java | 4 +- .../hud/gui/hud/vanilla/BossBarHud.java | 10 +- .../hud/gui/hud/vanilla/CrosshairHud.java | 4 +- .../hud/gui/hud/vanilla/HotbarHUD.java | 6 +- .../hud/gui/hud/vanilla/ScoreboardHud.java | 10 +- .../modules/hud/snapping/SnappingHelper.java | 8 +- .../modules/hud/util/ItemUtil.java | 8 +- .../modules/hud/util/RenderUtil.java | 4 +- .../modules/hypixel/HypixelMods.java | 6 +- .../modules/hypixel/autogg/AutoGG.java | 8 +- .../modules/hypixel/autotip/AutoTip.java | 4 +- .../modules/hypixel/bedwars/BedwarsGame.java | 739 ++++++++--------- .../modules/hypixel/bedwars/BedwarsMod.java | 10 +- .../hypixel/bedwars/BedwarsPlayer.java | 244 +++--- .../modules/particles/Particles.java | 6 +- .../axolotlclient/modules/rpc/DiscordRPC.java | 4 +- .../modules/screenshotUtils/ImageShare.java | 10 +- .../screenshotUtils/ImageViewerScreen.java | 26 +- .../screenshotUtils/ScreenshotUtils.java | 16 +- .../modules/sky/SkyResourceManager.java | 10 +- .../modules/sky/SkyboxInstance.java | 6 +- .../modules/sky/SkyboxManager.java | 6 +- .../modules/tnttime/TntTime.java | 4 +- .../axolotlclient/util/FeatureDisabler.java | 10 +- .../axolotlclient/util/NetworkHelper.java | 10 +- .../axolotlclient/util/ThreadExecuter.java | 4 +- .../io/github/axolotlclient/util/Util.java | 6 +- .../axolotlclient/util/events/Events.java | 6 +- .../util/events/impl/KeyPressEvent.java | 1 + .../axolotlclient/mixin/ChatHudMixin.java | 12 +- .../mixin/EntityRendererMixin.java | 2 +- .../axolotlclient/mixin/InGameHudMixin.java | 4 +- .../mixin/MinecraftClientMixin.java | 2 +- .../mixin/PlayerListHudMixin.java | 14 +- .../axolotlclient/modules/hud/HudManager.java | 6 +- .../modules/hud/gui/AbstractHudEntry.java | 6 +- .../modules/hud/gui/hud/KeystrokeHud.java | 8 +- .../modules/hud/gui/hud/PlayerHud.java | 4 +- .../modules/hud/gui/hud/iconHud.java | 5 +- .../modules/hud/gui/hud/simple/CPSHud.java | 6 +- .../modules/hud/gui/hud/simple/ReachHud.java | 8 +- .../modules/hypixel/autoboop/AutoBoop.java | 2 +- .../modules/hypixel/autogg/AutoGG.java | 2 +- .../modules/hypixel/autotip/AutoTip.java | 6 +- .../modules/hypixel/bedwars/BedwarsGame.java | 741 +++++++++--------- .../modules/hypixel/bedwars/BedwarsMod.java | 252 +++--- .../hypixel/bedwars/BedwarsPlayer.java | 235 +++--- .../hypixel/bedwars/TeamUpgradesOverlay.java | 33 +- .../axolotlclient/modules/rpc/DiscordRPC.java | 5 +- .../io/github/axolotlclient/util/Util.java | 10 +- .../axolotlclient/util/events/Events.java | 6 +- .../util/events/impl/KeyPressEvent.java | 1 + README.md | 74 +- common/build.gradle | 2 +- .../hypixel/HypixelAbstractionLayer.java | 8 +- .../hypixel/bedwars/BedwarsDeathType.java | 52 +- .../hypixel/bedwars/BedwarsLevelHeadMode.java | 26 +- .../hypixel/bedwars/BedwarsMessages.java | 516 ++++++------ .../modules/hypixel/bedwars/BedwarsMode.java | 20 +- .../hypixel/bedwars/BedwarsPlayerStats.java | 260 +++--- .../modules/hypixel/bedwars/BedwarsTeam.java | 76 +- .../bedwars/upgrades/BinaryUpgrade.java | 4 +- .../hypixel/bedwars/upgrades/TeamUpgrade.java | 6 +- .../bedwars/upgrades/TieredUpgrade.java | 6 +- .../hypixel/bedwars/upgrades/TrapUpgrade.java | 8 +- .../assets/axolotlclient/lang/en_us.json | 4 +- doc/README-de.md | 72 +- doc/README-tr.md | 24 +- formatting.xml | 508 ++++++------ gradle.properties | 2 - settings.gradle | 7 +- 180 files changed, 2524 insertions(+), 2402 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 768d7c5e1..8c5f4f8b2 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.mixin; +import java.util.List; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; @@ -58,8 +60,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.util.List; - @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index f1eafbc4e..b09c77a74 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud; +import java.util.*; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -42,9 +45,6 @@ import net.minecraft.util.Identifier; import org.lwjgl.glfw.GLFW; -import java.util.*; -import java.util.stream.Collectors; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -58,6 +58,7 @@ public class HudManager extends AbstractModule { private final OptionCategory hudCategory = new OptionCategory("hud", false); private final Map entries; private final MinecraftClient client; + private HudManager() { this.entries = new LinkedHashMap<>(); client = MinecraftClient.getInstance(); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 9c00079ed..ff2c1b0b4 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption; @@ -42,10 +46,6 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index edf227a6d..3d0cbfc84 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; @@ -41,8 +43,6 @@ import net.minecraft.util.math.Quaternion; import net.minecraft.util.math.Vec3f; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 3dcc576e8..442dc2cf6 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -29,9 +32,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 2fb578396..dffcc153d 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hypixel; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -35,9 +38,6 @@ import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import java.util.ArrayList; -import java.util.List; - public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index 083799dfe..242f04c78 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.hypixel.autogg; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; @@ -32,11 +37,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.stream.Collectors; - /** * Based on DragonEggBedrockBreaking's AutoGG Mod * diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 3d2f4a1f8..0ac749b0e 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hypixel.autotip; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; @@ -31,8 +33,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; -import java.util.regex.Pattern; - public class AutoTip implements AbstractHypixelMod { @Getter diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 76b0cb2e2..caa5fa9ec 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -36,10 +40,6 @@ import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.regex.Matcher; -import java.util.stream.Collectors; - /** * @author DarkKronicle */ @@ -121,7 +121,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return ""; + return "Top 3 Killers: \n" + players.values().stream() + .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + .collect(Collectors.joining("\n")); } public String getFormattedTime() { diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 4601c287a..92e2c3321 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -22,6 +22,12 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -40,12 +46,6 @@ import net.minecraft.text.LiteralText; import net.minecraft.util.Formatting; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - /** * @author DarkKronicle */ diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index 0b90f79dd..ba5d9490e 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -51,7 +51,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static boolean running; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static boolean running; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { @@ -206,6 +207,4 @@ public void initRPC() { } - - } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java index a620accb9..ceaab12d7 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -22,12 +22,12 @@ package io.github.axolotlclient.util.events; +import java.util.Arrays; + import io.github.axolotlclient.util.events.impl.*; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; -import java.util.Arrays; - public class Events { public static final Event> MOUSE_INPUT = createEvent(); @@ -38,7 +38,7 @@ public class Events { public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); public static final Event> WORLD_LOAD_EVENT = createEvent(); - private static Event> createEvent(){ + private static Event> createEvent() { return EventFactory .createArrayBacked(EventCallback.class, listeners -> (event) -> Arrays.stream(listeners).forEach(l -> l.invoke(event))); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index 0ae92b634..c7518b5b8 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -24,6 +24,7 @@ import lombok.Data; import net.minecraft.client.option.KeyBinding; + @Data public class KeyPressEvent { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 6fabee67d..25c14709f 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.mixin; +import java.util.List; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; @@ -59,8 +61,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.util.List; - @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 1beffdd52..cca9c19fa 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud; +import java.util.*; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -42,9 +45,6 @@ import net.minecraft.util.Identifier; import org.lwjgl.glfw.GLFW; -import java.util.*; -import java.util.stream.Collectors; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -58,6 +58,7 @@ public class HudManager extends AbstractModule { private final OptionCategory hudCategory = new OptionCategory("hud", false); private final Map entries; private final MinecraftClient client; + private HudManager() { this.entries = new LinkedHashMap<>(); client = MinecraftClient.getInstance(); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 414cb4635..f253f820f 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption; @@ -42,10 +46,6 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 2c1a8ebae..08fc39080 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; @@ -41,8 +43,6 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Quaternion; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 3dcc576e8..442dc2cf6 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -29,9 +32,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 2fb578396..dffcc153d 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hypixel; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -35,9 +38,6 @@ import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import java.util.ArrayList; -import java.util.List; - public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index 083799dfe..242f04c78 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.hypixel.autogg; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; @@ -32,11 +37,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.stream.Collectors; - /** * Based on DragonEggBedrockBreaking's AutoGG Mod * diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 7ee9561c1..6c24e6511 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hypixel.autotip; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; @@ -31,8 +33,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; -import java.util.regex.Pattern; - public class AutoTip implements AbstractHypixelMod { @Getter diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index c8affb592..1e1b1ffb6 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -36,10 +40,6 @@ import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.regex.Matcher; -import java.util.stream.Collectors; - /** * @author DarkKronicle */ @@ -121,7 +121,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return ""; + return "Top 3 Killers: \n" + players.values().stream() + .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + .collect(Collectors.joining("\n")); } public String getFormattedTime() { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index f4a8b5275..d931286ac 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -22,6 +22,12 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -40,12 +46,6 @@ import net.minecraft.text.LiteralText; import net.minecraft.util.Formatting; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - /** * @author DarkKronicle */ diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index 0b90f79dd..ba5d9490e 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -51,7 +51,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static boolean running; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static boolean running; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { @@ -206,6 +207,4 @@ public void initRPC() { } - - } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java index a620accb9..ceaab12d7 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -22,12 +22,12 @@ package io.github.axolotlclient.util.events; +import java.util.Arrays; + import io.github.axolotlclient.util.events.impl.*; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; -import java.util.Arrays; - public class Events { public static final Event> MOUSE_INPUT = createEvent(); @@ -38,7 +38,7 @@ public class Events { public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); public static final Event> WORLD_LOAD_EVENT = createEvent(); - private static Event> createEvent(){ + private static Event> createEvent() { return EventFactory .createArrayBacked(EventCallback.class, listeners -> (event) -> Arrays.stream(listeners).forEach(l -> l.invoke(event))); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 0322f240f..3d6e3eba1 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.mixin; +import java.util.List; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; @@ -55,8 +57,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.util.List; - @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index d8f4e46e4..7f0484b6a 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud; +import java.util.*; +import java.util.stream.Collectors; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; @@ -42,9 +45,6 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import java.util.*; -import java.util.stream.Collectors; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -58,6 +58,7 @@ public class HudManager extends AbstractModule { private final OptionCategory hudCategory = new OptionCategory("hud", false); private final Map entries; private final MinecraftClient client; + private HudManager() { this.entries = new LinkedHashMap<>(); client = MinecraftClient.getInstance(); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 47018ceea..52de2bd98 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -42,10 +46,6 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index e987bc934..a124dfa08 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import com.mojang.blaze3d.lighting.DiffuseLighting; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -41,8 +43,6 @@ import net.minecraft.util.math.Quaternion; import net.minecraft.util.math.Vec3f; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index ee170a3ad..b9f702184 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -29,9 +32,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java index a8916d1f5..ffc01fb5f 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -45,8 +47,6 @@ import net.minecraft.util.math.Vec3f; import net.minecraft.world.World; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java index c304e0737..9a757a3b4 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.util; +import java.util.function.Supplier; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -31,8 +33,6 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.Matrix4f; -import java.util.function.Supplier; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 2fb578396..dffcc153d 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hypixel; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -35,9 +38,6 @@ import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import java.util.ArrayList; -import java.util.List; - public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 317bbc2fe..5356bc592 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -35,10 +39,6 @@ import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.regex.Matcher; -import java.util.stream.Collectors; - /** * @author DarkKronicle */ @@ -121,7 +121,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return ""; + return "Top 3 Killers: \n" + players.values().stream() + .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + .collect(Collectors.joining("\n")); } public String getFormattedTime() { diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 272c0c276..976c8fe08 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -40,11 +45,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.regex.Pattern; - /** * @author DarkKronicle */ diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index abdcda05c..0ef205bc3 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -51,7 +51,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static boolean running; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static boolean running; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { @@ -197,6 +198,4 @@ public void initRPC() { } - - } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java index 0d0c8b8cd..65717aca9 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -22,11 +22,11 @@ package io.github.axolotlclient.util.events; +import java.util.Arrays; + import io.github.axolotlclient.util.events.impl.*; import org.quiltmc.qsl.base.api.event.Event; -import java.util.Arrays; - public class Events { public static final Event> MOUSE_INPUT = createEvent(); @@ -37,7 +37,7 @@ public class Events { public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); public static final Event> WORLD_LOAD_EVENT = createEvent(); - private static Event> createEvent(){ + private static Event> createEvent() { return Event .create(EventCallback.class, listeners -> (event) -> Arrays.stream(listeners).forEach(l -> l.invoke(event))); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index 21a85dce0..62ad3314d 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -24,6 +24,7 @@ import lombok.Data; import net.minecraft.client.option.KeyBind; + @Data public class KeyPressEvent { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index b7cade9e5..b1c18a471 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.mixin; +import java.util.List; +import java.util.UUID; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; @@ -55,9 +58,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.util.List; -import java.util.UUID; - @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 9b520da5a..977bf9eca 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud; +import java.util.*; +import java.util.stream.Collectors; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; @@ -41,9 +44,6 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import java.util.*; -import java.util.stream.Collectors; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -57,6 +57,7 @@ public class HudManager extends AbstractModule { private final OptionCategory hudCategory = new OptionCategory("hud", false); private final Map entries; private final MinecraftClient client; + private HudManager() { this.entries = new LinkedHashMap<>(); client = MinecraftClient.getInstance(); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 47018ceea..52de2bd98 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -42,10 +46,6 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 2ff4d84ba..8d119806a 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import com.mojang.blaze3d.lighting.DiffuseLighting; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -42,8 +44,6 @@ import org.joml.Quaternionf; import org.joml.Vector3f; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index ee170a3ad..b9f702184 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -29,9 +32,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java index b10c932e8..dbf59a2e8 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -45,8 +47,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java index 6a48d7964..7f1d07786 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.util; +import java.util.function.Supplier; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -31,8 +33,6 @@ import net.minecraft.client.util.math.MatrixStack; import org.joml.Matrix4f; -import java.util.function.Supplier; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 2fb578396..dffcc153d 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hypixel; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -35,9 +38,6 @@ import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import java.util.ArrayList; -import java.util.List; - public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index ddf958773..9aab4985b 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.autogg; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; @@ -32,10 +36,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - /** * Based on DragonEggBedrockBreaking's AutoGG Mod * diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 06350af80..72debfad4 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hypixel.autotip; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; @@ -31,8 +33,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; -import java.util.regex.Pattern; - public class AutoTip implements AbstractHypixelMod { @Getter diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 317bbc2fe..5356bc592 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -35,10 +39,6 @@ import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.regex.Matcher; -import java.util.stream.Collectors; - /** * @author DarkKronicle */ @@ -121,7 +121,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return ""; + return "Top 3 Killers: \n" + players.values().stream() + .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + .collect(Collectors.joining("\n")); } public String getFormattedTime() { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 272c0c276..976c8fe08 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -40,11 +45,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.regex.Pattern; - /** * @author DarkKronicle */ diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index c1513f7c5..0ef205bc3 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -51,7 +51,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static boolean running; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static boolean running; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java index 0d0c8b8cd..65717aca9 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -22,11 +22,11 @@ package io.github.axolotlclient.util.events; +import java.util.Arrays; + import io.github.axolotlclient.util.events.impl.*; import org.quiltmc.qsl.base.api.event.Event; -import java.util.Arrays; - public class Events { public static final Event> MOUSE_INPUT = createEvent(); @@ -37,7 +37,7 @@ public class Events { public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); public static final Event> WORLD_LOAD_EVENT = createEvent(); - private static Event> createEvent(){ + private static Event> createEvent() { return Event .create(EventCallback.class, listeners -> (event) -> Arrays.stream(listeners).forEach(l -> l.invoke(event))); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index 21a85dce0..62ad3314d 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -24,6 +24,7 @@ import lombok.Data; import net.minecraft.client.option.KeyBind; + @Data public class KeyPressEvent { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 85d04fe6c..feac351ba 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.mixin; +import java.util.List; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; @@ -55,8 +57,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.util.List; - @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 42f3ffeac..a125b7bbc 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud; +import java.util.*; +import java.util.stream.Collectors; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; @@ -41,9 +44,6 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import java.util.*; -import java.util.stream.Collectors; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -57,6 +57,7 @@ public class HudManager extends AbstractModule { private final OptionCategory hudCategory = new OptionCategory("hud", false); private final Map entries; private final MinecraftClient client; + private HudManager() { this.entries = new LinkedHashMap<>(); client = MinecraftClient.getInstance(); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 47018ceea..52de2bd98 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -42,10 +46,6 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 2ff4d84ba..8d119806a 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import com.mojang.blaze3d.lighting.DiffuseLighting; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -42,8 +44,6 @@ import org.joml.Quaternionf; import org.joml.Vector3f; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index ee170a3ad..b9f702184 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -29,9 +32,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java index b10c932e8..dbf59a2e8 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -45,8 +47,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java index 646f049f4..3d681a33a 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.util; +import java.util.function.Supplier; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -31,8 +33,6 @@ import net.minecraft.client.util.math.MatrixStack; import org.joml.Matrix4f; -import java.util.function.Supplier; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 2fb578396..dffcc153d 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hypixel; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -35,9 +38,6 @@ import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import java.util.ArrayList; -import java.util.List; - public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index ddf958773..9aab4985b 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.autogg; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; @@ -32,10 +36,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - /** * Based on DragonEggBedrockBreaking's AutoGG Mod * diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 095c74a84..345575912 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hypixel.autotip; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; @@ -31,8 +33,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; -import java.util.regex.Pattern; - public class AutoTip implements AbstractHypixelMod { @Getter diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 1d78941b6..a2426e751 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -35,10 +39,6 @@ import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.regex.Matcher; -import java.util.stream.Collectors; - /** * @author DarkKronicle */ @@ -120,7 +120,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return ""; + return "Top 3 Killers: \n" + players.values().stream() + .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + .collect(Collectors.joining("\n")); } public String getFormattedTime() { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 272c0c276..976c8fe08 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -40,11 +45,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.regex.Pattern; - /** * @author DarkKronicle */ diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index c1513f7c5..0ef205bc3 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -51,7 +51,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static boolean running; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static boolean running; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java index 0d0c8b8cd..65717aca9 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -22,11 +22,11 @@ package io.github.axolotlclient.util.events; +import java.util.Arrays; + import io.github.axolotlclient.util.events.impl.*; import org.quiltmc.qsl.base.api.event.Event; -import java.util.Arrays; - public class Events { public static final Event> MOUSE_INPUT = createEvent(); @@ -37,7 +37,7 @@ public class Events { public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); public static final Event> WORLD_LOAD_EVENT = createEvent(); - private static Event> createEvent(){ + private static Event> createEvent() { return Event .create(EventCallback.class, listeners -> (event) -> Arrays.stream(listeners).forEach(l -> l.invoke(event))); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index 21a85dce0..62ad3314d 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -24,6 +24,7 @@ import lombok.Data; import net.minecraft.client.option.KeyBind; + @Data public class KeyPressEvent { diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java index e40a06cbf..15ed76b02 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java @@ -22,6 +22,11 @@ package io.github.axolotlclient; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import io.github.axolotlclient.AxolotlClientConfig.AxolotlClientConfigManager; @@ -68,11 +73,6 @@ import org.quiltmc.qsl.resource.loader.api.ResourceLoader; import org.quiltmc.qsl.resource.loader.api.ResourcePackActivationType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; - public class AxolotlClient implements ClientModInitializer { public static final Identifier badgeIcon = new Identifier("axolotlclient", "textures/badge.png"); diff --git a/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 95c751da7..0893875f6 100644 --- a/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.config; +import java.util.ArrayList; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.texture.NativeImage; import io.github.axolotlclient.AxolotlClient; @@ -38,9 +41,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.texture.NativeImageBackedTexture; -import java.util.ArrayList; -import java.util.List; - public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption showOwnNametag = new BooleanOption("showOwnNametag", false); diff --git a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 18f8c3074..43b2ac491 100644 --- a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.config.screen; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + import com.mojang.blaze3d.glfw.Window; import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClient; @@ -51,10 +55,6 @@ import org.jetbrains.annotations.Nullable; import org.lwjgl.opengl.GL11; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - public class CreditsScreen extends Screen { public static final HashMap externalModuleCredits = new HashMap<>(); diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/BossBarHudAccessor.java b/1.20/src/main/java/io/github/axolotlclient/mixin/BossBarHudAccessor.java index 33e308987..3404b43f8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/BossBarHudAccessor.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/BossBarHudAccessor.java @@ -22,14 +22,14 @@ package io.github.axolotlclient.mixin; +import java.util.Map; +import java.util.UUID; + import net.minecraft.client.gui.hud.BossBarHud; import net.minecraft.client.gui.hud.ClientBossBar; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; -import java.util.UUID; - @Mixin(BossBarHud.class) public interface BossBarHudAccessor { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java index fc446f116..9923a30d2 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.mixin; +import java.util.Objects; +import java.util.function.Supplier; + import io.github.axolotlclient.modules.hud.HudEditScreen; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; import io.github.axolotlclient.modules.hypixel.HypixelMods; @@ -36,9 +39,6 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; -import java.util.Objects; -import java.util.function.Supplier; - @Mixin(GameMenuScreen.class) public abstract class GameMenuScreenMixin { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/ParticleManagerMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/ParticleManagerMixin.java index 30ffb20d0..cb012d35f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/ParticleManagerMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/ParticleManagerMixin.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.mixin; +import java.util.Collection; +import java.util.Iterator; +import java.util.Queue; + import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.Tessellator; import io.github.axolotlclient.modules.particles.Particles; @@ -43,10 +47,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.util.Collection; -import java.util.Iterator; -import java.util.Queue; - @Mixin(ParticleManager.class) public abstract class ParticleManagerMixin { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 9de52e48d..83f77bf3b 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.mixin; +import java.util.List; +import java.util.UUID; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; @@ -55,9 +58,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.util.List; -import java.util.UUID; - @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/ReloadableResourceManagerMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/ReloadableResourceManagerMixin.java index 3a30e06cf..a031c6830 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/ReloadableResourceManagerMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/ReloadableResourceManagerMixin.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.mixin; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PackDisplayHud; @@ -37,11 +42,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; - @Mixin(ReloadableResourceManager.class) public abstract class ReloadableResourceManagerMixin { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/ScreenshotRecorderMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/ScreenshotRecorderMixin.java index f11ffa3a5..6c7caa4ea 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/ScreenshotRecorderMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/ScreenshotRecorderMixin.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.mixin; +import java.io.File; +import java.util.function.Consumer; + import com.mojang.blaze3d.framebuffer.Framebuffer; import com.mojang.blaze3d.texture.NativeImage; import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils; @@ -40,9 +43,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.io.File; -import java.util.function.Consumer; - @Mixin(ScreenshotRecorder.class) public abstract class ScreenshotRecorderMixin { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/ShaderEffectAccessor.java b/1.20/src/main/java/io/github/axolotlclient/mixin/ShaderEffectAccessor.java index fcc3cd917..8d9afae49 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/ShaderEffectAccessor.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/ShaderEffectAccessor.java @@ -22,13 +22,13 @@ package io.github.axolotlclient.mixin; +import java.util.List; + import net.minecraft.client.gl.PostProcessShader; import net.minecraft.client.gl.ShaderEffect; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; - @Mixin(ShaderEffect.class) public interface ShaderEffectAccessor { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/SplashOverlayMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/SplashOverlayMixin.java index 6915e363b..408dcb5dd 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/SplashOverlayMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/SplashOverlayMixin.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.mixin; +import java.util.function.IntSupplier; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.Color; import net.minecraft.client.gui.screen.SplashOverlay; @@ -35,8 +37,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.function.IntSupplier; - @Mixin(value = SplashOverlay.class, priority = 1100) public abstract class SplashOverlayMixin { @Mutable diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/ModuleLoader.java b/1.20/src/main/java/io/github/axolotlclient/modules/ModuleLoader.java index b23467cb9..e89a01fb8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/ModuleLoader.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/ModuleLoader.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.config.screen.CreditsScreen; import org.quiltmc.loader.api.ModContributor; import org.quiltmc.loader.api.ModMetadata; import org.quiltmc.loader.api.QuiltLoader; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - public class ModuleLoader { public static List loadExternalModules() { diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/auth/AccountsListWidget.java b/1.20/src/main/java/io/github/axolotlclient/modules/auth/AccountsListWidget.java index ae5c42550..370c0cddf 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/auth/AccountsListWidget.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/auth/AccountsListWidget.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.auth; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; @@ -31,8 +33,6 @@ import net.minecraft.util.Util; import org.quiltmc.loader.api.minecraft.ClientOnly; -import java.util.List; - public class AccountsListWidget extends AlwaysSelectedEntryListWidget { private final AccountsScreen screen; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/auth/AddOfflineScreen.java b/1.20/src/main/java/io/github/axolotlclient/modules/auth/AddOfflineScreen.java index ea2b5d3b4..bfb8c53b1 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/auth/AddOfflineScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/auth/AddOfflineScreen.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.auth; +import java.util.UUID; + import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; @@ -29,8 +31,6 @@ import net.minecraft.text.CommonTexts; import net.minecraft.text.Text; -import java.util.UUID; - public class AddOfflineScreen extends Screen { private final Screen parent; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/auth/Auth.java b/1.20/src/main/java/io/github/axolotlclient/modules/auth/Auth.java index 3b77534fd..932a29e35 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/auth/Auth.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/auth/Auth.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.auth; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Optional; + import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.minecraft.UserApiService; import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; @@ -46,11 +51,6 @@ import net.minecraft.util.Identifier; import org.quiltmc.loader.api.QuiltLoader; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Optional; - public class Auth extends Accounts implements Module { @Getter diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/blur/MenuBlur.java b/1.20/src/main/java/io/github/axolotlclient/modules/blur/MenuBlur.java index 3cd5d39b3..f6ca8b728 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/blur/MenuBlur.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/blur/MenuBlur.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.blur; +import java.io.IOException; + import com.mojang.blaze3d.shader.GlUniform; import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -40,8 +42,6 @@ import net.minecraft.util.Identifier; import org.apache.commons.io.IOUtils; -import java.io.IOException; - /** * Totally not stolen from Sol. * License: GPL-3.0 diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/blur/MotionBlur.java b/1.20/src/main/java/io/github/axolotlclient/modules/blur/MotionBlur.java index 09b8e34e8..4fbc4891a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/blur/MotionBlur.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/blur/MotionBlur.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.blur; +import java.io.IOException; + import com.google.gson.JsonSyntaxException; import com.mojang.blaze3d.shader.GlUniform; import io.github.axolotlclient.AxolotlClient; @@ -36,8 +38,6 @@ import net.minecraft.util.Identifier; import org.apache.commons.io.IOUtils; -import java.io.IOException; - public class MotionBlur extends AbstractModule { private static final MotionBlur Instance = new MotionBlur(); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudEditScreen.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudEditScreen.java index 177633d8a..a348be06a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudEditScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudEditScreen.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud; +import java.awt.*; +import java.util.List; +import java.util.Optional; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -37,10 +41,6 @@ import net.minecraft.text.CommonTexts; import net.minecraft.text.Text; -import java.awt.*; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 779a35599..fc282797a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud; +import java.util.*; +import java.util.stream.Collectors; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; @@ -41,9 +44,6 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.util.Identifier; -import java.util.*; -import java.util.stream.Collectors; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java index 51707d2a3..ef41114a5 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; @@ -39,9 +42,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/component/Configurable.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/component/Configurable.java index b82e1ec1d..639bc52a7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/component/Configurable.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/component/Configurable.java @@ -22,11 +22,11 @@ package io.github.axolotlclient.modules.hud.gui.component; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/BoxHudEntry.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/BoxHudEntry.java index 397318fd2..f179a412a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/BoxHudEntry.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/BoxHudEntry.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.entry; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption; @@ -29,8 +31,6 @@ import io.github.axolotlclient.modules.hud.gui.AbstractHudEntry; import net.minecraft.client.gui.GuiGraphics; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/SimpleTextHudEntry.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/SimpleTextHudEntry.java index 0e7588257..ee1116626 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/SimpleTextHudEntry.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/SimpleTextHudEntry.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.entry; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -35,8 +37,6 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import net.minecraft.client.gui.GuiGraphics; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/TextHudEntry.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/TextHudEntry.java index 28e8231fb..f8fc6362c 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/TextHudEntry.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/TextHudEntry.java @@ -22,13 +22,13 @@ package io.github.axolotlclient.modules.hud.gui.entry; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CompassHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CompassHud.java index fcfa9abed..b88bd2de8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CompassHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CompassHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -37,8 +39,6 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java index 3773fa4f6..4951ec535 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.*; import io.github.axolotlclient.modules.hud.gui.component.DynamicallyPositionable; @@ -32,10 +36,6 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.util.Identifier; -import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index f1fec27a4..e1f842da5 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -42,10 +46,6 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/MemoryHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/MemoryHud.java index 78b81b5c8..92290580f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/MemoryHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/MemoryHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption; @@ -38,8 +40,6 @@ import net.minecraft.client.resource.language.I18n; import net.minecraft.util.Identifier; -import java.util.List; - public class MemoryHud extends TextHudEntry implements DynamicallyPositionable { public static final Identifier ID = new Identifier("axolotlclient", "memoryhud"); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PackDisplayHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PackDisplayHud.java index 0be46d04e..8b1920ddb 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PackDisplayHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PackDisplayHud.java @@ -22,6 +22,12 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.texture.NativeImage; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -37,12 +43,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - public class PackDisplayHud extends TextHudEntry { public static final Identifier ID = new Identifier("axolotlclient", "packdisplayhud"); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 18dcfb5f9..a58b2654a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import com.mojang.blaze3d.lighting.DiffuseLighting; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -43,8 +45,6 @@ import org.joml.Quaternionf; import org.joml.Vector3f; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PotionsHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PotionsHud.java index 798ac3115..e04a636e6 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PotionsHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PotionsHud.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.ArrayList; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; @@ -40,9 +43,6 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.util.Identifier; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java index 6d85ed30f..96aaa5029 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.item; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry; @@ -34,8 +36,6 @@ import net.minecraft.nbt.NbtList; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java index da1fbb41c..20fb65ff7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.item; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry; @@ -35,8 +37,6 @@ import net.minecraft.util.Hand; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ItemUpdateHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ItemUpdateHud.java index c9cd774e4..5520a1599 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ItemUpdateHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ItemUpdateHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud.item; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; @@ -40,10 +44,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Language; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 690926ccd..e5f40bbf3 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -29,9 +32,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/IRLTimeHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/IRLTimeHud.java index bb8d51f22..04b575b8b 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/IRLTimeHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/IRLTimeHud.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; -import io.github.axolotlclient.AxolotlClientConfig.options.Option; -import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; -import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import net.minecraft.util.Identifier; - import java.time.LocalDateTime; import java.time.Month; import java.time.format.DateTimeFormatter; import java.util.List; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; +import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; +import net.minecraft.util.Identifier; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/PingHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/PingHud.java index a1827ab7b..8264a9efd 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/PingHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/PingHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -42,8 +44,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java index 58def8e0c..1d9045ebd 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.List; + import com.google.common.util.concurrent.AtomicDouble; import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; @@ -35,10 +39,6 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; -import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/SpeedHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/SpeedHud.java index 2556344a5..201a53ffa 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/SpeedHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/SpeedHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -29,10 +33,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3d; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/TPSHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/TPSHud.java index 0552e1aa9..4c97b05e8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/TPSHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/TPSHud.java @@ -22,12 +22,12 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; -import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import net.minecraft.util.Identifier; - import java.text.DecimalFormat; import java.text.NumberFormat; +import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; +import net.minecraft.util.Identifier; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java index 7f164e4af..da037c236 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java @@ -22,6 +22,14 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Random; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; @@ -35,14 +43,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Random; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ActionBarHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ActionBarHud.java index 76700b7d2..b7c2fd761 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ActionBarHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ActionBarHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; @@ -32,8 +34,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/BossBarHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/BossBarHud.java index a6e720984..378e3a910 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/BossBarHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/BossBarHud.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; @@ -39,11 +44,6 @@ import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java index e7834d0db..7d054cb82 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -45,8 +47,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/HotbarHUD.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/HotbarHUD.java index 109a9094c..fba27b18e 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/HotbarHUD.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/HotbarHUD.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.ArrayList; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry; @@ -34,9 +37,6 @@ import net.minecraft.util.Arm; import net.minecraft.util.Identifier; -import java.util.ArrayList; -import java.util.List; - public class HotbarHUD extends TextHudEntry { public static final Identifier ID = new Identifier("axolotlclient", "hotbarhud"); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ScoreboardHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ScoreboardHud.java index f1dffadc2..ca28ff94e 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ScoreboardHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ScoreboardHud.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.mojang.datafixers.util.Pair; @@ -38,11 +43,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/snapping/SnappingHelper.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/snapping/SnappingHelper.java index 3a3f13cd8..68c19e4b1 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/snapping/SnappingHelper.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/snapping/SnappingHelper.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.snapping; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; + import com.mojang.blaze3d.glfw.Window; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hud.util.DrawUtil; @@ -30,10 +34,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/ItemUtil.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/ItemUtil.java index 4f07e2d9a..d37f0dff7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/ItemUtil.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/ItemUtil.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.util; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import com.mojang.blaze3d.lighting.DiffuseLighting; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; @@ -37,10 +41,6 @@ import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.util.Util; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java index 15caf802c..b6da409b7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.util; +import java.util.function.Supplier; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -31,8 +33,6 @@ import net.minecraft.client.render.ShaderProgram; import org.joml.Matrix4f; -import java.util.function.Supplier; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 2fb578396..dffcc153d 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hypixel; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -35,9 +38,6 @@ import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import java.util.ArrayList; -import java.util.List; - public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index fcf8bb044..b5d93e47f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.autogg; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; @@ -31,10 +35,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - /** * Based on DragonEggBedrockBreaking's AutoGG Mod * diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index e33ff9645..23c9956e7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hypixel.autotip; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; @@ -30,8 +32,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; -import java.util.regex.Pattern; - public class AutoTip implements AbstractHypixelMod { @Getter diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 0a4fdc368..a2426e751 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -35,379 +39,378 @@ import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.regex.Matcher; -import java.util.stream.Collectors; - /** * @author DarkKronicle */ public class BedwarsGame { - private BedwarsTeam won = null; - private int wonTick = -1; - private int seconds = 0; - private Text topBarText = Text.empty(); - private Text bottomBarText = Text.empty(); - - private BedwarsPlayer me = null; - - private final Map players = new HashMap<>(16); - private final Map playersById = new HashMap<>(16); - private final MinecraftClient mc; - @Getter - private boolean started = false; - private final BedwarsMod mod; - @Getter - private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); - - - public BedwarsGame(BedwarsMod mod) { - mc = MinecraftClient.getInstance(); - this.mod = mod; - } - - public void onStart() { - mod.upgradesOverlay.onStart(upgrades); - players.clear(); - playersById.clear(); - Map> teamPlayers = new HashMap<>(); - for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { - String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); - if (name.charAt(1) != ' ') { - continue; - } - BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); - if (team == null) { - continue; - } - 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); - BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); - if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { - me = p; - } - players.put(e.getProfile().getName(), p); - playersById.put(e.getProfile().getId(), p); - } - } - this.started = true; - } - - public Text getTopBarText() { - return topBarText; - } - - public Text getBottomBarText() { - return bottomBarText; - } - - private String calculateTopBarText() { - return getFormattedTime(); - } - - private String calculateBottomBarText() { - return ""; - } - - public String getFormattedTime() { - 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(UUID uuid) { - return Optional.ofNullable(playersById.getOrDefault(uuid, null)); - } - - public Optional getPlayer(String name) { - return Optional.ofNullable(players.getOrDefault(name, null)); - } - - private void debug(String message) { - mc.inGameHud.getChatHud().addMessage(Text.literal("§b§lINFO:§8 " + message)); - } - - private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - player.died(); - if (killer != null) { - killer.killed(finalDeath); - } - if (mod.overrideMessages.get()) { - event.setNewMessage(Text.literal(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) { - 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)) - .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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); - } - - private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - String inner = type.getInner(); - if (finalDeath) { - inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; - } else { - inner = "§7/" + inner + "/"; - } - String playerFormatted = getPlayerFormatted(player); - if (killer == null) { - return playerFormatted + " " + inner; - } - String killerFormatted = getPlayerFormatted(killer); - if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { - killerFormatted += " §6" + killer.getStats().getFinalKills(); - } - return playerFormatted + " " + inner + " " + killerFormatted; - } - - private String getPlayerFormatted(BedwarsPlayer player) { - return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); - } - - public boolean isTeamEliminated(BedwarsTeam team) { - return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); - } - - public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { - try { - if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { - event.setCancelled(true); - return; - } - 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 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(p -> disconnected(event, p)))) { - return; - } - 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 -> { - 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { - return; - } - upgrades.onMessage(rawMessage); - } catch (Exception e) { - debug("Error: " + e); - } - } - - 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(); - return; - } - - mc.inGameHud.getChatHud().addMessage( - Text.literal("§8§m----------[§7Winstreaks§8]----------") - ); - for (BedwarsPlayer p : players.values()) { - if (p.getStats() != null && p.getStats().getWinstreak() > 0) { - boolean winner = p.getTeam().equals(win); - int before = p.getStats().getWinstreak(); - int after = winner ? before + 1 : 0; - mc.inGameHud.getChatHud().addMessage( - Text.literal( - getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after - )); - } - } - - BedwarsMod.getInstance().gameEnd(); - } - - 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(); - }); - if (mod.overrideMessages.get()) { - event.setNewMessage(Text.literal(formatEliminated(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(); - } - if (mod.overrideMessages.get()) { - event.setNewMessage(Text.literal(formatBed(team, breaker))); - } - } - - private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { - player.disconnected(); - if (mod.overrideMessages.get()) { - event.setNewMessage(Text.literal(formatDisconnect(player))); - } - } - - - private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { - player.reconnected(); - if (mod.overrideMessages.get()) { - event.setNewMessage(Text.literal(formatReconnect(player))); - } - } - - public void onScoreboardRender(ScoreboardRenderEvent event) { - Scoreboard scoreboard = event.getObjective().getScoreboard(); - Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); - 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, Text.literal(score.getPlayerName())).getString(); - 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) { - updateClock(); - } - topBarText = Text.literal(calculateTopBarText()); - bottomBarText = Text.literal(calculateBottomBarText()); - } - } - - private void updateClock() { - this.seconds++; - } - - public void tick() { - int currentTick = mc.inGameHud.getTicks(); - if (won != null && currentTick >= wonTick) { - gameEnd(won); - } - players.values().forEach(p -> p.tick(currentTick)); - } - - 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()); - } - - public BedwarsPlayer getSelf() { - return me; - } - - public String getLevelHead(AbstractClientPlayerEntity entity) { + private BedwarsTeam won = null; + private int wonTick = -1; + private int seconds = 0; + private Text topBarText = Text.empty(); + private Text bottomBarText = Text.empty(); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(16); + private final Map playersById = new HashMap<>(16); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + 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); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + public Text getTopBarText() { + return topBarText; + } + + public Text getBottomBarText() { + return bottomBarText; + } + + private String calculateTopBarText() { + return getFormattedTime(); + } + + private String calculateBottomBarText() { + return "Top 3 Killers: \n" + players.values().stream() + .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + .collect(Collectors.joining("\n")); + } + + public String getFormattedTime() { + 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(UUID uuid) { + return Optional.ofNullable(playersById.getOrDefault(uuid, null)); + } + + public Optional getPlayer(String name) { + return Optional.ofNullable(players.getOrDefault(name, null)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(Text.literal("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(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) { + 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)) + .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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + 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 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(p -> disconnected(event, p)))) { + return; + } + 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 -> { + 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + 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(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + Text.literal("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + Text.literal( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + 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(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatEliminated(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(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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, Text.literal(score.getPlayerName())).getString(); + 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) { + updateClock(); + } + topBarText = Text.literal(calculateTopBarText()); + bottomBarText = Text.literal(calculateBottomBarText()); + } + } + + private void updateClock() { + this.seconds++; + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + 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()); + } + + public BedwarsPlayer getSelf() { + return me; + } + + public String getLevelHead(AbstractClientPlayerEntity entity) { BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); if (player == null) { return null; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 272c0c276..976c8fe08 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -40,11 +45,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.regex.Pattern; - /** * @author DarkKronicle */ diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java index 27865c880..c092237ca 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -35,126 +35,126 @@ @Data public class BedwarsPlayer { - private final BedwarsTeam team; - @Getter - private PlayerListEntry profile; - private boolean alive = true; - 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) { - this.team = team; - this.profile = profile; - 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(); - } - - 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 || (!bed && isDisconnected()); - } - - public void tick(int currentTick) { - if (stats == null && !triedStats) { - triedStats = true; - try { - stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); - } catch (Exception e) { - stats = BedwarsPlayerStats.generateFake(); - } - } - if (alive || tickAlive < 0) { - return; - } - if (currentTick >= tickAlive) { - alive = true; - tickAlive = -1; - } - } - - 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; - return; - } - int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); - tickAlive = currentTick + 20 * 5; // 5 second respawn - } - - public void disconnected() { - if (stats != null) { - if (!bed) { - stats.addFinalDeath(); - } else { - stats.addDeath(); - } - } - disconnected = true; - tickAlive = -1; - alive = false; - } - - public void reconnected() { - disconnected = false; - 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(); - } - stats.addKill(); - } - } + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + 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) { + this.team = team; + this.profile = profile; + 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(); + } + + 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 || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + 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; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + 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(); + } + stats.addKill(); + } + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/particles/Particles.java b/1.20/src/main/java/io/github/axolotlclient/modules/particles/Particles.java index ff3404150..2032f6355 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/particles/Particles.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/particles/Particles.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.particles; +import java.util.*; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.*; @@ -33,9 +36,6 @@ import net.minecraft.registry.Registries; import org.apache.commons.lang3.StringUtils; -import java.util.*; -import java.util.stream.Collectors; - public class Particles extends AbstractModule { private static final Particles Instance = new Particles(); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.20/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index a8a45eb9b..0ef205bc3 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.rpc; +import java.time.Instant; + import de.jcm.discordgamesdk.Core; import de.jcm.discordgamesdk.CreateParams; import de.jcm.discordgamesdk.DiscordEventAdapter; @@ -37,8 +39,6 @@ import io.github.axolotlclient.util.Util; import net.minecraft.client.MinecraftClient; -import java.time.Instant; - /** * This DiscordRPC module is derived from HyCord. * diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java index d4721833b..131fcab32 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.screenshotUtils; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.nio.file.Files; +import java.util.Base64; + import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.mojang.blaze3d.texture.NativeImage; @@ -38,11 +43,6 @@ import org.apache.http.impl.client.HttpClients; import org.quiltmc.loader.api.QuiltLoader; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.nio.file.Files; -import java.util.Base64; - public class ImageShare { @Getter diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageViewerScreen.java b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageViewerScreen.java index 4be10eace..44fea3f92 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageViewerScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageViewerScreen.java @@ -22,6 +22,19 @@ package io.github.axolotlclient.modules.screenshotUtils; +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.net.URI; +import java.nio.file.Files; +import java.util.HashMap; +import java.util.Locale; +import java.util.Objects; +import java.util.function.Supplier; + import com.google.common.hash.Hashing; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.texture.NativeImage; @@ -41,19 +54,6 @@ import org.jetbrains.annotations.NotNull; import org.quiltmc.loader.api.QuiltLoader; -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.net.URI; -import java.nio.file.Files; -import java.util.HashMap; -import java.util.Locale; -import java.util.Objects; -import java.util.function.Supplier; - public class ImageViewerScreen extends Screen { // Icon from https://lucide.dev, "arrow-right" diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ScreenshotUtils.java b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ScreenshotUtils.java index df81cb924..47b803b68 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ScreenshotUtils.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ScreenshotUtils.java @@ -22,6 +22,14 @@ package io.github.axolotlclient.modules.screenshotUtils; +import java.awt.*; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.io.File; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.*; import io.github.axolotlclient.modules.AbstractModule; @@ -33,14 +41,6 @@ import net.minecraft.util.Util; import org.jetbrains.annotations.Nullable; -import java.awt.*; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.io.File; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.List; - public class ScreenshotUtils extends AbstractModule { private static final ScreenshotUtils Instance = new ScreenshotUtils(); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 1d9570704..795795901 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.sky; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.Map; +import java.util.stream.Collectors; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; @@ -33,11 +38,6 @@ import org.jetbrains.annotations.NotNull; import org.quiltmc.qsl.resource.loader.api.reloader.SimpleSynchronousResourceReloader; -import java.io.BufferedReader; -import java.io.IOException; -import java.util.Map; -import java.util.stream.Collectors; - /** * This implementation of custom skies is based on the FabricSkyBoxes mod by AMereBagatelle * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxInstance.java b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxInstance.java index 9de86cea2..4640dab95 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxInstance.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxInstance.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.sky; +import java.util.Locale; +import java.util.Objects; + import com.google.gson.JsonObject; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; @@ -39,9 +42,6 @@ import org.joml.Matrix4f; import org.lwjgl.opengl.GL14; -import java.util.Locale; -import java.util.Objects; - /** * This implementation of custom skies is based on the FabricSkyBoxes mod by AMereBagatelle * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxManager.java b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxManager.java index 2331b406f..513775809 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxManager.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxManager.java @@ -22,13 +22,13 @@ package io.github.axolotlclient.modules.sky; -import net.minecraft.client.util.math.MatrixStack; -import org.joml.Matrix4f; - import java.util.ArrayList; import java.util.Objects; import java.util.function.Predicate; +import net.minecraft.client.util.math.MatrixStack; +import org.joml.Matrix4f; + /** * This implementation of custom skies is based on the FabricSkyBoxes mod by AMereBagatelle * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java b/1.20/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java index 922d57c75..906dcbe4c 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.tnttime; +import java.text.DecimalFormat; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; @@ -31,8 +33,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import java.text.DecimalFormat; - public class TntTime extends AbstractModule { private static final TntTime Instance = new TntTime(); diff --git a/1.20/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java b/1.20/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java index 219e4e940..496a21664 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.util; +import java.util.HashMap; +import java.util.Locale; +import java.util.Objects; +import java.util.function.Supplier; + import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonParser; @@ -35,11 +40,6 @@ import org.quiltmc.qsl.networking.api.client.ClientPlayConnectionEvents; import org.quiltmc.qsl.networking.api.client.ClientPlayNetworking; -import java.util.HashMap; -import java.util.Locale; -import java.util.Objects; -import java.util.function.Supplier; - public class FeatureDisabler { private static final HashMap disabledServers = new HashMap<>(); diff --git a/1.20/src/main/java/io/github/axolotlclient/util/NetworkHelper.java b/1.20/src/main/java/io/github/axolotlclient/util/NetworkHelper.java index 03615cde0..56bd7fa50 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/NetworkHelper.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/NetworkHelper.java @@ -22,17 +22,17 @@ package io.github.axolotlclient.util; +import java.io.IOException; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + import com.google.gson.JsonElement; import io.github.axolotlclient.AxolotlClient; import net.minecraft.client.MinecraftClient; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import java.io.IOException; -import java.util.UUID; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - public class NetworkHelper { private static final AtomicInteger concurrentCalls = new AtomicInteger(0); diff --git a/1.20/src/main/java/io/github/axolotlclient/util/ThreadExecuter.java b/1.20/src/main/java/io/github/axolotlclient/util/ThreadExecuter.java index 9ea06f89b..fc673cc3f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/ThreadExecuter.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/ThreadExecuter.java @@ -22,11 +22,11 @@ package io.github.axolotlclient.util; -import com.google.common.util.concurrent.ThreadFactoryBuilder; - import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import com.google.common.util.concurrent.ThreadFactoryBuilder; + public class ThreadExecuter { private static final ScheduledThreadPoolExecutor EXECUTER_SERVICE = new ScheduledThreadPoolExecutor(3, diff --git a/1.20/src/main/java/io/github/axolotlclient/util/Util.java b/1.20/src/main/java/io/github/axolotlclient/util/Util.java index c737025c2..05aa1596b 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/Util.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/Util.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.util; +import java.util.*; +import java.util.stream.Collectors; + import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.mojang.blaze3d.glfw.Window; @@ -38,9 +41,6 @@ import org.apache.commons.lang3.StringUtils; import org.lwjgl.opengl.GL11; -import java.util.*; -import java.util.stream.Collectors; - public class Util { private final static TreeMap map = new TreeMap<>(); diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.20/src/main/java/io/github/axolotlclient/util/events/Events.java index 0d0c8b8cd..65717aca9 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/events/Events.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -22,11 +22,11 @@ package io.github.axolotlclient.util.events; +import java.util.Arrays; + import io.github.axolotlclient.util.events.impl.*; import org.quiltmc.qsl.base.api.event.Event; -import java.util.Arrays; - public class Events { public static final Event> MOUSE_INPUT = createEvent(); @@ -37,7 +37,7 @@ public class Events { public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); public static final Event> WORLD_LOAD_EVENT = createEvent(); - private static Event> createEvent(){ + private static Event> createEvent() { return Event .create(EventCallback.class, listeners -> (event) -> Arrays.stream(listeners).forEach(l -> l.invoke(event))); diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index 21a85dce0..62ad3314d 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -24,6 +24,7 @@ import lombok.Data; import net.minecraft.client.option.KeyBind; + @Data public class KeyPressEvent { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index 0304d3009..02c8c357e 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.mixin; +import java.util.List; + import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.util.Util; @@ -39,8 +41,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.List; - @Mixin(ChatHud.class) public abstract class ChatHudMixin { @@ -50,18 +50,18 @@ public abstract class ChatHudMixin { @Inject(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;IIZ)V"), cancellable = true) public void axolotlclient$autoGG(Text message, int messageId, CallbackInfo ci) { - if(message == null){ + if (message == null) { ci.cancel(); } } @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At("HEAD"), argsOnly = true) - private Text axolotlclient$onChatMessage(Text message){ + private Text axolotlclient$onChatMessage(Text message) { ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.asUnformattedString(), message); Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); - if(event.isCancelled()){ + if (event.isCancelled()) { return null; - } else if(event.getNewMessage() != null){ + } else if (event.getNewMessage() != null) { return event.getNewMessage(); } return message; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 279b73f74..6dd5ccbb3 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -94,7 +94,7 @@ public abstract class EntityRendererMixin { } } - private void axolotlclient$drawLevelHead(String text){ + private void axolotlclient$drawLevelHead(String text) { TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; float x = textRenderer.getStringWidth(text) / 2F; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 6e3307bfe..105e28ee5 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -169,7 +169,7 @@ public abstract class InGameHudMixin { @ModifyVariable( method = "renderStatusBars", at = @At( - value="STORE" + value = "STORE" ), ordinal = 18 ) @@ -183,7 +183,7 @@ public abstract class InGameHudMixin { @ModifyVariable( method = "renderStatusBars", at = @At( - value="STORE" + value = "STORE" ), ordinal = 0 ) diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index c651dd152..bfc505621 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -85,7 +85,7 @@ protected MinecraftClientMixin(TextureManager textureManager) { } @Inject(method = "connect(Lnet/minecraft/client/world/ClientWorld;Ljava/lang/String;)V", at = @At("HEAD")) - private void axolotlclient$onWorldLoad(ClientWorld clientWorld, String string, CallbackInfo ci){ + private void axolotlclient$onWorldLoad(ClientWorld clientWorld, String string, CallbackInfo ci) { Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(clientWorld)); } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 89e16c5fe..2e68965c7 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.mixin; +import java.util.List; +import java.util.UUID; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; @@ -51,9 +54,6 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; -import java.util.List; -import java.util.UUID; - @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin extends DrawableHelper { @Unique @@ -173,7 +173,7 @@ public abstract class PlayerListHudMixin extends DrawableHelper { int endX = startX + n; String render; try { - if(playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())){ + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { return; } @@ -194,7 +194,7 @@ public abstract class PlayerListHudMixin extends DrawableHelper { @Inject( method = "renderScoreboardObjective", at = @At( - value="INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Ljava/lang/String;FFI)I", ordinal=1 + value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Ljava/lang/String;FFI)I", ordinal = 1 ), cancellable = true ) @@ -226,7 +226,7 @@ public abstract class PlayerListHudMixin extends DrawableHelper { color = new Color(200, 200, 200).getAsInt(); } else { int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); - color = Color.blend(new Color(255,255,255), new Color(215, 0, 64), (int) (1 - (health / 20f)*100)).getAsInt(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); render = String.valueOf(health); } // Health @@ -242,7 +242,7 @@ public abstract class PlayerListHudMixin extends DrawableHelper { @ModifyVariable( method = "render", at = @At( - value="STORE" + value = "STORE" ), ordinal = 7 ) diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index e51f48dac..09fe60c92 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud; +import java.util.*; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.AbstractModule; @@ -41,9 +44,6 @@ import net.minecraft.util.Identifier; import org.lwjgl.input.Keyboard; -import java.util.*; -import java.util.stream.Collectors; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java index 7dbb6ce31..8809aca19 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui; +import java.util.ArrayList; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -39,9 +42,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.util.math.MathHelper; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 18bda862e..df1eaa046 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import com.mojang.blaze3d.platform.GlStateManager; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -41,10 +45,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 29b996159..de3edaa1a 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import com.mojang.blaze3d.platform.GLX; import com.mojang.blaze3d.platform.GlStateManager; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -37,8 +39,6 @@ import net.minecraft.entity.player.ClientPlayerEntity; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/iconHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/iconHud.java index 25a5a41ce..163eb6441 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/iconHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/iconHud.java @@ -39,7 +39,9 @@ public iconHud() { @Override public Identifier getId() { return ID; - } @Override + } + + @Override public void renderComponent(float delta) { GlStateManager.color(1, 1, 1, 1); MinecraftClient.getInstance().getTextureManager().bindTexture(AxolotlClient.badgeIcon); @@ -63,7 +65,6 @@ public void renderPlaceholderComponent(float delta) { } - @Override public boolean movable() { return true; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index d69c39c74..8c9733416 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -30,9 +33,6 @@ import net.minecraft.client.option.KeyBinding; import net.minecraft.util.Identifier; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java index 88d64e43c..02c7dd1b1 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -31,10 +35,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3d; -import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.util.List; - // https://github.com/AxolotlClient/AxolotlClient-mod/blob/4ae2678bfe9e0908be1a7a34e61e689c8005ae0a/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/ReachDisplayHud.java // https://github.com/DarkKronicle/KronHUD/blob/703b87a7c938ba25da9105d731b70d3bc66efd1e/src/main/java/io/github/darkkronicle/kronhud/gui/hud/simple/ReachHud.java public class ReachHud extends SimpleTextHudEntry { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 2b809219c..cbc1f50ad 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -26,8 +26,8 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; -import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index 0dbaffd14..52402556b 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -31,8 +31,8 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; -import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 2b8fe8364..c706cdbe8 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,17 +22,17 @@ package io.github.axolotlclient.modules.hypixel.autotip; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; -import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import java.util.regex.Pattern; - public class AutoTip implements AbstractHypixelMod { @Getter diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 96a793859..2c0514861 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -36,381 +40,378 @@ import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.regex.Matcher; -import java.util.stream.Collectors; - /** - * * @author DarkKronicle */ public class BedwarsGame { - 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; - - private final Map players = new HashMap<>(16); - private final Map playersById = new HashMap<>(16); - private final MinecraftClient mc; - @Getter - private boolean started = false; - private final BedwarsMod mod; - @Getter - private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); - - - public BedwarsGame(BedwarsMod mod) { - mc = MinecraftClient.getInstance(); - this.mod = mod; - } - - public void onStart() { - 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("§.", ""); - if (name.charAt(1) != ' ') { - continue; - } - BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); - if (team == null) { - continue; - } - 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); - BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); - if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { - me = p; - } - players.put(e.getProfile().getName(), p); - playersById.put(e.getProfile().getId(), p); - } - } - this.started = true; - } - - public Text getTopBarText() { - return topBarText; - } - - public Text getBottomBarText() { - return bottomBarText; - } - - private String calculateTopBarText() { - return getFormattedTime(); - } - - private String calculateBottomBarText() { - return ""; - } - - public String getFormattedTime() { - 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(UUID uuid) { - return Optional.ofNullable(playersById.getOrDefault(uuid, null)); - } - - public Optional getPlayer(String name) { - return Optional.ofNullable(players.getOrDefault(name, null)); - } - - 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, BedwarsDeathType type, boolean finalDeath) { - player.died(); - if (killer != null) { - killer.killed(finalDeath); - } - if (mod.overrideMessages.get()) { - event.setNewMessage(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) { - 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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); - } - - private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - String inner = type.getInner(); - if (finalDeath) { - inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; - } else { - inner = "§7/" + inner + "/"; - } - String playerFormatted = getPlayerFormatted(player); - if (killer == null) { - return playerFormatted + " " + inner; - } - String killerFormatted = getPlayerFormatted(killer); - if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { - killerFormatted += " §6" + killer.getStats().getFinalKills(); - } - return playerFormatted + " " + inner + " " + killerFormatted; - } - - private String getPlayerFormatted(BedwarsPlayer player) { - return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); - } - - public boolean isTeamEliminated(BedwarsTeam team) { - return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); - } - - public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { - try { - if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { - event.setCancelled(true); - return; - } - 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 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(p -> disconnected(event, p)))) { - return; - } - 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 -> { - 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { - return; - } - upgrades.onMessage(rawMessage); - } catch (Exception e) { - debug("Error: " + e); - } - } - - 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(); - return; - } - - mc.inGameHud.getChatHud().addMessage( - new LiteralText("§8§m----------[§7Winstreaks§8]----------") - ); - for (BedwarsPlayer p : players.values()) { - if (p.getStats() != null && p.getStats().getWinstreak() > 0) { - 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 - )); - } - } - - BedwarsMod.getInstance().gameEnd(); - } - - 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(); - }); - if (mod.overrideMessages.get()) { - event.setNewMessage(new LiteralText(formatEliminated(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(); - } - if (mod.overrideMessages.get()) { - event.setNewMessage(new LiteralText(formatBed(team, breaker))); - } - } - - private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { - player.disconnected(); - if (mod.overrideMessages.get()) { - event.setNewMessage(new LiteralText(formatDisconnect(player))); - } - } - - - private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { - player.reconnected(); - if (mod.overrideMessages.get()) { - event.setNewMessage(new LiteralText(formatReconnect(player))); - } - } - - public void onScoreboardRender(ScoreboardRenderEvent event) { - Scoreboard scoreboard = event.getObjective().getScoreboard(); - Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); - 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) { - updateClock(); - } - topBarText = new LiteralText(calculateTopBarText()); - bottomBarText = new LiteralText(calculateBottomBarText()); - } - } - - private void updateClock() { - this.seconds++; - } - - public void tick() { - int currentTick = mc.inGameHud.getTicks(); - if (won != null && currentTick >= wonTick) { - gameEnd(won); - } - players.values().forEach(p -> p.tick(currentTick)); - } - - 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()); - } - - public BedwarsPlayer getSelf() { - return me; - } - - public String getLevelHead(AbstractClientPlayerEntity entity) { + 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; + + private final Map players = new HashMap<>(16); + private final Map playersById = new HashMap<>(16); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + 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("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + 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); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + public Text getTopBarText() { + return topBarText; + } + + public Text getBottomBarText() { + return bottomBarText; + } + + private String calculateTopBarText() { + return getFormattedTime(); + } + + private String calculateBottomBarText() { + return "Top 3 Killers: \n" + players.values().stream() + .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + .collect(Collectors.joining("\n")); + } + + public String getFormattedTime() { + 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(UUID uuid) { + return Optional.ofNullable(playersById.getOrDefault(uuid, null)); + } + + public Optional getPlayer(String name) { + return Optional.ofNullable(players.getOrDefault(name, null)); + } + + 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, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(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) { + 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 || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + 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 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(p -> disconnected(event, p)))) { + return; + } + 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 -> { + 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 (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + 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(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + new LiteralText("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + 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 + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + 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(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatEliminated(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(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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) { + updateClock(); + } + topBarText = new LiteralText(calculateTopBarText()); + bottomBarText = new LiteralText(calculateBottomBarText()); + } + } + + private void updateClock() { + this.seconds++; + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + 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()); + } + + public BedwarsPlayer getSelf() { + return me; + } + + public String getLevelHead(AbstractClientPlayerEntity entity) { BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); if (player == null) { return null; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index f44b425d6..e36cc5c70 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -22,6 +22,12 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -40,26 +46,20 @@ import net.minecraft.text.LiteralText; import net.minecraft.util.Formatting; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - /** * @author DarkKronicle */ public class BedwarsMod implements AbstractHypixelMod { - 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 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*?$") + }; @Getter - private static BedwarsMod instance = new BedwarsMod(); + private static BedwarsMod instance = new BedwarsMod(); @Getter private final OptionCategory category = new OptionCategory("bedwars"); @@ -90,20 +90,20 @@ public class BedwarsMod implements AbstractHypixelMod { private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); - protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); - private int targetTick = -1; - private boolean waiting = false; + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; - public BedwarsMod() { - upgradesOverlay = new TeamUpgradesOverlay(this); - } + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } - public String getDetail() { - return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); - } + public String getDetail() { + return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); + } - @Override - public void init() { + @Override + public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); @@ -115,46 +115,46 @@ public void init() { Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); } - public boolean isEnabled(){ + public boolean isEnabled() { return enabled.get(); } - public void onWorldLoad(WorldLoadEvent event) { - if (currentGame != null) { - gameEnd(); - } - } - - public boolean isWaiting() { - if (inGame()) { - waiting = false; - } - return waiting; - } - - public void onMessage(ReceiveChatMessageEvent event) { - // Remove formatting - String rawMessage = event.getFormattedMessage().asUnformattedString(); - if (currentGame != null) { - currentGame.onChatMessage(rawMessage, event); - String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; - if (!event.isCancelled() && showChatTime.get()) { - // Add time to every message received in game - if (event.getNewMessage() != null) { - event.setNewMessage(new LiteralText(time).append(event.getNewMessage())); - } else { - event.setNewMessage(new LiteralText(time).append(event.getFormattedMessage())); - } - } - } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { - // Give time for Hypixel to sync - targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; - } - } - - public Optional getGame() { - return currentGame == null ? Optional.empty() : Optional.of(currentGame); - } + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().asUnformattedString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(new LiteralText(time).append(event.getNewMessage())); + } else { + event.setNewMessage(new LiteralText(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } @Override public boolean tickable() { @@ -162,72 +162,72 @@ public boolean tickable() { } @Override - public void tick() { - if (currentGame != null) { - waiting = false; - if (currentGame.isStarted()) { - // Trigger setting the header - MinecraftClient.getInstance().inGameHud.getPlayerListWidget().setHeader(null); - currentGame.tick(); - } else { - if (checkReady()) { - currentGame.onStart(); - } - } - } else { - if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { - currentGame = new BedwarsGame(this); - targetTick = -1; - } - } - } - - private boolean checkReady() { - for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { - String name = MinecraftClient.getInstance().inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); - if (name.charAt(1) == ' ') { - return true; - } - } - return false; - } - - public boolean inGame() { - return currentGame != null && currentGame.isStarted(); - } - - public void onScoreboardRender(ScoreboardRenderEvent event) { - if (inGame()) { - waiting = false; - currentGame.onScoreboardRender(event); - return; - } - if (!Formatting.strip(event.getObjective().getDisplayName()).contains("BED WARS")) { - return; - } - Scoreboard scoreboard = event.getObjective().getScoreboard(); - Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); - 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() { - upgradesOverlay.onEnd(); - currentGame = null; - } - - public boolean blockLatencyIcon() { - return !tabRenderLatencyIcon.get(); - } - - private String getTranslationKey(String name){ - return "bedwars."+name; + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListWidget().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + 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() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java index 821912aff..c092237ca 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -29,133 +29,132 @@ import net.minecraft.client.network.PlayerListEntry; /** - * * @author DarkKronicle */ @Data public class BedwarsPlayer { - private final BedwarsTeam team; - @Getter - private PlayerListEntry profile; - private boolean alive = true; - 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) { - this.team = team; - this.profile = profile; - 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(); - } - - 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 || (!bed && isDisconnected()); - } - - public void tick(int currentTick) { - if (stats == null && !triedStats) { - triedStats = true; + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + 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) { + this.team = team; + this.profile = profile; + 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(); + } + + 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 || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; try { stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); } catch (Exception e) { stats = BedwarsPlayerStats.generateFake(); } - } - if (alive || tickAlive < 0) { - return; - } - if (currentTick >= tickAlive) { - alive = true; - tickAlive = -1; - } - } - - 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; - return; - } - int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); - tickAlive = currentTick + 20 * 5; // 5 second respawn - } - - public void disconnected() { - if (stats != null) { - if (!bed) { - stats.addFinalDeath(); - } else { - stats.addDeath(); - } - } - disconnected = true; - tickAlive = -1; - alive = false; - } - - public void reconnected() { - disconnected = false; - 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(); - } - stats.addKill(); - } - } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + 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; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + 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(); + } + stats.addKill(); + } + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 733f0f5e0..79fe21330 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -33,34 +33,33 @@ import net.minecraft.util.Identifier; /** - * * @author DarkKronicle */ public class TeamUpgradesOverlay extends BoxHudEntry { - public final static Identifier ID = new Identifier("axolotlclient","bedwars_teamupgrades"); + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); - private BedwarsTeamUpgrades upgrades = null; - private final BedwarsMod mod; - private final MinecraftClient mc; - private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; - public TeamUpgradesOverlay(BedwarsMod mod) { + public TeamUpgradesOverlay(BedwarsMod mod) { super(60, 40, true); this.mod = mod; - this.mc = MinecraftClient.getInstance(); - } + this.mc = MinecraftClient.getInstance(); + } - public void onStart(BedwarsTeamUpgrades newUpgrades) { - upgrades = newUpgrades; - } + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } - public void onEnd() { - upgrades = null; - } + public void onEnd() { + upgrades = null; + } - public void drawOverlay(DrawPosition position, boolean editMode) { + public void drawOverlay(DrawPosition position, boolean editMode) { if (upgrades == null && !editMode) { return; } @@ -96,7 +95,7 @@ public void drawOverlay(DrawPosition position, boolean editMode) { DrawableHelper.drawTexture(x, y, 0, 0, 16, 16, 16, 16); x += 17; } - } + } @Override public void renderComponent(float delta) { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index b96c5436d..f2cc5339b 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -55,7 +55,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static String modVersion; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static String modVersion; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { @@ -220,6 +221,4 @@ public void initRPC() { } - - } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/Util.java b/1.8.9/src/main/java/io/github/axolotlclient/util/Util.java index bbe430f75..d3e8b1d11 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/Util.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/Util.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.util; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Supplier; +import java.util.stream.Collectors; + import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import io.github.axolotlclient.mixin.MinecraftClientAccessor; @@ -37,11 +42,6 @@ import org.jetbrains.annotations.ApiStatus; import org.lwjgl.opengl.GL11; -import java.util.*; -import java.util.function.Consumer; -import java.util.function.Supplier; -import java.util.stream.Collectors; - public class Util { public static Color GlColor = new Color(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java index 551e09025..36ed807fa 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -22,12 +22,12 @@ package io.github.axolotlclient.util.events; +import java.util.Arrays; + import io.github.axolotlclient.util.events.impl.*; import net.legacyfabric.fabric.api.event.Event; import net.legacyfabric.fabric.api.event.EventFactory; -import java.util.Arrays; - public class Events { public static final Event> MOUSE_INPUT = createEvent(); @@ -38,7 +38,7 @@ public class Events { public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); public static final Event> WORLD_LOAD_EVENT = createEvent(); - private static Event> createEvent(){ + private static Event> createEvent() { return EventFactory .createArrayBacked(EventCallback.class, listeners -> (event) -> Arrays.stream(listeners).forEach(l -> l.invoke(event))); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java index 0ae92b634..c7518b5b8 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -24,6 +24,7 @@ import lombok.Data; import net.minecraft.client.option.KeyBinding; + @Data public class KeyPressEvent { diff --git a/README.md b/README.md index 2890a2fcd..a90993140 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A Complete (nearly) mod to have various features on various Minecraft versions -*Also available in other Languages: [Türkçe](doc/README-tr.md)* +*Also available in other Languages: [Türkçe](doc/README-tr.md), [Deutsch](doc/README-de.md)* ### Features @@ -16,42 +16,42 @@ A Complete (nearly) mod to have various features on various Minecraft versions - Screenshot Utils - Zoom - Various Hud Modules (port of [KronHUD](https://github.com/DarkKronicle/KronHUD), but with additions) - - including, but not limited to: - - Ping - - FPS - - CPS - - Armor - - Potions - - Keystrokes - - ToggleModifiers - - Server IP - - Icon - - Speed - - Scoreboard - - Crosshair - - Coordinates - - ActionBar - - BossBar - - Arrow - - Item Update - - Pack Display - - Real Time - - Reach - - Hotbar - - Memory - - PlayerCount - - Compass - - TPS (Ticks per second) - - Combo - - Player - - Chat + - including, but not limited to: + - Ping + - FPS + - CPS + - Armor + - Potions + - Keystrokes + - ToggleModifiers + - Server IP + - Icon + - Speed + - Scoreboard + - Crosshair + - Coordinates + - ActionBar + - BossBar + - Arrow + - Item Update + - Pack Display + - Real Time + - Reach + - Hotbar + - Memory + - PlayerCount + - Compass + - TPS (Ticks per second) + - Combo + - Player + - Chat - Hypixel Features - - AutoGG / GF / GLHF - - LevelHead - - Nick Hider - - Skyblock - - AutoTip - - AutoBoop + - AutoGG / GF / GLHF + - LevelHead + - Nick Hider + - Skyblock + - AutoTip + - AutoBoop - Custom Block Outlines - Time Changer - Fullbright @@ -75,9 +75,11 @@ A Complete (nearly) mod to have various features on various Minecraft versions - note your changes in CHANGELOG.md to be added to the next version's changelog. To build: + ``` ./gradlew build ``` + Use `-Paxolotlclient.modules.=true` to add a version to the build. Add `-Paxolotlclient.modules.all=true` to build everything. In case you use an IDE, you can also add the respective properties to `gradle.properties` files (or remove them). diff --git a/common/build.gradle b/common/build.gradle index 8bb8eaf9c..85831d8ae 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -32,7 +32,7 @@ repositories { } dependencies { - implementation 'org.jetbrains:annotations:24.0.0' + implementation 'org.jetbrains:annotations:24.0.0' // take the oldest version just to build against compileOnly("io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}") diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java index 3be664d49..e23145733 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java @@ -64,8 +64,8 @@ public static boolean hasValidAPIKey() { return validApiKey; } - public static JsonElement getPlayerProperty(String uuid, String stat){ - if(loadPlayerDataIfAbsent(uuid)){ + public static JsonElement getPlayerProperty(String uuid, String stat) { + if (loadPlayerDataIfAbsent(uuid)) { return getPlayer(uuid).getProperty(stat); } return new JsonObject(); @@ -94,13 +94,13 @@ public static int getPlayerLevel(String uuid, String mode) { return 0; } - private static PlayerReply.Player getPlayer(String uuid){ + private static PlayerReply.Player getPlayer(String uuid) { if (api == null) { loadApiKey(); } if (loadPlayerDataIfAbsent(uuid)) { try { - return cachedPlayerData.get(uuid).get(1, TimeUnit.MICROSECONDS).getPlayer(); + return cachedPlayerData.get(uuid).get(1, TimeUnit.MICROSECONDS).getPlayer(); } catch (TimeoutException | InterruptedException | ExecutionException ignored) { } } diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java index 76945484a..6928af22b 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -22,45 +22,45 @@ package io.github.axolotlclient.modules.hypixel.bedwars; -import lombok.AllArgsConstructor; -import lombok.Getter; - import java.util.regex.Matcher; import java.util.regex.Pattern; +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * @author DarkKronicle */ @AllArgsConstructor public enum BedwarsDeathType { - 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}), - ; + 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 String inner; - @Getter - private final Pattern[] patterns; + @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 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 { + public interface BedwarsDeathMatch { - void onMatch(BedwarsDeathType type, Matcher matcher); + void onMatch(BedwarsDeathType type, Matcher matcher); - } + } } diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java index 7a3c97a0f..33e646e5b 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.modules.hypixel.bedwars; import java.util.Arrays; @@ -18,7 +40,9 @@ public enum BedwarsLevelHeadMode { LOSSES(stats -> "§7Losses: §f" + stats.getLosses()), WINS(stats -> "§7Wins: §f" + stats.getWins()), WINSTREAK(stats -> "§7Winstreak: §f" + stats.getWinstreak()), - STARS(stats -> "§7Stars: §f" + stats.getStars()); + STARS(stats -> "§7Stars: §f" + stats.getStars()), + FKDR(stats -> "§7FKDR: §f" + stats.getFKDR()), + BBLR(stats -> "§7BBLR: §f" + stats.getFKDR()); private final Function titleSupplier; diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java index 6698b8dd0..afdaaa861 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -34,279 +34,279 @@ 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[] 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[] 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[] 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} 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}.", - "{killed} was knocked into the void 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} 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}.", + "{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[] 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}")), - Pattern.compile(formatPlaceholder("Bed was destroyed by {player}")), - }; + 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}")), + Pattern.compile(formatPlaceholder("Bed was destroyed 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 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 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 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 will respawn in \\d* second!$"), - 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"), - Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), - }; + 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!"), + Pattern.compile("^\\+\\d+ coins!"), + 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) { - return Arrays.stream(input).map(str -> Pattern.compile("^" + formatPlaceholder(str) + "(?: FINAL KILL!)?\\s*?")).toArray(Pattern[]::new); - } + 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,]+"); - } + 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 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) { + 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 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/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java index 6a6ebafb9..511145cc4 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java @@ -29,17 +29,17 @@ */ 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); + 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; + @Getter + private final BedwarsTeam[] teams; - BedwarsMode(BedwarsTeam... teams) { - this.teams = teams; - } + BedwarsMode(BedwarsTeam... teams) { + this.teams = teams; + } } diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java index ab5d906db..337a46afd 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -36,135 +36,135 @@ @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 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, - 0, - 0, - 0, - 0, - 0, - 1 - ); - } - - @Nullable - public static BedwarsPlayerStats fromAPI(String uuid) { - JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); - JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); - 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) { - if (obj.has(key)) { - try { - return obj.get(key).getAsInt(); - } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { - // Not actually an int - } - } - return other; - } - - public 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++; - gameDeaths++; - } - - public void addFinalDeath() { - finalDeaths++; - gameFinalDeaths++; - } - - public void addKill() { - kills++; - gameKills++; - } - - public void addFinalKill() { - finalKills++; - gameFinalKills++; - } - - public void addBed() { - bedsBroken++; - gameBedsBroken++; - } - - public float getFKDR() { - return (float) finalKills / finalDeaths; - } - - public float getBBLR() { - return (float) bedsBroken / losses; - } + @Getter + private int finalKills; + @Getter + private int finalDeaths; + @Getter + private int bedsBroken; + @Getter + private int deaths; + @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, + 0, + 0, + 0, + 0, + 0, + 1 + ); + } + + @Nullable + public static BedwarsPlayerStats fromAPI(String uuid) { + JsonElement rawStats = HypixelAbstractionLayer.getPlayerProperty(uuid, "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); + JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); + 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) { + if (obj.has(key)) { + try { + return obj.get(key).getAsInt(); + } catch (NumberFormatException | UnsupportedOperationException | IllegalStateException e) { + // Not actually an int + } + } + return other; + } + + public 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++; + gameDeaths++; + } + + public void addFinalDeath() { + finalDeaths++; + gameFinalDeaths++; + } + + public void addKill() { + kills++; + gameKills++; + } + + public void addFinalKill() { + finalKills++; + gameFinalKills++; + } + + public void addBed() { + bedsBroken++; + gameBedsBroken++; + } + + public float getFKDR() { + return (float) finalKills / finalDeaths; + } + + public float getBBLR() { + return (float) bedsBroken / losses; + } } diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java index 035e42430..f2e00ac1c 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsTeam.java @@ -22,58 +22,58 @@ package io.github.axolotlclient.modules.hypixel.bedwars; -import lombok.AllArgsConstructor; -import lombok.Getter; - import java.util.Locale; import java.util.Optional; +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * @author DarkKronicle */ @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'), + AQUA('b', 'A'), + WHITE('f', 'W'), + PINK('d', 'P'), + GRAY('8', 'S'), + ; - @Getter - private final char code; + @Getter + private final char code; - @Getter - private final char prefix; + @Getter + private final char prefix; - public String getColorSection() { - return "§" + code; - } + public String getColorSection() { + return "§" + code; + } - public static Optional fromPrefix(char prefix) { - for (BedwarsTeam t : values()) { - if (t.getPrefix() == prefix) { - return Optional.of(t); - } - } - return Optional.empty(); - } + public static Optional fromPrefix(char prefix) { + for (BedwarsTeam t : values()) { + if (t.getPrefix() == prefix) { + return Optional.of(t); + } + } + 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(); - } + public static Optional fromName(String name) { + for (BedwarsTeam t : values()) { + if (name.equalsIgnoreCase(t.name())) { + return Optional.of(t); + } + } + return Optional.empty(); + } - public String getName() { - return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); - } + public String getName() { + return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); + } } diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java index bfd8eabda..8232a301d 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -22,11 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; - import java.util.regex.Matcher; import java.util.regex.Pattern; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; + /** * @author DarkKronicle */ diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java index 78126e8cd..7e5d19ea0 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -22,13 +22,13 @@ package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; import lombok.Getter; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * @author DarkKronicle */ diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java index a1bda0577..5bf094ed4 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -22,12 +22,12 @@ package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.Getter; - import java.util.regex.Matcher; import java.util.regex.Pattern; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + /** * @author DarkKronicle */ diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 4c56947f1..7a39ef970 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; -import lombok.AllArgsConstructor; -import lombok.Getter; - import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * @author DarkKronicle */ diff --git a/common/src/main/resources/assets/axolotlclient/lang/en_us.json b/common/src/main/resources/assets/axolotlclient/lang/en_us.json index d53bce3fe..61c3a09d0 100644 --- a/common/src/main/resources/assets/axolotlclient/lang/en_us.json +++ b/common/src/main/resources/assets/axolotlclient/lang/en_us.json @@ -399,5 +399,7 @@ "LOSSES": "Losses", "WINS": "Wins", "WINSTREAK": "Winstreak", - "STARS": "Stars" + "STARS": "Stars", + "FKDR": "Final Kill/Lose Ratio", + "BBLR": "Bed Break/Lose Ratio" } diff --git a/doc/README-de.md b/doc/README-de.md index a5f5031ab..c3783beea 100644 --- a/doc/README-de.md +++ b/doc/README-de.md @@ -16,42 +16,42 @@ Ein (fast) vollständiger mod mit verschiedene Funktionen auf verschiedenen Mine - Screenshot Werkzeuge - Zoom - Verschiede Hud Module (teile von [KronHUD](https://github.com/DarkKronicle/KronHUD), aber mit zusätzlichen Funktionen) - - zusätzlich, aber nich aussschließlich: - - Ping - - FPS - - CPS - - Rüstung - - Tränke - - Tastenanschläge - - ToggleModifiers - - Server IP - - Icon - - Geschwindigkeit - - Scoreboard - - Fadenkreuz - - Koordinaten - - Aktions Anzeige - - Boss Anzeige - - Pfeile - - Item Update - - Pack Anzeige - - Echtzeit - - Reichweite - - Hotbar - - Speicher - - Spielerzahl - - Kompass - - TPS (Ticks pro Sekunde) - - Combo - - Spieler - - Chat + - zusätzlich, aber nicht aussschließlich: + - Ping + - FPS + - CPS + - Rüstung + - Tränke + - Tastenanschläge + - ToggleModifiers + - Server IP + - Icon + - Geschwindigkeit + - Scoreboard + - Fadenkreuz + - Koordinaten + - Aktions Anzeige + - Boss Anzeige + - Pfeile + - Item Update + - Pack Anzeige + - Echtzeit + - Reichweite + - Hotbar + - Speicher + - Spielerzahl + - Kompass + - TPS (Ticks pro Sekunde) + - Combo + - Spieler + - Chat - Hypixel Funktionen - - AutoGG / GF / GLHF - - LevelHead - - Spitznamen Verstecker - - Skyblock - - Autotippen - - AutoBoop + - AutoGG / GF / GLHF + - LevelHead + - Spitznamen Verstecker + - Skyblock + - Autotippen + - AutoBoop - Eigene Blockränder - Zeitwechsler - Volle Helligkeit @@ -78,7 +78,7 @@ Ein (fast) vollständiger mod mit verschiedene Funktionen auf verschiedenen Mine - Dieser Mod ist lizensiert unter der LGPL-3.0 Lizenz. - Die deutsche Übersetzung des Lizenztextes unten ist nicht rechtlich bindend. - Die rechtlich bindende Version ist die [vollständige Englische Version](../LICENSE) + Die rechtlich bindende Version ist die [vollständige Englische Version](../LICENSE) ``` AxolotlClient-mod diff --git a/doc/README-tr.md b/doc/README-tr.md index 6b05ad0eb..1d5f20c65 100644 --- a/doc/README-tr.md +++ b/doc/README-tr.md @@ -9,19 +9,19 @@ Legacy Fabric 1.8.9'da çeşitli özelliklere sahip olmak için tamamlanmış (n - Bir Özel Gökyüzü uygulanımı - Zoom tuşu - çeşitli Arayüz modülleri ([KronHUD](https://github.com/DarkKronicle/KronHUD)'un bir alınımı) - - bunları içerir, ama bunlarla limitli değil: - - Sohbet - - Skor Tahtası - - CPS - - FPS - - Gecikme - - Can Barı Arayüzü - - Koordinatlar - - ve başka! + - bunları içerir, ama bunlarla limitli değil: + - Sohbet + - Skor Tahtası + - CPS + - FPS + - Gecikme + - Can Barı Arayüzü + - Koordinatlar + - ve başka! - Hypixel Modları - - OtomatikGG / GF / GLHF - - Seviye Etiketi - - Otomatik Bağış + - OtomatikGG / GF / GLHF + - Seviye Etiketi + - Otomatik Bağış - Özel Blok Anahatları - Discord RPC - Mod'u kullanan oyuncular için rozetler diff --git a/formatting.xml b/formatting.xml index 82de37f90..7eaa84fe1 100644 --- a/formatting.xml +++ b/formatting.xml @@ -1,225 +1,293 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle.properties b/gradle.properties index 39b74ba5a..23f369d11 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,10 +2,8 @@ org.gradle.jvmargs=-Xmx5G org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true - # change this line if you do not want to import all submodules: axolotlclient.modules.all=true - # Mod Properties version=3.0.4-darkkronicle-bedwars-overlay-beta.4 maven_group=io.github.axolotlclient diff --git a/settings.gradle b/settings.gradle index 9828c6d24..b0546d0c6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,14 +14,15 @@ pluginManagement { boolean checkProp(String property) { - String value = getProperties().get("axolotlclient.modules."+property) + String value = getProperties().get("axolotlclient.modules." + property) return !(value == null || value.isEmpty() || value == "false" || value == "f") } void optional(String project) { - if (checkProp(project) || checkProp("all")) - System.out.println("Adding "+project) + if (checkProp(project) || checkProp("all")) { + System.out.println("Adding " + project) include project + } } include 'common' From c347e597cd452f6001998c56f478a8bf479ba76e Mon Sep 17 00:00:00 2001 From: moehreag Date: Mon, 10 Jul 2023 19:15:42 +0200 Subject: [PATCH 14/41] add customisable death messages --- .../modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../modules/hypixel/bedwars/BedwarsMod.java | 1 + .../hypixel/bedwars/BedwarsDeathType.java | 30 ++++++++++++++----- .../assets/axolotlclient/lang/en_us.json | 10 ++++++- 16 files changed, 45 insertions(+), 16 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index caa5fa9ec..e39062d93 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -206,7 +206,7 @@ private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { } private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - String inner = type.getInner(); + String inner = type.getInner().get(); if (finalDeath) { inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; } else { diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 92e2c3321..db6cda13a 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -108,6 +108,7 @@ public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); instance = this; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 1e1b1ffb6..e4af00e3d 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -206,7 +206,7 @@ private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { } private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - String inner = type.getInner(); + String inner = type.getInner().get(); if (finalDeath) { inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; } else { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index d931286ac..cd304e33a 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -108,6 +108,7 @@ public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); instance = this; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 5356bc592..d4694da6d 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -206,7 +206,7 @@ private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { } private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - String inner = type.getInner(); + String inner = type.getInner().get(); if (finalDeath) { inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; } else { diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 976c8fe08..e8fd0c9c3 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -107,6 +107,7 @@ public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); instance = this; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 5356bc592..d4694da6d 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -206,7 +206,7 @@ private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { } private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - String inner = type.getInner(); + String inner = type.getInner().get(); if (finalDeath) { inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; } else { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 976c8fe08..e8fd0c9c3 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -107,6 +107,7 @@ public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); instance = this; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index a2426e751..51a220d15 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -205,7 +205,7 @@ private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { } private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - String inner = type.getInner(); + String inner = type.getInner().get(); if (finalDeath) { inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; } else { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 976c8fe08..e8fd0c9c3 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -107,6 +107,7 @@ public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); instance = this; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index a2426e751..51a220d15 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -205,7 +205,7 @@ private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { } private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - String inner = type.getInner(); + String inner = type.getInner().get(); if (finalDeath) { inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; } else { diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 976c8fe08..e8fd0c9c3 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -107,6 +107,7 @@ public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); instance = this; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 2c0514861..9ef7787b6 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -206,7 +206,7 @@ private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { } private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { - String inner = type.getInner(); + String inner = type.getInner().get(); if (finalDeath) { inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; } else { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index e36cc5c70..ec4c5ef19 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -107,6 +107,7 @@ public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); instance = this; diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java index 6928af22b..404712016 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -22,9 +22,12 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import lombok.AllArgsConstructor; import lombok.Getter; @@ -34,17 +37,17 @@ @AllArgsConstructor public enum BedwarsDeathType { - 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}), + COMBAT(createOption("combat", "rekt"), BedwarsMessages.COMBAT_KILL), + VOID(createOption("void","yeeted into void"), BedwarsMessages.VOID_KILL), + PROJECTILE(createOption("projectile","shot"), BedwarsMessages.PROJECTILE_KILL), + FALL(createOption("fall","fall"), BedwarsMessages.FALL_KILL), + GOLEM(createOption("golem","golem moment"), BedwarsMessages.GOLEM_KILL), + SELF_VOID(createOption("self_void","voided"), new Pattern[]{BedwarsMessages.SELF_VOID}), + SELF_UNKNOWN(createOption("self_unknown","died"), new Pattern[]{BedwarsMessages.SELF_UNKNOWN}), ; @Getter - private final String inner; + private final StringOption inner; @Getter private final Pattern[] patterns; @@ -63,4 +66,15 @@ public interface BedwarsDeathMatch { void onMatch(BedwarsDeathType type, Matcher matcher); } + + private static StringOption createOption(String type, String def){ + return new StringOption("bedwars.deathType."+type, def); + } + + @Getter + private static final OptionCategory options = new OptionCategory("bedwars.deathType"); + + static { + Arrays.stream(values()).map(BedwarsDeathType::getInner).forEach(options::add); + } } diff --git a/common/src/main/resources/assets/axolotlclient/lang/en_us.json b/common/src/main/resources/assets/axolotlclient/lang/en_us.json index 61c3a09d0..3e20d6322 100644 --- a/common/src/main/resources/assets/axolotlclient/lang/en_us.json +++ b/common/src/main/resources/assets/axolotlclient/lang/en_us.json @@ -401,5 +401,13 @@ "WINSTREAK": "Winstreak", "STARS": "Stars", "FKDR": "Final Kill/Lose Ratio", - "BBLR": "Bed Break/Lose Ratio" + "BBLR": "Bed Break/Lose Ratio", + "bedwars.deathType": "Death Messages", + "bedwars.deathType.combat": "Combat", + "bedwars.deathType.void": "Void", + "bedwars.deathType.projectile": "Projectiles", + "bedwars.deathType.fall": "Fall", + "bedwars.deathType.golem": "Golems", + "bedwars.deathType.self_void": "Void (Self)", + "bedwars.deathType.self_unknown": "Unknown (Self)" } From 8e2609ecbac11668957db194f3c163a619bada1a Mon Sep 17 00:00:00 2001 From: moehreag Date: Mon, 10 Jul 2023 20:01:49 +0200 Subject: [PATCH 15/41] add credits --- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 3 ++- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 3 ++- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 3 ++- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 3 ++- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 3 ++- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 3 ++- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 7bb9bbadd..ccbbd4f09 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -167,11 +167,12 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 7bb9bbadd..ccbbd4f09 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -167,11 +167,12 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 8403295f0..3fbf6a051 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -163,11 +163,12 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index a19f93005..64589d2c6 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -161,11 +161,12 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 8d8975673..5aafbeb36 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -162,11 +162,12 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 43b2ac491..9bb78fdda 100644 --- a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -161,11 +161,12 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index de4b3b169..b6dacf31b 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -250,11 +250,12 @@ private void initCredits() { credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); credits.add(new Credit("CornetPanique86", "French Translation")); credits.add(new Credit("kuchenag", "Logo/Icon Creator")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { From 169814dad88f79faaa1134d331b00c94592e626c Mon Sep 17 00:00:00 2001 From: moehreag Date: Mon, 10 Jul 2023 22:25:13 +0200 Subject: [PATCH 16/41] fix a bug, add option to usually hide the hud --- .../hypixel/bedwars/TeamUpgradesOverlay.java | 26 +++++++++++++++---- .../hypixel/bedwars/TeamUpgradesOverlay.java | 26 +++++++++++++++---- .../hypixel/bedwars/TeamUpgradesOverlay.java | 26 +++++++++++++++---- .../hypixel/bedwars/TeamUpgradesOverlay.java | 26 +++++++++++++++---- .../hypixel/bedwars/TeamUpgradesOverlay.java | 26 +++++++++++++++---- .../config/screen/CreditsScreen.java | 9 +------ .../hypixel/bedwars/TeamUpgradesOverlay.java | 26 +++++++++++++++---- .../hypixel/bedwars/TeamUpgradesOverlay.java | 25 ++++++++++++++---- .../hypixel/bedwars/BedwarsDeathType.java | 2 +- .../assets/axolotlclient/lang/en_us.json | 3 ++- gradle.properties | 2 +- 11 files changed, 151 insertions(+), 46 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 86885fa6e..71b82c967 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -22,7 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; @@ -41,6 +45,8 @@ public class TeamUpgradesOverlay extends BoxHudEntry { public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final MinecraftClient mc; @@ -60,6 +66,13 @@ public void onEnd() { upgrades = null; } + @Override + public void render(MatrixStack matrices, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(matrices, delta); + } + } + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { if (upgrades == null && !editMode) { return; @@ -100,11 +113,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo @Override public void renderComponent(MatrixStack stack, float delta) { - if (mod.isWaiting()) { - - } else { - drawOverlay(stack, getPos(), false); - } + drawOverlay(stack, getPos(), false); } @Override @@ -116,4 +125,11 @@ public void renderPlaceholderComponent(MatrixStack stack, float delta) { public Identifier getId() { return ID; } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 86885fa6e..71b82c967 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -22,7 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; @@ -41,6 +45,8 @@ public class TeamUpgradesOverlay extends BoxHudEntry { public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final MinecraftClient mc; @@ -60,6 +66,13 @@ public void onEnd() { upgrades = null; } + @Override + public void render(MatrixStack matrices, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(matrices, delta); + } + } + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { if (upgrades == null && !editMode) { return; @@ -100,11 +113,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo @Override public void renderComponent(MatrixStack stack, float delta) { - if (mod.isWaiting()) { - - } else { - drawOverlay(stack, getPos(), false); - } + drawOverlay(stack, getPos(), false); } @Override @@ -116,4 +125,11 @@ public void renderPlaceholderComponent(MatrixStack stack, float delta) { public Identifier getId() { return ID; } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 0d7e64aa5..64046bbab 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -22,7 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; @@ -41,6 +45,8 @@ public class TeamUpgradesOverlay extends BoxHudEntry { public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final MinecraftClient mc; @@ -60,6 +66,13 @@ public void onEnd() { upgrades = null; } + @Override + public void render(MatrixStack matrices, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(matrices, delta); + } + } + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { if (upgrades == null && !editMode) { return; @@ -99,11 +112,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo @Override public void renderComponent(MatrixStack stack, float delta) { - if (mod.isWaiting()) { - - } else { - drawOverlay(stack, getPos(), false); - } + drawOverlay(stack, getPos(), false); } @Override @@ -115,4 +124,11 @@ public void renderPlaceholderComponent(MatrixStack stack, float delta) { public Identifier getId() { return ID; } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index cbcfcffc6..61f92a5c7 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -22,7 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; @@ -40,6 +44,8 @@ public class TeamUpgradesOverlay extends BoxHudEntry { public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; @@ -57,6 +63,13 @@ public void onEnd() { upgrades = null; } + @Override + public void render(MatrixStack matrices, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(matrices, delta); + } + } + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { if (upgrades == null && !editMode) { return; @@ -96,11 +109,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo @Override public void renderComponent(MatrixStack stack, float delta) { - if (mod.isWaiting()) { - - } else { - drawOverlay(stack, getPos(), false); - } + drawOverlay(stack, getPos(), false); } @Override @@ -112,4 +121,11 @@ public void renderPlaceholderComponent(MatrixStack stack, float delta) { public Identifier getId() { return ID; } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index cbcfcffc6..61f92a5c7 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -22,7 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; @@ -40,6 +44,8 @@ public class TeamUpgradesOverlay extends BoxHudEntry { public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; @@ -57,6 +63,13 @@ public void onEnd() { upgrades = null; } + @Override + public void render(MatrixStack matrices, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(matrices, delta); + } + } + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { if (upgrades == null && !editMode) { return; @@ -96,11 +109,7 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo @Override public void renderComponent(MatrixStack stack, float delta) { - if (mod.isWaiting()) { - - } else { - drawOverlay(stack, getPos(), false); - } + drawOverlay(stack, getPos(), false); } @Override @@ -112,4 +121,11 @@ public void renderPlaceholderComponent(MatrixStack stack, float delta) { public Identifier getId() { return ID; } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 9bb78fdda..a4cc40c0b 100644 --- a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -271,14 +271,7 @@ public Credit(String name, String... things) { public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { if (hovered || c.isFocused()) { - RenderUtil.drawVerticalLine(graphics, x - 100, y, y + 20, - Color.ERROR.getAsInt()); - RenderUtil.drawVerticalLine(graphics, x + 100, y, y + 20, - Color.ERROR.getAsInt()); - RenderUtil.drawHorizontalLine(graphics, x - 100, y + 20, x + 100, - Color.ERROR.getAsInt()); - RenderUtil.drawHorizontalLine(graphics, x - 100, y, x + 100, - Color.ERROR.getAsInt()); + RenderUtil.drawOutline(graphics, x-100, y, 200, 20, Color.ERROR.getAsInt()); } this.hovered = hovered; DrawUtil.drawCenteredString(graphics, MinecraftClient.getInstance().textRenderer, name, x, y + 5, diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index ac3c49de3..3c2e45196 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -22,7 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; @@ -40,6 +44,8 @@ public class TeamUpgradesOverlay extends BoxHudEntry { public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final MinecraftClient mc; @@ -59,6 +65,13 @@ public void onEnd() { upgrades = null; } + @Override + public void render(GuiGraphics graphics, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(graphics, delta); + } + } + public void drawOverlay(GuiGraphics graphics, DrawPosition position, boolean editMode) { if (upgrades == null && !editMode) { return; @@ -96,11 +109,7 @@ public void drawOverlay(GuiGraphics graphics, DrawPosition position, boolean edi @Override public void renderComponent(GuiGraphics stack, float delta) { - if (mod.isWaiting()) { - - } else { - drawOverlay(stack, getPos(), false); - } + drawOverlay(stack, getPos(), false); } @Override @@ -112,4 +121,11 @@ public void renderPlaceholderComponent(GuiGraphics stack, float delta) { public Identifier getId() { return ID; } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 79fe21330..9641da82c 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -22,7 +22,11 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; @@ -39,6 +43,7 @@ public class TeamUpgradesOverlay extends BoxHudEntry { public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; @@ -59,6 +64,13 @@ public void onEnd() { upgrades = null; } + @Override + public void render(float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(delta); + } + } + public void drawOverlay(DrawPosition position, boolean editMode) { if (upgrades == null && !editMode) { return; @@ -99,11 +111,7 @@ public void drawOverlay(DrawPosition position, boolean editMode) { @Override public void renderComponent(float delta) { - if (mod.isWaiting()) { - - } else { - drawOverlay(getPos(), false); - } + drawOverlay(getPos(), false); } @Override @@ -115,4 +123,11 @@ public void renderPlaceholderComponent(float delta) { public Identifier getId() { return ID; } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } } diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java index 404712016..f17e347aa 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -43,7 +43,7 @@ public enum BedwarsDeathType { FALL(createOption("fall","fall"), BedwarsMessages.FALL_KILL), GOLEM(createOption("golem","golem moment"), BedwarsMessages.GOLEM_KILL), SELF_VOID(createOption("self_void","voided"), new Pattern[]{BedwarsMessages.SELF_VOID}), - SELF_UNKNOWN(createOption("self_unknown","died"), new Pattern[]{BedwarsMessages.SELF_UNKNOWN}), + SELF_UNKNOWN(createOption("self_unknown","died"), new Pattern[]{BedwarsMessages.SELF_UNKNOWN}) ; @Getter diff --git a/common/src/main/resources/assets/axolotlclient/lang/en_us.json b/common/src/main/resources/assets/axolotlclient/lang/en_us.json index 3e20d6322..b354b4fa8 100644 --- a/common/src/main/resources/assets/axolotlclient/lang/en_us.json +++ b/common/src/main/resources/assets/axolotlclient/lang/en_us.json @@ -409,5 +409,6 @@ "bedwars.deathType.fall": "Fall", "bedwars.deathType.golem": "Golems", "bedwars.deathType.self_void": "Void (Self)", - "bedwars.deathType.self_unknown": "Unknown (Self)" + "bedwars.deathType.self_unknown": "Unknown (Self)", + "bedwars_teamupgrades.renderWhenRelevant": "Only Render When Relevant" } diff --git a/gradle.properties b/gradle.properties index 23f369d11..542d04e5a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ fabric.loom.multiProjectOptimisation=true # change this line if you do not want to import all submodules: axolotlclient.modules.all=true # Mod Properties -version=3.0.4-darkkronicle-bedwars-overlay-beta.4 +version=3.0.4-darkkronicle-bedwars-overlay-beta.5 maven_group=io.github.axolotlclient archives_base_name=AxolotlClient minecraft_1192=1.19.2 From 1f15b11edde76819241717924ba6bd60c43fbb96 Mon Sep 17 00:00:00 2001 From: moehreag Date: Tue, 11 Jul 2023 17:55:52 +0200 Subject: [PATCH 17/41] re-use original footer - modify credits for Sybillian to match what is probably expected by them --- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 2 +- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 4 ++-- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 2 +- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 4 ++-- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 2 +- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 4 ++-- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 2 +- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 4 ++-- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 2 +- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 4 ++-- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 2 +- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 4 ++-- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 2 +- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 4 ++-- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 5 +++-- 15 files changed, 24 insertions(+), 23 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index ccbbd4f09..9b197b752 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -171,7 +171,7 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 8c5f4f8b2..bb9edb1b6 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -310,11 +310,11 @@ public abstract class PlayerListHudMixin { } @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) - public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); ci.cancel(); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index ccbbd4f09..9b197b752 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -171,7 +171,7 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 25c14709f..a421bbfa8 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -313,11 +313,11 @@ public abstract class PlayerListHudMixin { } @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) - public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); ci.cancel(); } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 3fbf6a051..5478650ac 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -167,7 +167,7 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 3d6e3eba1..055ba9878 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -307,11 +307,11 @@ public abstract class PlayerListHudMixin { } @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) - public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); ci.cancel(); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 64589d2c6..84bca8708 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -165,7 +165,7 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index b1c18a471..f03366fcf 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -306,11 +306,11 @@ public abstract class PlayerListHudMixin { } @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) - public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); ci.cancel(); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 5aafbeb36..2af569b83 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -166,7 +166,7 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index feac351ba..32f2185e3 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -306,11 +306,11 @@ public abstract class PlayerListHudMixin { } @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) - public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); ci.cancel(); } } diff --git a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index a4cc40c0b..bd1a2a79c 100644 --- a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -165,7 +165,7 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 83f77bf3b..5f64acdaa 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -306,11 +306,11 @@ public abstract class PlayerListHudMixin { } @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) - public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); ci.cancel(); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index b6dacf31b..4bc6576c5 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -254,7 +254,7 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://github.com/sybillian")); + credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 2e68965c7..33447b425 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -294,11 +294,11 @@ public abstract class PlayerListHudMixin extends DrawableHelper { } @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) - public void axolotlclient$changeFooter(Text header, CallbackInfo ci) { + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().append("\n").append(footer); ci.cancel(); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 9ef7787b6..b5f81e375 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -121,9 +121,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { + Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); return "Top 3 Killers: \n" + players.values().stream() - .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) - .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) .collect(Collectors.joining("\n")); } From acf0abb9e8c737f97b01df938ef9da67c2e0b6f8 Mon Sep 17 00:00:00 2001 From: moehreag Date: Wed, 12 Jul 2023 01:02:31 +0200 Subject: [PATCH 18/41] use vanilla textures instead of custom ones - advantages: easy replacement through resourcepacks - disadvantages: *slightly* more messy code --- .../hypixel/bedwars/TeamUpgradesOverlay.java | 27 ++-- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 32 ++++- .../hypixel/bedwars/upgrades/TrapUpgrade.java | 19 +-- .../hypixel/bedwars/TeamUpgradesOverlay.java | 27 ++-- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 100 ++++++++++++++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 130 ++++++++++++++++++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 19 ++- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 100 ++++++++++++++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 130 ++++++++++++++++++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 19 ++- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 100 ++++++++++++++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 130 ++++++++++++++++++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 19 ++- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 100 ++++++++++++++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 130 ++++++++++++++++++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 15 +- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 100 ++++++++++++++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 130 ++++++++++++++++++ .../hypixel/bedwars/TeamUpgradesOverlay.java | 20 ++- .../bedwars/upgrades/BedwarsTeamUpgrades.java | 100 ++++++++++++++ .../hypixel/bedwars/upgrades/TrapUpgrade.java | 130 ++++++++++++++++++ .../bedwars/upgrades/BinaryUpgrade.java | 10 +- .../hypixel/bedwars/upgrades/TeamUpgrade.java | 2 +- .../hypixel/bedwars/upgrades/TextureInfo.java | 77 +++++++++++ .../bedwars/upgrades/TieredUpgrade.java | 9 +- .../textures/bedwars/dragonbuff_0.png | Bin 291 -> 0 bytes .../textures/bedwars/dragonbuff_1.png | Bin 291 -> 0 bytes .../textures/bedwars/forge_0.png | Bin 255 -> 0 bytes .../textures/bedwars/forge_1.png | Bin 255 -> 0 bytes .../textures/bedwars/forge_2.png | Bin 255 -> 0 bytes .../textures/bedwars/forge_3.png | Bin 255 -> 0 bytes .../textures/bedwars/forge_4.png | Bin 255 -> 0 bytes .../textures/bedwars/haste_0.png | Bin 269 -> 0 bytes .../textures/bedwars/haste_1.png | Bin 269 -> 0 bytes .../textures/bedwars/haste_2.png | Bin 269 -> 0 bytes .../textures/bedwars/healpool_0.png | Bin 223 -> 0 bytes .../textures/bedwars/healpool_1.png | Bin 223 -> 0 bytes .../axolotlclient/textures/bedwars/note.txt | 1 - .../axolotlclient/textures/bedwars/prot_0.png | Bin 245 -> 0 bytes .../axolotlclient/textures/bedwars/prot_1.png | Bin 266 -> 0 bytes .../axolotlclient/textures/bedwars/prot_2.png | Bin 272 -> 0 bytes .../axolotlclient/textures/bedwars/prot_3.png | Bin 264 -> 0 bytes .../axolotlclient/textures/bedwars/prot_4.png | Bin 245 -> 0 bytes .../textures/bedwars/sharp_0.png | Bin 255 -> 0 bytes .../textures/bedwars/sharp_1.png | Bin 255 -> 0 bytes .../textures/bedwars/trap/alarm.png | Bin 293 -> 0 bytes .../bedwars/trap/counteroffensive.png | Bin 304 -> 0 bytes .../textures/bedwars/trap/empty.png | Bin 228 -> 0 bytes .../textures/bedwars/trap/itsatrap.png | Bin 312 -> 0 bytes .../textures/bedwars/trap/minerfatigue.png | Bin 265 -> 0 bytes 50 files changed, 1598 insertions(+), 78 deletions(-) rename {common => 1.16.5}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java (56%) rename {common => 1.16.5}/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java (81%) create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java create mode 100644 common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TextureInfo.java delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/dragonbuff_0.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/dragonbuff_1.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_0.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_1.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_2.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_3.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_4.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_0.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_1.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_2.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/healpool_0.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/healpool_1.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/note.txt delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_0.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_1.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_2.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_3.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_4.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/sharp_0.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/sharp_1.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/alarm.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/counteroffensive.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/empty.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/itsatrap.png delete mode 100644 common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/minerfatigue.png diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 71b82c967..f150b14c3 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -24,13 +24,14 @@ import java.util.List; -import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; @@ -50,7 +51,7 @@ public class TeamUpgradesOverlay extends BoxHudEntry { private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final MinecraftClient mc; - private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; public TeamUpgradesOverlay(BedwarsMod mod) { super(60, 40, true); @@ -80,9 +81,9 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo int x = position.x() + 1; int y = position.y() + 2; - GlStateManager.enableAlphaTest(); - GlStateManager.enableBlend(); - GlStateManager.color4f(1, 1, 1, 1); + RenderSystem.enableAlphaTest(); + RenderSystem.enableBlend(); + RenderSystem.color4f(1, 1, 1, 1); boolean normalUpgrades = false; if (upgrades != null) { for (TeamUpgrade u : upgrades.upgrades) { @@ -92,10 +93,12 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo if (u instanceof TrapUpgrade) { continue; } - String texture; + TextureInfo texture; texture = u.getTexture()[0]; - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + RenderSystem.color4f(texture.getColor().getAlpha(), texture.getColor().getRed(), texture.getColor().getBlue(), texture.getColor().getGreen()); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.color4f(1, 1, 1, 1); x += 17; normalUpgrades = true; } @@ -104,9 +107,11 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo if (normalUpgrades) { y += 17; } - for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.color4f(texture.getColor().getAlpha(), texture.getColor().getRed(), texture.getColor().getBlue(), texture.getColor().getGreen()); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.color4f(1, 1, 1, 1); x += 17; } } diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java similarity index 56% rename from common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java rename to 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java index 156a7f31d..45b5b26c5 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -25,6 +25,8 @@ import java.util.regex.Pattern; +import io.github.axolotlclient.AxolotlClientConfig.Color; + /** * @author DarkKronicle */ @@ -35,32 +37,50 @@ public class BedwarsTeamUpgrades { public final TeamUpgrade sharpness = new BinaryUpgrade( "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords"), - 8, 4 + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") ); public final TeamUpgrade dragonBuff = new BinaryUpgrade( "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), - 5, 5 + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") ); public final TeamUpgrade healPool = new BinaryUpgrade( "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), - 3, 1 + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) ); public final TeamUpgrade protection = new TieredUpgrade( "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} + new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } ); public final TeamUpgrade maniacMiner = new TieredUpgrade( "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} + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } ); 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} + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } ); public final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java similarity index 81% rename from common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java rename to 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 7a39ef970..6701c7541 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -28,6 +28,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; import lombok.AllArgsConstructor; import lombok.Getter; @@ -85,14 +86,14 @@ public boolean isPurchased() { } @Override - public String[] getTexture() { + public TextureInfo[] getTexture() { if (traps.size() == 0) { - return new String[]{"trap/empty"}; + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; } - String[] trapTextures = new String[traps.size()]; + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; for (int i = 0; i < traps.size(); i++) { TrapType type = traps.get(i); - trapTextures[i] = "trap/" + type.getTextureName(); + trapTextures[i] = type.getTexInfo(); } return trapTextures; } @@ -104,13 +105,13 @@ public boolean isMultiUpgrade() { @AllArgsConstructor public enum TrapType { - ITS_A_TRAP("itsatrap"), - COUNTER_OFFENSIVE("counteroffensive"), - ALARM("alarm"), - MINER_FATIGUE("minerfatigue"); + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); @Getter - private final String textureName; + private final TextureInfo texInfo; public static TrapType getFuzzy(String s) { s = s.toLowerCase(Locale.ROOT); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 71b82c967..f150b14c3 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -24,13 +24,14 @@ import java.util.List; -import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; @@ -50,7 +51,7 @@ public class TeamUpgradesOverlay extends BoxHudEntry { private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final MinecraftClient mc; - private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; public TeamUpgradesOverlay(BedwarsMod mod) { super(60, 40, true); @@ -80,9 +81,9 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo int x = position.x() + 1; int y = position.y() + 2; - GlStateManager.enableAlphaTest(); - GlStateManager.enableBlend(); - GlStateManager.color4f(1, 1, 1, 1); + RenderSystem.enableAlphaTest(); + RenderSystem.enableBlend(); + RenderSystem.color4f(1, 1, 1, 1); boolean normalUpgrades = false; if (upgrades != null) { for (TeamUpgrade u : upgrades.upgrades) { @@ -92,10 +93,12 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo if (u instanceof TrapUpgrade) { continue; } - String texture; + TextureInfo texture; texture = u.getTexture()[0]; - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + RenderSystem.color4f(texture.getColor().getAlpha(), texture.getColor().getRed(), texture.getColor().getBlue(), texture.getColor().getGreen()); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.color4f(1, 1, 1, 1); x += 17; normalUpgrades = true; } @@ -104,9 +107,11 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo if (normalUpgrades) { y += 17; } - for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.color4f(texture.getColor().getAlpha(), texture.getColor().getRed(), texture.getColor().getBlue(), texture.getColor().getGreen()); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.color4f(1, 1, 1, 1); x += 17; } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..45b5b26c5 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + 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}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public 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/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..6701c7541 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,130 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + 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; + } + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 64046bbab..a1b76928e 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -31,6 +31,7 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; @@ -50,7 +51,7 @@ public class TeamUpgradesOverlay extends BoxHudEntry { private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final MinecraftClient mc; - private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; public TeamUpgradesOverlay(BedwarsMod mod) { super(60, 40, true); @@ -91,10 +92,12 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo if (u instanceof TrapUpgrade) { continue; } - String texture; + TextureInfo texture; texture = u.getTexture()[0]; - RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); x += 17; normalUpgrades = true; } @@ -103,9 +106,11 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo if (normalUpgrades) { y += 17; } - for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); x += 17; } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..45b5b26c5 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + 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}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public 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/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..6701c7541 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,130 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + 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; + } + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 61f92a5c7..d06f0280f 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -31,6 +31,7 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.util.math.MatrixStack; @@ -48,7 +49,7 @@ public class TeamUpgradesOverlay extends BoxHudEntry { private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; - private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; public TeamUpgradesOverlay(BedwarsMod mod) { super(60, 40, true); @@ -88,10 +89,12 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo if (u instanceof TrapUpgrade) { continue; } - String texture; + TextureInfo texture; texture = u.getTexture()[0]; - RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); x += 17; normalUpgrades = true; } @@ -100,9 +103,11 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo if (normalUpgrades) { y += 17; } - for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); x += 17; } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..45b5b26c5 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + 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}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public 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/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..6701c7541 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,130 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + 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; + } + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 61f92a5c7..d06f0280f 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -31,6 +31,7 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.util.math.MatrixStack; @@ -48,7 +49,7 @@ public class TeamUpgradesOverlay extends BoxHudEntry { private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; - private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; public TeamUpgradesOverlay(BedwarsMod mod) { super(60, 40, true); @@ -88,10 +89,12 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo if (u instanceof TrapUpgrade) { continue; } - String texture; + TextureInfo texture; texture = u.getTexture()[0]; - RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); x += 17; normalUpgrades = true; } @@ -100,9 +103,11 @@ public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMo if (normalUpgrades) { y += 17; } - for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - RenderSystem.setShaderTexture(0, new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(stack, x, y, 0, 0, 16, 16, 16, 16); + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); x += 17; } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..45b5b26c5 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + 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}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public 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/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..6701c7541 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,130 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + 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; + } + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 3c2e45196..0537b7297 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -31,6 +31,7 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; @@ -49,7 +50,7 @@ public class TeamUpgradesOverlay extends BoxHudEntry { private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final MinecraftClient mc; - private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; public TeamUpgradesOverlay(BedwarsMod mod) { super(60, 40, true); @@ -90,9 +91,11 @@ public void drawOverlay(GuiGraphics graphics, DrawPosition position, boolean edi if (u instanceof TrapUpgrade) { continue; } - String texture; + TextureInfo texture; texture = u.getTexture()[0]; - graphics.drawTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png"), x, y, 0, 0, 16, 16, 16, 16); + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + graphics.drawTexture(new Identifier("minecraft", texture.getTexture()), x, y, 16, 16, texture.getU(), texture.getV(), texture.getWidth(), texture.getHeight(), texture.getRegionWidth(), texture.getRegionHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); x += 17; normalUpgrades = true; } @@ -101,8 +104,10 @@ public void drawOverlay(GuiGraphics graphics, DrawPosition position, boolean edi if (normalUpgrades) { y += 17; } - for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - graphics.drawTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png"), x, y, 0, 0, 16, 16, 16, 16); + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + graphics.drawTexture(new Identifier("minecraft", texture.getTexture()), x, y, 16, 16, texture.getU(), texture.getV(), texture.getWidth(), texture.getHeight(), texture.getRegionWidth(), texture.getRegionHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); x += 17; } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..45b5b26c5 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + 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}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public 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/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..6701c7541 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,130 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + 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; + } + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 9641da82c..301be6058 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -31,6 +31,7 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; @@ -48,7 +49,7 @@ public class TeamUpgradesOverlay extends BoxHudEntry { private BedwarsTeamUpgrades upgrades = null; private final BedwarsMod mod; private final MinecraftClient mc; - private final static String[] trapEdit = {"trap/minerfatigue", "trap/itsatrap"}; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; public TeamUpgradesOverlay(BedwarsMod mod) { super(60, 40, true); @@ -90,10 +91,12 @@ public void drawOverlay(DrawPosition position, boolean editMode) { if (u instanceof TrapUpgrade) { continue; } - String texture; + TextureInfo texture; texture = u.getTexture()[0]; - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(x, y, 0, 0, 16, 16, 16, 16); + GlStateManager.color(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + GlStateManager.color(1, 1, 1); x += 17; normalUpgrades = true; } @@ -102,9 +105,12 @@ public void drawOverlay(DrawPosition position, boolean editMode) { if (normalUpgrades) { y += 17; } - for (String texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { - mc.getTextureManager().bindTexture(new Identifier("axolotlclient", "textures/bedwars/" + texture + ".png")); - DrawableHelper.drawTexture(x, y, 0, 0, 16, 16, 16, 16); + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + GlStateManager.color(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(x, y, texture.getU(), texture.getV(), texture.getRegionHeight(), texture.getRegionHeight(), 16, 16, texture.getWidth(), texture.getHeight()); + //DrawableHelper.drawTexture(x, y, 0, 198, 18, 18, 16, 16, 256, 256); + GlStateManager.color(1, 1, 1); x += 17; } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..f23660488 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +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"), + 8, 4, new TextureInfo("textures/items/stone_sword.png"), new TextureInfo("textures/items/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/items/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/items/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/gui/container/inventory.png", 7*18, 198, 256, 256, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/gui/container/inventory.png", 7*18, 198, 256, 256, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/gui/container/inventory.png", 6*18, 198 + 18, 256, 256, 18, 18, Color.DARK_GRAY.withAlpha(100)), + new TextureInfo("textures/gui/container/inventory.png", 6*18, 198 + 18, 256, 256, 18, 18), + new TextureInfo("textures/gui/container/inventory.png", 6*18, 198 + 18, 256, 256, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/gui/container/inventory.png", 6*18, 198 + 18, 256, 256, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/gui/container/inventory.png", 6*18, 198 + 18, 256, 256, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "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}, new TextureInfo[]{ + new TextureInfo("textures/gui/container/inventory.png", 2*18, 198, 256, 256, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/gui/container/inventory.png", 2*18, 198, 256, 256, 18, 18, Color.GRAY), + new TextureInfo("textures/gui/container/inventory.png", 2*18, 198, 256, 256, 18, 18), + } + ); + + 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}, new TextureInfo[]{ + new TextureInfo("textures/blocks/furnace_front_off.png", 6*18, 198 + 18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18), + new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18, Color.parse("#FF0000")), + } + ); + + public 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/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..2121765a0 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,130 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +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; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/gui/container/inventory.png", 5*18, 198 + 18, 256, 256,18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/gui/container/inventory.png", 0, 198, 256, 256, 18, 18)), + ALARM(new TextureInfo("textures/items/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/gui/container/inventory.png", 3 * 18, 198, 256, 256, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + 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; + } + } +} diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java index 8232a301d..dd4b9aec2 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -38,10 +38,14 @@ public class BinaryUpgrade extends TeamUpgrade { private final int foursPrice; private final int doublesPrice; - public BinaryUpgrade(String name, Pattern regex, int foursPrice, int doublesPrice) { + private final TextureInfo inactiveTexture, activeTexture; + + public BinaryUpgrade(String name, Pattern regex, int foursPrice, int doublesPrice, TextureInfo inactiveTexture, TextureInfo activeTexture) { super(name, regex); this.foursPrice = foursPrice; this.doublesPrice = doublesPrice; + this.inactiveTexture = inactiveTexture; + this.activeTexture = activeTexture; } @Override @@ -50,8 +54,8 @@ protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { } @Override - public String[] getTexture() { - return new String[]{name + "_" + (purchased ? "1" : "0")}; + public TextureInfo[] getTexture() { + return new TextureInfo[]{(purchased ? activeTexture : inactiveTexture)}; } @Override diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java index 7e5d19ea0..a6041274d 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -52,7 +52,7 @@ public boolean match(String unformatedMessage) { return BedwarsMessages.matched(regex, unformatedMessage, matcher -> onMatch(this, matcher)); } - public abstract String[] getTexture(); + public abstract TextureInfo[] getTexture(); public boolean isMultiUpgrade() { // Basically only trap diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TextureInfo.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TextureInfo.java new file mode 100644 index 000000000..2474349d5 --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TextureInfo.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.modules.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import lombok.Getter; + +@Getter +public class TextureInfo { + private final String texture; + private int u = 0, v = 0, width = 16, height = 16, regionWidth = width, regionHeight = height; + private Color color = Color.WHITE.withAlpha(255); + + public TextureInfo(String texture){ + this.texture = texture; + } + + public TextureInfo(String texture, int u, int v){ + this(texture); + this.u = u; + this.v = v; + } + + public TextureInfo(String texture, int u, int v, int width, int height){ + this(texture, u, v); + this.width = width; + this.height = height; + this.regionWidth = width; + this.regionHeight = height; + } + + public TextureInfo(String texture, int u, int v, int width, int height, int regionWidth, int regionHeight){ + this(texture, u, v, width, height); + this.regionWidth = regionWidth; + this.regionHeight = regionHeight; + } + + public TextureInfo(String texture, Color color){ + this(texture); + this.color = color; + } + + public TextureInfo(String texture, int u, int v, Color color){ + this(texture, u, v); + this.color = color; + } + + public TextureInfo(String texture, int u, int v, int width, int height, Color color){ + this(texture, u, v, width, height); + this.color = color; + } + + public TextureInfo(String texture, int u, int v, int width, int height, int regionWidth, int regionHeight, Color color){ + this(texture, u, v, width, height, regionWidth, regionHeight); + this.color = color; + } +} diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java index 5bf094ed4..108c40277 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -39,15 +39,18 @@ public class TieredUpgrade extends TeamUpgrade { @Getter private int level = 0; - public TieredUpgrade(String name, Pattern regex, int[] foursPrice, int[] doublesPrice) { + private final TextureInfo[] textures; + + public TieredUpgrade(String name, Pattern regex, int[] foursPrice, int[] doublesPrice, TextureInfo[] textures) { super(name, regex); this.foursPrice = foursPrice; this.doublesPrice = doublesPrice; + this.textures = textures; } @Override - public String[] getTexture() { - return new String[]{name + "_" + level}; + public TextureInfo[] getTexture() { + return new TextureInfo[]{textures[level]}; } @Override diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/dragonbuff_0.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/dragonbuff_0.png deleted file mode 100644 index a9cf7905c71f0aaf52540aa540c79c7692d1149a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/dragonbuff_1.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/dragonbuff_1.png deleted file mode 100644 index c9b22218179224ff6ac5a423fb0673d66a64d0e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_2.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_2.png deleted file mode 100644 index c4d14eea361e12c71aecf68dbfc262fb7ec05e72..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_3.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_3.png deleted file mode 100644 index 8d6e083aa2db79e7b207731c1cecca79ad3bea8c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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$< diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_4.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/forge_4.png deleted file mode 100644 index c346b66aa482ef085327f1ebc6fafeba13dee15d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_0.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_0.png deleted file mode 100644 index f10edaaf1e9587ff5502daeec69651c7b3b45590..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_2.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/haste_2.png deleted file mode 100644 index 23c562ad8057f1291b5ac1aabbe357a0bd343528..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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# diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/healpool_0.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/healpool_0.png deleted file mode 100644 index efb9c84d9765ad42cdb8eaddef7885f3c938dcac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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&{ diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_1.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_1.png deleted file mode 100644 index 184eda3adcfdafaa0d4a7af42e3b9c726cfc83a0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_2.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_2.png deleted file mode 100644 index 559047b3fbfd15273688d5d29ffa12b350be1222..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_3.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_3.png deleted file mode 100644 index aaa5ce0f5b7539d3f59ee3f18f240c8da54007b5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_4.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/prot_4.png deleted file mode 100644 index d2715e825a12104e5cf8543b78d0459577c59ab6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/sharp_0.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/sharp_0.png deleted file mode 100644 index 1662e97d7807fd8d20280556c12c20a96e0164cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/sharp_1.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/sharp_1.png deleted file mode 100644 index 880201af22bfe019274cbd1153262e63bd6e626d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/counteroffensive.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/counteroffensive.png deleted file mode 100644 index 1ec03a522baaaefa7a15b0960999a27b3448f364..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/empty.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/empty.png deleted file mode 100644 index 5029b747549447126e87add037193c1d62b7c076..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/itsatrap.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/itsatrap.png deleted file mode 100644 index 3d79a94a8bc592a20ce2419c841dac555d907390..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/minerfatigue.png b/common/src/main/resources/assets/axolotlclient/textures/bedwars/trap/minerfatigue.png deleted file mode 100644 index 3eb866b7794f8a5078f2f9e340fa1f71a464c454..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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, 12 Jul 2023 01:06:24 +0200 Subject: [PATCH 19/41] update credits to reflect the latest changes --- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 1 - .../io/github/axolotlclient/config/screen/CreditsScreen.java | 1 - .../io/github/axolotlclient/config/screen/CreditsScreen.java | 1 - .../io/github/axolotlclient/config/screen/CreditsScreen.java | 1 - .../io/github/axolotlclient/config/screen/CreditsScreen.java | 1 - .../io/github/axolotlclient/config/screen/CreditsScreen.java | 3 +-- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 1 - gradle.properties | 2 +- 8 files changed, 2 insertions(+), 9 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 9b197b752..bfc168488 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -171,7 +171,6 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 9b197b752..bfc168488 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -171,7 +171,6 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 5478650ac..bdb02b38c 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -167,7 +167,6 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 84bca8708..b7d6cb511 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -165,7 +165,6 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 2af569b83..b684d53be 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -166,7 +166,6 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index bd1a2a79c..3aa0b31b5 100644 --- a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -162,10 +162,9 @@ private void initCredits() { credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); - + credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 4bc6576c5..0b1512a87 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -254,7 +254,6 @@ private void initCredits() { credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); - credits.add(new Credit("Sybillian", "Bedwars Overlay Texture author", "https://youtube.com/sybillian")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); diff --git a/gradle.properties b/gradle.properties index 542d04e5a..f65ef8bc5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ fabric.loom.multiProjectOptimisation=true # change this line if you do not want to import all submodules: axolotlclient.modules.all=true # Mod Properties -version=3.0.4-darkkronicle-bedwars-overlay-beta.5 +version=3.0.4-darkkronicle-bedwars-overlay-beta.6 maven_group=io.github.axolotlclient archives_base_name=AxolotlClient minecraft_1192=1.19.2 From 42fd44cbad2128d92edcf21ead08bc0f7735e978 Mon Sep 17 00:00:00 2001 From: moehreag Date: Wed, 12 Jul 2023 14:25:12 +0200 Subject: [PATCH 20/41] oversight --- .../io/github/axolotlclient/config/screen/CreditsScreen.java | 2 +- .../modules/hypixel/bedwars/TeamUpgradesOverlay.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 3aa0b31b5..93210e2ac 100644 --- a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -162,7 +162,7 @@ private void initCredits() { credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); - + credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java index 301be6058..124eeddda 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -95,7 +95,7 @@ public void drawOverlay(DrawPosition position, boolean editMode) { texture = u.getTexture()[0]; GlStateManager.color(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); - DrawableHelper.drawTexture(x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + DrawableHelper.drawTexture(x, y, texture.getU(), texture.getV(), texture.getRegionHeight(), texture.getRegionHeight(), 16, 16, texture.getWidth(), texture.getHeight()); GlStateManager.color(1, 1, 1); x += 17; normalUpgrades = true; @@ -109,7 +109,6 @@ public void drawOverlay(DrawPosition position, boolean editMode) { GlStateManager.color(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); DrawableHelper.drawTexture(x, y, texture.getU(), texture.getV(), texture.getRegionHeight(), texture.getRegionHeight(), 16, 16, texture.getWidth(), texture.getHeight()); - //DrawableHelper.drawTexture(x, y, 0, 198, 18, 18, 16, 16, 256, 256); GlStateManager.color(1, 1, 1); x += 17; } From df47dc4568414f91bf1073d916cc5569e4f01b5e Mon Sep 17 00:00:00 2001 From: moehreag Date: Wed, 12 Jul 2023 14:49:59 +0200 Subject: [PATCH 21/41] fix a potential crash --- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 7 ++++--- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 7 ++++--- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 7 ++++--- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 7 ++++--- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 7 ++++--- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 7 ++++--- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 2 +- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index e39062d93..dda9dad78 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -121,9 +121,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "Top 3 Killers: \n" + players.values().stream() - .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) - .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) .collect(Collectors.joining("\n")); } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index e4af00e3d..55eef37a2 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -121,9 +121,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "Top 3 Killers: \n" + players.values().stream() - .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) - .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) .collect(Collectors.joining("\n")); } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index d4694da6d..6f623876a 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -121,9 +121,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "Top 3 Killers: \n" + players.values().stream() - .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) - .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) .collect(Collectors.joining("\n")); } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index d4694da6d..6f623876a 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -121,9 +121,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "Top 3 Killers: \n" + players.values().stream() - .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) - .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) .collect(Collectors.joining("\n")); } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 51a220d15..801a98f7a 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -120,9 +120,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "Top 3 Killers: \n" + players.values().stream() - .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) - .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) .collect(Collectors.joining("\n")); } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 51a220d15..801a98f7a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -120,9 +120,10 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - return "Top 3 Killers: \n" + players.values().stream() - .sorted(Comparator.comparingInt(o -> o.getStats().getKills())).limit(3) - .map(p -> p.getColoredName() + ": " + p.getStats().getKills()) + Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) .collect(Collectors.joining("\n")); } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index b5f81e375..a0822c55e 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -122,7 +122,7 @@ private String calculateTopBarText() { private String calculateBottomBarText() { Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); - return "Top 3 Killers: \n" + players.values().stream() + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) .sorted(comparator.reversed()).limit(3) .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) .collect(Collectors.joining("\n")); From 2608f97a902431630a575844b6819d784a308898 Mon Sep 17 00:00:00 2001 From: moehreag Date: Wed, 12 Jul 2023 15:16:09 +0200 Subject: [PATCH 22/41] remove unnecessary darkening of the disabled furnace - this isn't shown anyway but still --- .../modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java | 2 +- .../modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java | 2 +- .../modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java | 2 +- .../modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java | 2 +- .../modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java | 2 +- .../modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java | 2 +- .../modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java index 45b5b26c5..b93109e79 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -75,7 +75,7 @@ public class BedwarsTeamUpgrades { 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}, new TextureInfo[]{ - new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java index 45b5b26c5..b93109e79 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -75,7 +75,7 @@ public class BedwarsTeamUpgrades { 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}, new TextureInfo[]{ - new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java index 45b5b26c5..b93109e79 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -75,7 +75,7 @@ public class BedwarsTeamUpgrades { 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}, new TextureInfo[]{ - new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java index 45b5b26c5..b93109e79 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -75,7 +75,7 @@ public class BedwarsTeamUpgrades { 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}, new TextureInfo[]{ - new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java index 45b5b26c5..b93109e79 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -75,7 +75,7 @@ public class BedwarsTeamUpgrades { 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}, new TextureInfo[]{ - new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java index 45b5b26c5..b93109e79 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -75,7 +75,7 @@ public class BedwarsTeamUpgrades { 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}, new TextureInfo[]{ - new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java index f23660488..a18988493 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -75,7 +75,7 @@ public class BedwarsTeamUpgrades { 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}, new TextureInfo[]{ - new TextureInfo("textures/blocks/furnace_front_off.png", 6*18, 198 + 18, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/blocks/furnace_front_off.png", 6*18, 198 + 18, 18, 18), new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18), new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18, Color.parse("#FFFF00")), new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18, Color.parse("#00FF00")), From 954fb9a93fc85fc7be7ac6561e92d71d86fe9565 Mon Sep 17 00:00:00 2001 From: moehreag Date: Wed, 12 Jul 2023 19:28:50 +0200 Subject: [PATCH 23/41] fix typo + PlayerHud scaling --- .../io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java | 3 +++ common/src/main/resources/assets/axolotlclient/lang/en_us.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index de3edaa1a..f03cda974 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -112,6 +112,9 @@ public boolean movable() { } public void renderPlayer(boolean placeholder, double x, double y, float delta) { + GlStateManager.popMatrix(); + GlStateManager.pushMatrix(); + if (client.player == null) { return; } diff --git a/common/src/main/resources/assets/axolotlclient/lang/en_us.json b/common/src/main/resources/assets/axolotlclient/lang/en_us.json index b354b4fa8..cca6e2b6b 100644 --- a/common/src/main/resources/assets/axolotlclient/lang/en_us.json +++ b/common/src/main/resources/assets/axolotlclient/lang/en_us.json @@ -388,7 +388,7 @@ "bedwars.bedwarsLevelHeadMode": "LevelHead Mode", "FINAL_KILLS": "Final Kills (Total)", "FINAL_DEATHS": "Final Deaths (Total)", - "BEDS_BROKEN": "Beds Broken (Totak)", + "BEDS_BROKEN": "Beds Broken (Total)", "GAME_KILLS_GAME_DEATHS": "Kills (Game)/Deaths (Game)", "KILLS": "Kills (Total)", "DEATHS": "Deaths (Total)", From 944c51d8e0e2b353936526e83e2c261b95a2c1da Mon Sep 17 00:00:00 2001 From: moehreag Date: Wed, 12 Jul 2023 20:35:45 +0200 Subject: [PATCH 24/41] add option to remove vignette, fix more things - f.e. interpreting sun.properties files as skyX.properties --- .../config/AxolotlClientConfig.java | 4 ++-- .../axolotlclient/mixin/InGameHudMixin.java | 9 ++++++++ .../config/AxolotlClientConfig.java | 4 ++-- .../axolotlclient/mixin/InGameHudMixin.java | 9 ++++++++ .../config/AxolotlClientConfig.java | 4 ++-- .../axolotlclient/mixin/InGameHudMixin.java | 9 ++++++++ .../config/AxolotlClientConfig.java | 4 ++-- .../axolotlclient/mixin/InGameHudMixin.java | 9 ++++++++ .../config/AxolotlClientConfig.java | 4 ++-- .../axolotlclient/mixin/InGameHudMixin.java | 9 ++++++++ .../config/AxolotlClientConfig.java | 2 ++ .../axolotlclient/mixin/InGameHudMixin.java | 9 ++++++++ .../config/AxolotlClientConfig.java | 2 ++ .../axolotlclient/mixin/InGameHudMixin.java | 11 +++++++++ .../mixin/VertexBufferMixin.java | 23 +++++++++++++++++++ .../modules/sky/SkyResourceManager.java | 8 +++++-- .../main/resources/axolotlclient.mixins.json | 1 + gradle.properties | 2 +- 18 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java diff --git a/1.16.5/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.16.5/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index dffc5a5f0..fad983405 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -60,9 +60,9 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption timeChangerEnabled = new BooleanOption("enabled", false); public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -176,10 +176,10 @@ public void init() { general.addSubCategory(searchFilters); rendering.add(customSky, - showSunMoon, AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index a4f55dc6c..1686945be 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,6 +22,7 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; @@ -34,6 +35,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.util.Window; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; @@ -218,4 +220,11 @@ public abstract class InGameHudMixin { } return heartCount; } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(float f, Window window, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index dffc5a5f0..fad983405 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -60,9 +60,9 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption timeChangerEnabled = new BooleanOption("enabled", false); public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -176,10 +176,10 @@ public void init() { general.addSubCategory(searchFilters); rendering.add(customSky, - showSunMoon, AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index a4f55dc6c..1686945be 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,6 +22,7 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; @@ -34,6 +35,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.util.Window; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; @@ -218,4 +220,11 @@ public abstract class InGameHudMixin { } return heartCount; } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(float f, Window window, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.19.2/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 65391d00d..2f0c3f79a 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -60,9 +60,9 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption timeChangerEnabled = new BooleanOption("enabled", false); public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -176,10 +176,10 @@ public void init() { general.addSubCategory(searchFilters); rendering.add(customSky, - showSunMoon, AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index db36e7cd8..b5e0655c6 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,6 +22,7 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; @@ -35,6 +36,7 @@ import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; @@ -218,4 +220,11 @@ public abstract class InGameHudMixin { } return heartCount; } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.19.3/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 0893875f6..3409983b9 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -60,9 +60,9 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption timeChangerEnabled = new BooleanOption("enabled", false); public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -176,10 +176,10 @@ public void init() { general.addSubCategory(searchFilters); rendering.add(customSky, - showSunMoon, AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 502b75076..100ed7239 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,6 +22,7 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; @@ -35,6 +36,7 @@ import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; @@ -218,4 +220,11 @@ public abstract class InGameHudMixin { } return heartCount; } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.19.4/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 0893875f6..3409983b9 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -60,9 +60,9 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption timeChangerEnabled = new BooleanOption("enabled", false); public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -176,10 +176,10 @@ public void init() { general.addSubCategory(searchFilters); rendering.add(customSky, - showSunMoon, AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 502b75076..100ed7239 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,6 +22,7 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; @@ -35,6 +36,7 @@ import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; @@ -218,4 +220,11 @@ public abstract class InGameHudMixin { } return heartCount; } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 0893875f6..fa092bdfd 100644 --- a/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -63,6 +63,7 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -180,6 +181,7 @@ public void init() { AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 2fdd6a96e..91582023a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,6 +22,7 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; @@ -35,6 +36,7 @@ import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; @@ -218,4 +220,11 @@ public abstract class InGameHudMixin { } return heartCount; } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.8.9/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 0e2e3a24f..06f96bcaf 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -56,6 +56,7 @@ public class AxolotlClientConfig extends ConfigHolder { public final IntegerOption cloudHeight = new IntegerOption("cloudHeight", 128, 100, 512); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final ColorOption hitColor = new ColorOption("hitColor", new Color(255, 0, 0, 77)); public final BooleanOption minimalViewBob = new BooleanOption("minimalViewBob", false); @@ -138,6 +139,7 @@ public void init() { AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, hitColor, minimalViewBob, diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 105e28ee5..3f85548db 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -23,6 +23,8 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.platform.GlStateManager; +import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.config.AxolotlClientConfig; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; @@ -37,6 +39,7 @@ import net.minecraft.scoreboard.ScoreboardObjective; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -164,6 +167,7 @@ public abstract class InGameHudMixin { return instance.getWidth(); } + @Unique private static final Entity axolotlclient$noHungerEntityTM = new MinecartEntity(null); @ModifyVariable( @@ -195,4 +199,11 @@ public abstract class InGameHudMixin { } return normal; } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(float f, Window window, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java new file mode 100644 index 000000000..24ea6ba68 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java @@ -0,0 +1,23 @@ +package io.github.axolotlclient.mixin; + +import java.nio.ByteBuffer; + +import net.minecraft.client.render.VertexBuffer; +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.callback.CallbackInfo; + +@Mixin(VertexBuffer.class) +public class VertexBufferMixin { + @Shadow + private int id; + + @Inject(method = "data", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/VertexBuffer;bind()V"), cancellable = true) + private void axolotlclient$ignoreDeletedBuffers(ByteBuffer byteBuffer, CallbackInfo ci) { + if (id == -1) { + ci.cancel(); + } + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 64f9cf488..e23b8c965 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -79,14 +79,14 @@ public void reload(ResourceManager resourceManager) { } for (Map.Entry entry : ((SearchableResourceManager) resourceManager) - .findResources("minecraft", "optifine/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("minecraft", "optifine/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loaded sky: " + entry.getKey()); loadMCPSky("optifine", entry.getKey(), entry.getValue()); } for (Map.Entry entry : ((SearchableResourceManager) resourceManager) - .findResources("minecraft", "mcpatcher/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("minecraft", "mcpatcher/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loaded sky: " + entry.getKey()); loadMCPSky("mcpatcher", entry.getKey(), entry.getValue()); @@ -94,6 +94,10 @@ public void reload(ResourceManager resourceManager) { initialized = true; } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private void loadMCPSky(String loader, Identifier id, Resource resource) { BufferedReader reader = new BufferedReader( new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)); diff --git a/1.8.9/src/main/resources/axolotlclient.mixins.json b/1.8.9/src/main/resources/axolotlclient.mixins.json index e79b40c69..91a7ee373 100644 --- a/1.8.9/src/main/resources/axolotlclient.mixins.json +++ b/1.8.9/src/main/resources/axolotlclient.mixins.json @@ -52,6 +52,7 @@ "TextRendererMixin", "TitleScreenMixin", "TntEntityRendererMixin", + "VertexBufferMixin", "WorldRendererAccessor", "WorldRendererMixin" ], diff --git a/gradle.properties b/gradle.properties index f65ef8bc5..ff4aaf848 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ fabric.loom.multiProjectOptimisation=true # change this line if you do not want to import all submodules: axolotlclient.modules.all=true # Mod Properties -version=3.0.4-darkkronicle-bedwars-overlay-beta.6 +version=3.0.4-darkkronicle-bedwars-overlay-beta.7 maven_group=io.github.axolotlclient archives_base_name=AxolotlClient minecraft_1192=1.19.2 From 46a1e71f827f81b3ec1f78c2073433f4de28b9a9 Mon Sep 17 00:00:00 2001 From: moehreag Date: Wed, 12 Jul 2023 20:40:09 +0200 Subject: [PATCH 25/41] apply sky fix on other versions as well --- .../modules/sky/SkyResourceManager.java | 8 +++++-- .../modules/sky/SkyResourceManager.java | 8 +++++-- .../modules/sky/SkyResourceManager.java | 8 +++++-- .../modules/sky/SkyResourceManager.java | 8 +++++-- .../modules/sky/SkyResourceManager.java | 8 +++++-- .../modules/sky/SkyResourceManager.java | 8 +++++-- .../mixin/VertexBufferMixin.java | 22 +++++++++++++++++++ 7 files changed, 58 insertions(+), 12 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index e0ca4926e..2b5c4d7c5 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -78,14 +78,14 @@ public void reload(ResourceManager manager) { } for (Identifier entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.endsWith(".properties"))) { + .findResources("mcpatcher/sky", this::isMCPSky)) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry); loadMCPSky("mcpatcher", entry, manager.getResource(entry)); AxolotlClient.LOGGER.debug("Loaded MCP sky from " + entry); } for (Identifier entry : manager - .findResources("optifine/sky", identifier -> identifier.endsWith(".properties"))) { + .findResources("optifine/sky", this::isMCPSky)) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry); loadMCPSky("optifine", entry, manager.getResource(entry)); AxolotlClient.LOGGER.debug("Loaded OF sky from " + entry); @@ -97,6 +97,10 @@ public void reload(ResourceManager manager) { } } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private void loadMCPSky(String loader, Identifier id, Resource resource) { BufferedReader reader = new BufferedReader( new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 83c6c373d..17926a810 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -78,14 +78,14 @@ public void apply(ResourceManager manager) { } for (Identifier entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.endsWith(".properties"))) { + .findResources("mcpatcher/sky", this::isMCPSky)) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry); loadMCPSky("mcpatcher", entry, manager.getResource(entry)); AxolotlClient.LOGGER.debug("Loaded MCP sky from " + entry); } for (Identifier entry : manager - .findResources("optifine/sky", identifier -> identifier.endsWith(".properties"))) { + .findResources("optifine/sky", this::isMCPSky)) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry); loadMCPSky("optifine", entry, manager.getResource(entry)); AxolotlClient.LOGGER.debug("Loaded OF sky from " + entry); @@ -97,6 +97,10 @@ public void apply(ResourceManager manager) { } } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private void loadMCPSky(String loader, Identifier id, Resource resource) { BufferedReader reader = new BufferedReader( new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 795795901..faf901207 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -81,7 +81,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("mcpatcher/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry.getKey()); SkyboxManager.getInstance() @@ -90,7 +90,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("optifine/sky", identifier -> identifier.getPath().endsWith(".properties")).entrySet()) { + .findResources("optifine/sky", identifier -> isMCPSky(identifier.getPath())).entrySet()) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry.getKey()); SkyboxManager.getInstance() .addSkybox(new MCPSkyboxInstance(loadMCPSky("optifine", entry.getKey(), entry.getValue()))); @@ -100,6 +100,10 @@ public void reload(ResourceManager manager) { AxolotlClient.LOGGER.debug("Finished Loading Custom Skies!"); } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private static JsonObject loadMCPSky(String loader, Identifier id, Resource resource) { JsonObject object = new JsonObject(); String line; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 795795901..faf901207 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -81,7 +81,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("mcpatcher/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry.getKey()); SkyboxManager.getInstance() @@ -90,7 +90,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("optifine/sky", identifier -> identifier.getPath().endsWith(".properties")).entrySet()) { + .findResources("optifine/sky", identifier -> isMCPSky(identifier.getPath())).entrySet()) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry.getKey()); SkyboxManager.getInstance() .addSkybox(new MCPSkyboxInstance(loadMCPSky("optifine", entry.getKey(), entry.getValue()))); @@ -100,6 +100,10 @@ public void reload(ResourceManager manager) { AxolotlClient.LOGGER.debug("Finished Loading Custom Skies!"); } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private static JsonObject loadMCPSky(String loader, Identifier id, Resource resource) { JsonObject object = new JsonObject(); String line; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 795795901..faf901207 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -81,7 +81,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("mcpatcher/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry.getKey()); SkyboxManager.getInstance() @@ -90,7 +90,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("optifine/sky", identifier -> identifier.getPath().endsWith(".properties")).entrySet()) { + .findResources("optifine/sky", identifier -> isMCPSky(identifier.getPath())).entrySet()) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry.getKey()); SkyboxManager.getInstance() .addSkybox(new MCPSkyboxInstance(loadMCPSky("optifine", entry.getKey(), entry.getValue()))); @@ -100,6 +100,10 @@ public void reload(ResourceManager manager) { AxolotlClient.LOGGER.debug("Finished Loading Custom Skies!"); } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private static JsonObject loadMCPSky(String loader, Identifier id, Resource resource) { JsonObject object = new JsonObject(); String line; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 795795901..faf901207 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -81,7 +81,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("mcpatcher/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry.getKey()); SkyboxManager.getInstance() @@ -90,7 +90,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("optifine/sky", identifier -> identifier.getPath().endsWith(".properties")).entrySet()) { + .findResources("optifine/sky", identifier -> isMCPSky(identifier.getPath())).entrySet()) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry.getKey()); SkyboxManager.getInstance() .addSkybox(new MCPSkyboxInstance(loadMCPSky("optifine", entry.getKey(), entry.getValue()))); @@ -100,6 +100,10 @@ public void reload(ResourceManager manager) { AxolotlClient.LOGGER.debug("Finished Loading Custom Skies!"); } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private static JsonObject loadMCPSky(String loader, Identifier id, Resource resource) { JsonObject object = new JsonObject(); String line; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java index 24ea6ba68..bd1722f5a 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java @@ -1,3 +1,25 @@ +/* + * Copyright © 2021-2023 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.mixin; import java.nio.ByteBuffer; From 2a9ede4a3634a2b2e1f0c510f50144d72dcf0929 Mon Sep 17 00:00:00 2001 From: moehreag Date: Wed, 12 Jul 2023 21:10:19 +0200 Subject: [PATCH 26/41] another spotted error + missing translation key --- .../io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java | 2 +- .../io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java | 2 +- .../io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java | 2 +- .../io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java | 2 +- .../io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java | 2 +- .../io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java | 2 +- .../io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java | 2 +- common/src/main/resources/assets/axolotlclient/lang/en_us.json | 3 ++- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index 067fa5c07..ea0cd5cef 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index 9e6d2e2c1..e4549ff12 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index 8ef6214f8..e77bfa8cc 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index 198d62349..c1e169f04 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index aec4442c5..848eadec7 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.20/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index aec4442c5..848eadec7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index a95edd99e..825a3873d 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -59,7 +59,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/common/src/main/resources/assets/axolotlclient/lang/en_us.json b/common/src/main/resources/assets/axolotlclient/lang/en_us.json index cca6e2b6b..7e6c8f4b3 100644 --- a/common/src/main/resources/assets/axolotlclient/lang/en_us.json +++ b/common/src/main/resources/assets/axolotlclient/lang/en_us.json @@ -410,5 +410,6 @@ "bedwars.deathType.golem": "Golems", "bedwars.deathType.self_void": "Void (Self)", "bedwars.deathType.self_unknown": "Unknown (Self)", - "bedwars_teamupgrades.renderWhenRelevant": "Only Render When Relevant" + "bedwars_teamupgrades.renderWhenRelevant": "Only Render When Relevant", + "removeVignette": "Remove Vignette" } From 73bc7f466a1ef1134f65d77bed774534158082d3 Mon Sep 17 00:00:00 2001 From: moehreag Date: Wed, 12 Jul 2023 22:10:07 +0200 Subject: [PATCH 27/41] suggested changes by DarkKronicle --- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 5 ++++- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 5 ++++- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 5 ++++- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 5 ++++- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 5 ++++- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 5 ++++- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 5 ++++- 14 files changed, 35 insertions(+), 14 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index bb9edb1b6..81a0e4f7e 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -314,7 +314,7 @@ public abstract class PlayerListHudMixin { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); ci.cancel(); } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index dda9dad78..d7e21deba 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -117,7 +117,10 @@ public Text getBottomBarText() { } private String calculateTopBarText() { - return getFormattedTime(); + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); } private String calculateBottomBarText() { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index a421bbfa8..2a797fbac 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -317,7 +317,7 @@ public abstract class PlayerListHudMixin { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); ci.cancel(); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 55eef37a2..57208b7ba 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -117,7 +117,10 @@ public Text getBottomBarText() { } private String calculateTopBarText() { - return getFormattedTime(); + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); } private String calculateBottomBarText() { diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 055ba9878..d50d672c7 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -311,7 +311,7 @@ public abstract class PlayerListHudMixin { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); ci.cancel(); } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 6f623876a..6cf035f68 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -117,7 +117,10 @@ public Text getBottomBarText() { } private String calculateTopBarText() { - return getFormattedTime(); + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); } private String calculateBottomBarText() { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index f03366fcf..6cfc0e348 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -310,7 +310,7 @@ public abstract class PlayerListHudMixin { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); ci.cancel(); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 6f623876a..6cf035f68 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -117,7 +117,10 @@ public Text getBottomBarText() { } private String calculateTopBarText() { - return getFormattedTime(); + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); } private String calculateBottomBarText() { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 32f2185e3..007c518a8 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -310,7 +310,7 @@ public abstract class PlayerListHudMixin { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); ci.cancel(); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 801a98f7a..fc3730076 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -116,7 +116,10 @@ public Text getBottomBarText() { } private String calculateTopBarText() { - return getFormattedTime(); + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); } private String calculateBottomBarText() { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 5f64acdaa..56a49bed2 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -310,7 +310,7 @@ public abstract class PlayerListHudMixin { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().copy().append("\n").append(footer); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); ci.cancel(); } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 801a98f7a..fc3730076 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -116,7 +116,10 @@ public Text getBottomBarText() { } private String calculateTopBarText() { - return getFormattedTime(); + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); } private String calculateBottomBarText() { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 33447b425..01e6c28b0 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -298,7 +298,7 @@ public abstract class PlayerListHudMixin extends DrawableHelper { if (!BedwarsMod.getInstance().inGame()) { return; } - this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText().append("\n").append(footer); + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); ci.cancel(); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index a0822c55e..d1e0e960a 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -117,7 +117,10 @@ public Text getBottomBarText() { } private String calculateTopBarText() { - return getFormattedTime(); + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); } private String calculateBottomBarText() { From 7ecaef92552e6b3a10750a3ba23f3d80ba08d6ae Mon Sep 17 00:00:00 2001 From: moehreag Date: Wed, 12 Jul 2023 23:19:10 +0200 Subject: [PATCH 28/41] mixin fixes + remove unused methods --- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 4 ---- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 3 --- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 4 ---- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 4 ---- .../java/io/github/axolotlclient/mixin/InGameHudMixin.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 4 ---- .../java/io/github/axolotlclient/mixin/InGameHudMixin.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 3 --- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 4 ---- 9 files changed, 2 insertions(+), 28 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index db6cda13a..694b31301 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -99,10 +99,6 @@ public BedwarsMod() { upgradesOverlay = new TeamUpgradesOverlay(this); } - public String getDetail() { - return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); - } - @Override public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index cd304e33a..41d915775 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -99,9 +99,6 @@ public BedwarsMod() { upgradesOverlay = new TeamUpgradesOverlay(this); } - public String getDetail() { - return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); - } @Override public void init() { diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index e8fd0c9c3..15745e675 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -98,10 +98,6 @@ public BedwarsMod() { upgradesOverlay = new TeamUpgradesOverlay(this); } - public String getDetail() { - return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); - } - @Override public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index e8fd0c9c3..15745e675 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -98,10 +98,6 @@ public BedwarsMod() { upgradesOverlay = new TeamUpgradesOverlay(this); } - public String getDetail() { - return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); - } - @Override public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 100ed7239..20733dbbb 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -222,7 +222,7 @@ public abstract class InGameHudMixin { } @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) - private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ + private void axolotlclient$removeVignette(MatrixStack matrices, Entity entity, CallbackInfo ci){ if(AxolotlClient.CONFIG.removeVignette.get()){ ci.cancel(); } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index e8fd0c9c3..15745e675 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -98,10 +98,6 @@ public BedwarsMod() { upgradesOverlay = new TeamUpgradesOverlay(this); } - public String getDetail() { - return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); - } - @Override public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 91582023a..edde1f934 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -222,7 +222,7 @@ public abstract class InGameHudMixin { } @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) - private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ + private void axolotlclient$removeVignette(GuiGraphics graphics, Entity entity, CallbackInfo ci){ if(AxolotlClient.CONFIG.removeVignette.get()){ ci.cancel(); } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index e8fd0c9c3..e83faa267 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -98,9 +98,6 @@ public BedwarsMod() { upgradesOverlay = new TeamUpgradesOverlay(this); } - public String getDetail() { - return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); - } @Override public void init() { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index ec4c5ef19..b4c35bb8d 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -98,10 +98,6 @@ public BedwarsMod() { upgradesOverlay = new TeamUpgradesOverlay(this); } - public String getDetail() { - return I18n.translate("sol_client.mod.screen.by", "DarkKronicle") + I18n.translate("sol_client.mod.screen.textures_by", "Sybillian"); - } - @Override public void init() { category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, From 45a0145cdb24a9676a84a292cc21dbfeffab9767 Mon Sep 17 00:00:00 2001 From: moehreag Date: Thu, 13 Jul 2023 07:51:40 +0200 Subject: [PATCH 29/41] change bottom bar --- .../modules/hypixel/bedwars/BedwarsGame.java | 15 +++++++++++++-- .../modules/hypixel/bedwars/BedwarsMod.java | 1 - .../modules/hypixel/bedwars/BedwarsGame.java | 15 +++++++++++++-- .../modules/hypixel/bedwars/BedwarsMod.java | 1 - .../modules/hypixel/bedwars/BedwarsGame.java | 15 +++++++++++++-- .../modules/hypixel/bedwars/BedwarsMod.java | 1 - .../modules/hypixel/bedwars/BedwarsGame.java | 15 +++++++++++++-- .../modules/hypixel/bedwars/BedwarsMod.java | 1 - .../modules/hypixel/bedwars/BedwarsGame.java | 15 +++++++++++++-- .../modules/hypixel/bedwars/BedwarsMod.java | 1 - .../modules/hypixel/bedwars/BedwarsGame.java | 15 +++++++++++++-- .../modules/hypixel/bedwars/BedwarsMod.java | 1 - .../modules/hypixel/bedwars/BedwarsGame.java | 15 +++++++++++++-- .../modules/hypixel/bedwars/BedwarsMod.java | 1 - 14 files changed, 91 insertions(+), 21 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index d7e21deba..ef96c98fa 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -38,6 +38,7 @@ import net.minecraft.scoreboard.Team; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; /** @@ -61,6 +62,8 @@ public class BedwarsGame { private final BedwarsMod mod; @Getter private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; public BedwarsGame(BedwarsMod mod) { @@ -124,11 +127,14 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) .sorted(comparator.reversed()).limit(3) .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining("\n"));*/ } public String getFormattedTime() { @@ -163,6 +169,11 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if (mod.overrideMessages.get()) { event.setNewMessage(new LiteralText(formatDeath(player, killer, type, finalDeath))); } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = player; + } } private String formatDisconnect(BedwarsPlayer disconnected) { diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 694b31301..926d38ef7 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -39,7 +39,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; 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; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 57208b7ba..1389b9df3 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -38,6 +38,7 @@ import net.minecraft.scoreboard.Team; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; /** @@ -61,6 +62,8 @@ public class BedwarsGame { private final BedwarsMod mod; @Getter private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; public BedwarsGame(BedwarsMod mod) { @@ -124,11 +127,14 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) .sorted(comparator.reversed()).limit(3) .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining("\n"));*/ } public String getFormattedTime() { @@ -163,6 +169,11 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if (mod.overrideMessages.get()) { event.setNewMessage(new LiteralText(formatDeath(player, killer, type, finalDeath))); } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = player; + } } private String formatDisconnect(BedwarsPlayer disconnected) { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 41d915775..13f1c3ac8 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -39,7 +39,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; 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; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 6cf035f68..da83b8ffe 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -37,6 +37,7 @@ import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; /** @@ -61,6 +62,8 @@ public class BedwarsGame { private final BedwarsMod mod; @Getter private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; public BedwarsGame(BedwarsMod mod) { @@ -124,11 +127,14 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) .sorted(comparator.reversed()).limit(3) .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining("\n"));*/ } public String getFormattedTime() { @@ -163,6 +169,11 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if (mod.overrideMessages.get()) { event.setNewMessage(Text.literal(formatDeath(player, killer, type, finalDeath))); } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = player; + } } private String formatDisconnect(BedwarsPlayer disconnected) { diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 15745e675..adf4a117c 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -38,7 +38,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; 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; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 6cf035f68..da83b8ffe 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -37,6 +37,7 @@ import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; /** @@ -61,6 +62,8 @@ public class BedwarsGame { private final BedwarsMod mod; @Getter private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; public BedwarsGame(BedwarsMod mod) { @@ -124,11 +127,14 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) .sorted(comparator.reversed()).limit(3) .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining("\n"));*/ } public String getFormattedTime() { @@ -163,6 +169,11 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if (mod.overrideMessages.get()) { event.setNewMessage(Text.literal(formatDeath(player, killer, type, finalDeath))); } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = player; + } } private String formatDisconnect(BedwarsPlayer disconnected) { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 15745e675..adf4a117c 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -38,7 +38,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; 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; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index fc3730076..f12805d6e 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -37,6 +37,7 @@ import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; /** @@ -60,6 +61,8 @@ public class BedwarsGame { private final BedwarsMod mod; @Getter private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; public BedwarsGame(BedwarsMod mod) { @@ -123,11 +126,14 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) .sorted(comparator.reversed()).limit(3) .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining("\n"));*/ } public String getFormattedTime() { @@ -162,6 +168,11 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if (mod.overrideMessages.get()) { event.setNewMessage(Text.literal(formatDeath(player, killer, type, finalDeath))); } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = player; + } } private String formatDisconnect(BedwarsPlayer disconnected) { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 15745e675..adf4a117c 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -38,7 +38,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; 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; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index fc3730076..f12805d6e 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -37,6 +37,7 @@ import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; /** @@ -60,6 +61,8 @@ public class BedwarsGame { private final BedwarsMod mod; @Getter private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; public BedwarsGame(BedwarsMod mod) { @@ -123,11 +126,14 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) .sorted(comparator.reversed()).limit(3) .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining("\n"));*/ } public String getFormattedTime() { @@ -162,6 +168,11 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if (mod.overrideMessages.get()) { event.setNewMessage(Text.literal(formatDeath(player, killer, type, finalDeath))); } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = player; + } } private String formatDisconnect(BedwarsPlayer disconnected) { diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index e83faa267..4be61aa58 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -38,7 +38,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; 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; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index d1e0e960a..b4751a1de 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -38,6 +38,7 @@ import net.minecraft.scoreboard.Team; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; /** @@ -61,6 +62,8 @@ public class BedwarsGame { private final BedwarsMod mod; @Getter private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; public BedwarsGame(BedwarsMod mod) { @@ -124,11 +127,14 @@ private String calculateTopBarText() { } private String calculateBottomBarText() { - Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) .sorted(comparator.reversed()).limit(3) .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining("\n"));*/ } public String getFormattedTime() { @@ -163,6 +169,11 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if (mod.overrideMessages.get()) { event.setNewMessage(new LiteralText(formatDeath(player, killer, type, finalDeath))); } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = player; + } } private String formatDisconnect(BedwarsPlayer disconnected) { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index b4c35bb8d..f413ab9c6 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -39,7 +39,6 @@ import lombok.Getter; import net.minecraft.client.MinecraftClient; 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; From 5889424de35eac90187369808e03c7570395e302 Mon Sep 17 00:00:00 2001 From: moehreag Date: Fri, 14 Jul 2023 20:33:29 +0200 Subject: [PATCH 30/41] address changes requested by TheKodeToad --- .../modules/hypixel/bedwars/BedwarsGame.java | 4 +- .../modules/hypixel/bedwars/BedwarsGame.java | 4 +- .../modules/hypixel/bedwars/BedwarsGame.java | 4 +- .../modules/hypixel/bedwars/BedwarsGame.java | 4 +- .../modules/hypixel/bedwars/BedwarsGame.java | 4 +- .../axolotlclient/mixin/InGameHudMixin.java | 8 ++ .../mixin/PlayerEntityMixin.java | 9 -- .../modules/hypixel/bedwars/BedwarsGame.java | 4 +- .../modules/hypixel/bedwars/BedwarsGame.java | 4 +- .../hypixel/HypixelAbstractionLayer.java | 8 +- .../hypixel/bedwars/BedwarsLevelHeadMode.java | 9 +- .../hypixel/bedwars/BedwarsMessages.java | 94 +++++++++---------- .../hypixel/bedwars/BedwarsPlayerStats.java | 20 +--- 13 files changed, 81 insertions(+), 95 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index ef96c98fa..aa143caba 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -54,8 +54,8 @@ public class BedwarsGame { private BedwarsPlayer me = null; - private final Map players = new HashMap<>(16); - private final Map playersById = new HashMap<>(16); + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); private final MinecraftClient mc; @Getter private boolean started = false; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 1389b9df3..4df2d2ff9 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -54,8 +54,8 @@ public class BedwarsGame { private BedwarsPlayer me = null; - private final Map players = new HashMap<>(16); - private final Map playersById = new HashMap<>(16); + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); private final MinecraftClient mc; @Getter private boolean started = false; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index da83b8ffe..e14023d21 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -54,8 +54,8 @@ public class BedwarsGame { private BedwarsPlayer me = null; - private final Map players = new HashMap<>(16); - private final Map playersById = new HashMap<>(16); + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); private final MinecraftClient mc; @Getter private boolean started = false; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index da83b8ffe..e14023d21 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -54,8 +54,8 @@ public class BedwarsGame { private BedwarsPlayer me = null; - private final Map players = new HashMap<>(16); - private final Map playersById = new HashMap<>(16); + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); private final MinecraftClient mc; @Getter private boolean started = false; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index f12805d6e..87737bdf4 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -53,8 +53,8 @@ public class BedwarsGame { private BedwarsPlayer me = null; - private final Map players = new HashMap<>(16); - private final Map playersById = new HashMap<>(16); + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); private final MinecraftClient mc; @Getter private boolean started = false; diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index edde1f934..d168e0c5d 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -227,4 +227,12 @@ public abstract class InGameHudMixin { ci.cancel(); } } + + @ModifyVariable(method = "renderStatusBars", at = @At("STORE"), ordinal = 12) + private int axolotlclient$dontShowArmor(int armorValue){ + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return armorValue; + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 930b26d3b..42c729666 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,7 +25,6 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; -import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; @@ -86,12 +85,4 @@ protected PlayerEntityMixin(EntityType entityType, World comboHud.onEntityDamage(this); } } - - @Override - public int getArmor() { - if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { - return 0; - } - return super.getArmor(); - } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index f12805d6e..87737bdf4 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -53,8 +53,8 @@ public class BedwarsGame { private BedwarsPlayer me = null; - private final Map players = new HashMap<>(16); - private final Map playersById = new HashMap<>(16); + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); private final MinecraftClient mc; @Getter private boolean started = false; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index b4751a1de..2af8797dc 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -54,8 +54,8 @@ public class BedwarsGame { private BedwarsPlayer me = null; - private final Map players = new HashMap<>(16); - private final Map playersById = new HashMap<>(16); + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); private final MinecraftClient mc; @Getter private boolean started = false; diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java index e23145733..4b33d471a 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java @@ -32,7 +32,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.util.ThreadExecuter; @@ -64,11 +63,12 @@ public static boolean hasValidAPIKey() { return validApiKey; } - public static JsonElement getPlayerProperty(String uuid, String stat) { + public static JsonObject getPlayerProperty(String uuid, String stat) { if (loadPlayerDataIfAbsent(uuid)) { - return getPlayer(uuid).getProperty(stat); + PlayerReply.Player player = getPlayer(uuid); + return player == null ? null : player.getProperty(stat).getAsJsonObject(); } - return new JsonObject(); + return null; } public static int getPlayerLevel(String uuid, String mode) { diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java index 33e646e5b..189ed702e 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java @@ -24,7 +24,9 @@ import java.util.Arrays; import java.util.HashMap; +import java.util.Map; import java.util.function.Function; +import java.util.stream.Collectors; public enum BedwarsLevelHeadMode { FINAL_KILLS(stats -> "§7Final Kills (Total): §f" + stats.getFinalKills()), @@ -54,14 +56,13 @@ public String apply(BedwarsPlayerStats stats) { return titleSupplier.apply(stats); } - private static final HashMap modes; + private static final Map modes; static { - modes = new HashMap<>(); - Arrays.stream(values()).forEach(m -> modes.put(m.toString(), m)); + modes = Arrays.stream(values()).collect(Collectors.toMap(Enum::name, value -> value)); } public static BedwarsLevelHeadMode get(String mode) { - return modes.getOrDefault(mode, null); + return modes.get(mode); } } diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java index afdaaa861..e086a0c94 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -201,41 +201,41 @@ public class BedwarsMessages { "{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}")), - Pattern.compile(formatPlaceholder("Bed was destroyed by {player}")), - }; + public final static Pattern[] BED_BREAK = Arrays.stream(new String[]{ + "Bed was broken by {player}", + "Bed was incinerated by {player}", + "Bed was iced by {player}", + "Bed had to raise the white flag to {player}", + "Bed was dismantled by {player}", + "Bed was deep fried by {player}", + "Bed was ripped apart by {player}", + "Bed was traded in for milk and cookies by {player}", + "Bed was sacrificed by {player}", + "Bed was gulped by {player}", + "Bed was gulped by {player}", + "Bed was squeaked apart by {player}", + "Bed was stung by {player}", + "Bed was impaled by {player}", + "Bed be shot with cannon by {player}", + "Bed got memed by {player}", + "Bed was made into a snowman by {player}", + "Bed was scrambled by {player}", + "Bed was stuffed with tissue paper by {player}", + "Bed was scrambled by {player}", + "Bed was bed #{number} destroyed by {player}", + "Bed was spooked by {player}", + "Bed was dreadfully corrupted by {player}", + "Bed was bed #{number} destroyed by {player}", + "Bed exploded from a firework by {player}", + "Bed was blasted to dust by {player}", + "Bed was melted by {player}'s holiday spirit", + "Bed was ripped to shreds by {player}", + "Bed has left the game after seeing {player}", + "Bed was spooked by {player}", + "Bed was contaminated by {player}", + "Bed was sold in a garage sale by {player}", + "Bed was destroyed by {player}" + }).map(BedwarsMessages::formatPlaceholder).map(Pattern::compile).toArray(Pattern[]::new); 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\\.$"); @@ -248,18 +248,18 @@ public class BedwarsMessages { 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 will respawn in \\d* second!$"), - 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"), - Pattern.compile("^If you get disconnected use /rejoin to join back in the game\\.$"), - }; + public final static Pattern[] ANNOYING_MESSAGES = Arrays.stream(new String[]{ + "^You will respawn in \\d* seconds!$", + "^You will respawn in \\d* second!$", + "^You purchased Wool$", + "^Cross-teaming is not allowed", + "^\\+\\d+ Coins!", + "^\\+\\d+ coins!", + "^Coins just earned DOUBLE", + "^\\+\\d+ Bed Wars Experience", + "^You have respawned", + "^If you get disconnected use /rejoin to join back in the game\\.$", + }).map(Pattern::compile).toArray(Pattern[]::new); private static Pattern[] convert(String... input) { return Arrays.stream(input).map(str -> Pattern.compile("^" + formatPlaceholder(str) + "(?: FINAL KILL!)?\\s*?")).toArray(Pattern[]::new); diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java index 337a46afd..f11af6be4 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -67,22 +67,8 @@ public class BedwarsPlayerStats { public static BedwarsPlayerStats generateFake() { - return new BedwarsPlayerStats( - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1 - ); + return new BedwarsPlayerStats(0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1); } @Nullable @@ -104,7 +90,7 @@ public static BedwarsPlayerStats fromAPI(String uuid) { int losses = getAsIntElse(bedwars, "losses_bedwars", 0); int wins = getAsIntElse(bedwars, "wins_bedwars", 0); int winstreak = getAsIntElse(bedwars, "winstreak", 0); - JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements").getAsJsonObject(); + JsonObject achievements = HypixelAbstractionLayer.getPlayerProperty(uuid, "achievements"); int stars = 1; if (achievements != null) { stars = getAsIntElse(achievements, "bedwars_level", 1); From 2544fcd226dc55ac2dfbc0c46214028582c5534b Mon Sep 17 00:00:00 2001 From: moehreag Date: Fri, 14 Jul 2023 20:43:26 +0200 Subject: [PATCH 31/41] fix 1.19.4 mixin --- .../github/axolotlclient/mixin/PlayerListHudMixin.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 007c518a8..c6292c83c 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -23,6 +23,7 @@ package io.github.axolotlclient.mixin; import java.util.List; +import java.util.UUID; import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; @@ -173,7 +174,7 @@ public abstract class PlayerListHudMixin { ) public void axolotlclient$renderWithoutObjective( MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, CallbackInfo ci, - ClientPlayNetworkHandler clientPlayNetworkHandler, List list, int i, int j, int l, int m, int k, + 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, int z, PlayerListEntry playerListEntry2 ) { if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { @@ -211,7 +212,7 @@ public abstract class PlayerListHudMixin { ) private void axolotlclient$renderCustomScoreboardObjective( ScoreboardObjective objective, int y, String player, int startX, int endX, - PlayerListEntry playerEntry, MatrixStack matrices, CallbackInfo ci + UUID uuid, MatrixStack matrices, CallbackInfo ci ) { if (!BedwarsMod.getInstance().isEnabled()) { return; @@ -221,7 +222,7 @@ public abstract class PlayerListHudMixin { if (game == null) { return; } - BedwarsPlayer bedwarsPlayer = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + BedwarsPlayer bedwarsPlayer = game.getPlayer(player).orElse(null); if (bedwarsPlayer == null) { return; } @@ -284,7 +285,7 @@ public abstract class PlayerListHudMixin { cir.setReturnValue(player.getTabListDisplay()); } - @ModifyVariable(method = "method_48213", at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/stream/Stream;toList()Ljava/util/List;", remap = false)) + @ModifyVariable(method = "render", at = @At(value = "STORE"), ordinal = 1) public List axolotlclient$overrideSortedPlayers(List original) { if (!BedwarsMod.getInstance().inGame()) { return original; From f504db4d1e8fcf0280af8256b15b86351b5dfb48 Mon Sep 17 00:00:00 2001 From: moehreag Date: Fri, 14 Jul 2023 20:45:11 +0200 Subject: [PATCH 32/41] bump version and add changelog --- CHANGELOG.md | 4 ++++ gradle.properties | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68ce35542..763241bfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -132,3 +132,7 @@ - add DarkKronicle's Bedwars Overlay - fix the controls screen crashing in 1.8.9 +- add option to remove the vignette +- fix the sky impl mistaking suns for skies +- fix a client lockup issue on 1.8.9 +- fix PlayerHud scaling on 1.8.9 diff --git a/gradle.properties b/gradle.properties index ff4aaf848..4b6e3b38d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,10 +2,13 @@ org.gradle.jvmargs=-Xmx5G org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true + # change this line if you do not want to import all submodules: axolotlclient.modules.all=true + # Mod Properties -version=3.0.4-darkkronicle-bedwars-overlay-beta.7 +version=3.0.4-beta.1 + maven_group=io.github.axolotlclient archives_base_name=AxolotlClient minecraft_1192=1.19.2 From f56c622c77487cc65efa3e119228830681da14f4 Mon Sep 17 00:00:00 2001 From: moehreag Date: Fri, 14 Jul 2023 20:50:25 +0200 Subject: [PATCH 33/41] remove code duplication --- .../modules/hypixel/HypixelAbstractionLayer.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java index 4b33d471a..bb7d51a4d 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java @@ -76,19 +76,17 @@ public static int getPlayerLevel(String uuid, String mode) { loadApiKey(); } if (loadPlayerDataIfAbsent(uuid)) { - try { + PlayerReply.Player player = getPlayer(uuid); + if (player != null) { if (Objects.equals(mode, LevelHeadMode.NETWORK.toString())) { - return (int) cachedPlayerData.get(uuid).get(1, TimeUnit.MICROSECONDS).getPlayer().getNetworkLevel(); + return (int) player.getNetworkLevel(); } else if (Objects.equals(mode, LevelHeadMode.BEDWARS.toString())) { - return cachedPlayerData.get(uuid).get(1, TimeUnit.MICROSECONDS).getPlayer() - .getIntProperty("achievements.bedwars_level", 0); + return player.getIntProperty("achievements.bedwars_level", 0); } else if (Objects.equals(mode, LevelHeadMode.SKYWARS.toString())) { - int exp = cachedPlayerData.get(uuid).get(1, TimeUnit.MICROSECONDS).getPlayer() + int exp = player .getIntProperty("stats.SkyWars.skywars_experience", 0); return Math.round(ExpCalculator.getLevelForExp(exp)); } - } catch (TimeoutException | InterruptedException | ExecutionException e) { - return -1; } } return 0; From 664b0c9c52dd96e88cee98ba8db195b327bb42f3 Mon Sep 17 00:00:00 2001 From: moehreag Date: Fri, 14 Jul 2023 21:10:12 +0200 Subject: [PATCH 34/41] fix the ArmorHUD on 1.20 --- .../github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java | 2 ++ .../github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java index 96aaa5029..655ca12a1 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java @@ -86,10 +86,12 @@ public void renderMainItem(GuiGraphics graphics, ItemStack stack, int x, int y) if (total.equals("1")) { total = null; } + graphics.drawItem(stack, x, y); graphics.drawItemInSlot(client.textRenderer, stack, x, y, total); } public void renderItem(GuiGraphics graphics, ItemStack stack, int x, int y) { + graphics.drawItem(stack, x, y); graphics.drawItemInSlot(client.textRenderer, stack, x, y); } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java index 20fb65ff7..1be344b51 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java @@ -75,7 +75,7 @@ public void renderComponent(GuiGraphics graphics, float delta) { DrawPosition pos = getPos(); drawCenteredString(graphics, client.textRenderer, String.valueOf(arrows), pos.x() + getWidth() / 2, pos.y() + getHeight() - 10, textColor.get(), shadow.get()); - ItemUtil.renderGuiItemModel(getScale(), currentArrow, pos.x() + 2, pos.y() + 2); + graphics.drawItem(currentArrow, pos.x() + 2, pos.y() + 2); } @Override From a5b6cd69c760307117da34840e5354151bd77bef Mon Sep 17 00:00:00 2001 From: moehreag Date: Fri, 14 Jul 2023 21:38:41 +0200 Subject: [PATCH 35/41] update config version to fix a bug - involving the chroma switch - https://github.com/AxolotlClient/AxolotlClient-config/commit/0bca1721525f0e1b1260bc73883eb6893900e871 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 4b6e3b38d..0ddfc236d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -34,5 +34,5 @@ qsl_120=6.0.3 fabric_cts8=0.42.0+1.16 fabric_1165=0.42.0+1.16 lfapi=1.9.0 -config=2.1.12 +config=2.1.13 asmVersion=6.0_BETA From d5acde90ffa83f192547022558d2be92a4a09308 Mon Sep 17 00:00:00 2001 From: moehreag Date: Sat, 15 Jul 2023 09:49:07 +0200 Subject: [PATCH 36/41] address suggestions from DarkKronicle --- .../mixin/PlayerListHudMixin.java | 29 ++-------- .../modules/hypixel/bedwars/BedwarsGame.java | 31 +++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 3 +- .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ------------------- .../mixin/PlayerListHudMixin.java | 30 ++--------- .../modules/hypixel/bedwars/BedwarsGame.java | 31 +++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 3 +- .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ------------------- .../mixin/PlayerListHudMixin.java | 30 ++--------- .../modules/hypixel/bedwars/BedwarsGame.java | 31 +++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 3 +- .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ------------------- .../mixin/PlayerListHudMixin.java | 30 ++--------- .../modules/hypixel/bedwars/BedwarsGame.java | 31 +++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 3 +- .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ------------------- .../mixin/PlayerListHudMixin.java | 30 ++--------- .../modules/hypixel/bedwars/BedwarsGame.java | 31 +++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 3 +- .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ------------------- .../mixin/PlayerListHudMixin.java | 37 +++---------- .../modules/hypixel/bedwars/BedwarsGame.java | 32 +++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 3 +- .../hypixel/bedwars/stats/LobbyStatsHud.java | 53 ------------------- .../hypixel/bedwars/upgrades/TrapUpgrade.java | 10 ++-- .../mixin/PlayerListHudMixin.java | 29 ++-------- .../modules/hypixel/bedwars/BedwarsGame.java | 31 +++++++++++ .../modules/hypixel/bedwars/BedwarsMod.java | 3 +- .../hypixel/bedwars/stats/LobbyStatsHud.java | 52 ------------------ .../assets/axolotlclient/lang/en_us.json | 3 +- 30 files changed, 257 insertions(+), 580 deletions(-) delete mode 100644 1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java delete mode 100644 1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java delete mode 100644 1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java delete mode 100644 1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java delete mode 100644 1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java delete mode 100644 1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java delete mode 100644 1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 81a0e4f7e..03c2a4a79 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -225,33 +225,10 @@ public abstract class PlayerListHudMixin { if (game == null) { return; } - BedwarsPlayer bedwarsPlayer = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); - if (bedwarsPlayer == null) { - return; - } + + game.renderCustomScoreboardObjective(matrices, playerEntry.getProfile().getName(), objective, y, endX); ci.cancel(); - String render; - 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("%.1f", secondsTillLive) + "s"; - color = new Color(200, 200, 200).getAsInt(); - } else { - int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); - color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); - render = String.valueOf(health); - } - // Health - this.client.textRenderer.drawWithShadow(matrices, - render, - (float) (endX - this.client.textRenderer.getWidth(render)), - (float) y, - color - ); + } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index aa143caba..a51724829 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -26,6 +26,7 @@ import java.util.regex.Matcher; import java.util.stream.Collectors; +import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -33,7 +34,9 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.LiteralText; @@ -439,4 +442,32 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { return mode.apply(stats); } + public void renderCustomScoreboardObjective(MatrixStack matrices, String playerName, ScoreboardObjective objective, int y, int endX){ + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - mc.textRenderer.getWidth(render)), + (float) y, + color + ); + } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 926d38ef7..f5c47fd8f 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -53,8 +53,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?$") + Pattern.compile("^\\s*?Bed Wars Lucky Blocks\\s*?$") }; @Getter diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java deleted file mode 100644 index 2053d498a..000000000 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.stats; - -import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; - -/** - * @author DarkKronicle - */ - -public class LobbyStatsHud extends BoxHudEntry { - - public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { - super(width, height, backgroundAllowed); - } - - @Override - public void renderComponent(MatrixStack matrices, float delta) { - - } - - @Override - public void renderPlaceholderComponent(MatrixStack matrices, float delta) { - - } - - @Override - public Identifier getId() { - return null; - } -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 2a797fbac..718bec32c 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -228,34 +228,10 @@ public abstract class PlayerListHudMixin { if (game == null) { return; } - BedwarsPlayer bedwarsPlayer = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); - if (bedwarsPlayer == null) { - return; - } - ci.cancel(); - String render; - 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("%.1f", secondsTillLive) + "s"; - color = new Color(200, 200, 200).getAsInt(); - } else { - int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); - color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); - render = String.valueOf(health); - } - // Health - this.client.textRenderer.drawWithShadow(matrices, - render, - (float) (endX - this.client.textRenderer.getWidth(render)), - (float) y, - color - ); + game.renderCustomScoreboardObjective(matrices, playerEntry.getProfile().getName(), objective, y, endX); + + ci.cancel(); } @ModifyVariable( diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 4df2d2ff9..a416fa7e4 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -26,6 +26,7 @@ import java.util.regex.Matcher; import java.util.stream.Collectors; +import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -33,7 +34,9 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.LiteralText; @@ -439,4 +442,32 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { return mode.apply(stats); } + public void renderCustomScoreboardObjective(MatrixStack matrices, String playerName, ScoreboardObjective objective, int y, int endX){ + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - mc.textRenderer.getWidth(render)), + (float) y, + color + ); + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 13f1c3ac8..eedb556cd 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -53,8 +53,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?$") + Pattern.compile("^\\s*?Bed Wars Lucky Blocks\\s*?$") }; @Getter diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java deleted file mode 100644 index 2053d498a..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.stats; - -import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; - -/** - * @author DarkKronicle - */ - -public class LobbyStatsHud extends BoxHudEntry { - - public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { - super(width, height, backgroundAllowed); - } - - @Override - public void renderComponent(MatrixStack matrices, float delta) { - - } - - @Override - public void renderPlaceholderComponent(MatrixStack matrices, float delta) { - - } - - @Override - public Identifier getId() { - return null; - } -} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index d50d672c7..9e290e75e 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -222,34 +222,10 @@ public abstract class PlayerListHudMixin { if (game == null) { return; } - BedwarsPlayer bedwarsPlayer = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); - if (bedwarsPlayer == null) { - return; - } - ci.cancel(); - String render; - 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("%.1f", secondsTillLive) + "s"; - color = new Color(200, 200, 200).getAsInt(); - } else { - int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); - color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); - render = String.valueOf(health); - } - // Health - this.client.textRenderer.drawWithShadow(matrices, - render, - (float) (endX - this.client.textRenderer.getWidth(render)), - (float) y, - color - ); + game.renderCustomScoreboardObjective(matrices, playerEntry.getProfile().getName(), objective, y, endX); + + ci.cancel(); } @ModifyVariable( diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index e14023d21..a308bfc85 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -26,6 +26,7 @@ import java.util.regex.Matcher; import java.util.stream.Collectors; +import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -33,7 +34,9 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.Text; @@ -439,4 +442,32 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { return mode.apply(stats); } + public void renderCustomScoreboardObjective(MatrixStack matrices, String playerName, ScoreboardObjective objective, int y, int endX) { + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - mc.textRenderer.getWidth(render)), + (float) y, + color + ); + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index adf4a117c..b656a9eeb 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -52,8 +52,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?$") + Pattern.compile("^\\s*?Bed Wars Lucky Blocks\\s*?$") }; @Getter diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java deleted file mode 100644 index 2053d498a..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.stats; - -import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; - -/** - * @author DarkKronicle - */ - -public class LobbyStatsHud extends BoxHudEntry { - - public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { - super(width, height, backgroundAllowed); - } - - @Override - public void renderComponent(MatrixStack matrices, float delta) { - - } - - @Override - public void renderPlaceholderComponent(MatrixStack matrices, float delta) { - - } - - @Override - public Identifier getId() { - return null; - } -} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 6cfc0e348..5134a77b9 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -221,34 +221,10 @@ public abstract class PlayerListHudMixin { if (game == null) { return; } - BedwarsPlayer bedwarsPlayer = game.getPlayer(player).orElse(null); - if (bedwarsPlayer == null) { - return; - } - ci.cancel(); - String render; - 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("%.1f", secondsTillLive) + "s"; - color = new Color(200, 200, 200).getAsInt(); - } else { - int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); - color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); - render = String.valueOf(health); - } - // Health - this.client.textRenderer.drawWithShadow(matrices, - render, - (float) (endX - this.client.textRenderer.getWidth(render)), - (float) y, - color - ); + game.renderCustomScoreboardObjective(matrices, player, objective, y, endX); + + ci.cancel(); } @ModifyVariable( diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index e14023d21..a308bfc85 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -26,6 +26,7 @@ import java.util.regex.Matcher; import java.util.stream.Collectors; +import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -33,7 +34,9 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.Text; @@ -439,4 +442,32 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { return mode.apply(stats); } + public void renderCustomScoreboardObjective(MatrixStack matrices, String playerName, ScoreboardObjective objective, int y, int endX) { + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - mc.textRenderer.getWidth(render)), + (float) y, + color + ); + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index adf4a117c..b656a9eeb 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -52,8 +52,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?$") + Pattern.compile("^\\s*?Bed Wars Lucky Blocks\\s*?$") }; @Getter diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java deleted file mode 100644 index 2053d498a..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.stats; - -import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; - -/** - * @author DarkKronicle - */ - -public class LobbyStatsHud extends BoxHudEntry { - - public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { - super(width, height, backgroundAllowed); - } - - @Override - public void renderComponent(MatrixStack matrices, float delta) { - - } - - @Override - public void renderPlaceholderComponent(MatrixStack matrices, float delta) { - - } - - @Override - public Identifier getId() { - return null; - } -} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index c6292c83c..ccedd519a 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -222,34 +222,10 @@ public abstract class PlayerListHudMixin { if (game == null) { return; } - BedwarsPlayer bedwarsPlayer = game.getPlayer(player).orElse(null); - if (bedwarsPlayer == null) { - return; - } - ci.cancel(); - String render; - 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("%.1f", secondsTillLive) + "s"; - color = new Color(200, 200, 200).getAsInt(); - } else { - int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); - color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); - render = String.valueOf(health); - } - // Health - this.client.textRenderer.drawWithShadow(matrices, - render, - (float) (endX - this.client.textRenderer.getWidth(render)), - (float) y, - color - ); + game.renderCustomScoreboardObjective(matrices, player, objective, y, endX); + + ci.cancel(); } @ModifyVariable( diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 87737bdf4..a8d2e11f2 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -26,6 +26,7 @@ import java.util.regex.Matcher; import java.util.stream.Collectors; +import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -33,7 +34,9 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.Text; @@ -438,4 +441,32 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { return mode.apply(stats); } + public void renderCustomScoreboardObjective(MatrixStack matrices, String playerName, ScoreboardObjective objective, int y, int endX) { + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - mc.textRenderer.getWidth(render)), + (float) y, + color + ); + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index adf4a117c..b656a9eeb 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -52,8 +52,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?$") + Pattern.compile("^\\s*?Bed Wars Lucky Blocks\\s*?$") }; @Getter diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java deleted file mode 100644 index 2053d498a..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.stats; - -import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; - -/** - * @author DarkKronicle - */ - -public class LobbyStatsHud extends BoxHudEntry { - - public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { - super(width, height, backgroundAllowed); - } - - @Override - public void renderComponent(MatrixStack matrices, float delta) { - - } - - @Override - public void renderPlaceholderComponent(MatrixStack matrices, float delta) { - - } - - @Override - public Identifier getId() { - return null; - } -} diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 56a49bed2..a06c602a7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -28,7 +28,6 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; @@ -188,9 +187,9 @@ public abstract class PlayerListHudMixin { return; } - render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + render = HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 .getProfile().getId().toString().replace("-", ""), - LevelHeadMode.BEDWARS.toString())); + LevelHeadMode.BEDWARS.toString()) + "☆"; } catch (Exception e) { return; } @@ -221,34 +220,10 @@ public abstract class PlayerListHudMixin { if (game == null) { return; } - BedwarsPlayer bedwarsPlayer = game.getPlayer(player).orElse(null); - if (bedwarsPlayer == null) { - return; - } - ci.cancel(); - String render; - 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("%.1f", secondsTillLive) + "s"; - color = new Color(200, 200, 200).getAsInt(); - } else { - int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); - color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); - render = String.valueOf(health); - } - // Health - graphics.drawShadowedText(client.textRenderer, - render, - (endX - this.client.textRenderer.getWidth(render)), - y, - color - ); + game.renderCustomScoreboardObjective(graphics, player, objective, y, endX); + + ci.cancel(); } @ModifyVariable( @@ -258,7 +233,7 @@ public abstract class PlayerListHudMixin { ), ordinal = 7 ) - public int axolotlclient$changeWidth(int value) { + public int axolotlclient$changeWidth(int value, GuiGraphics graphics, int scaledWindowWidth, Scoreboard scoreboard, @Nullable ScoreboardObjective objective) { if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { value -= 9; } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 87737bdf4..2131c4750 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -26,14 +26,17 @@ import java.util.regex.Matcher; import java.util.stream.Collectors; +import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.Text; @@ -438,4 +441,33 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { return mode.apply(stats); } + public void renderCustomScoreboardObjective(GuiGraphics graphics, String playerName, ScoreboardObjective objective, int y, int endX) { + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + graphics.drawShadowedText(mc.textRenderer, + render, + (endX - mc.textRenderer.getWidth(render)), + y, + color + ); + + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 4be61aa58..603db6fb1 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -52,8 +52,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?$") + Pattern.compile("^\\s*?Bed Wars Lucky Blocks\\s*?$") }; @Getter diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java deleted file mode 100644 index c956da4c3..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.stats; - -import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.util.Identifier; - -/** - * @author DarkKronicle - */ - -public class LobbyStatsHud extends BoxHudEntry { - - public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { - super(width, height, backgroundAllowed); - } - - @Override - public void renderComponent(GuiGraphics graphics, float delta) { - - } - - @Override - public void renderPlaceholderComponent(GuiGraphics graphics, float delta) { - - } - - @Override - public Identifier getId() { - return null; - } -} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 6701c7541..64225f261 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -69,14 +69,16 @@ public boolean canPurchase() { @Override public int getPrice(BedwarsMode mode) { switch (traps.size()) { - case 0: + case 0 -> { return 1; - case 1: + } + case 1 -> { return 2; - case 2: + } + case 2 -> { return 4; + } } - ; return 0; } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 01e6c28b0..63549b02b 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -209,33 +209,10 @@ public abstract class PlayerListHudMixin extends DrawableHelper { if (game == null) { return; } - BedwarsPlayer bedwarsPlayer = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); - if (bedwarsPlayer == null) { - return; - } + + game.renderCustomScoreboardObjective(playerEntry.getProfile().getName(), objective, y, endX); ci.cancel(); - String render; - int color; - if (!bedwarsPlayer.isAlive()) { - if (bedwarsPlayer.isDisconnected()) { - return; - } - int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - this.axolotlclient$client.inGameHud.getTicks()); - float secondsTillLive = tickTillLive / 20f; - render = String.format("%.1f", secondsTillLive) + "s"; - color = new Color(200, 200, 200).getAsInt(); - } else { - int health = objective.getScoreboard().getPlayerScore(player, objective).getScore(); - color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); - render = String.valueOf(health); - } - // Health - this.axolotlclient$client.textRenderer.drawWithShadow( - render, - (float) (endX - this.axolotlclient$client.textRenderer.getStringWidth(render)), - (float) y, - color - ); + } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 2af8797dc..16038a9aa 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -26,6 +26,7 @@ import java.util.regex.Matcher; import java.util.stream.Collectors; +import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; @@ -34,6 +35,7 @@ import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.scoreboard.ScoreboardPlayerScore; import net.minecraft.scoreboard.Team; import net.minecraft.text.LiteralText; @@ -439,4 +441,33 @@ public String getLevelHead(AbstractClientPlayerEntity entity) { return mode.apply(stats); } + public void renderCustomScoreboardObjective(String playerName, ScoreboardObjective objective, int y, int endX){ + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow( + render, + (float) (endX - mc.textRenderer.getStringWidth(render)), + (float) y, + color + ); + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index f413ab9c6..979401c89 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -53,8 +53,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?$") + Pattern.compile("^\\s*?Bed Wars Lucky Blocks\\s*?$") }; @Getter diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java deleted file mode 100644 index 895b8f5d5..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/stats/LobbyStatsHud.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright © 2021-2023 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.hypixel.bedwars.stats; - -import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import net.minecraft.util.Identifier; - -/** - * @author DarkKronicle - */ - -public class LobbyStatsHud extends BoxHudEntry { - - public LobbyStatsHud(int width, int height, boolean backgroundAllowed) { - super(width, height, backgroundAllowed); - } - - @Override - public Identifier getId() { - return null; - } - - @Override - public void renderComponent(float delta) { - - } - - @Override - public void renderPlaceholderComponent(float delta) { - - } -} diff --git a/common/src/main/resources/assets/axolotlclient/lang/en_us.json b/common/src/main/resources/assets/axolotlclient/lang/en_us.json index 7e6c8f4b3..fc189d692 100644 --- a/common/src/main/resources/assets/axolotlclient/lang/en_us.json +++ b/common/src/main/resources/assets/axolotlclient/lang/en_us.json @@ -411,5 +411,6 @@ "bedwars.deathType.self_void": "Void (Self)", "bedwars.deathType.self_unknown": "Unknown (Self)", "bedwars_teamupgrades.renderWhenRelevant": "Only Render When Relevant", - "removeVignette": "Remove Vignette" + "removeVignette": "Remove Vignette", + "bedwars.tabRenderLatencyIcon.tooltip": "This lets you remove the latency icon
since it's always 1 for others while in a game.
This is probably some kind of limitation of hypixel." } From d2870a87d756075914f525bb3cf184ca83ac3de6 Mon Sep 17 00:00:00 2001 From: moehreag Date: Sat, 15 Jul 2023 17:46:06 +0200 Subject: [PATCH 37/41] remove Lucky Block Bedwars from start triggers --- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 3 +-- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 3 +-- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 3 +-- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 3 +-- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 3 +-- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 3 +-- .../axolotlclient/modules/hypixel/bedwars/BedwarsMod.java | 3 +-- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index f5c47fd8f..2238e880d 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -52,8 +52,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?Protect your bed and destroy the enemy beds\\.\\s*?$") }; @Getter diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index eedb556cd..995aeda4b 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -52,8 +52,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?Protect your bed and destroy the enemy beds\\.\\s*?$") }; @Getter diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index b656a9eeb..70e09404a 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -51,8 +51,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?Protect your bed and destroy the enemy beds\\.\\s*?$") }; @Getter diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index b656a9eeb..70e09404a 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -51,8 +51,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?Protect your bed and destroy the enemy beds\\.\\s*?$") }; @Getter diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index b656a9eeb..70e09404a 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -51,8 +51,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?Protect your bed and destroy the enemy beds\\.\\s*?$") }; @Getter diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 603db6fb1..a43a7a9eb 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -51,8 +51,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?Protect your bed and destroy the enemy beds\\.\\s*?$") }; @Getter diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java index 979401c89..cf6c1b17b 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -52,8 +52,7 @@ public class BedwarsMod implements AbstractHypixelMod { 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*?Protect your bed and destroy the enemy beds\\.\\s*?$") }; @Getter From 8dcdc980d198cd927445ffc3247fc3201eec4e51 Mon Sep 17 00:00:00 2001 From: moehreag Date: Sat, 15 Jul 2023 19:10:27 +0200 Subject: [PATCH 38/41] fix last killer display --- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 2 +- .../axolotlclient/modules/hypixel/bedwars/BedwarsGame.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index a51724829..9550fc1f7 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -175,7 +175,7 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if(me.equals(killer)){ lastKill = player; } else if (me.equals(player)){ - lastKiller = player; + lastKiller = killer; } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index a416fa7e4..eff0ee94c 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -175,7 +175,7 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if(me.equals(killer)){ lastKill = player; } else if (me.equals(player)){ - lastKiller = player; + lastKiller = killer; } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index a308bfc85..8131a1957 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -175,7 +175,7 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if(me.equals(killer)){ lastKill = player; } else if (me.equals(player)){ - lastKiller = player; + lastKiller = killer; } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index a308bfc85..8131a1957 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -175,7 +175,7 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if(me.equals(killer)){ lastKill = player; } else if (me.equals(player)){ - lastKiller = player; + lastKiller = killer; } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index a8d2e11f2..9e9f32e9c 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -174,7 +174,7 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if(me.equals(killer)){ lastKill = player; } else if (me.equals(player)){ - lastKiller = player; + lastKiller = killer; } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 2131c4750..f38d654d8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -174,7 +174,7 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if(me.equals(killer)){ lastKill = player; } else if (me.equals(player)){ - lastKiller = player; + lastKiller = killer; } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java index 16038a9aa..15bd70b26 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -174,7 +174,7 @@ private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable if(me.equals(killer)){ lastKill = player; } else if (me.equals(player)){ - lastKiller = player; + lastKiller = killer; } } From 3bc62ae80aac6e808cc339103d7cb636b88a5231 Mon Sep 17 00:00:00 2001 From: moehreag Date: Sun, 16 Jul 2023 00:34:54 +0200 Subject: [PATCH 39/41] fix a mixin on 1.16 versions --- .../java/io/github/axolotlclient/mixin/InGameHudMixin.java | 4 ++-- .../java/io/github/axolotlclient/mixin/InGameHudMixin.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 1686945be..64aa00f06 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -35,8 +35,8 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.util.Window; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; @@ -222,7 +222,7 @@ public abstract class InGameHudMixin { } @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) - private void axolotlclient$removeVignette(float f, Window window, CallbackInfo ci){ + private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ if(AxolotlClient.CONFIG.removeVignette.get()){ ci.cancel(); } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 1686945be..64aa00f06 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -35,8 +35,8 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.util.Window; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; @@ -222,7 +222,7 @@ public abstract class InGameHudMixin { } @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) - private void axolotlclient$removeVignette(float f, Window window, CallbackInfo ci){ + private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ if(AxolotlClient.CONFIG.removeVignette.get()){ ci.cancel(); } From 5439dabe8d6a88ccc85671510d8e9cf4041b52af Mon Sep 17 00:00:00 2001 From: moehreag Date: Sun, 16 Jul 2023 14:26:26 +0200 Subject: [PATCH 40/41] add random stat generation - lower the request limit due to new API rate limits --- .../hypixel/bedwars/BedwarsPlayer.java | 2 +- .../hypixel/bedwars/BedwarsPlayer.java | 2 +- .../hypixel/bedwars/BedwarsPlayer.java | 2 +- .../hypixel/bedwars/BedwarsPlayer.java | 2 +- .../hypixel/bedwars/BedwarsPlayer.java | 2 +- .../hypixel/bedwars/BedwarsPlayer.java | 2 +- .../hypixel/bedwars/BedwarsPlayer.java | 2 +- .../hypixel/HypixelAbstractionLayer.java | 16 ++++++---- .../hypixel/bedwars/BedwarsPlayerStats.java | 30 +++++++++++++++++-- 9 files changed, 45 insertions(+), 15 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java index c092237ca..07bce84e3 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -95,7 +95,7 @@ public void tick(int currentTick) { try { stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); } catch (Exception e) { - stats = BedwarsPlayerStats.generateFake(); + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); } } if (alive || tickAlive < 0) { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java index c092237ca..07bce84e3 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -95,7 +95,7 @@ public void tick(int currentTick) { try { stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); } catch (Exception e) { - stats = BedwarsPlayerStats.generateFake(); + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); } } if (alive || tickAlive < 0) { diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java index c092237ca..07bce84e3 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -95,7 +95,7 @@ public void tick(int currentTick) { try { stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); } catch (Exception e) { - stats = BedwarsPlayerStats.generateFake(); + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); } } if (alive || tickAlive < 0) { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java index c092237ca..07bce84e3 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -95,7 +95,7 @@ public void tick(int currentTick) { try { stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); } catch (Exception e) { - stats = BedwarsPlayerStats.generateFake(); + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); } } if (alive || tickAlive < 0) { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java index c092237ca..07bce84e3 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -95,7 +95,7 @@ public void tick(int currentTick) { try { stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); } catch (Exception e) { - stats = BedwarsPlayerStats.generateFake(); + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); } } if (alive || tickAlive < 0) { diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java index c092237ca..07bce84e3 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -95,7 +95,7 @@ public void tick(int currentTick) { try { stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); } catch (Exception e) { - stats = BedwarsPlayerStats.generateFake(); + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); } } if (alive || tickAlive < 0) { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java index c092237ca..07bce84e3 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -95,7 +95,7 @@ public void tick(int currentTick) { try { stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); } catch (Exception e) { - stats = BedwarsPlayerStats.generateFake(); + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); } } if (alive || tickAlive < 0) { diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java index bb7d51a4d..7450e1469 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.Objects; +import java.util.Random; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -81,15 +82,20 @@ public static int getPlayerLevel(String uuid, String mode) { if (Objects.equals(mode, LevelHeadMode.NETWORK.toString())) { return (int) player.getNetworkLevel(); } else if (Objects.equals(mode, LevelHeadMode.BEDWARS.toString())) { - return player.getIntProperty("achievements.bedwars_level", 0); + int level = player.getIntProperty("achievements.bedwars_level", -1); + if(level != -1){ + return level; + } } else if (Objects.equals(mode, LevelHeadMode.SKYWARS.toString())) { int exp = player - .getIntProperty("stats.SkyWars.skywars_experience", 0); - return Math.round(ExpCalculator.getLevelForExp(exp)); + .getIntProperty("stats.SkyWars.skywars_experience", -1); + if(exp != -1) { + return Math.round(ExpCalculator.getLevelForExp(exp)); + } } } } - return 0; + return (int) (new Random().nextGaussian()+150*30); } private static PlayerReply.Player getPlayer(String uuid) { @@ -125,7 +131,7 @@ public static void loadApiKey() { private static boolean loadPlayerDataIfAbsent(String uuid) { if (cachedPlayerData.get(uuid) == null) { // set at 115 to have a buffer in case of disparity between threads - if (hypixelApiCalls.get() <= 115) { + if (hypixelApiCalls.get() <= 55) { cachedPlayerData.put(uuid, api.getPlayerByUuid(uuid)); hypixelApiCalls.incrementAndGet(); ThreadExecuter.scheduleTask(hypixelApiCalls::decrementAndGet, 1, TimeUnit.MINUTES); diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java index f11af6be4..ff0b54fc5 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hypixel.bedwars; +import java.nio.charset.StandardCharsets; +import java.util.Random; + import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; @@ -66,9 +69,30 @@ public class BedwarsPlayerStats { private final int stars; - public static BedwarsPlayerStats generateFake() { - return new BedwarsPlayerStats(0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1); + public static BedwarsPlayerStats generateFake(String name) { + long seed = 0; + for(int i = 0; i Date: Sun, 16 Jul 2023 18:46:48 +0200 Subject: [PATCH 41/41] clamp randomly generated stats - update Trap RegEx --- .../modules/hypixel/bedwars/upgrades/TrapUpgrade.java | 4 +--- .../modules/hypixel/bedwars/upgrades/TrapUpgrade.java | 4 +--- .../modules/hypixel/bedwars/upgrades/TrapUpgrade.java | 4 +--- .../modules/hypixel/bedwars/upgrades/TrapUpgrade.java | 4 +--- .../modules/hypixel/bedwars/upgrades/TrapUpgrade.java | 4 +--- .../io/github/axolotlclient/mixin/PlayerListHudMixin.java | 4 ++-- .../modules/hypixel/bedwars/upgrades/TrapUpgrade.java | 4 +--- .../modules/hypixel/bedwars/upgrades/TrapUpgrade.java | 4 +--- .../modules/hypixel/bedwars/BedwarsPlayerStats.java | 2 +- 9 files changed, 10 insertions(+), 24 deletions(-) diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 6701c7541..71de40a58 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -40,9 +40,7 @@ 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("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), Pattern.compile("Trap was set (off)!"), }; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 6701c7541..71de40a58 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -40,9 +40,7 @@ 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("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), Pattern.compile("Trap was set (off)!"), }; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 6701c7541..71de40a58 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -40,9 +40,7 @@ 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("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), Pattern.compile("Trap was set (off)!"), }; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 6701c7541..71de40a58 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -40,9 +40,7 @@ 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("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), Pattern.compile("Trap was set (off)!"), }; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 6701c7541..71de40a58 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -40,9 +40,7 @@ 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("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), Pattern.compile("Trap was set (off)!"), }; diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index efa529a70..32147684f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -187,9 +187,9 @@ public abstract class PlayerListHudMixin { return; } - render = HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 .getProfile().getId().toString().replace("-", ""), - LevelHeadMode.BEDWARS.toString()) + "☆"; + LevelHeadMode.BEDWARS.toString())); } catch (Exception e) { return; } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 64225f261..a4b43b345 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -40,9 +40,7 @@ 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("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), Pattern.compile("Trap was set (off)!"), }; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java index 2121765a0..d4ef4209c 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -40,9 +40,7 @@ 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("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), Pattern.compile("Trap was set (off)!"), }; diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java index ff0b54fc5..5a4a8a2aa 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -92,7 +92,7 @@ public static BedwarsPlayerStats generateFake(String name) { } private static double getGaussian(Random random, float mean, float deviation){ - return random.nextGaussian()+mean*deviation; + return Math.max(Math.min(random.nextGaussian()+mean*deviation, mean - deviation*3), mean + deviation*3); } @Nullable