From 9c52cce10df4851f517d2c64a486ff90e49c8a2b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 21 Feb 2023 15:04:40 +0100 Subject: Added Plot Price. --- CHANGELOG.md | 1 + FEATURES.md | 1 + .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 6 +-- .../hannibal2/skyhanni/config/features/Garden.java | 5 +++ .../features/garden/GardenNextPlotPrice.kt | 50 ++++++++++++++++++++++ .../features/garden/GardenVisitorFeatures.kt | 3 +- 6 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index d4e6236c6..0920dc8a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ + Added **Crop Upgrades** Number - Show the number of upgrades in the crop upgrades inventory. + Added **Visitor Timer** - Timer when the next visitor will appear, and a number how many visitors are already waiting. + Added **Visitor Notification** - Show as title and in chat when a new visitor is visiting your island. ++ Added **Plot Price** - Show the price of the plot in coins when inside the Configure Plots inventory. ### Features from other Mods > *The following features are only there because I want them when testing SkyHanni features without other mods present.* diff --git a/FEATURES.md b/FEATURES.md index b04fb1a3b..913a32087 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -167,6 +167,7 @@ + **Crop Upgrades** Number - Show the number of upgrades in the crop upgrades inventory. + **Visitor Timer** - Timer when the next visitor will appear, and a number how many visitors are already waiting. + **Visitor Notification** - Show as title and in chat when a new visitor is visiting your island. ++ **Plot Price** - Show the price of the plot in coins when inside the Configure Plots inventory. ## Commands - /wiki (using hypixel-skyblock.fandom.com instead of Hypixel wiki) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 52f696542..c07feba3b 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -23,10 +23,7 @@ import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper; import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder; import at.hannibal2.skyhanni.features.event.diana.SoopyGuessBurrow; import at.hannibal2.skyhanni.features.fishing.*; -import at.hannibal2.skyhanni.features.garden.GardenInventoryNumbers; -import at.hannibal2.skyhanni.features.garden.GardenVisitorFeatures; -import at.hannibal2.skyhanni.features.garden.GardenVisitorTimer; -import at.hannibal2.skyhanni.features.garden.SkyMartBestProfit; +import at.hannibal2.skyhanni.features.garden.*; import at.hannibal2.skyhanni.features.inventory.*; import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles; import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown; @@ -206,6 +203,7 @@ public class SkyHanniMod { loadModule(new GardenVisitorFeatures()); loadModule(new GardenInventoryNumbers()); loadModule(new GardenVisitorTimer()); + loadModule(new GardenNextPlotPrice()); Commands.INSTANCE.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index 78ddb5e37..b2684880d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -105,4 +105,9 @@ public class Garden { @ConfigEditorBoolean @ConfigAccordionId(id = 4) public boolean numberCropUpgrades = true; + + @Expose + @ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.") + @ConfigEditorBoolean + public boolean plotPrice = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt new file mode 100644 index 000000000..0612faaf7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt @@ -0,0 +1,50 @@ +package at.hannibal2.skyhanni.features.garden + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.ItemUtils.name +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class GardenNextPlotPrice { + + @SubscribeEvent + fun onTooltip(event: ItemTooltipEvent) { + if (!isEnabled()) return + if (!SkyHanniMod.feature.garden.plotPrice) return + + if (InventoryUtils.openInventoryName() != "Configure Plots") return + + val name = event.itemStack.name ?: return + if (!name.startsWith("§ePlot")) return + + var next = false + val list = event.toolTip + var i = -1 + for (l in list) { + i++ + val line = l.substring(4) + if (line.contains("Cost")) { + next = true + continue + } + + if (next) { + val (itemName, amount) = ItemUtils.readItemAmount(line) + if (itemName != null) { + val internalName = NEUItems.getInternalNameByName(itemName) + val auctionManager = NotEnoughUpdates.INSTANCE.manager.auctionManager + val lowestBin = auctionManager.getBazaarOrBin(internalName, false) + val price = lowestBin * amount + val format = NumberUtil.format(price) + list[i] = list[i] + " §f(§6$format§f)" + } + break + } + } + } + + private fun isEnabled() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.GARDEN +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt index 6567397cc..b20c699cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt @@ -15,7 +15,6 @@ import net.minecraft.client.Minecraft import net.minecraft.entity.EntityLivingBase import net.minecraft.network.play.client.C02PacketUseEntity import net.minecraftforge.event.entity.player.ItemTooltipEvent -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -101,7 +100,7 @@ class GardenVisitorFeatures { var tick = 0 - @SubscribeEvent(priority = EventPriority.LOW) + @SubscribeEvent fun onTooltip(event: ItemTooltipEvent) { if (!isEnabled()) return if (!nearby) return -- cgit