From d0bbd687ca9d33cc7bd8f53e3103ecc92905f8dc Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:36:50 +0200 Subject: Fixed crash in Copy NBT data --- src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt | 2 +- src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt b/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt index 7ac530452..e3df5c54c 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt @@ -42,7 +42,7 @@ object TestExportTools { @SubscribeEvent fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent) { - if (!Keyboard.getEventKeyState() || Keyboard.getEventKey() != SkyHanniMod.feature.dev.copyNBTDataCompressed) return + if (!Keyboard.isKeyDown(SkyHanniMod.feature.dev.copyNBTDataCompressed)) return val gui = event.gui as? GuiContainer ?: return val focussedSlot = gui.slotUnderMouse ?: return val stack = focussedSlot.stack ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt index 63b8e01fb..9c56d142f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.test.command.CopyErrorCommand import net.minecraft.client.settings.KeyBinding import org.lwjgl.input.Keyboard import java.awt.Desktop @@ -28,7 +29,11 @@ object OSUtils { } fun copyToClipboard(text: String) { - Toolkit.getDefaultToolkit().systemClipboard.setContents(StringSelection(text), null) + try { + Toolkit.getDefaultToolkit().systemClipboard.setContents(StringSelection(text), null) + } catch (e: Exception) { + CopyErrorCommand.logError(e, "Error while trying to set clipboard content.") + } } fun readFromClipboard(): String? { -- cgit