aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock
diff options
context:
space:
mode:
authorRime <81419447+Emirlol@users.noreply.github.com>2024-07-05 12:53:09 +0300
committerGitHub <noreply@github.com>2024-07-05 17:53:09 +0800
commit4e3f74507728a52271636e25331920a6f239bcb2 (patch)
treecd64551030883e509c39e2904685ccdf59631992 /src/main/java/de/hysky/skyblocker/skyblock
parentfbf7f62b5049d0a5bce3a490e08bbfd3c7e1a8a9 (diff)
downloadSkyblocker-4e3f74507728a52271636e25331920a6f239bcb2.tar.gz
Skyblocker-4e3f74507728a52271636e25331920a6f239bcb2.tar.bz2
Skyblocker-4e3f74507728a52271636e25331920a6f239bcb2.zip
Jerry timer (#748)
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/mayors/JerryTimer.java37
1 files changed, 37 insertions, 0 deletions
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 00000000..7131a567
--- /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 "<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, 100f, 1.0f);
+ }, 20*60*6); // 6 minutes
+ });
+ }
+}