summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-02-22 21:15:35 +0100
committerGitHub <noreply@github.com>2024-02-22 21:15:35 +0100
commita9263a24a55396739e4bbfd7af7119863dc1e953 (patch)
tree9390c28f111e5c8ac81c412e58de2a8ec380a967 /src/main/java/at/hannibal2/skyhanni/features
parentdf9710ee23a3497f13e6ab810e34111151d6de85 (diff)
downloadskyhanni-a9263a24a55396739e4bbfd7af7119863dc1e953.tar.gz
skyhanni-a9263a24a55396739e4bbfd7af7119863dc1e953.tar.bz2
skyhanni-a9263a24a55396739e4bbfd7af7119863dc1e953.zip
Added not fully completed tasks in Way to gain SkyBlock Xp menus. #974
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBlockLevelGuideHelper.kt38
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt246
2 files changed, 246 insertions, 38 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBlockLevelGuideHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBlockLevelGuideHelper.kt
deleted file mode 100644
index 60c1a28de..000000000
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyBlockLevelGuideHelper.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-package at.hannibal2.skyhanni.features.inventory
-
-import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.GuiContainerEvent
-import at.hannibal2.skyhanni.utils.InventoryUtils
-import at.hannibal2.skyhanni.utils.ItemUtils.name
-import at.hannibal2.skyhanni.utils.LorenzColor
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.RenderUtils.highlight
-import net.minecraft.client.gui.inventory.GuiChest
-import net.minecraft.inventory.ContainerChest
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-
-class SkyBlockLevelGuideHelper {
-
- @SubscribeEvent
- fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (!SkyHanniMod.feature.inventory.highlightMissingSkyBlockLevelGuide) return
-
- if (InventoryUtils.openInventoryName().contains("Guide ➜")) {
-
- if (event.gui !is GuiChest) return
- val guiChest = event.gui
- val chest = guiChest.inventorySlots as ContainerChest
-
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- if (slot.slotNumber != slot.slotIndex) continue
- val name = slot.stack?.name ?: continue
-
- if (name.startsWith("§c✖")) {
- slot highlight LorenzColor.RED
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt
new file mode 100644
index 000000000..4cbaf896e
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt
@@ -0,0 +1,246 @@
+package at.hannibal2.skyhanni.features.inventory
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.events.InventoryCloseEvent
+import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
+import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.highlight
+import at.hannibal2.skyhanni.utils.StringUtils.anyMatches
+import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import org.intellij.lang.annotations.Language
+
+val group = RepoPattern.group("skyblockguide.highlight")
+
+private const val keyPrefixInventory = "inventory"
+private const val keyPrefixCondition = "condition"
+
+class SkyblockGuideHighlightFeature private constructor(
+ private val config: () -> Boolean,
+ inventory: RepoPattern,
+ loreCondition: RepoPattern,
+ private val onSlotClicked: (GuiContainerEvent.SlotClickEvent) -> Unit = {},
+ private val onTooltip: (LorenzToolTipEvent) -> Unit = {},
+) {
+
+ private val inventoryPattern by inventory
+ private val conditionPattern by loreCondition
+
+ private constructor(
+ config: () -> Boolean,
+ key: String,
+ @Language("RegExp") inventory: String,
+ @Language("RegExp") loreCondition: String,
+ onSlotClicked: (GuiContainerEvent.SlotClickEvent) -> Unit = {},
+ onTooltip: (LorenzToolTipEvent) -> Unit = {},
+ ) : this(
+ config,
+ group.pattern("$key.$keyPrefixInventory", inventory),
+ group.pattern("$key.$keyPrefixCondition", loreCondition),
+ onSlotClicked,
+ onTooltip
+ )
+
+ private constructor(
+ config: () -> Boolean,
+ key: String,
+ @Language("RegExp") inventory: String,
+ loreCondition: RepoPattern,
+ onSlotClicked: (GuiContainerEvent.SlotClickEvent) -> Unit = {},
+ onTooltip: (LorenzToolTipEvent) -> Unit = {},
+ ) : this(config, group.pattern("$key.$keyPrefixInventory", inventory), loreCondition, onSlotClicked, onTooltip)
+
+ init {
+ objectList.add(this)
+ }
+
+ companion object {
+
+ private val skyblockGuideConfig get() = SkyHanniMod.feature.inventory.skyblockGuideConfig
+
+ private val objectList = mutableListOf<SkyblockGuideHighlightFeature>()
+
+ private var activeObject: SkyblockGuideHighlightFeature? = null
+ private var missing = mutableSetOf<Int>()
+
+ fun isEnabled() = LorenzUtils.inSkyBlock
+ fun close() {
+ activeObject = null
+ }
+
+ @SubscribeEvent
+ fun onInventoryClose(event: InventoryCloseEvent) = close()
+
+ @SubscribeEvent
+ fun onInventoryClose(event: GuiContainerEvent.CloseWindowEvent) = close()
+
+ @SubscribeEvent
+ fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
+ if (!isEnabled()) return
+ val current = activeObject ?: return
+ if (!missing.contains(event.slotId)) return
+ current.onSlotClicked.invoke(event)
+ }
+
+ @SubscribeEvent
+ fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
+ if (!isEnabled()) return
+ if (activeObject == null) return
+
+ event.gui.inventorySlots.inventorySlots.filter { missing.contains(it.slotNumber) }
+ .forEach { it highlight LorenzColor.RED }
+ }
+
+ @SubscribeEvent
+ fun onTooltip(event: LorenzToolTipEvent) {
+ if (!isEnabled()) return
+ val current = activeObject ?: return
+ if (!missing.contains(event.slot.slotNumber)) return
+ current.onTooltip.invoke(event)
+ }
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
+ if (!isEnabled()) return
+ val current =
+ objectList.firstOrNull { it.config.invoke() && it.inventoryPattern.matches(event.inventoryName) }
+ ?: return
+
+ missing.clear()
+ activeObject = current
+
+ for ((slot, item) in event.inventoryItems) {
+ if (slot == 4) continue // Overview Item
+ val loreAndName = listOf(item.name ?: "") + item.getLore()
+ if (!current.conditionPattern.anyMatches(loreAndName)) continue
+ missing.add(slot)
+ }
+ }
+
+ private val taskOnlyCompleteOncePattern =
+ group.pattern("$keyPrefixCondition.once", "§7§eThis task can only be completed once!")
+ private val xPattern = group.pattern("$keyPrefixCondition.x", "§c ?✖.*")
+ private val totalProgressPattern =
+ group.pattern("$keyPrefixCondition.total", "§7Total Progress: §3\\d{1,2}(?:\\.\\d)?%")
+ private val categoryProgressPattern =
+ group.pattern("$keyPrefixCondition.category", "§7Progress to Complete Category: §6\\d{1,2}(?:\\.\\d)?%")
+
+ private val openWikiOnClick: (GuiContainerEvent.SlotClickEvent) -> Unit = { event ->
+ val internalName = event.item?.getInternalName()
+ if (internalName != null) {
+ LorenzUtils.sendCommandToServer("wiki ${internalName.asString()}")
+ }
+ }
+
+ private val openWikiTooltip: (LorenzToolTipEvent) -> Unit = { event ->
+ event.toolTip.add("")
+ event.toolTip.add("§7§eClick to view on the SkyBlock Wiki!")
+ }
+
+ init {
+ SkyblockGuideHighlightFeature(
+ { SkyHanniMod.feature.inventory.highlightMissingSkyBlockLevelGuide },
+ "level.guide",
+ ".*Guide ➜.*",
+ xPattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.abiphoneGuide },
+ "abiphone",
+ "Miscellaneous ➜ Abiphone Contac",
+ taskOnlyCompleteOncePattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.oneTimeCompletion }, "bank", "Core ➜ Bank Upgrades", taskOnlyCompleteOncePattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.storyGuide },
+ "travel",
+ "Core ➜ Fast Travels Unlocked",
+ taskOnlyCompleteOncePattern,
+ { LorenzUtils.sendCommandToServer("wiki MUSEUM_TRAVEL_SCROLL") }, // The items do not have proper internal names and using the fact that all travel scrolls lead to the same wiki page
+ openWikiTooltip
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.oneTimeCompletion },
+ "spooky",
+ "Event ➜ Spooky Festival",
+ taskOnlyCompleteOncePattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.oneTimeCompletion },
+ "belt",
+ "Miscellaneous ➜ The Dojo",
+ taskOnlyCompleteOncePattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.jacobGuide },
+ "jacob",
+ "Event ➜ Jacob's Farming Contest",
+ taskOnlyCompleteOncePattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.oneTimeCompletion },
+ "slaying",
+ "Slaying ➜ .*",
+ taskOnlyCompleteOncePattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.storyGuide }, "story", "Story ➜ Complete Objectives", taskOnlyCompleteOncePattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.oneTimeCompletion },
+ "pet.rock",
+ "Mining ➜ Rock Milestones",
+ taskOnlyCompleteOncePattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.oneTimeCompletion },
+ "pet.dolphin",
+ "Fishing ➜ Dolphin Milestones",
+ taskOnlyCompleteOncePattern
+ )
+ SkyblockGuideHighlightFeature({ skyblockGuideConfig.essenceGuide }, "essence", "Essence Shop ➜.*", xPattern)
+ SkyblockGuideHighlightFeature({ skyblockGuideConfig.minionGuide }, "minion", "Crafted Minions", xPattern)
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.storyGuide }, "harp", "Miscellaneous ➜ Harp Songs", xPattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.consumableGuide },
+ "consumable",
+ "Miscellaneous ➜ Consumable Items",
+ "§7§eThis task can be completed \\d+ times!",
+ openWikiOnClick,
+ openWikiTooltip
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.oneTimeCompletion },
+ "dungeon.floor",
+ "Complete Dungeons ➜.*",
+ "§7§eThis task can only be completed once!|§7§7You have not unlocked the content"
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.oneTimeCompletion }, "dungeon.layers", "Dungeon ➜ Complete Dungeons", xPattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.menuGuide }, "tasks", "Tasks ➜ .*", totalProgressPattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.menuGuide }, "tasks.skill", "Skill Related Tasks", categoryProgressPattern
+ )
+ SkyblockGuideHighlightFeature(
+ { skyblockGuideConfig.collectionGuide },
+ "collections",
+ "\\w+ Collections|Collections",
+ "§7Progress to .*|§7Find this item to add it to your|§7Kill this boss once to view collection|§7Collections Maxed Out: §e.*|§7Boss Collections Unlocked: §e.*"
+ )
+ }
+ }
+}