aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/skyblock/ScreenIdentification.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/util/skyblock/ScreenIdentification.kt')
-rw-r--r--src/main/kotlin/util/skyblock/ScreenIdentification.kt61
1 files changed, 38 insertions, 23 deletions
diff --git a/src/main/kotlin/util/skyblock/ScreenIdentification.kt b/src/main/kotlin/util/skyblock/ScreenIdentification.kt
index 4fea3df..0e7797c 100644
--- a/src/main/kotlin/util/skyblock/ScreenIdentification.kt
+++ b/src/main/kotlin/util/skyblock/ScreenIdentification.kt
@@ -7,31 +7,46 @@ import moe.nea.firmament.util.mc.loreAccordingToNbt
import moe.nea.firmament.util.unformattedString
-fun Screen.isBazaarUi(): Boolean {
- if (this !is GenericContainerScreen) return false
- return (
- this.screenHandler.stacks[this.screenHandler.rows * 9 - 4]
- .displayNameAccordingToNbt
- .unformattedString == "Manage Orders"
- || this.screenHandler.stacks[this.screenHandler.rows * 9 - 5]
- .loreAccordingToNbt
- .any {
- it.unformattedString == "To Bazaar"
- })
-}
-
-fun Screen.isEnchantmentGuide(): Boolean {
- return title.unformattedString.endsWith("Enchantments Guide")
-}
+object ScreenIdentification {
+ private var lastScreen: Screen? = null
+ private var lastScreenType: ScreenType? = null
-fun Screen.isSuperPairs(): Boolean {
- return title.unformattedString.startsWith("Superpairs")
+ fun getType(screen: Screen?): ScreenType? {
+ if (screen == null) return null
+ if (screen !== lastScreen) {
+ lastScreenType = ScreenType.entries
+ .find { it.detector(screen) }
+ lastScreen = screen
+ }
+ return lastScreenType
+ }
}
-fun Screen.isExperimentationRngMeter(): Boolean {
- return this.title.unformattedString.contains("Experimentation Table RNG")
+enum class ScreenType(val detector: (Screen) -> Boolean) {
+ BAZAAR_ANY({
+ it is GenericContainerScreen && (
+ it.screenHandler.getSlot(it.screenHandler.rows * 9 - 4)
+ .stack
+ .displayNameAccordingToNbt
+ .unformattedString == "Manage Orders"
+ || it.screenHandler.getSlot(it.screenHandler.rows * 9 - 5)
+ .stack
+ .loreAccordingToNbt
+ .any {
+ it.unformattedString == "To Bazaar"
+ })
+ }),
+ ENCHANTMENT_GUIDE({
+ it.title.unformattedString.endsWith("Enchantments Guide")
+ }),
+ SUPER_PAIRS({
+ it.title.unformattedString.startsWith("Superpairs")
+ }),
+ EXPERIMENTATION_RNG_METER({
+ it.title.unformattedString.contains("Experimentation Table RNG")
+ }),
+ DYE_COMPENDIUM({
+ it.title.unformattedString.contains("Dye Compendium")
+ })
}
-fun Screen.isDyeCompendium(): Boolean {
- return this.title.unformattedString.contains("Dye Compendium")
-}