mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
55 lines
1.6 KiB
Kotlin
55 lines
1.6 KiB
Kotlin
import com.google.common.primitives.Ints
|
|
import org.apollo.game.model.Position
|
|
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
|
import org.apollo.game.plugin.util.command.valid_arg_length
|
|
import org.apollo.game.plugins.api.component1
|
|
import org.apollo.game.plugins.api.component2
|
|
import org.apollo.game.plugins.api.component3
|
|
|
|
/**
|
|
* Sends the player's position.
|
|
*/
|
|
on_command("pos", PrivilegeLevel.MODERATOR)
|
|
.then { player ->
|
|
val (x, y, z) = player.position
|
|
val region = player.position.regionCoordinates
|
|
|
|
player.sendMessage("You are at: ($x, $y, $z) in region (${region.x}, ${region.y}).")
|
|
}
|
|
|
|
/**
|
|
* Teleports the player to the specified position.
|
|
*/
|
|
on_command("tele", PrivilegeLevel.ADMINISTRATOR)
|
|
.then { player ->
|
|
val invalidSyntax = "Invalid syntax - ::tele [x] [y] [optional-z]"
|
|
if (!valid_arg_length(arguments, 2..3, player, invalidSyntax)) {
|
|
return@then
|
|
}
|
|
|
|
val x = Ints.tryParse(arguments[0])
|
|
if (x == null) {
|
|
player.sendMessage(invalidSyntax)
|
|
return@then
|
|
}
|
|
|
|
val y = Ints.tryParse(arguments[1])
|
|
if (y == null) {
|
|
player.sendMessage(invalidSyntax)
|
|
return@then
|
|
}
|
|
|
|
var z = player.position.height
|
|
if (arguments.size == 3) {
|
|
val plane = Ints.tryParse(arguments[2])
|
|
if (plane == null) {
|
|
player.sendMessage(invalidSyntax)
|
|
return@then
|
|
}
|
|
z = plane
|
|
}
|
|
|
|
if (z in 0..4) {
|
|
player.teleport(Position(x, y, z))
|
|
}
|
|
} |