aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dummy/kotlin/skytils/skytilsmod/core/Config.kt14
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/Chatting.kt95
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt16
3 files changed, 122 insertions, 3 deletions
diff --git a/src/dummy/kotlin/skytils/skytilsmod/core/Config.kt b/src/dummy/kotlin/skytils/skytilsmod/core/Config.kt
new file mode 100644
index 0000000..e01f5fa
--- /dev/null
+++ b/src/dummy/kotlin/skytils/skytilsmod/core/Config.kt
@@ -0,0 +1,14 @@
+package skytils.skytilsmod.core
+
+object Config {
+ var chatTabs = false
+ var copyChat = false
+
+ fun markDirty() {
+ throw AssertionError()
+ }
+
+ fun writeData() {
+ throw AssertionError()
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/cc/woverflow/chatting/Chatting.kt b/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
index 5fb7c67..4b39a5b 100644
--- a/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
@@ -10,7 +10,14 @@ import cc.woverflow.chatting.mixin.GuiNewChatAccessor
import cc.woverflow.chatting.updater.Updater
import cc.woverflow.chatting.utils.ModCompatHooks
import cc.woverflow.chatting.utils.RenderHelper
+import com.google.gson.JsonParser
import gg.essential.api.EssentialAPI
+import gg.essential.api.gui.buildConfirmationModal
+import gg.essential.api.utils.Multithreading
+import gg.essential.api.utils.WebUtil
+import gg.essential.elementa.ElementaVersion
+import gg.essential.elementa.WindowScreen
+import gg.essential.elementa.dsl.childOf
import gg.essential.universal.UDesktop
import gg.essential.universal.UResolution
import net.minecraft.client.Minecraft
@@ -23,12 +30,11 @@ import net.minecraftforge.common.MinecraftForge.EVENT_BUS
import net.minecraftforge.fml.client.registry.ClientRegistry
import net.minecraftforge.fml.common.Loader
import net.minecraftforge.fml.common.Mod
-import net.minecraftforge.fml.common.event.FMLInitializationEvent
-import net.minecraftforge.fml.common.event.FMLPostInitializationEvent
-import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
+import net.minecraftforge.fml.common.event.*
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
@@ -54,6 +60,12 @@ object Chatting {
private set
var isBetterChat = false
private set
+ var isSkyclientStupid = false
+ private set
+ var isSkytils = false
+ private set
+ var isHychat = false
+ private set
private val fileFormatter: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd_HH.mm.ss'.png'")
@@ -80,6 +92,83 @@ object Chatting {
fun onPostInitialization(event: FMLPostInitializationEvent) {
isPatcher = Loader.isModLoaded("patcher")
isBetterChat = Loader.isModLoaded("betterchat")
+ isSkytils = Loader.isModLoaded("skytils")
+ val date = Date(jarFile.lastModified())
+ isSkyclientStupid = date.before(Date(1641985860)) && date.after(Date(1641956460)) && Loader.isModLoaded("skyblockclientupdater") && !isSkytils // between 10am gmt+7 and 6pm gmt+7 skyclient updater falsely detected skytils as chatting
+ isHychat = Loader.isModLoaded("hychat")
+ }
+
+ @Mod.EventHandler
+ fun onForgeLoad(event: FMLLoadCompleteEvent) {
+ if (ChattingConfig.firstLaunch) {
+ ChattingConfig.firstLaunch = false
+ ChattingConfig.markDirty()
+ ChattingConfig.writeData()
+ if (isSkyclientStupid) {
+ EssentialAPI.getGuiUtil().openScreen(object : WindowScreen(version = ElementaVersion.V1) {
+ override fun initScreen(width: Int, height: Int) {
+ super.initScreen(width, height)
+ EssentialAPI.getEssentialComponentFactory().buildConfirmationModal {
+ this.text = "You may have had Skytils accidentally update to Chatting. Do you want to install the latest version of Skytils?"
+ this.onConfirm = {
+ restorePreviousScreen()
+ Multithreading.runAsync {
+ val json = JsonParser().parse(WebUtil.fetchString(
+ "https://api.github.com/repos/Skytils/SkytilsMod/releases"
+ )).asJsonArray[0].asJsonObject
+ if (Updater.download(
+ json["assets"].asJsonArray[0].asJsonObject["browser_download_url"].asString,
+ File(
+ "mods/Skytils-${
+ json["tag_name"].asString.substringAfter("v")
+ }.jar"
+ )
+ )
+ ) {
+ EssentialAPI.getNotifications()
+ .push(
+ NAME,
+ "The ingame updater has successfully installed Skytils."
+ )
+ } else {
+ EssentialAPI.getNotifications().push(
+ NAME,
+ "The ingame updater has NOT installed Skytils as something went wrong."
+ )
+ }
+ }
+ }
+ this.onDeny = {
+ restorePreviousScreen()
+ }
+ } childOf this.window
+ }
+ })
+ }
+ }
+ if (ChattingConfig.informForAlternatives) {
+ if (isHychat) {
+ EssentialAPI.getNotifications().push(NAME, "Hychat can be removed at it is replaced by Chatting.")
+ }
+ if (isSkytils) {
+ if (Config.chatTabs) {
+ EssentialAPI.getNotifications().push(NAME, "Skytils' chat tabs can be disabled as it is replace by Chatting.\nClick here to automatically do this.", 6F) {
+ Config.chatTabs = false
+ ChattingConfig.chatTabs = true
+ ChattingConfig.hypixelOnlyChatTabs = true
+ Config.markDirty()
+ Config.writeData()
+ }
+ }
+ if (Config.copyChat) {
+ EssentialAPI.getNotifications().push(NAME, "Skytils' copy chat messages can be disabled as it is replace by Chatting.\nClick here to automatically do this.", 6F) {
+ Config.copyChat = false
+ Config.markDirty()
+ Config.writeData()
+ }
+ }
+ }
+ }
}
@SubscribeEvent
diff --git a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt
index 846297b..4065966 100644
--- a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt
@@ -36,6 +36,14 @@ object ChattingConfig : Vigilant(File(Chatting.modDir, "${Chatting.ID}.toml"), C
@Property(
type = PropertyType.SWITCH,
+ name = "Inform for Alternatives",
+ description = "Inform the user if a mod they are using can be replaced by a feature in Chatting.",
+ category = "General"
+ )
+ var informForAlternatives = true
+
+ @Property(
+ type = PropertyType.SWITCH,
name = "Custom Chat Height",
description = "Allows you to change the height of chat to heights greater than before.",
category = "Chat Window"
@@ -164,6 +172,14 @@ object ChattingConfig : Vigilant(File(Chatting.modDir, "${Chatting.ID}.toml"), C
)
}
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "First Launch",
+ category = "General",
+ hidden = true
+ )
+ var firstLaunch = true
+
init {
initialize()
registerListener("chatTabs") { funny: Boolean ->