aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-05-23 20:28:08 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-05-23 20:28:08 +0700
commit5da5f6efd284076b65d1811f13e1b4825c34d2db (patch)
tree724a0a907069742ed742f4e6e0180dffa233bcdd /src/main/kotlin/cc/woverflow/chatting/Chatting.kt
parentc2eb1590e5ef48e0e9c59b3eff149c09c607dc95 (diff)
downloadChatting-5da5f6efd284076b65d1811f13e1b4825c34d2db.tar.gz
Chatting-5da5f6efd284076b65d1811f13e1b4825c34d2db.tar.bz2
Chatting-5da5f6efd284076b65d1811f13e1b4825c34d2db.zip
fix skytils chat tab notifications not working
Diffstat (limited to 'src/main/kotlin/cc/woverflow/chatting/Chatting.kt')
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/Chatting.kt51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/main/kotlin/cc/woverflow/chatting/Chatting.kt b/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
index 0fe85f9..d012ab3 100644
--- a/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
@@ -31,7 +31,6 @@ 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 skytils.skytilsmod.core.Config
import java.awt.image.BufferedImage
import java.io.File
import java.text.SimpleDateFormat
@@ -101,26 +100,46 @@ object Chatting {
})
}
if (isSkytils) {
- if (Config.chatTabs) {
- sendBrandedNotification(NAME, "Skytils' chat tabs can be disabled as it is replace by Chatting.\nClick here to automatically do this.", 6F, action = {
- Config.chatTabs = false
- ChattingConfig.chatTabs = true
- ChattingConfig.hypixelOnlyChatTabs = true
- Config.markDirty()
- Config.writeData()
- })
- }
- if (Config.copyChat) {
- sendBrandedNotification(NAME, "Skytils' copy chat messages can be disabled as it is replace by Chatting.\nClick here to automatically do this.", 6F, action = {
- Config.copyChat = false
- Config.markDirty()
- Config.writeData()
- })
+ try {
+ skytilsCompat(Class.forName("gg.skytils.skytilsmod.core.Config"))
+ } catch (e: Exception) {
+ e.printStackTrace()
+ try {
+ skytilsCompat(Class.forName("skytils.skytilsmod.core.Config"))
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
}
}
}
}
+ private fun skytilsCompat(skytilsClass: Class<*>) {
+ val instance = skytilsClass.getDeclaredField("INSTANCE")
+ val chatTabs = skytilsClass.getDeclaredField("chatTabs")
+ chatTabs.isAccessible = true
+ if (chatTabs.getBoolean(instance)) {
+ sendBrandedNotification(NAME, "Skytils' chat tabs can be disabled as it is replace by Chatting.\nClick here to automatically do this.", 6F, action = {
+ chatTabs.setBoolean(instance, false)
+ ChattingConfig.chatTabs = true
+ ChattingConfig.hypixelOnlyChatTabs = true
+ ChattingConfig.markDirty()
+ ChattingConfig.writeData()
+ skytilsClass.getMethod("markDirty").invoke(instance)
+ skytilsClass.getMethod("writeData").invoke(instance)
+ })
+ }
+ val copyChat = skytilsClass.getDeclaredField("chatTabs")
+ copyChat.isAccessible = true
+ if (copyChat.getBoolean(instance)) {
+ sendBrandedNotification(NAME, "Skytils' copy chat messages can be disabled as it is replace by Chatting.\nClick here to automatically do this.", 6F, action = {
+ copyChat.setBoolean(instance, false)
+ skytilsClass.getMethod("markDirty").invoke(instance)
+ skytilsClass.getMethod("writeData").invoke(instance)
+ })
+ }
+ }
+
@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)) {