Skip to content

Commit e81e8ee

Browse files
committed
refactor(conf): 重构菜单加载器配置结构
- 将默认菜单数组提取为独立变量 - 添加 ensureMenuFolder 函数确保菜单文件夹存在 - 优化文件夹获取逻辑并改进代码可读性 - 更新版本号从 3.10.3 到 3.10.4
1 parent 318f222 commit e81e8ee

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
group=me.arasple.mc.trmenu
2-
version=3.10.3
2+
version=3.10.4

plugin/src/main/kotlin/trplugins/menu/module/conf/Loader.kt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,25 @@ import java.io.File
2222
*/
2323
object Loader {
2424

25-
private val folder by lazy {
26-
Menu.menus.clear()
25+
private val defaults = arrayOf(
26+
"Example.yml",
27+
"Demo-Buttons.yml",
28+
"Profile.yml",
29+
"Dialog-Example.yml",
30+
"Dialog-Confirmation-Example.yml",
31+
"Dialog-Layout-Example.yml",
32+
"shop-example/Shop-Categories.yml",
33+
"shop-example/categories/Shop-Ores.yml",
34+
"shop-example/handler/Shop-Handler-Purchase.yml",
35+
"shop-example/handler/Shop-Handler-Sell.yml",
36+
)
37+
38+
private val folder: File
39+
get() = ensureMenuFolder()
40+
41+
private fun ensureMenuFolder(): File {
2742
val folder = File(getDataFolder(), "menus")
2843

29-
val defaults = arrayOf(
30-
"Example.yml",
31-
"Demo-Buttons.yml",
32-
"Profile.yml",
33-
"Dialog-Example.yml",
34-
"Dialog-Confirmation-Example.yml",
35-
"Dialog-Layout-Example.yml",
36-
"shop-example/Shop-Categories.yml",
37-
"shop-example/categories/Shop-Ores.yml",
38-
"shop-example/handler/Shop-Handler-Purchase.yml",
39-
"shop-example/handler/Shop-Handler-Sell.yml",
40-
)
41-
4244
if (!folder.exists()) {
4345
folder.mkdirs()
4446
}
@@ -49,7 +51,7 @@ object Loader {
4951
}
5052
}
5153

52-
folder
54+
return folder
5355
}
5456

5557
var isLoading = false

0 commit comments

Comments
 (0)