From 575c7a806aeb80ce5be6e51ddd957fcd0e18b639 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 25 Mar 2023 20:59:56 +0100 Subject: Added CH join - Helps buy a Pass for accessing the Crystal Hollows if needed --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 1 + .../hannibal2/skyhanni/config/features/Misc.java | 5 ++ .../skyhanni/features/misc/JoinCrystalHollows.kt | 81 ++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 9c7538839..bb82c5cc6 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -230,6 +230,7 @@ public class SkyHanniMod { loadModule(new GardenNextJacobContest()); loadModule(new WrongFungiCutterWarning()); loadModule(new FarmingArmorDrops()); + loadModule(new JoinCrystalHollows()); Commands.INSTANCE.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index 4268a4286..8e59cb297 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -252,6 +252,11 @@ public class Misc { @ConfigEditorBoolean public boolean hideExplosions = false; + @Expose + @ConfigOption(name = "CH Join", desc = "Helps buy a Pass for accessing the Crystal Hollows if needed.") + @ConfigEditorBoolean + public boolean crystalHollowsJoin = true; + @Expose @ConfigOption(name = "Fire Overlay Hider", desc = "Hide the fire overlay (Like in Skytils)") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt new file mode 100644 index 000000000..f12506c33 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt @@ -0,0 +1,81 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.IslandChangeEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import net.minecraft.client.Minecraft +import net.minecraft.event.ClickEvent +import net.minecraft.event.HoverEvent +import net.minecraft.util.ChatComponentText +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class JoinCrystalHollows { + + private var lastWrongPassTime = 0L + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!isEnabled()) return + + val message = event.message + if (message == "§cYou do not have an active Crystal Hollows pass!") { + lastWrongPassTime = System.currentTimeMillis() + if (LorenzUtils.skyBlockIsland != IslandType.DWARVEN_MINES) { + sendClickableMessage("§e[SkyHanni] Click here to warp to Dwarven Mines!", "warp mines") + } else { + LorenzUtils.chat("§e[SkyHanni] Buy a §2Crystal Hollows Pass §efrom §5Gwendolyn") + } + } + if (message == "§e[NPC] §5Gwendolyn§f: §rGreat! Now hop on into the Minecart and I'll get you on your way!") { + if (inTime()) { + sendClickableMessage("§e[SkyHanni] Click here to warp to Crystal Hollows!", "warp ch") + } + } + } + + private fun sendClickableMessage(message: String, command: String) { + val text = ChatComponentText(message) + text.chatStyle.chatClickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/$command") + text.chatStyle.chatHoverEvent = + HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText("§eExecute /$command")) + Minecraft.getMinecraft().thePlayer.addChatMessage(text) + } + + @SubscribeEvent + fun onIslandChange(event: IslandChangeEvent) { + if (!isEnabled()) return + + if (event.newIsland == IslandType.DWARVEN_MINES) { + if (inTime()) { + LorenzUtils.chat("§e[SkyHanni] Buy a §2Crystal Hollows Pass §efrom §5Gwendolyn§e!") + } + } + if (event.newIsland == IslandType.CRYSTAL_HOLLOWS) { + lastWrongPassTime = 0 + } + } + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!isEnabled()) return + if (LorenzUtils.skyBlockIsland != IslandType.DWARVEN_MINES) return + + if (inTime()) { + val location = LorenzVec(88, 198, -99) + event.drawWaypointFilled(location, LorenzColor.YELLOW.toColor()) + event.drawDynamicText(location, "§eBuy Crystal Hollows Pass", 1.3) + } + } + + private fun inTime() = lastWrongPassTime + 1000 * 60 * 2 > System.currentTimeMillis() + + fun isEnabled() = SkyHanniMod.feature.misc.crystalHollowsJoin +} \ No newline at end of file -- cgit