diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-25 20:59:56 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-25 20:59:56 +0100 |
commit | 575c7a806aeb80ce5be6e51ddd957fcd0e18b639 (patch) | |
tree | 61ca4ca05c5c0c0b2b2ba22e610fe26fdeea10c8 /src/main/java/at | |
parent | 3a16772807010ed96b646b4760c556e10b09ebfb (diff) | |
download | skyhanni-575c7a806aeb80ce5be6e51ddd957fcd0e18b639.tar.gz skyhanni-575c7a806aeb80ce5be6e51ddd957fcd0e18b639.tar.bz2 skyhanni-575c7a806aeb80ce5be6e51ddd957fcd0e18b639.zip |
Added CH join - Helps buy a Pass for accessing the Crystal Hollows if needed
Diffstat (limited to 'src/main/java/at')
3 files changed, 87 insertions, 0 deletions
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 @@ -253,6 +253,11 @@ public class Misc { 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 public boolean hideFireOverlay = false; 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 |