Skip to content

Commit 2187adb

Browse files
committed
🚑️(wayzer/cmds/voteKick) CommandApi更新
1 parent 16e09e9 commit 2187adb

1 file changed

Lines changed: 23 additions & 25 deletions

File tree

scripts/wayzer/cmds/voteKick.kts

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,37 @@ suspend fun CommandContext.getInput(name: String, whenEmpty: PlaceHoldString): S
4848
}
4949

5050
val banImpl = contextScript<wayzer.user.Ban>()
51-
onEnable {
52-
val script = this
53-
VoteEvent.VoteCommands += CommandInfo(this, "kick", "踢出某人") {
54-
aliases = listOf("踢出")
55-
usage = "<玩家名/id> <理由>"
56-
permission = "wayzer.vote.kick"
57-
body {
58-
val target = getTarget()
59-
val reason = getInput("踢人理由", "[red]投票踢人需要理由".with())
60-
val player = player!!
61-
val event = VoteEvent(
62-
script, player,
63-
voteDesc = "踢人(踢出[red]{target}[yellow])".with("target" to target),
64-
extDesc = "[red]理由: [yellow]${reason}"
65-
)
66-
val snapshot = PlayerData[target]
67-
if (event.awaitResult()) {
68-
if (target.hasPermission("wayzer.admin.skipKick"))
69-
return@body broadcast(
70-
"[red]错误: {target.name}[red]为管理员, 如有问题请与服主联系".with("target" to target)
71-
)
72-
banImpl.ban(snapshot, 60, "投票踢出: $reason", player)
73-
}
51+
command("kick", "踢出某人".with(), commands = VoteEvent.VoteCommands) {
52+
aliases = listOf("踢出")
53+
usage = "<玩家名/id> <理由>"
54+
attr(RequirePermission("wayzer.vote.kick"))
55+
body {
56+
val target = getTarget()
57+
val reason = getInput("踢人理由", "[red]投票踢人需要理由".with())
58+
val player = player!!
59+
val event = VoteEvent(
60+
thisScript, player,
61+
voteDesc = "踢人(踢出[red]{target}[yellow])".with("target" to target),
62+
extDesc = "[red]理由: [yellow]${reason}"
63+
)
64+
val snapshot = PlayerData[target]
65+
if (event.awaitResult()) {
66+
if (target.hasPermission("wayzer.admin.skipKick"))
67+
return@body broadcast(
68+
"[red]错误: {target.name}[red]为管理员, 如有问题请与服主联系".with("target" to target)
69+
)
70+
banImpl.ban(snapshot, 60, "投票踢出: $reason", player)
7471
}
7572
}
7673
}
7774

7875
command("votekick", "(弃用)投票踢人") {
79-
this.usage = "<player...>";this.type = CommandType.Client
76+
usage = "<player...>"
77+
attr(ClientOnly)
8078
body {
8179
//Redirect
8280
arg = listOf("kick", *arg.toTypedArray())
83-
VoteEvent.VoteCommands.invoke(this)
81+
VoteEvent.VoteCommands.handle()
8482
}
8583
}
8684
PermissionApi.registerDefault("wayzer.admin.skipKick", group = "@admin")

0 commit comments

Comments
 (0)