aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-03 00:48:23 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-03 00:48:23 +0200
commit9d003c15ea6b24a8abca54a5383b52ece4855839 (patch)
treeaebc9abe829a649fd6843b41b1c34687f9de433f /src/main/java/at/hannibal2/skyhanni/utils
parent38708c86377bfd257470d4839a1103ac76a6ceeb (diff)
downloadskyhanni-9d003c15ea6b24a8abca54a5383b52ece4855839.tar.gz
skyhanni-9d003c15ea6b24a8abca54a5383b52ece4855839.tar.bz2
skyhanni-9d003c15ea6b24a8abca54a5383b52ece4855839.zip
Added Paste Into Signs - Allows you to paste the clipboard into Sings when you press Ctrl + V
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt12
2 files changed, 21 insertions, 0 deletions
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 {