diff --git a/gradle.properties b/gradle.properties index 49c3a76..cd47f96 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ mod_name = Rat-ons mod_id = ratons mod_version = 0.0.1 -skyhanni_version = 0.27.Beta.4 +skyhanni_version = 0.27.Beta.8 loom.platform=forge org.gradle.jvmargs=-Xmx4g diff --git a/src/main/kotlin/com/ratons/Ratons.kt b/src/main/kotlin/com/ratons/Ratons.kt index 26e224c..22c6bbe 100644 --- a/src/main/kotlin/com/ratons/Ratons.kt +++ b/src/main/kotlin/com/ratons/Ratons.kt @@ -6,6 +6,7 @@ import com.ratons.commands.Commands import com.ratons.config.features.Features import com.ratons.features.instances.AutoRefill import com.ratons.features.misc.UpdateManager +import com.ratons.utils.KuudraAPI import net.minecraft.client.Minecraft import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.Mod @@ -17,6 +18,7 @@ import java.io.File @Mod( modid = Ratons.MOD_ID, + name = Ratons.MOD_NAME, clientSideOnly = true, useMetadata = true, version = Ratons.VERSION, @@ -33,6 +35,9 @@ class Ratons { AutoRefill, UpdateManager, + // utils + KuudraAPI, + ).loadModules() Commands.init() diff --git a/src/main/kotlin/com/ratons/events/KuudraStartEvent.kt b/src/main/kotlin/com/ratons/events/KuudraStartEvent.kt new file mode 100644 index 0000000..f144293 --- /dev/null +++ b/src/main/kotlin/com/ratons/events/KuudraStartEvent.kt @@ -0,0 +1,5 @@ +package com.ratons.events + +import at.hannibal2.skyhanni.api.event.SkyHanniEvent + +class KuudraStartEvent(val kuudraTier: Int?) : SkyHanniEvent() diff --git a/src/main/kotlin/com/ratons/features/instances/AutoRefill.kt b/src/main/kotlin/com/ratons/features/instances/AutoRefill.kt index 4cd564e..17ca62f 100644 --- a/src/main/kotlin/com/ratons/features/instances/AutoRefill.kt +++ b/src/main/kotlin/com/ratons/features/instances/AutoRefill.kt @@ -1,17 +1,16 @@ package com.ratons.features.instances import at.hannibal2.skyhanni.api.GetFromSackAPI +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.SackAPI.getAmountInSacks import at.hannibal2.skyhanni.events.DungeonStartEvent -import at.hannibal2.skyhanni.events.KuudraEnterEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.dungeon.DungeonFloor -import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.InventoryUtils.getAmountInInventory import com.ratons.Ratons +import com.ratons.events.KuudraStartEvent import com.ratons.utils.ChatUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.Duration.Companion.seconds @Suppress("SkyHanniModuleInspection") object AutoRefill { @@ -23,12 +22,9 @@ object AutoRefill { newInstance() } - @SubscribeEvent - fun onKuudraStart(event: KuudraEnterEvent) { - // TODO: use chat pattern instead - DelayedRun.runDelayed(10.seconds) { - newInstance() - } + @HandleEvent + fun onKuudraStart(event: KuudraStartEvent) { + newInstance() } private fun newInstance() { diff --git a/src/main/kotlin/com/ratons/utils/KuudraAPI.kt b/src/main/kotlin/com/ratons/utils/KuudraAPI.kt new file mode 100644 index 0000000..b37e27a --- /dev/null +++ b/src/main/kotlin/com/ratons/utils/KuudraAPI.kt @@ -0,0 +1,22 @@ +package com.ratons.utils + +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import com.ratons.events.KuudraStartEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@Suppress("SkyHanniModuleInspection") +object KuudraAPI { + + private val startPattern = "§e\\[NPC] §cElle§f: §rOkay adventurers, I will go and fish up Kuudra!".toPattern() + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!KuudraAPI.inKuudra()) return + if (startPattern.matches(event.message)) { + KuudraStartEvent(KuudraAPI.kuudraTier).post() + } + } + +}