From ddc94dc9388086657b889d8fd43a82bcadd82bbe Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Sun, 9 Jan 2022 00:15:10 +0700 Subject: fix chat copy being in the wrong position --- .../kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt | 16 ++++++++++------ src/main/kotlin/cc/woverflow/chatting/updater/Updater.kt | 2 +- .../cc/woverflow/chatting/utils/ListenableArrayList.kt | 9 --------- 3 files changed, 11 insertions(+), 16 deletions(-) delete mode 100644 src/main/kotlin/cc/woverflow/chatting/utils/ListenableArrayList.kt (limited to 'src/main/kotlin/cc/woverflow') diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt index f72967f..5cbbc2d 100644 --- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt +++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt @@ -1,7 +1,6 @@ package cc.woverflow.chatting.chat import cc.woverflow.chatting.Chatting -import cc.woverflow.chatting.utils.ListenableArrayList import com.google.gson.JsonObject import com.google.gson.JsonParser import java.io.File @@ -12,11 +11,16 @@ object ChatShortcuts { private var initialized = false - val shortcuts = ListenableArrayList>({ - it.sortWith(comparator) - }) - private val comparator = Comparator> { o1, o2 -> - return@Comparator o2.first.length.compareTo(o1.first.length) + val shortcuts = object : ArrayList>() { + private val comparator = Comparator> { o1, o2 -> + return@Comparator o2.first.length.compareTo(o1.first.length) + } + + override fun add(element: Pair): Boolean { + val value = super.add(element) + sortWith(comparator) + return value + } } diff --git a/src/main/kotlin/cc/woverflow/chatting/updater/Updater.kt b/src/main/kotlin/cc/woverflow/chatting/updater/Updater.kt index ef1e376..dadaf0c 100644 --- a/src/main/kotlin/cc/woverflow/chatting/updater/Updater.kt +++ b/src/main/kotlin/cc/woverflow/chatting/updater/Updater.kt @@ -27,7 +27,7 @@ object Updater { DefaultArtifactVersion(Chatting.VER.substringBefore("-")) val latestVersion = DefaultArtifactVersion(latestTag!!.substringAfter("v").substringBefore("-")) if (currentVersion >= latestVersion) { - if (currentVersion != latestVersion || !Chatting.VER.contains("-")) { + if (currentVersion.compareTo(latestVersion) == 0 || !Chatting.VER.contains("-")) { return@runAsync } } diff --git a/src/main/kotlin/cc/woverflow/chatting/utils/ListenableArrayList.kt b/src/main/kotlin/cc/woverflow/chatting/utils/ListenableArrayList.kt deleted file mode 100644 index 0cd598c..0000000 --- a/src/main/kotlin/cc/woverflow/chatting/utils/ListenableArrayList.kt +++ /dev/null @@ -1,9 +0,0 @@ -package cc.woverflow.chatting.utils - -class ListenableArrayList(private val runnable: (ListenableArrayList) -> Unit, vararg elements: T): ArrayList() { - override fun add(element: T): Boolean { - val value = super.add(element) - runnable.invoke(this) - return value - } -} \ No newline at end of file -- cgit