aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-08-02 10:57:02 +0200
committerGitHub <noreply@github.com>2024-08-02 10:57:02 +0200
commit2f53d615b8cf6054e96dba6a5ad45ab244b3fc33 (patch)
tree8a0ed9e1df9c303c38cdcfa5f0d5add33bd6c9a5 /src
parenta6b7559cec69bda9e8202de6440da784d3f8925a (diff)
downloadskyhanni-2f53d615b8cf6054e96dba6a5ad45ab244b3fc33.tar.gz
skyhanni-2f53d615b8cf6054e96dba6a5ad45ab244b3fc33.tar.bz2
skyhanni-2f53d615b8cf6054e96dba6a5ad45ab244b3fc33.zip
Backend: /shdebugprice (#2289)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt66
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt11
3 files changed, 77 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
index 6dd8db8ad..89d7bb9bb 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -59,7 +59,6 @@ import at.hannibal2.skyhanni.features.minion.MinionFeatures
import at.hannibal2.skyhanni.features.misc.CollectionTracker
import at.hannibal2.skyhanni.features.misc.LockMouseLook
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
-import at.hannibal2.skyhanni.features.misc.MiscFeatures
import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager
import at.hannibal2.skyhanni.features.misc.limbo.LimboTimeTracker
import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures
@@ -87,6 +86,7 @@ import at.hannibal2.skyhanni.test.command.TrackSoundsCommand
import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ExtendedChatColor
+import at.hannibal2.skyhanni.utils.ItemPriceUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.TabListData
@@ -452,6 +452,7 @@ object Commands {
"shtestisland",
"Sets the current skyblock island for testing purposes.",
) { SkyBlockIslandTest.onCommand(it) }
+ registerCommand("shdebugprice", "Debug different price sources for an item.") { ItemPriceUtils.debugItemPrice(it) }
}
private fun developersCodingHelp() {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt
new file mode 100644
index 000000000..e604c29ff
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt
@@ -0,0 +1,66 @@
+package at.hannibal2.skyhanni.utils
+
+import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.itemName
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
+import at.hannibal2.skyhanni.utils.NEUItems.getLowestBinOrNull
+import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull
+import at.hannibal2.skyhanni.utils.NEUItems.getPrice
+import at.hannibal2.skyhanni.utils.NEUItems.getRawCraftCostOrNull
+import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+
+object ItemPriceUtils {
+
+ fun debugItemPrice(args: Array<String>) {
+ val internalName = getItemOrFromHand(args)
+ if (internalName == null) {
+ ChatUtils.userError("Hold an item in hand or do /shdebugprice <item name/id>")
+ return
+ }
+
+
+ val defaultPrice = internalName.getPrice().addSeparators()
+ ChatUtils.chat("${internalName.itemName}§f: §6$defaultPrice")
+
+ println("")
+ println(" Debug Item Price for $internalName ")
+ println("defaultPrice: $defaultPrice")
+
+ println(" #")
+ for (source in ItemPriceSource.values()) {
+ val price = internalName.getPrice(source)
+ println("${source.displayName} price: ${price.addSeparators()}")
+ }
+ println(" #")
+
+ println(" ")
+ println("getLowestBinOrNull: ${internalName.getLowestBinOrNull()?.addSeparators()}")
+
+ internalName.getBazaarData().let {
+ println("getBazaarData sellOfferPrice: ${it?.sellOfferPrice?.addSeparators()}")
+ println("getBazaarData instantBuyPrice: ${it?.instantBuyPrice?.addSeparators()}")
+ }
+
+ println("getNpcPriceOrNull: ${internalName.getNpcPriceOrNull()?.addSeparators()}")
+ println("getRawCraftCostOrNull: ${internalName.getRawCraftCostOrNull()?.addSeparators()}")
+ println(" ")
+ }
+
+ // TODO move either into inventory utils or new command utils
+ fun getItemOrFromHand(args: Array<String>): NEUInternalName? {
+ val name = args.joinToString(" ")
+ return if (name.isEmpty()) {
+ InventoryUtils.getItemInHand()?.getInternalName()
+ } else {
+ val internalName = name.asInternalName()
+ if (internalName.getItemStackOrNull() != null) {
+ internalName
+ } else {
+ NEUInternalName.fromItemNameOrNull(name)
+ }
+
+ }
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 35992a15e..f3657d10e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -193,8 +193,9 @@ object NEUItems {
return if (priceSource == ItemPriceSource.BAZAAR_INSTANT_BUY) it.sellOfferPrice else it.instantBuyPrice
}
- val result = manager.auctionManager.getLowestBin(asString())
- if (result != -1L) return result.toDouble()
+ getLowestBinOrNull()?.let {
+ return it
+ }
if (equals("JACK_O_LANTERN")) {
return "PUMPKIN".asInternalName().getPrice(priceSource) + 1
@@ -208,6 +209,12 @@ object NEUItems {
return getNpcPriceOrNull() ?: getRawCraftCostOrNull(pastRecipes)
}
+ fun NEUInternalName.getLowestBinOrNull(): Double? {
+ val result = manager.auctionManager.getLowestBin(asString())
+ if (result == -1L) return null
+ return result.toDouble()
+ }
+
// If NEU fails to calculate the craft costs, we calculate it ourself.
fun NEUInternalName.getRawCraftCostOrNull(pastRecipes: List<NeuRecipe> = emptyList()): Double? =
manager.auctionManager.getCraftCost(asString())?.craftCost ?: run {