From 7e6f330f6efdaa7bc7d10c2d7e4b2b2b92b8d73a Mon Sep 17 00:00:00 2001 From: Rime <81419447+Emirlol@users.noreply.github.com> Date: Tue, 4 Jun 2024 20:00:50 +0300 Subject: [PATCH] Jerry timer initial commit --- .../de/hysky/skyblocker/SkyblockerMod.java | 3 +- .../config/categories/HelperCategory.java | 14 +++++++ .../config/configs/HelperConfig.java | 8 ++++ .../skyblock/mayors/JerryTimer.java | 37 +++++++++++++++++++ .../assets/skyblocker/lang/en_us.json | 5 +++ 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/mayors/JerryTimer.java diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index a9aab3b6eb..33ca826b24 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -34,7 +34,7 @@ import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview; import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; -import de.hysky.skyblocker.skyblock.quicknav.QuickNav; +import de.hysky.skyblocker.skyblock.mayors.JerryTimer; import de.hysky.skyblocker.skyblock.rift.TheRift; import de.hysky.skyblocker.skyblock.searchoverlay.SearchOverManager; import de.hysky.skyblocker.skyblock.shortcut.Shortcuts; @@ -185,6 +185,7 @@ public void onInitializeClient() { EggFinder.init(); TimeTowerReminder.init(); SkyblockTime.init(); + JerryTimer.init(); Scheduler.INSTANCE.scheduleCyclic(Utils::update, 20); Scheduler.INSTANCE.scheduleCyclic(DiscordRPCManager::updateDataAndPresence, 200); diff --git a/src/main/java/de/hysky/skyblocker/config/categories/HelperCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/HelperCategory.java index 9e4935cb8d..1518dfe7d9 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/HelperCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/HelperCategory.java @@ -38,6 +38,20 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .build()) + //Jerry Timer + .group(OptionGroup.createBuilder() + .name(Text.translatable("skyblocker.config.helpers.jerry")) + .collapsed(true) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.helpers.jerry.enableJerryTimer")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.helpers.jerry.enableJerryTimer.@Tooltip"))) + .binding(defaults.helpers.jerry.enableJerryTimer, + () -> config.helpers.jerry.enableJerryTimer, + newValue -> config.helpers.jerry.enableJerryTimer = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .build()) + //Experiments Solver .group(OptionGroup.createBuilder() .name(Text.translatable("skyblocker.config.helpers.experiments")) diff --git a/src/main/java/de/hysky/skyblocker/config/configs/HelperConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/HelperConfig.java index c031492422..33047f1c5b 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/HelperConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/HelperConfig.java @@ -11,6 +11,9 @@ public class HelperConfig { @SerialEntry public MythologicalRitual mythologicalRitual = new MythologicalRitual(); + @SerialEntry + public Jerry jerry = new Jerry(); + @SerialEntry public Experiments experiments = new Experiments(); @@ -28,6 +31,11 @@ public static class MythologicalRitual { public boolean enableMythologicalRitualHelper = true; } + public static class Jerry { + @SerialEntry + public boolean enableJerryTimer = false; + } + public static class Experiments { @SerialEntry public boolean enableChronomatronSolver = true; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/mayors/JerryTimer.java b/src/main/java/de/hysky/skyblocker/skyblock/mayors/JerryTimer.java new file mode 100644 index 0000000000..378d77dc81 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/mayors/JerryTimer.java @@ -0,0 +1,37 @@ +package de.hysky.skyblocker.skyblock.mayors; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.Constants; +import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.scheduler.Scheduler; +import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.text.HoverEvent; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; + +public final class JerryTimer { + private JerryTimer() { + } + public static void init() { + //Example message: "§b ☺ §eThere is a §aGreen Jerry§e!" + //There are various formats, all of which start with the "§b ☺ " prefix and contain the word " Jerry" + ClientReceiveMessageEvents.GAME.register((message, overlay) -> { + if (overlay || !Utils.getMayor().equals("Jerry") || !SkyblockerConfigManager.get().helpers.jerry.enableJerryTimer) return; + String text = message.getString(); + //This part of hypixel still uses legacy text formatting, so we can't directly check for the actual text + if (!text.startsWith("§b ☺ ") || !text.contains("Jerry")) return; + HoverEvent hoverEvent = message.getStyle().getHoverEvent(); + if (hoverEvent == null || hoverEvent.getAction() != HoverEvent.Action.SHOW_TEXT) return; + ClientPlayerEntity player = MinecraftClient.getInstance().player; + Scheduler.INSTANCE.schedule(() -> { + if (player == null || !Utils.isOnSkyblock()) return; + player.sendMessage(Constants.PREFIX.get().append(Text.literal("Jerry cooldown is over!")).formatted(Formatting.GREEN), false); + player.playSoundToPlayer(SoundEvents.ENTITY_VILLAGER_TRADE, SoundCategory.NEUTRAL, 1.0f, 1.0f); + }, 20*60*6); // 6 minutes + }); + } +} diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 57abdc46cf..b051e6793d 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -313,6 +313,11 @@ "skyblocker.config.helpers.fishing.hideOtherPlayers": "Hide Other Players Rods", "skyblocker.config.helpers.fishing.hideOtherPlayers.@Tooltip": "Hide other players fishing rods from showing for you", + "skyblocker.config.helpers.jerry": "Jerry", + "skyblocker.config.helpers.jerry.enableJerryTimer": "Enable Jerry Timer", + "skyblocker.config.helpers.jerry.enableJerryTimer.@Tooltip": "Sends a message in chat and plays a sound when the hidden jerry spawn cooldown is over.", + + "skyblocker.config.helpers.mythologicalRitual": "Mythological Ritual Helper", "skyblocker.config.helpers.mythologicalRitual.enableMythologicalRitualHelper": "Enable Mythological Ritual Helper",