This repository has been archived by the owner on Dec 28, 2024. It is now read-only.
generated from ItsEmpa/SkyHanniDependantModTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
118 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/com/ratons/config/features/instances/AutoRefillConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.ratons.config.features.instances; | ||
|
||
import at.hannibal2.skyhanni.deps.moulconfig.annotations.ConfigEditorBoolean; | ||
import at.hannibal2.skyhanni.deps.moulconfig.annotations.ConfigOption; | ||
import com.google.gson.annotations.Expose; | ||
|
||
public class AutoRefillConfig { | ||
|
||
@Expose | ||
@ConfigOption(name = "Enabled", desc = "Automatically refill items at the start of an instance (Required for below options).") | ||
@ConfigEditorBoolean | ||
public boolean enabled = false; | ||
|
||
@Expose | ||
@ConfigOption(name = "Refill Peals", desc = "Enables auto refill for Ender Pearls.") | ||
@ConfigEditorBoolean | ||
public boolean refillPearls = false; | ||
|
||
@Expose | ||
@ConfigOption(name = "Refill Decoys", desc = "Enables auto refill for Decoys on F4/M4.") | ||
@ConfigEditorBoolean | ||
public boolean refillDecoys = false; | ||
|
||
@Expose | ||
@ConfigOption(name = "Refill Inflatable Jerrys", desc = "Enables auto refill for Inflatable Jerrys on M7.") | ||
@ConfigEditorBoolean | ||
public boolean refillJerrys = false; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/ratons/config/features/instances/InstancesConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.ratons.config.features.instances; | ||
|
||
import at.hannibal2.skyhanni.deps.moulconfig.annotations.Accordion; | ||
import at.hannibal2.skyhanni.deps.moulconfig.annotations.ConfigOption; | ||
import com.google.gson.annotations.Expose; | ||
|
||
public class InstancesConfig { | ||
|
||
@ConfigOption(name = "Auto Refill", desc = "") | ||
@Accordion | ||
@Expose | ||
public AutoRefillConfig autoRefill = new AutoRefillConfig(); | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
src/main/kotlin/com/ratons/features/instances/AutoRefill.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.ratons.features.instances | ||
|
||
import at.hannibal2.skyhanni.api.GetFromSackAPI | ||
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.ChatUtils | ||
import at.hannibal2.skyhanni.utils.InventoryUtils.getAmountInInventory | ||
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName | ||
import at.hannibal2.skyhanni.utils.SimpleTimeMark | ||
import com.ratons.Ratons | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
import kotlin.time.Duration.Companion.seconds | ||
|
||
@Suppress("SkyHanniModuleInspection") | ||
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() | ||
} | ||
|
||
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 | ||
|
||
val amount = it.internalName.asInternalName().getAmountInInventory() | ||
val difference = it.stackSize - amount | ||
|
||
if (it.internalName.asInternalName().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) | ||
} | ||
} | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/com/ratons/features/instances/Refillables.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.ratons.features.instances | ||
|
||
enum class Refillables( | ||
val 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), | ||
} |
19 changes: 0 additions & 19 deletions
19
src/main/kotlin/com/ratons/features/misc/ExampleFeature.kt
This file was deleted.
Oops, something went wrong.