aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/AuctionHouseConfig.java47
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java26
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt52
5 files changed, 109 insertions, 27 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
index f779fb282..2984dcf02 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
@@ -10,7 +10,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {
val logger = LorenzLogger("ConfigMigration")
- const val CONFIG_VERSION = 24
+ const val CONFIG_VERSION = 25
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/AuctionHouseConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/AuctionHouseConfig.java
new file mode 100644
index 000000000..8c3d8d385
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/AuctionHouseConfig.java
@@ -0,0 +1,47 @@
+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.ConfigEditorKeybind;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
+import org.lwjgl.input.Keyboard;
+
+public class AuctionHouseConfig {
+
+
+ @Expose
+ @ConfigOption(
+ name = "Highlight Auctions",
+ desc = "Highlight own items that are sold in green and that are expired in red."
+ )
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean highlightAuctions = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Highlight Underbid Auctions",
+ desc = "Highlight underbid own lowest BIN auctions that are outbid."
+ )
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean highlightAuctionsUnderbid = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Auto Copy Underbid",
+ desc = "Automatically copies the price of an item in the \"Create BIN Auction\" minus 1 coin into the clipboard for faster under-bidding."
+ )
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean autoCopyUnderbidPrice = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Copy Underbid Keybind",
+ desc = "Copies the price of the hovered item in Auction House minus 1 coin into the clipboard for easier under-bidding."
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
+ public int copyUnderbidKeybind = Keyboard.KEY_NONE;
+}
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 82235a828..553d58214 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
@@ -66,6 +66,11 @@ public class InventoryConfig {
public GetFromSackConfig gfs = new GetFromSackConfig();
@Expose
+ @ConfigOption(name = "Auctions", desc = "")
+ @Accordion
+ public AuctionHouseConfig auctions = new AuctionHouseConfig();
+
+ @Expose
@ConfigOption(
name = "Item Number",
desc = "Showing the item number as a stack size for these items."
@@ -174,27 +179,6 @@ public class InventoryConfig {
public boolean powerStoneGuide = true;
@Expose
- @ConfigOption(name = "Highlight Auctions",
- desc = "Highlight own items that are sold in green and that are expired in red.")
- @ConfigEditorBoolean
- @FeatureToggle
- public boolean highlightAuctions = true;
-
- @Expose
- @ConfigOption(name = "Highlight Underbid Auctions",
- desc = "Highlight underbid own lowest BIN auctions that are outbid.")
- @ConfigEditorBoolean
- @FeatureToggle
- public boolean highlightAuctionsUnderbid = false;
-
- @Expose
- @ConfigOption(name = "Copy Underbid Price",
- desc = "Copies the price of an item in the \"Create BIN Auction\" minus 1 coin into the clipboard for faster under-bidding.")
- @ConfigEditorBoolean
- @FeatureToggle
- public boolean copyUnderbidPrice = false;
-
- @Expose
@ConfigOption(name = "Shift Click Equipment", desc = "Makes normal clicks to shift clicks in equipment inventory.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt
index 6c8ff6bf8..be7451090 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.inventory
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
@@ -18,7 +19,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class AuctionsHighlighter {
- private val config get() = SkyHanniMod.feature.inventory
+ private val config get() = SkyHanniMod.feature.inventory.auctions
private val buyItNowPattern by RepoPattern.pattern(
"auctions.highlight.buyitnow",
@@ -63,4 +64,10 @@ class AuctionsHighlighter {
}
}
}
+
+ @SubscribeEvent
+ fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
+ event.move(25, "inventory.highlightAuctions", "inventory.auctions.highlightAuctions")
+ event.move(25, "inventory.highlightAuctionsUnderbid", "inventory.auctions.highlightAuctionsUnderbid")
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt
index 6ebcf08c0..5cfaa558a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt
@@ -1,23 +1,44 @@
package at.hannibal2.skyhanni.features.misc.items
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getPrice
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.OSUtils
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraft.client.gui.inventory.GuiContainer
+import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class AuctionHouseCopyUnderbidPrice {
- private val config get() = SkyHanniMod.feature.inventory
+ private val config get() = SkyHanniMod.feature.inventory.auctions
+
+ private val patternGroup = RepoPattern.group("auctions.underbid")
+ private val auctionPricePattern by patternGroup.pattern(
+ "price",
+ "^§7(?:Buy it now|Starting bid|Top bid): §6(?<coins>[0-9,]+) coins\$"
+ )
+ private val allowedInventoriesPattern by patternGroup.pattern(
+ "allowedinventories",
+ "^(?:Auctions Browser|Manage Auctions|Auctions: \".*\")$"
+ )
@SubscribeEvent
fun onInventoryUpdated(event: InventoryUpdatedEvent) {
- if (!isEnabled()) return
+ if (!LorenzUtils.inSkyBlock) return
+ if (!config.autoCopyUnderbidPrice) return
if (!event.fullyOpenedOnce) return
if (event.inventoryName != "Create BIN Auction") return
val item = event.inventoryItems[13] ?: return
@@ -32,8 +53,31 @@ class AuctionHouseCopyUnderbidPrice {
}
val newPrice = price * item.stackSize - 1
OSUtils.copyToClipboard("$newPrice")
- ChatUtils.chat("Set §e${newPrice.addSeparators()} §eto clipboard. (Copy Underbid Price)")
+ ChatUtils.chat("Copied ${newPrice.addSeparators()} to clipboard. (Copy Underbid Price)")
}
- fun isEnabled() = LorenzUtils.inSkyBlock && config.copyUnderbidPrice
+ @SubscribeEvent
+ fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent.Post) {
+ if (!config.copyUnderbidKeybind.isKeyHeld()) return
+ if (!LorenzUtils.inSkyBlock) return
+ if (!allowedInventoriesPattern.matches(InventoryUtils.openInventoryName())) return
+
+ val gui = event.gui as? GuiContainer ?: return
+ val stack = gui.slotUnderMouse?.stack ?: return
+ val lore = stack.getLore()
+
+ for (line in lore) {
+ auctionPricePattern.matchMatcher(line) {
+ val underbid = group("coins").formatNumber() - 1
+ OSUtils.copyToClipboard("$underbid")
+ ChatUtils.chat("Copied ${underbid.addSeparators()} to clipboard.")
+ return
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
+ event.move(25, "inventory.copyUnderbidPrice", "inventory.auctions.autoCopyUnderbidPrice")
+ }
}