diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-16 13:27:44 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-16 13:27:44 +0200 |
commit | 6e8b4eba4d96fa71e5ed7263245ca9f19490d244 (patch) | |
tree | e6b8559466a126f0b536f17fcd38366e6432e658 | |
parent | b90d16f0a377a900877f4eebba7fe0c371f92fc6 (diff) | |
download | skyhanni-6e8b4eba4d96fa71e5ed7263245ca9f19490d244.tar.gz skyhanni-6e8b4eba4d96fa71e5ed7263245ca9f19490d244.tar.bz2 skyhanni-6e8b4eba4d96fa71e5ed7263245ca9f19490d244.zip |
Fixed SkyHanni gui edit button not working inside storage even if neu storage is not disabled.
5 files changed, 52 insertions, 42 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt index fa633eaa4..4f3110789 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt @@ -22,6 +22,7 @@ class GuiEditManager { @SubscribeEvent fun onKeyClick(event: LorenzKeyPressEvent) { if (!LorenzUtils.inSkyBlock) return + if (event.keyCode != SkyHanniMod.feature.gui.keyBindOpen) return if (isInGui()) return Minecraft.getMinecraft().currentScreen?.let { @@ -31,7 +32,7 @@ class GuiEditManager { if (NEUItems.neuHasFocus()) return - if (event.keyCode == SkyHanniMod.feature.gui.keyBindOpen) openGuiPositionEditor() + openGuiPositionEditor() } @SubscribeEvent(priority = EventPriority.LOWEST) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt index 23d7af564..82db5d451 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt @@ -1,17 +1,13 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.data.OtherMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue -import at.hannibal2.skyhanni.test.command.ErrorManager -import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.LorenzUtils @@ -21,7 +17,6 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.RecalculatingValue import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SpecialColour @@ -34,15 +29,13 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color -import java.io.File -import kotlin.time.Duration.Companion.seconds class ChestValue { private val config get() = SkyHanniMod.feature.inventory.chestValueConfig private var display = emptyList<List<Any>>() private val chestItems = mutableMapOf<NEUInternalName, Item>() - private val inInventory get() = InventoryUtils.openInventoryName().removeColor().isValidStorage() + private val inInventory get() = isValidStorage() @SubscribeEvent fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { @@ -234,34 +227,19 @@ class ChestValue { COMPACT("Aligned") } - private fun String.isValidStorage(): Boolean { + private fun isValidStorage(): Boolean { + val name = InventoryUtils.openInventoryName().removeColor() if (Minecraft.getMinecraft().currentScreen !is GuiChest) return false - if ((contains("Backpack") && contains("Slot #") || startsWith("Ender Chest (")) && - !isNeuStorageEnabled.getValue() + if ((name.contains("Backpack") && name.contains("Slot #") || name.startsWith("Ender Chest (")) && + !InventoryUtils.isNeuStorageEnabled.getValue() ) { return true } - val inMinion = contains("Minion") && !contains("Recipe") && + val inMinion = name.contains("Minion") && !name.contains("Recipe") && LorenzUtils.skyBlockIsland == IslandType.PRIVATE_ISLAND - return this == "Chest" || this == "Large Chest" || inMinion || this == "Personal Vault" - } - - private val isNeuStorageEnabled = RecalculatingValue(1.seconds) { - try { - val configPath = OtherMod.NEU.configPath - if (File(configPath).exists()) { - val json = ConfigManager.gson.fromJson( - APIUtil.readFile(File(configPath)), - com.google.gson.JsonObject::class.java - ) - json["storageGUI"].asJsonObject["enableStorageGUI3"].asBoolean - } else false - } catch (e: Exception) { - ErrorManager.logError(e, "Could not read NEU config to determine if the neu storage is emabled.") - false - } + return name == "Chest" || name == "Large Chest" || inMinion || name == "Personal Vault" } private fun String.reduceStringLength(targetLength: Int, char: Char): String { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt index e5763ed58..5325da375 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt @@ -24,8 +24,20 @@ class SkyBlockKickDuration { fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return if (event.message == "§cYou were kicked while joining that server!") { - //if is in hub: enable rn - kickMessage = true + + if (LorenzUtils.onHypixel && !LorenzUtils.inSkyBlock) { + kickMessage = false + showTime = true + lastKickTime = SimpleTimeMark.farPast() + } else { + kickMessage = true + } + } + + if (event.message == "§cThere was a problem joining SkyBlock, try again in a moment!") { + kickMessage = false + showTime = true + lastKickTime = SimpleTimeMark.farPast() } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index 8aefe5a2e..4c60444c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -1,10 +1,15 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.data.OtherMod +import at.hannibal2.skyhanni.test.command.ErrorManager import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack +import java.io.File +import kotlin.time.Duration.Companion.seconds object InventoryUtils { var itemInHandId = NEUInternalName.NONE @@ -39,14 +44,28 @@ object InventoryUtils { fun countItemsInLowerInventory(predicate: (ItemStack) -> Boolean) = getItemsInOwnInventory().filter { predicate(it) }.sumOf { it.stackSize } - fun inStorage() = - openInventoryName().let { - (it.contains("Storage") && !it.contains("Rift Storage")) || it.contains("Ender Chest") || it.contains( - "Backpack" - ) - } + fun inStorage() = openInventoryName().let { + (it.contains("Storage") && !it.contains("Rift Storage")) + || it.contains("Ender Chest") || it.contains("Backpack") + } fun getItemInHand(): ItemStack? = Minecraft.getMinecraft().thePlayer.heldItem fun getArmor(): Array<ItemStack?> = Minecraft.getMinecraft().thePlayer.inventory.armorInventory + + val isNeuStorageEnabled = RecalculatingValue(10.seconds) { + try { + val configPath = OtherMod.NEU.configPath + if (File(configPath).exists()) { + val json = ConfigManager.gson.fromJson( + APIUtil.readFile(File(configPath)), + com.google.gson.JsonObject::class.java + ) + json["storageGUI"].asJsonObject["enableStorageGUI3"].asBoolean + } else false + } catch (e: Exception) { + ErrorManager.logError(e, "Could not read NEU config to determine if the neu storage is emabled.") + false + } + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index ab21c47b1..dd4e21dc1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -252,17 +252,17 @@ object NEUItems { // ignore wheat in enchanted cookie if (internalName == "ENCHANTED_COOKIE" && internalItemId == "WHEAT") { - continue + continue } // ignore golden carrot in enchanted golden carrot if (internalName == "ENCHANTED_GOLDEN_CARROT" && internalItemId == "GOLDEN_CARROT") { - continue + continue } // ignore rabbit hide in leather if (internalName == "LEATHER" && internalItemId == "RABBIT_HIDE") { - continue + continue } val old = map.getOrDefault(internalItemId, 0) @@ -298,7 +298,7 @@ object NEUItems { fun neuHasFocus(): Boolean { if (AuctionSearchOverlay.shouldReplace()) return true if (BazaarSearchOverlay.shouldReplace()) return true - if (InventoryUtils.inStorage()) return true + if (InventoryUtils.inStorage() && InventoryUtils.isNeuStorageEnabled.getValue()) return true if (NEUOverlay.searchBarHasFocus) return true return false |