aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-11-17 17:29:15 +0100
committerLinnea Gräf <nea@nea.moe>2024-11-17 17:29:15 +0100
commit970dfddaf9e80d6b206f411139227397f4d9e847 (patch)
tree999f15cf28127c2053058dd877f6354540c22553 /src/main/kotlin/features
parent915ab96b2444fa2e93d99a9747861b619d77f8f8 (diff)
downloadFirmament-970dfddaf9e80d6b206f411139227397f4d9e847.tar.gz
Firmament-970dfddaf9e80d6b206f411139227397f4d9e847.tar.bz2
Firmament-970dfddaf9e80d6b206f411139227397f4d9e847.zip
feat: Add bazaar/ah search hotkey
Diffstat (limited to 'src/main/kotlin/features')
-rw-r--r--src/main/kotlin/features/FeatureManager.kt3
-rw-r--r--src/main/kotlin/features/inventory/ItemHotkeys.kt39
-rw-r--r--src/main/kotlin/features/mining/HotmPresets.kt3
3 files changed, 42 insertions, 3 deletions
diff --git a/src/main/kotlin/features/FeatureManager.kt b/src/main/kotlin/features/FeatureManager.kt
index 55f6328..2110d09 100644
--- a/src/main/kotlin/features/FeatureManager.kt
+++ b/src/main/kotlin/features/FeatureManager.kt
@@ -90,6 +90,9 @@ object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "feature
fun subscribeEvents() {
SubscriptionList.allLists.forEach {
it.provideSubscriptions {
+ it.owner.javaClass.classes.forEach {
+ runCatching { it.getDeclaredField("INSTANCE").get(null) }
+ }
subscribeSingleEvent(it)
}
}
diff --git a/src/main/kotlin/features/inventory/ItemHotkeys.kt b/src/main/kotlin/features/inventory/ItemHotkeys.kt
new file mode 100644
index 0000000..4aa8202
--- /dev/null
+++ b/src/main/kotlin/features/inventory/ItemHotkeys.kt
@@ -0,0 +1,39 @@
+package moe.nea.firmament.features.inventory
+
+import moe.nea.firmament.annotations.Subscribe
+import moe.nea.firmament.events.HandledScreenKeyPressedEvent
+import moe.nea.firmament.gui.config.ManagedConfig
+import moe.nea.firmament.repo.HypixelStaticData
+import moe.nea.firmament.repo.ItemCache
+import moe.nea.firmament.repo.ItemCache.asItemStack
+import moe.nea.firmament.repo.ItemCache.isBroken
+import moe.nea.firmament.repo.RepoManager
+import moe.nea.firmament.util.MC
+import moe.nea.firmament.util.focusedItemStack
+import moe.nea.firmament.util.skyBlockId
+import moe.nea.firmament.util.skyblock.SBItemUtil.getSearchName
+
+object ItemHotkeys {
+ object TConfig : ManagedConfig("item-hotkeys", Category.INVENTORY) {
+ val openGlobalTradeInterface by keyBindingWithDefaultUnbound("global-trade-interface")
+ }
+
+ @Subscribe
+ fun onHandledInventoryPress(event: HandledScreenKeyPressedEvent) {
+ if (!event.matches(TConfig.openGlobalTradeInterface)) {
+ return
+ }
+ var item = event.screen.focusedItemStack ?: return
+ val skyblockId = item.skyBlockId ?: return
+ item = RepoManager.getNEUItem(skyblockId)?.asItemStack()?.takeIf { !it.isBroken } ?: item
+ if (HypixelStaticData.hasBazaarStock(skyblockId)) {
+ MC.sendCommand("bz ${item.getSearchName()}")
+ } else if (HypixelStaticData.hasAuctionHouseOffers(skyblockId)) {
+ MC.sendCommand("ahs ${item.getSearchName()}")
+ } else {
+ return
+ }
+ event.cancel()
+ }
+
+}
diff --git a/src/main/kotlin/features/mining/HotmPresets.kt b/src/main/kotlin/features/mining/HotmPresets.kt
index 533aa1e..2241fee 100644
--- a/src/main/kotlin/features/mining/HotmPresets.kt
+++ b/src/main/kotlin/features/mining/HotmPresets.kt
@@ -34,9 +34,6 @@ import moe.nea.firmament.util.unformattedString
import moe.nea.firmament.util.useMatch
object HotmPresets {
- object Config : ManagedConfig("hotm-presets", Category.MINING) {
- }
-
val SHARE_PREFIX = "FIRMHOTM/"
@Serializable