From 99be374aa343029e670dd1c8abcc834004363fc5 Mon Sep 17 00:00:00 2001 From: xtrm Date: Sat, 4 Feb 2023 18:18:04 +0100 Subject: added mod icon, fixed potential crash, bumped gradle to 7.6, bumped to 1.4.2-beta5 --- .../cc/woverflow/chatting/chat/ChatShortcuts.kt | 28 ++++++++++++---------- .../cc/woverflow/chatting/config/ChattingConfig.kt | 1 + src/main/resources/chatting_dark.svg | 5 ++++ src/main/resources/mcmod.info | 4 ++-- 4 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 src/main/resources/chatting_dark.svg (limited to 'src/main') diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt index 6add813..ef1881d 100644 --- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt +++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt @@ -31,20 +31,24 @@ object ChatShortcuts { } else { initialized = true } - if (!shortcutsFile.exists()) { - shortcutsFile.createNewFile() - if (oldShortcutsFile.exists()) { - shortcutsFile.writeText( - oldShortcutsFile.readText() - ) - } else { - JsonObject().toString() + if (shortcutsFile.exists()) { + try { + val jsonObj = PARSER.parse(shortcutsFile.readText()).asJsonObject + for (shortcut in jsonObj.entrySet()) { + shortcuts.add(shortcut.key to shortcut.value.asString) + } + return + } catch (_: Throwable) { + shortcutsFile.renameTo(File(shortcutsFile.parentFile, "chatshortcuts.json.bak")) } + } + shortcutsFile.createNewFile() + if (oldShortcutsFile.exists()) { + shortcutsFile.writeText( + oldShortcutsFile.readText() + ) } else { - val jsonObj = PARSER.parse(shortcutsFile.readText()).asJsonObject - for (shortcut in jsonObj.entrySet()) { - shortcuts.add(shortcut.key to shortcut.value.asString) - } + shortcutsFile.writeText(JsonObject().toString()) } } diff --git a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt index 6e6e0ff..f8e6b2a 100644 --- a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt +++ b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt @@ -21,6 +21,7 @@ object ChattingConfig : Config( Mod( Chatting.NAME, ModType.UTIL_QOL, + "/chatting_dark.svg", VigilanceMigrator(File(Chatting.oldModDir, Chatting.ID + ".toml").toPath().toString()) ), "chatting.json" ) { diff --git a/src/main/resources/chatting_dark.svg b/src/main/resources/chatting_dark.svg new file mode 100644 index 0000000..42db03e --- /dev/null +++ b/src/main/resources/chatting_dark.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 46cce6c..ae069a9 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -2,13 +2,13 @@ { "modid": "${id}", "name": "${name}", - "description": "A chat mod.", + "description": "A chat mod adding utilities such as extremely customizable chat tabs, chat shortcuts, chat screenshots, and message copying.", "version": "${version}", "mcversion": "1.8.9", "url": "", "updateUrl": "", "authorList": [ - "W-OVERFLOW" + "Polyfrost" ], "credits": "Mo2men#2806 for chat icons, Pablo", "logoFile": "", -- cgit