From f5ac8fd82564fdfefba5db52b2e0b150c900cf58 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Tue, 21 Dec 2021 23:58:41 +0700 Subject: copy chat message --- src/main/kotlin/com/raeids/stratus/Stratus.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/main/kotlin/com/raeids') diff --git a/src/main/kotlin/com/raeids/stratus/Stratus.kt b/src/main/kotlin/com/raeids/stratus/Stratus.kt index 653c265..ba2e739 100644 --- a/src/main/kotlin/com/raeids/stratus/Stratus.kt +++ b/src/main/kotlin/com/raeids/stratus/Stratus.kt @@ -3,6 +3,7 @@ package com.raeids.stratus import com.raeids.stratus.command.StratusCommand import com.raeids.stratus.config.StratusConfig import com.raeids.stratus.hook.ChatTabs +import com.raeids.stratus.hook.GuiNewChatHook import com.raeids.stratus.mixin.GuiNewChatAccessor import com.raeids.stratus.updater.Updater import com.raeids.stratus.utils.RenderHelper @@ -14,6 +15,7 @@ import net.minecraft.client.gui.GuiChat import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.settings.KeyBinding import net.minecraft.client.shader.Framebuffer +import net.minecraftforge.client.event.MouseEvent import net.minecraftforge.common.MinecraftForge.EVENT_BUS import net.minecraftforge.fml.client.registry.ClientRegistry import net.minecraftforge.fml.common.Mod @@ -22,6 +24,8 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.input.Keyboard +import java.awt.Toolkit +import java.awt.datatransfer.StringSelection import java.io.File import java.io.IOException import java.text.SimpleDateFormat @@ -64,6 +68,18 @@ object Stratus { Updater.update() } + @SubscribeEvent + fun onMouseClick(event: MouseEvent) { + val hook = Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook + if (hook.shouldCopy()) { + try { + Toolkit.getDefaultToolkit().systemClipboard.setContents(StringSelection(hook.copyString()), null) + } catch (e: Exception) { + e.printStackTrace() + } + } + } + @SubscribeEvent fun onTickEvent(event: TickEvent.ClientTickEvent) { if (event.phase == TickEvent.Phase.START && Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null && (Minecraft.getMinecraft().currentScreen == null || Minecraft.getMinecraft().currentScreen is GuiChat)) { -- cgit