diff --git a/build.gradle.kts b/build.gradle.kts index c95019ee..29b1c533 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -72,7 +72,7 @@ subprojects { disableOnSkippedVersion = false } version { - taboolib = "6.2.4-7f8b30dc" + taboolib = "6.2.4-abd325ee" coroutines = null } } diff --git a/gradle.properties b/gradle.properties index 99c55623..c788b3aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=me.arasple.mc.trmenu -version=3.9.10 \ No newline at end of file +version=3.9.11 \ No newline at end of file diff --git a/plugin/src/main/kotlin/trplugins/menu/module/conf/MenuSerializer.kt b/plugin/src/main/kotlin/trplugins/menu/module/conf/MenuSerializer.kt index c8f79db1..d6d52778 100644 --- a/plugin/src/main/kotlin/trplugins/menu/module/conf/MenuSerializer.kt +++ b/plugin/src/main/kotlin/trplugins/menu/module/conf/MenuSerializer.kt @@ -42,6 +42,8 @@ import trplugins.menu.util.collections.IndivList import trplugins.menu.util.conf.Property import trplugins.menu.util.parseIconId import java.io.File +import java.util.concurrent.ConcurrentHashMap +import kotlin.collections.forEach import kotlin.jvm.optionals.getOrNull import kotlin.math.max @@ -104,10 +106,10 @@ object MenuSerializer : ISerializer { } // 读取菜单语言 - val lang: Map>? = if (languages.isEmpty()) null else { - val map = HashMap>() + val lang: Map>? = if (languages.isEmpty()) null else { + val map = mutableMapOf>() languages.forEach { entry -> - val nodes = serializeLocaleNodes(entry.key, entry.value, HashMap()) + val nodes = serializeLocaleNodes(entry.key, entry.value, ConcurrentHashMap()) if (nodes.isNotEmpty()) { map[entry.key.lowercase()] = nodes } @@ -432,7 +434,7 @@ object MenuSerializer : ISerializer { // Method body taken from Taboolib, licensed under the MIT License // // Copyright (c) 2018 Bkm016 - private fun serializeLocaleNodes(code: String, file: ConfigurationSection, nodes: HashMap, root: String = ""): HashMap { + private fun serializeLocaleNodes(code: String, file: ConfigurationSection, nodes: ConcurrentHashMap, root: String = ""): ConcurrentHashMap { file.getKeys(false).forEach { node -> val key = "$root$node" when (val obj = file[node]) { diff --git a/plugin/src/main/kotlin/trplugins/menu/module/display/Menu.kt b/plugin/src/main/kotlin/trplugins/menu/module/display/Menu.kt index 6e1a068d..cd6432af 100644 --- a/plugin/src/main/kotlin/trplugins/menu/module/display/Menu.kt +++ b/plugin/src/main/kotlin/trplugins/menu/module/display/Menu.kt @@ -34,7 +34,7 @@ class Menu( val icons: Set, conf: Configuration, private val langKey: String? = null, - lang: Map>? = null + lang: Map>? = null ) { companion object { @@ -47,7 +47,7 @@ class Menu( var conf: Configuration = conf internal set - var lang: Map>? = lang + var lang: Map>? = lang internal set val viewers: MutableSet = mutableSetOf() diff --git a/plugin/src/main/kotlin/trplugins/menu/module/internal/data/Metadata.kt b/plugin/src/main/kotlin/trplugins/menu/module/internal/data/Metadata.kt index 16696a70..40960c25 100644 --- a/plugin/src/main/kotlin/trplugins/menu/module/internal/data/Metadata.kt +++ b/plugin/src/main/kotlin/trplugins/menu/module/internal/data/Metadata.kt @@ -49,6 +49,7 @@ object Metadata { // Copy in the Adyeshach val database by lazy { + if (!isUseLegacy) return@lazy null when (val db = SETTINGS.getString("Database.Method")?.uppercase()) { "LOCAL", "SQLITE", null -> DatabaseSQLite() "SQL" -> DatabaseSQL() @@ -90,7 +91,7 @@ object Metadata { fun pushData(player: Player, dataMap: DataMap = getData(player)) { if (isUseLegacy) { - getLocalePlayer(player).let { + getLocalePlayer(player)?.let { it.getConfigurationSection("TrMenu.Data")?.getKeys(true)?.forEach { key -> if (!dataMap.data.containsKey(key)) { it["TrMenu.Data.$key"] = null @@ -98,7 +99,7 @@ object Metadata { } dataMap.data.forEach { (key, value) -> it["TrMenu.Data.$key"] = value } } - database.push(player) + database?.push(player) } else { dataMap.data.forEach { (key, value) -> MetaDataDao.door.update(DataEntity.constructor(player, key, value?.toString() ?: "")) @@ -106,15 +107,15 @@ object Metadata { } } - private fun getLocalePlayer(player: Player): Configuration { - return database.pull(player) + private fun getLocalePlayer(player: Player): Configuration? { + return database?.pull(player) } fun loadData(player: Player) { val map: MutableMap = mutableMapOf() if (isUseLegacy) { - getLocalePlayer(player).getConfigurationSection("TrMenu.Data")?.let { section -> + getLocalePlayer(player)?.getConfigurationSection("TrMenu.Data")?.let { section -> section.getKeys(true).forEach { key -> map[key] = section[key] } } } else {