Skip to content

Commit 2e84681

Browse files
committed
👽️(*) unit()可能null
1 parent e712cea commit 2e84681

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

scripts/wayzer/cmds/gatherTp.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ command("gather", "发出集合请求") {
2020
body {
2121
if (state.rules.pvp)
2222
returnReply("[red]PVP模式禁用".with())
23-
if (!player!!.unit().type.targetable)
23+
if (player!!.dead() || !player!!.unit().type.targetable)
2424
returnReply("[red]当前单位无法使用 集合".with())
2525
if (Duration.between(lastTime, Instant.now()) < Duration.ofSeconds(30)) {
2626
returnReply("[red]刚刚有人发起请求,请稍等30s再试".with())
@@ -45,7 +45,7 @@ command("tp", "传送到鼠标坐标") {
4545
permission = "wayzer.ext.tp"
4646
body {
4747
val player = player!!
48-
player.unit().apply {
48+
player.unit()?.apply {
4949
set(player.mouseX, player.mouseY)
5050
snapInterpolation()
5151
}
@@ -65,7 +65,7 @@ fun check(unit: Unit, x: Float, y: Float): Boolean {
6565
}
6666
listen<EventType.PlayerChatEvent> {
6767
if (it.message.equals("go", true) && lastPos != Vec2.ZERO) {
68-
it.player.unit().apply {
68+
it.player.unit()?.apply {
6969
if (!check(this, lastPos.x, lastPos.y)) {
7070
it.player.sendMessage("[yellow]目标位置无法安全传送")
7171
return@listen

scripts/wayzer/user/ext/skills.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ skill("mono", "技能: 召唤采矿机,一局限一次,PVP禁用", "矿机") {
9898
returnReply("[red]该地图采矿机已禁封,禁止召唤".with())
9999
checkNotPvp()
100100
checkOrSetCoolDown(-1)
101-
val unit = player.unit()
102101
UnitTypes.mono.create(player.team()).apply {
103-
set(unit.x, unit.y)
102+
set(player)
104103
add()
105104
}
106105
broadcastSkill("采矿机?")

0 commit comments

Comments
 (0)