Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ subprojects {
disableOnSkippedVersion = false
}
version {
taboolib = "6.2.4-7f8b30dc"
taboolib = "6.2.4-abd325ee"
coroutines = null
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=me.arasple.mc.trmenu
version=3.9.10
version=3.9.11
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -104,10 +106,10 @@ object MenuSerializer : ISerializer {
}

// 读取菜单语言
val lang: Map<String, HashMap<String, taboolib.module.lang.Type>>? = if (languages.isEmpty()) null else {
val map = HashMap<String, HashMap<String, taboolib.module.lang.Type>>()
val lang: Map<String, ConcurrentHashMap<String, taboolib.module.lang.Type>>? = if (languages.isEmpty()) null else {
val map = mutableMapOf<String, ConcurrentHashMap<String, taboolib.module.lang.Type>>()
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
}
Expand Down Expand Up @@ -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<String, taboolib.module.lang.Type>, root: String = ""): HashMap<String, taboolib.module.lang.Type> {
private fun serializeLocaleNodes(code: String, file: ConfigurationSection, nodes: ConcurrentHashMap<String, taboolib.module.lang.Type>, root: String = ""): ConcurrentHashMap<String, taboolib.module.lang.Type> {
file.getKeys(false).forEach { node ->
val key = "$root$node"
when (val obj = file[node]) {
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/main/kotlin/trplugins/menu/module/display/Menu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Menu(
val icons: Set<Icon>,
conf: Configuration,
private val langKey: String? = null,
lang: Map<String, HashMap<String, Type>>? = null
lang: Map<String, Map<String, Type>>? = null
) {

companion object {
Expand All @@ -47,7 +47,7 @@ class Menu(
var conf: Configuration = conf
internal set

var lang: Map<String, HashMap<String, Type>>? = lang
var lang: Map<String, Map<String, Type>>? = lang
internal set

val viewers: MutableSet<String> = mutableSetOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -90,31 +91,31 @@ 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
}
}
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() ?: ""))
}
}
}

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<String, Any?> = 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 {
Expand Down