diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-21 15:04:40 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-21 15:04:40 +0100 |
commit | 9c52cce10df4851f517d2c64a486ff90e49c8a2b (patch) | |
tree | d75f84d085855348a4dcf2f04034d0d5655b8ec8 /src/main/java/at | |
parent | 6cc2646eaaec81581ec4914f3a656578323ead28 (diff) | |
download | skyhanni-9c52cce10df4851f517d2c64a486ff90e49c8a2b.tar.gz skyhanni-9c52cce10df4851f517d2c64a486ff90e49c8a2b.tar.bz2 skyhanni-9c52cce10df4851f517d2c64a486ff90e49c8a2b.zip |
Added Plot Price.
Diffstat (limited to 'src/main/java/at')
4 files changed, 58 insertions, 6 deletions
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 |