mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 16:49:11 +00:00
Let ::pos return other players positions (#422)
Rework ::pos to allow a user to return another player's position
This commit is contained in:
@@ -1,20 +1,36 @@
|
||||
|
||||
import com.google.common.primitives.Ints
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
||||
import org.apollo.game.plugin.api.Position.component1
|
||||
import org.apollo.game.plugin.api.Position.component2
|
||||
import org.apollo.game.plugin.api.Position.component3
|
||||
|
||||
/**
|
||||
* Sends the player's position.
|
||||
* Sends a player's position.
|
||||
*/
|
||||
on_command("pos", PrivilegeLevel.MODERATOR)
|
||||
.then { player ->
|
||||
val (x, y, z) = player.position
|
||||
val region = player.position.regionCoordinates
|
||||
val target: Player
|
||||
val name: String
|
||||
|
||||
player.sendMessage("You are at: ($x, $y, $z) in region (${region.x}, ${region.y}).")
|
||||
if (arguments.size >= 1) {
|
||||
name = arguments.joinToString(" ")
|
||||
if (player.world.isPlayerOnline(name)) {
|
||||
target = player.world.getPlayer(name)
|
||||
} else {
|
||||
player.sendMessage("$name is offline.")
|
||||
return@then
|
||||
}
|
||||
} else {
|
||||
target = player
|
||||
}
|
||||
|
||||
val (x, y, z) = target.position
|
||||
val region = target.position.regionCoordinates
|
||||
|
||||
player.sendMessage("${target.username} is located at ($x, $y, $z) in region (${region.x}, ${region.y}).")
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user