aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
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
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')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt23
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/OSUtils.kt12
6 files changed, 51 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index be749d95a..2f8f33e22 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -240,6 +240,7 @@ public class SkyHanniMod {
loadModule(new ComposterDisplay());
loadModule(new GardenComposterInventoryFeatures());
loadModule(new MinionCollectLogic());
+ loadModule(new PasteIntoSigns());
Commands.INSTANCE.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index 54e63c904..609f72e43 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -244,6 +244,11 @@ public class Misc {
public boolean hideFireOverlay = false;
@Expose
+ @ConfigOption(name = "Paste Into Signs", desc = "Allows you to paste the clipboard into Sings when you press Ctrl + V")
+ @ConfigEditorBoolean
+ public boolean pasteIntoSigns = true;
+
+ @Expose
@ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.")
@ConfigEditorBoolean
public boolean configButtonOnPause = true;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
index 0c8d83cc3..5c1b83610 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt
@@ -13,7 +13,6 @@ import at.hannibal2.skyhanni.utils.renderables.Renderable
import io.github.moulberry.notenoughupdates.mixins.AccessorGuiEditSign
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiEditSign
-import net.minecraft.util.ChatComponentText
import net.minecraftforge.client.event.GuiOpenEvent
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -43,10 +42,7 @@ class GardenOptimalSpeed {
fun onGuiOpen(event: GuiOpenEvent) {
rancherOverlayList = CropType.values().map { crop ->
listOf(crop.icon, Renderable.link("${crop.cropName} - ${crop.getOptimalSpeed()}") {
- val gui = Minecraft.getMinecraft().currentScreen
- if (gui !is GuiEditSign) return@link
- gui as AccessorGuiEditSign
- gui.tileSign.signText[0] = ChatComponentText("${crop.getOptimalSpeed()}")
+ LorenzUtils.setTextIntoSign("${crop.getOptimalSpeed()}")
})
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
new file mode 100644
index 000000000..e77db7969
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
@@ -0,0 +1,23 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.HyPixelData
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.OSUtils
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import org.lwjgl.input.Keyboard
+
+class PasteIntoSigns {
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (!HyPixelData.hypixel) return
+ if (!SkyHanniMod.feature.misc.pasteIntoSigns) return
+
+ if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_V)) {
+ val clipboard = OSUtils.readFromClipboard() ?: return
+ LorenzUtils.setTextIntoSign(clipboard.take(15))
+ }
+ }
+} \ No newline at end of file
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 {