Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
bit of cleanup in pearl refill and refillables
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsEmpa committed Sep 13, 2024
1 parent f0113c7 commit 74d1620
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

public class InstancesConfig {

@Expose
@ConfigOption(name = "Auto Refill", desc = "")
@Accordion
@Expose
public AutoRefillConfig autoRefill = new AutoRefillConfig();

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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.ChatUtils
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.InventoryUtils.getAmountInInventory
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.SimpleTimeMark
Expand All @@ -19,40 +20,40 @@ object PearlRefill {

private val config get() = Ratons.feature.instancesConfig.autoRefill

init {
Refillables.entries
}

@SubscribeEvent
fun onDungeonStart(event: DungeonStartEvent) {
newInstance()
}

@SubscribeEvent
fun onKuudraStart(event: KuudraEnterEvent) {
val enter = SimpleTimeMark.now()
while (enter.passedSince() < 10.seconds) return
newInstance()
// TODO: use chat pattern instead
DelayedRun.runDelayed(10.seconds) {
newInstance()
}
}

private fun newInstance() {
if (!config.enabled) return
for (it in Refillables.entries) {
if (!config.refillPearls && it.internalName == "ENDER_PEARL") return
if (it.internalName == "DUNGEON_DECOY" && (!config.refillDecoys || DungeonAPI.getCurrentBoss() != DungeonFloor.F4)) return
if (it.internalName == "INFLATABLE_JERRY" && (!config.refillJerrys || DungeonAPI.dungeonFloor!! != "M7")) return
when (it) {
Refillables.ENDER_PEARL -> if (!config.refillPearls) return
Refillables.DECOY -> if (!config.refillDecoys || DungeonAPI.getCurrentBoss() != DungeonFloor.F4) return
Refillables.INFLATABLE_JERRY -> if (!config.refillJerrys || DungeonAPI.dungeonFloor!! != "M7") return
}
val internalName = it.internalName

val amount = it.internalName.asInternalName().getAmountInInventory()
val amount = internalName.getAmountInInventory()
val difference = it.stackSize - amount

if (it.internalName.asInternalName().getAmountInSacks() < difference) {
if (internalName.getAmountInSacks() < difference) {
ChatUtils.chat("You do not have enough items to refill ${it.displayName}(s).")
return
}
if (difference > 0) {
GetFromSackAPI.getFromSack(it.internalName.asInternalName(), difference)
GetFromSackAPI.getFromSack(internalName, difference)
}
}

}
}
}
7 changes: 6 additions & 1 deletion src/main/kotlin/com/ratons/features/instances/Refillables.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.ratons.features.instances

import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName

enum class Refillables(
val internalName: String,
internalName: String,
val displayName: String,
val stackSize: Int,
) {
ENDER_PEARL("ENDER_PEARL", "§fEnder Pearl", 16),
DECOY("DUNGEON_DECOY", "§aDecoy", 64),
INFLATABLE_JERRY("INFLATABLE_JERRY", "§fInflatable Jerry", 64),
;

val internalName = internalName.asInternalName()
}

0 comments on commit 74d1620

Please sign in to comment.