From ad946bccdb1dd666f2648434ed3653eaf0b137a1 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Mon, 22 Aug 2022 02:08:50 +0200 Subject: added support for books and essence to bazaar --- .../skyhanni/features/bazaar/BazaarApi.kt | 13 +++----- .../features/bazaar/BazaarBestSellMethod.kt | 2 +- .../skyhanni/features/bazaar/BazaarDataGrabber.kt | 37 +++++++++++++++++++--- .../skyhanni/features/bazaar/BazaarOrderHelper.kt | 2 +- .../java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 7 ++++ 5 files changed, 46 insertions(+), 15 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt index 3de78206b..5ae100ac2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.bazaar import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.removeColor class BazaarApi { @@ -29,22 +30,18 @@ class BazaarApi { if (name.endsWith(" Gemstone")) { return name.substring(6) } - if (name.startsWith("ยง")) { - return name.substring(2) - } - - return name + return name.removeColor() } - fun getBazaarDataForName(name: String): BazaarData { + fun getBazaarDataForName(name: String): BazaarData? { if (bazaarMap.containsKey(name)) { val bazaarData = bazaarMap[name] if (bazaarData != null) { return bazaarData } - LorenzUtils.error("Bazaar data is null for item '$name'") + LorenzUtils.error("Bazaar data not found! '$name'") } - throw Error("no bz data found for name '$name'") + return null } fun isBazaarItem(name: String): Boolean { diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt index c4afc33fc..e97ff5817 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt @@ -40,7 +40,7 @@ class BazaarBestSellMethod { val bazaarItem = inv.getStackInSlot(13) ?: return "" var name = bazaarItem.displayName name = BazaarApi.getCleanBazaarName(name) - val data = BazaarApi.getBazaarDataForName(name) + val data = BazaarApi.getBazaarDataForName(name) ?: return "" var having = 0 for (slot in chest.inventorySlots) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt index eea1138fa..f8f05845b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt @@ -3,6 +3,8 @@ package at.hannibal2.skyhanni.features.bazaar import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round +import at.hannibal2.skyhanni.utils.NumberUtil.isInt +import at.hannibal2.skyhanni.utils.NumberUtil.toRoman import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase import kotlin.concurrent.fixedRateTimer @@ -114,14 +116,39 @@ internal class BazaarDataGrabber(private var bazaarMap: MutableMap