aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarBestSellMethod.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/bazaar/BazaarBestSellMethod.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/bazaar/BazaarBestSellMethod.kt79
1 files changed, 0 insertions, 79 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarBestSellMethod.kt
deleted file mode 100644
index 56c264312..000000000
--- a/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarBestSellMethod.kt
+++ /dev/null
@@ -1,79 +0,0 @@
-package at.hannibal2.skyhanni.bazaar
-
-import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.GuiContainerEvent
-import at.hannibal2.skyhanni.utils.GuiRender.renderString
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.NumberUtil
-import net.minecraft.client.gui.inventory.GuiChest
-import net.minecraft.inventory.ContainerChest
-import net.minecraftforge.client.event.GuiScreenEvent
-import net.minecraftforge.fml.common.eventhandler.EventPriority
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-
-class BazaarBestSellMethod {
-
- companion object {
- private var textToRender = ""
- }
-
- @SubscribeEvent
- fun onBackgroundDrawn(event: GuiContainerEvent.CloseWindowEvent) {
- textToRender = ""
- }
-
- @SubscribeEvent
- fun onGuiDrawEvent(event: GuiScreenEvent.DrawScreenEvent.Post) {
- if (!isEnabled()) return
- textToRender = getNewText(event)
- }
-
- private fun getNewText(event: GuiScreenEvent.DrawScreenEvent.Post): String {
- try {
- if (event.gui !is GuiChest) return ""
- val chest = (event.gui as GuiChest).inventorySlots as ContainerChest
-
- val inv = chest.lowerChestInventory ?: return ""
-
- val buyInstantly = inv.getStackInSlot(10)
- if (buyInstantly == null || buyInstantly.displayName != "§aBuy Instantly") return ""
- val bazaarItem = inv.getStackInSlot(13) ?: return ""
- var name = bazaarItem.displayName
- name = BazaarApi.getCleanBazaarName(name)
- val data = BazaarApi.getBazaarDataForName(name)
-
- var having = 0
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- if (slot.slotNumber == slot.slotIndex) continue
- if (slot.stack == null) continue
- val stack = slot.stack
- val displayName = stack.displayName
- if (BazaarApi.getCleanBazaarName(displayName) == name) {
- having += stack.stackSize
- }
- }
-
- if (having <= 0) return ""
-
- val totalDiff = (data.buyPrice - data.sellPrice) * having
- val result = NumberUtil.format(totalDiff.toInt())
-
- return "§b$name§f sell difference: §e$result coins"
- } catch (e: Error) {
- e.printStackTrace()
- return ""
- }
- }
-
- @SubscribeEvent(priority = EventPriority.LOWEST)
- fun renderOverlay(event: GuiScreenEvent.BackgroundDrawnEvent) {
- if (!isEnabled()) return
-
- SkyHanniMod.feature.bazaar.bestSellMethodPos.renderString(textToRender)
- }
-
- private fun isEnabled(): Boolean {
- return LorenzUtils.inSkyblock && SkyHanniMod.feature.bazaar.bestSellMethod
- }
-} \ No newline at end of file