diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt | 50 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt | 3 |
2 files changed, 51 insertions, 2 deletions
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 |