From 9d003c15ea6b24a8abca54a5383b52ece4855839 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 3 Apr 2023 00:48:23 +0200 Subject: Added Paste Into Signs - Allows you to paste the clipboard into Sings when you press Ctrl + V --- src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 9 +++++++++ src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt | 12 ++++++++++++ 2 files changed, 21 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index eb0aa48dd..938a0326f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -6,8 +6,10 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.features.dungeon.DungeonData import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.toDashlessUUID +import io.github.moulberry.notenoughupdates.mixins.AccessorGuiEditSign import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiEditSign import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.SharedMonsterAttributes import net.minecraft.util.ChatComponentText @@ -189,4 +191,11 @@ object LorenzUtils { } } } + + fun setTextIntoSign(text: String) { + val gui = Minecraft.getMinecraft().currentScreen + if (gui !is GuiEditSign) return + gui as AccessorGuiEditSign + gui.tileSign.signText[0] = ChatComponentText(text) + } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt index 3819573c3..5089b4d82 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt @@ -4,7 +4,9 @@ import net.minecraft.client.settings.KeyBinding import org.lwjgl.input.Keyboard import java.awt.Desktop import java.awt.Toolkit +import java.awt.datatransfer.DataFlavor import java.awt.datatransfer.StringSelection +import java.awt.datatransfer.UnsupportedFlavorException import java.io.IOException import java.net.URI @@ -27,6 +29,16 @@ object OSUtils { Toolkit.getDefaultToolkit().systemClipboard.setContents(StringSelection(text), null) } + fun readFromClipboard(): String? { + val systemClipboard = Toolkit.getDefaultToolkit().systemClipboard ?: return null + try { + val data = systemClipboard.getData(DataFlavor.stringFlavor) ?: return null + return data.toString() + } catch (e: UnsupportedFlavorException) { + return null + } + } + fun KeyBinding.isActive() : Boolean { if (!Keyboard.isCreated()) return false try { -- cgit