Skip to content

Commit

Permalink
Jerry timer initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Emirlol committed Jun 4, 2024
1 parent cfa71fe commit 7e6f330
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/de/hysky/skyblocker/SkyblockerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.<Boolean>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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/de/hysky/skyblocker/skyblock/mayors/JerryTimer.java
Original file line number Diff line number Diff line change
@@ -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 "<color> 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
});
}
}
5 changes: 5 additions & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down

0 comments on commit 7e6f330

Please sign in to comment.