diff options
Diffstat (limited to 'src/main')
7 files changed, 331 insertions, 43 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index d0f2bc9b4..07d2e7aa9 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -222,7 +222,7 @@ import at.hannibal2.skyhanni.features.inventory.SackDisplay import at.hannibal2.skyhanni.features.inventory.ShiftClickBrewing import at.hannibal2.skyhanni.features.inventory.ShiftClickEquipment import at.hannibal2.skyhanni.features.inventory.ShiftClickNPCSell -import at.hannibal2.skyhanni.features.inventory.SkyBlockLevelGuideHelper +import at.hannibal2.skyhanni.features.inventory.SkyblockGuideHighlightFeature import at.hannibal2.skyhanni.features.inventory.StatsTuning import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayHelper import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayWaypoints @@ -571,8 +571,8 @@ class SkyHanniMod { loadModule(LesserOrbHider()) loadModule(FishingHookDisplay()) loadModule(CrimsonIsleReputationHelper(this)) + loadModule(SkyblockGuideHighlightFeature) loadModule(SharkFishCounter()) - loadModule(SkyBlockLevelGuideHelper()) loadModule(PowerStoneGuideFeatures()) loadModule(OdgerWaypoint()) loadModule(TiaRelayHelper()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 2c9813bcc..84ebfd9ca 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -9,7 +9,6 @@ import io.github.moulberry.moulconfig.annotations.Category; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; import io.github.moulberry.moulconfig.annotations.ConfigOption; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -53,6 +52,10 @@ public class InventoryConfig { public ChestValueConfig chestValueConfig = new ChestValueConfig(); @Expose + @Category(name = "Skyblock Guide", desc = "") + public SkyblockGuideConfig skyblockGuideConfig = new SkyblockGuideConfig(); + + @Expose @Category(name = "Helpers", desc = "Settings for Helpers") public HelperConfig helper = new HelperConfig(); @@ -156,6 +159,7 @@ public class InventoryConfig { @Expose @ConfigOption(name = "Missing Tasks", desc = "Highlight missing tasks in the SkyBlock Level Guide inventory.") + // TODO move( , "inventory.highlightMissingSkyBlockLevelGuide", "inventory.skyblockGuideConfig.highlightMissingSkyBlockLevelGuide") @ConfigEditorBoolean @FeatureToggle public boolean highlightMissingSkyBlockLevelGuide = true; @@ -163,6 +167,7 @@ public class InventoryConfig { @Expose @ConfigOption(name = "Power Stone Guide", desc = "Highlight missing power stones, show their total bazaar price, and allows to open the bazaar when clicking on the items in the Power Stone Guide.") + // TODO move( , "inventory.powerStoneGuide", "inventory.skyblockGuideConfig.powerStoneGuide") @ConfigEditorBoolean @FeatureToggle public boolean powerStoneGuide = true; diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/SkyblockGuideConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/SkyblockGuideConfig.java new file mode 100644 index 000000000..6a4e213ce --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/SkyblockGuideConfig.java @@ -0,0 +1,73 @@ +package at.hannibal2.skyhanni.config.features.inventory; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; + +public class SkyblockGuideConfig { + + @Expose + @ConfigOption(name = "Menu Highlight", + desc = "Highlights the toplevel of not completed task in the skyblock guide.") + @ConfigEditorBoolean + @FeatureToggle + public boolean menuGuide = true; + + @Expose + @ConfigOption(name = "Collection Highlight", + desc = "Highlights missing collections.") + @ConfigEditorBoolean + @FeatureToggle + public boolean collectionGuide = true; + + @Expose + @ConfigOption(name = "Abiphone Highlight", + desc = "Highlights missing abiphone contacts.") + @ConfigEditorBoolean + @FeatureToggle + public boolean abiphoneGuide = true; + + @Expose + @ConfigOption(name = "Minion Highlight", + desc = "Highlights not maxed minions.") + @ConfigEditorBoolean + @FeatureToggle + public boolean minionGuide = true; + + @Expose + @ConfigOption(name = "Essence Shop Highlight", + desc = "Highlights missing essence shop upgrades.") + @ConfigEditorBoolean + @FeatureToggle + public boolean essenceGuide = false; + + @Expose + @ConfigOption(name = "Consumable Highlight", + desc = "Highlight not fully consumed consumables.") + @ConfigEditorBoolean + @FeatureToggle + public boolean consumableGuide = true; + + @Expose + @ConfigOption(name = "Jacob Contest Highlight", + desc = "Highlight crop where no gold medal was earned.") + @ConfigEditorBoolean + @FeatureToggle + public boolean jacobGuide = true; + + @Expose + @ConfigOption(name = "Story Highlight", + desc = "Highlights uncompleted story lines, missing fast travel scrolls and not 100% completed harp songs.") + @ConfigEditorBoolean + @FeatureToggle + public boolean storyGuide = true; + + @Expose + @ConfigOption(name = "One Time Completion Highlights", + desc = "Highlights missing kuudra defeats, dungeon floors completions, spooky ranks, bank upgrades, rock/dolphin rarities, undefeated dragons, unobtained dojo belts.") + @ConfigEditorBoolean + @FeatureToggle + public boolean oneTimeCompletion = true; + +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt index f6ffc4295..74202594c 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.events import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.inventory.Container import net.minecraft.inventory.Slot +import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.Cancelable abstract class GuiContainerEvent(open val gui: GuiContainer, open val container: Container) : LorenzEvent() { @@ -50,6 +51,7 @@ abstract class GuiContainerEvent(open val gui: GuiContainer, open val container: data class SlotClickEvent( override val gui: GuiContainer, override val container: Container, + val item: ItemStack?, val slot: Slot?, val slotId: Int, val clickedButton: Int, 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.*" + ) + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt index a09d8d923..d855c6e5a 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt @@ -40,7 +40,7 @@ class GuiContainerHook(guiAny: Any) { } fun onMouseClick(slot: Slot?, slotId: Int, clickedButton: Int, clickType: Int, ci: CallbackInfo) { - if (SlotClickEvent(gui, gui.inventorySlots, slot, slotId, clickedButton, clickType).postAndCatch()) ci.cancel() + if (SlotClickEvent(gui, gui.inventorySlots, gui.inventorySlots?.inventory?.takeIf { it.size > slotId && slotId >= 0 }?.get(slotId), slot, slotId, clickedButton, clickType).postAndCatch()) ci.cancel() } fun onDrawScreenAfter( @@ -50,4 +50,4 @@ class GuiContainerHook(guiAny: Any) { ) { if (DrawScreenAfterEvent(mouseX, mouseY, ci).postAndCatch()) ci.cancel() } -}
\ No newline at end of file +} |