diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt | 11 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt | 21 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt index 2486c7eee..7477d74bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt @@ -19,9 +19,13 @@ import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.UUID +import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.minutes class GuiEditManager { + + var lastHotkeyPressed = SimpleTimeMark.farPast() + @SubscribeEvent fun onKeyClick(event: LorenzKeyPressEvent) { if (!LorenzUtils.inSkyBlock) return @@ -33,8 +37,11 @@ class GuiEditManager { if (it is GuiEditSign && !it.isRancherSign()) return } + if (lastHotkeyPressed.passedSince() < 500.milliseconds) return if (NEUItems.neuHasFocus()) return + lastHotkeyPressed = SimpleTimeMark.now() + Minecraft.getMinecraft().thePlayer.closeScreen() openGuiPositionEditor(hotkeyReminder = false) } @@ -71,8 +78,8 @@ class GuiEditManager { lastHotkeyReminded = SimpleTimeMark.now() LorenzUtils.chat( "§eTo edit hidden GUI elements:\n" + - " §7- §e1. Set a key in /sh edit.\n" + - " §7- §e2. Click that key while the GUI element is visible." + " §7- §e1. Set a key in /sh edit.\n" + + " §7- §e2. Click that key while the GUI element is visible." ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index eb06c23ee..2a6b002af 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -1,14 +1,12 @@ 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 io.github.moulberry.notenoughupdates.NotEnoughUpdates 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 { @@ -56,15 +54,14 @@ object InventoryUtils { 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) { + val config = NotEnoughUpdates.INSTANCE.config + + val storageField = config.javaClass.getDeclaredField("storageGUI") + val storage = storageField.get(config) + + val booleanField = storage.javaClass.getDeclaredField("enableStorageGUI3") + booleanField.get(storage) as Boolean + } catch (e: Throwable) { ErrorManager.logError(e, "Could not read NEU config to determine if the neu storage is emabled.") false } |