@@ -3,10 +3,9 @@ package cn.kloping.lsys.sc1
3
3
import cn.kloping.lsys.Resource
4
4
import io.github.kloping.initialize.FileInitializeValue
5
5
import net.mamoe.mirai.console.command.CommandSender
6
- import net.mamoe.mirai.console.command.SimpleCommand
7
- import java.lang.System.err
6
+ import net.mamoe.mirai.console.command.CompositeCommand
8
7
9
- class CommandLine : SimpleCommand (
8
+ class CommandLine : CompositeCommand (
10
9
PluginMain .INSTANCE , " Lsys_sc1" , " sc1" ,
11
10
description = " kloping的Lsys_sc1插件指令"
12
11
) {
@@ -16,30 +15,19 @@ class CommandLine : SimpleCommand(
16
15
val INSTANCE = CommandLine ()
17
16
}
18
17
19
- @Handler
20
- fun CommandSender.handle (arg : String ) {
21
- when {
22
- arg == " reload" -> {
23
- sc1.conf = FileInitializeValue .getValue(Resource .rootPath + " /conf/Lsys/sc1.json" , sc1.conf, true )
24
- println (" 已重新getSc1加载配置" )
25
- }
26
- arg.startsWith(" win" ) -> {
27
- try {
28
- val cd = java.lang.Long .parseLong(arg.split(" =" )[1 ])
29
- sc1.conf.setWin(cd.toInt())
30
- sc1.conf.apply ();
31
- println (" 设置赢的概率为${cd} %" )
32
- } catch (e: Exception ) {
33
- println (" 格式错误 示例:win=40 (单位:%)" )
34
- }
35
- }
36
- else -> {
37
- err.println (
38
- " 已知参数:\n " +
39
- " reload\t #重新加载配置\n " +
40
- " win=?\t\t #设置猜拳赢的概率\n "
41
- )
42
- }
43
- }
18
+ @Description(" 重载配置" )
19
+ @SubCommand(" reload" )
20
+ suspend fun CommandSender.LsysSc1Reload () {
21
+ sc1.conf = FileInitializeValue .getValue(Resource .rootPath + " /conf/Lsys/sc1.json" , sc1.conf, true )
22
+ sendMessage(" 已重新getSc1加载配置" )
23
+ }
24
+
25
+ @Description(" 设置猜拳赢得概率" )
26
+ @SubCommand(" reload" )
27
+ suspend fun CommandSender.LsysSc1SetWin (arg : String ) {
28
+ val cd = java.lang.Long .parseLong(arg.trim())
29
+ sc1.conf.setWin(cd.toInt())
30
+ sc1.conf.apply ();
31
+ sendMessage(" 设置赢的概率为${cd} %" )
44
32
}
45
33
}
0 commit comments