This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.kt
55 lines (50 loc) · 2.22 KB
/
Main.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import vip.cdms.lse.dsl.command.MCCommandHelper
import vip.cdms.lse.dsl.form.ModalFormBuilder
import vip.cdms.lse.dsl.form.SimpleFormBuilder
import vip.cdms.lse.dsl.form.send
fun main() {
log("Hello, Kotlin/JS!")
mc.listen("onJoin") {
player: Player ->
logger.warn("${player.name} joined the server!")
}
mc.listen("onServerStarted") {
val helper = MCCommandHelper {
cmd = "tpa"
description = "玩家互传"
permission = PermType.Any
}
val command = helper.build()
command.overload(arrayOf())
command.setCallback { _, origin, _, _ ->
if (origin.player == null) return@setCallback
origin.player!! send SimpleFormBuilder {
val root = this // 传送锚点 (
title = "TPA玩家互传"
content = "选择传送模式"
fun playerSelector(title: String, callback: Player.(select: Player) -> Unit)
= custom(title) {
this.title = title
val players = mc.getOnlinePlayers()
val index by dropdown("选择", players.map { it.name }.toTypedArray())
submit = { callback(this, players[index]) }
cancel = { root send this }
// also cancel = { this@SimpleFormBuilder send this }
// also cancel = { this send root }
}
fun Player.questPlayer(content: String, confirm: () -> Unit)
= this send ModalFormBuilder {
this.title = this@SimpleFormBuilder.title
this.content = content
this.confirm = ModalFormBuilder.Action("同意") { confirm() }
}
playerSelector("传送自己到别人") { select ->
select.questPlayer("$name 请求传送到你这里") { teleport(select.pos) }
}
playerSelector("传送别人到自己") { select ->
select.questPlayer("$name 请求你传送到TA那里") { select.teleport(pos) }
}
} }
command.setup()
}
}