diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-10 17:18:09 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-10 17:18:09 +0200 |
commit | b8e54dd10bb6383d11d15863c2d90c0cabd7ee2e (patch) | |
tree | 4712b7cd5979f1c6b246b47954496d25a69b867c /src/main/java/at/hannibal2 | |
parent | 30805daacae5f5b9d06bd239c958368815236c73 (diff) | |
download | skyhanni-b8e54dd10bb6383d11d15863c2d90c0cabd7ee2e.tar.gz skyhanni-b8e54dd10bb6383d11d15863c2d90c0cabd7ee2e.tar.bz2 skyhanni-b8e54dd10bb6383d11d15863c2d90c0cabd7ee2e.zip |
Adding Motes NPC price to item lore
Diffstat (limited to 'src/main/java/at/hannibal2')
5 files changed, 57 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index e19feb339..cc16baa95 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -321,6 +321,7 @@ class SkyHanniMod { loadModule(RiftUpsideDownParkour()) loadModule(RiftLavaMazeParkour()) loadModule(HighlightMiningCommissionMobs()) + loadModule(ShowMotesNpcSellPrice()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java index 9464cd420..d9d90cd35 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -333,4 +333,9 @@ public class RiftConfig { } + @Expose + @ConfigOption(name = "Show Motes Price", desc = "Show the Motes NPC price in the item lore.") + @ConfigEditorBoolean + public boolean showMotesPrice = true; + } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt index d426af0cf..d359cebc1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.bazaar import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils @@ -20,15 +21,21 @@ class BazaarDataHolder { val list = mutableMapOf<String, Double>() try { val itemsData = APIUtil.getJSONResponse("https://api.hypixel.net/resources/skyblock/items") + val motesPrice = mutableMapOf<String, Double>() for (element in itemsData["items"].asJsonArray) { val jsonObject = element.asJsonObject - if (jsonObject.has("npc_sell_price")) { - val hypixelId = jsonObject["id"].asString - val npcPrice = jsonObject["npc_sell_price"].asDouble + val hypixelId = jsonObject["id"].asString + jsonObject["npc_sell_price"]?.let { val neuItemId = NEUItems.transHypixelNameToInternalName(hypixelId) - list[neuItemId] = npcPrice + list[neuItemId] = it.asDouble + } + jsonObject["motes_sell_price"]?.let { + val neuItemId = NEUItems.transHypixelNameToInternalName(hypixelId) + println("motes price: $neuItemId = $it") + motesPrice[neuItemId] = it.asDouble } } + RiftAPI.motesPrice = motesPrice } catch (e: Throwable) { e.printStackTrace() LorenzUtils.error("Error while trying to read bazaar item list from api: " + e.message) diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt index ea2f929e6..e0ff66926 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt @@ -1,8 +1,19 @@ package at.hannibal2.skyhanni.features.rift +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.features.RiftConfig import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.item.ItemStack object RiftAPI { fun inRift() = LorenzUtils.inIsland(IslandType.THE_RIFT) + + val config: RiftConfig get() = SkyHanniMod.feature.rift + + // internal name -> motes + var motesPrice = emptyMap<String, Double>() + + fun ItemStack.motesNpcPrice() = motesPrice[getInternalName()] }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/ShowMotesNpcSellPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/ShowMotesNpcSellPrice.kt new file mode 100644 index 000000000..41fb1f0b5 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/ShowMotesNpcSellPrice.kt @@ -0,0 +1,29 @@ +package at.hannibal2.skyhanni.features.rift + +import at.hannibal2.skyhanni.features.rift.RiftAPI.motesNpcPrice +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ShowMotesNpcSellPrice { + + @SubscribeEvent + fun onItemTooltipLow(event: ItemTooltipEvent) { +// if (!SkyHanniMod.feature.dev.showInternalName) return + + if (!isEnabled()) return + + val itemStack = event.itemStack ?: return + + val motesPerItem = itemStack.motesNpcPrice() ?: return + val size = itemStack.stackSize + if (size > 1) { + val motes = motesPerItem * size + event.toolTip.add("§6NPC price: §d${motes.addSeparators()} Motes §7($size x §d${motesPerItem.addSeparators()} Motes§7)") + } else { + event.toolTip.add("§6NPC price: §d${motesPerItem.addSeparators()} Motes") + } + } + + fun isEnabled() = RiftAPI.inRift() && RiftAPI.config.showMotesPrice +} |