mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-05 16:49:04 +00:00
Remove command utilities plugin
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
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.Position.component1
|
||||
import org.apollo.game.plugins.api.Position.component2
|
||||
import org.apollo.game.plugins.api.Position.component3
|
||||
@@ -18,7 +17,65 @@ on_command("pos", PrivilegeLevel.MODERATOR)
|
||||
player.sendMessage("You are at: ($x, $y, $z) in region (${region.x}, ${region.y}).")
|
||||
}
|
||||
|
||||
val TELEPORT_DESTINATIONS = listOf(
|
||||
/**
|
||||
* Teleports the player to the specified position.
|
||||
*/
|
||||
on_command("tele", PrivilegeLevel.ADMINISTRATOR)
|
||||
.then { player ->
|
||||
val invalidSyntax = "Invalid syntax - ::tele [x] [y] [optional-z] or ::tele [place name]"
|
||||
|
||||
if (arguments.size == 1) {
|
||||
val query = arguments[0]
|
||||
val results = TELEPORT_DESTINATIONS.filter { (name) -> name.startsWith(query) }
|
||||
|
||||
if (results.isEmpty()) {
|
||||
player.sendMessage("No destinations matching '$query'.")
|
||||
return@then
|
||||
} else if (results.size > 1) {
|
||||
player.sendMessage("Ambiguous query '$query' (could be $results). Please disambiguate.")
|
||||
return@then
|
||||
}
|
||||
|
||||
val (name, dest) = results[0]
|
||||
player.sendMessage("Teleporting to $name.")
|
||||
player.teleport(dest)
|
||||
|
||||
return@then
|
||||
}
|
||||
|
||||
if (arguments.size !in 2..3) {
|
||||
player.sendMessage(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))
|
||||
}
|
||||
}
|
||||
|
||||
private val TELEPORT_DESTINATIONS = listOf(
|
||||
"alkharid" to Position(3292, 3171, 0),
|
||||
"ardougne" to Position(2662, 3304, 0),
|
||||
"barrows" to Position(3565, 3314, 0),
|
||||
@@ -49,64 +106,4 @@ val TELEPORT_DESTINATIONS = listOf(
|
||||
"varrock" to Position(3212, 3423, 0),
|
||||
"yanille" to Position(2605, 3096, 0),
|
||||
"zanaris" to Position(2452, 4473, 0)
|
||||
)
|
||||
|
||||
/**
|
||||
* Teleports the player to the specified position.
|
||||
*/
|
||||
on_command("tele", PrivilegeLevel.ADMINISTRATOR)
|
||||
.then { player ->
|
||||
val invalidSyntax = "Invalid syntax - ::tele [x] [y] [optional-z] or ::tele [place name]"
|
||||
|
||||
if (arguments.size == 1) {
|
||||
val query = arguments[0]
|
||||
val results = TELEPORT_DESTINATIONS.filter {
|
||||
(name, _) -> name.startsWith(query)
|
||||
}
|
||||
|
||||
if (results.size == 0) {
|
||||
player.sendMessage("No destinations matching '$query'.")
|
||||
return@then
|
||||
} else if (results.size > 1) {
|
||||
player.sendMessage("Ambiguous query '$query' (could " +
|
||||
"be $results). Please disambiguate.")
|
||||
return@then
|
||||
}
|
||||
|
||||
val (name, dest) = results[0]
|
||||
player.sendMessage("Teleporting to $name.")
|
||||
player.teleport(dest)
|
||||
|
||||
return@then
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user