mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 16:51:37 +00:00
Remove command utilities plugin
This commit is contained in:
@@ -7,7 +7,6 @@ plugin {
|
|||||||
"cubeee",
|
"cubeee",
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"api",
|
"api"
|
||||||
"util:command",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,15 @@
|
|||||||
import com.google.common.primitives.Ints
|
|
||||||
import org.apollo.game.model.Animation
|
import org.apollo.game.model.Animation
|
||||||
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
||||||
import org.apollo.game.plugin.util.command.valid_arg_length
|
|
||||||
|
|
||||||
on_command("animate", PrivilegeLevel.MODERATOR)
|
on_command("animate", PrivilegeLevel.MODERATOR)
|
||||||
.then { player ->
|
.then { player ->
|
||||||
val invalidSyntax = "Invalid syntax - ::animate [animation-id]"
|
arguments.firstOrNull()
|
||||||
if (valid_arg_length(arguments, 1, player, invalidSyntax)) {
|
?.let(String::toIntOrNull)
|
||||||
val id = Ints.tryParse(arguments[0])
|
?.let(::Animation)
|
||||||
if (id == null) {
|
?.let {
|
||||||
player.sendMessage(invalidSyntax)
|
player.playAnimation(it)
|
||||||
return@then
|
return@then
|
||||||
}
|
}
|
||||||
|
|
||||||
player.playAnimation(Animation(id))
|
player.sendMessage("Invalid syntax - ::animate [animation-id]")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,29 +1,31 @@
|
|||||||
import com.google.common.primitives.Ints
|
import com.google.common.primitives.Ints
|
||||||
import org.apollo.cache.def.ItemDefinition
|
import org.apollo.cache.def.ItemDefinition
|
||||||
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
||||||
import org.apollo.game.plugin.util.command.valid_arg_length
|
|
||||||
|
|
||||||
on_command("item", PrivilegeLevel.ADMINISTRATOR)
|
on_command("item", PrivilegeLevel.ADMINISTRATOR)
|
||||||
.then { player ->
|
.then { player ->
|
||||||
val invalidSyntax = "Invalid syntax - ::item [id] [amount]"
|
if (arguments.size !in 1..2) {
|
||||||
if (!valid_arg_length(arguments, 1..2, player, invalidSyntax)) {
|
player.sendMessage("Invalid syntax - ::item [id] [amount]")
|
||||||
return@then
|
return@then
|
||||||
}
|
}
|
||||||
|
|
||||||
val id = Ints.tryParse(arguments[0])
|
val id = Ints.tryParse(arguments[0])
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
player.sendMessage(invalidSyntax)
|
player.sendMessage("Invalid syntax - ::item [id] [amount]")
|
||||||
return@then
|
return@then
|
||||||
}
|
}
|
||||||
|
|
||||||
var amount = 1
|
val amount = if (arguments.size == 2) {
|
||||||
if (arguments.size == 2) {
|
|
||||||
val amt = Ints.tryParse(arguments[1])
|
val amt = Ints.tryParse(arguments[1])
|
||||||
|
|
||||||
if (amt == null) {
|
if (amt == null) {
|
||||||
player.sendMessage(invalidSyntax)
|
player.sendMessage("Invalid syntax - ::item [id] [amount]")
|
||||||
return@then
|
return@then
|
||||||
}
|
}
|
||||||
amount = amt
|
|
||||||
|
amt
|
||||||
|
} else {
|
||||||
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id < 0 || id >= ItemDefinition.count()) {
|
if (id < 0 || id >= ItemDefinition.count()) {
|
||||||
|
|||||||
@@ -1,67 +1,52 @@
|
|||||||
import com.google.common.primitives.Ints
|
|
||||||
import org.apollo.cache.def.ItemDefinition
|
|
||||||
import org.apollo.cache.def.NpcDefinition
|
|
||||||
import org.apollo.cache.def.ObjectDefinition
|
|
||||||
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
||||||
import org.apollo.game.plugin.util.command.valid_arg_length
|
import org.apollo.game.plugin.api.Definitions
|
||||||
|
|
||||||
on_command("iteminfo", PrivilegeLevel.ADMINISTRATOR)
|
on_command("iteminfo", PrivilegeLevel.ADMINISTRATOR)
|
||||||
.then { player ->
|
.then { player ->
|
||||||
val invalidSyntax = "Invalid syntax - ::npcinfo [npc id]"
|
arguments.firstOrNull()
|
||||||
if (!valid_arg_length(arguments, 1, player, invalidSyntax)) {
|
?.let(String::toIntOrNull)
|
||||||
return@then
|
?.let(Definitions::item)
|
||||||
}
|
?.apply {
|
||||||
|
val members = if (isMembersOnly) "members" else "not members"
|
||||||
|
|
||||||
val id = Ints.tryParse(arguments[0])
|
player.sendMessage("Item $id is called $name and is $members only.")
|
||||||
if (id == null) {
|
player.sendMessage("Its description is `$description`.")
|
||||||
player.sendMessage(invalidSyntax)
|
|
||||||
return@then
|
|
||||||
}
|
|
||||||
|
|
||||||
val definition = ItemDefinition.lookup(id)
|
return@then
|
||||||
val members = if (definition.isMembersOnly) "members" else "not members"
|
}
|
||||||
|
|
||||||
player.sendMessage("Item $id is called ${definition.name}, is $members only, and has a " +
|
player.sendMessage("Invalid syntax - ::iteminfo [item id]")
|
||||||
"team of ${definition.team}.")
|
|
||||||
player.sendMessage("Its description is \"${definition.description}\".")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
on_command("npcinfo", PrivilegeLevel.ADMINISTRATOR)
|
on_command("npcinfo", PrivilegeLevel.ADMINISTRATOR)
|
||||||
.then { player ->
|
.then { player ->
|
||||||
val invalidSyntax = "Invalid syntax - ::npcinfo [npc id]"
|
arguments.firstOrNull()
|
||||||
if (!valid_arg_length(arguments, 1, player, invalidSyntax)) {
|
?.let(String::toIntOrNull)
|
||||||
return@then
|
?.let(Definitions::npc)
|
||||||
|
?.apply {
|
||||||
|
val combat = if (hasCombatLevel()) "has a combat level of $combatLevel" else
|
||||||
|
"does not have a combat level"
|
||||||
|
|
||||||
|
player.sendMessage("Npc $id is called $name and $combat.")
|
||||||
|
player.sendMessage("Its description is `$description`.")
|
||||||
|
|
||||||
|
return@then
|
||||||
}
|
}
|
||||||
|
|
||||||
val id = Ints.tryParse(arguments[0])
|
player.sendMessage("Invalid syntax - ::npcinfo [npc id]")
|
||||||
if (id == null) {
|
|
||||||
player.sendMessage(invalidSyntax)
|
|
||||||
return@then
|
|
||||||
}
|
|
||||||
|
|
||||||
val definition = NpcDefinition.lookup(id)
|
|
||||||
val isCombative = if (definition.hasCombatLevel()) "has a combat level of ${definition.combatLevel}" else
|
|
||||||
"does not have a combat level"
|
|
||||||
|
|
||||||
player.sendMessage("Npc $id is called ${definition.name} and $isCombative.")
|
|
||||||
player.sendMessage("Its description is \"${definition.description}\".")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
on_command("objectinfo", PrivilegeLevel.ADMINISTRATOR)
|
on_command("objectinfo", PrivilegeLevel.ADMINISTRATOR)
|
||||||
.then { player ->
|
.then { player ->
|
||||||
val invalidSyntax = "Invalid syntax - ::objectinfo [object id]"
|
arguments.firstOrNull()
|
||||||
if (!valid_arg_length(arguments, 1, player, invalidSyntax)) {
|
?.let(String::toIntOrNull)
|
||||||
return@then
|
?.let(Definitions::obj)
|
||||||
}
|
?.apply {
|
||||||
|
player.sendMessage("Object ${arguments[0]} is called $name (width=$width, length=$length).")
|
||||||
|
player.sendMessage("Its description is `$description`.")
|
||||||
|
|
||||||
val id = Ints.tryParse(arguments[0])
|
return@then
|
||||||
if (id == null) {
|
}
|
||||||
player.sendMessage(invalidSyntax)
|
|
||||||
return@then
|
|
||||||
}
|
|
||||||
|
|
||||||
val definition = ObjectDefinition.lookup(id)
|
player.sendMessage("Invalid syntax - ::objectinfo [object id]")
|
||||||
player.sendMessage("Object $id is called ${definition.name} and its description is " +
|
|
||||||
"\"${definition.description}\".")
|
|
||||||
player.sendMessage("Its width is ${definition.width} and its length is ${definition.length}.")
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
import com.google.common.primitives.Ints
|
import com.google.common.primitives.Ints
|
||||||
import org.apollo.game.model.Position
|
import org.apollo.game.model.Position
|
||||||
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
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.component1
|
||||||
import org.apollo.game.plugins.api.Position.component2
|
import org.apollo.game.plugins.api.Position.component2
|
||||||
import org.apollo.game.plugins.api.Position.component3
|
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}).")
|
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),
|
"alkharid" to Position(3292, 3171, 0),
|
||||||
"ardougne" to Position(2662, 3304, 0),
|
"ardougne" to Position(2662, 3304, 0),
|
||||||
"barrows" to Position(3565, 3314, 0),
|
"barrows" to Position(3565, 3314, 0),
|
||||||
@@ -49,64 +106,4 @@ val TELEPORT_DESTINATIONS = listOf(
|
|||||||
"varrock" to Position(3212, 3423, 0),
|
"varrock" to Position(3212, 3423, 0),
|
||||||
"yanille" to Position(2605, 3096, 0),
|
"yanille" to Position(2605, 3096, 0),
|
||||||
"zanaris" to Position(2452, 4473, 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))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ plugin {
|
|||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"entity:walk-to",
|
"entity:walk-to",
|
||||||
"util:command",
|
|
||||||
"entity:player-action",
|
"entity:player-action",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
plugin {
|
|
||||||
name = "command_utilities"
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package org.apollo.game.plugin.util.command
|
|
||||||
|
|
||||||
import org.apollo.game.model.entity.Player
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the amount of arguments provided is correct, sending the player the specified
|
|
||||||
* message if not.
|
|
||||||
*/
|
|
||||||
fun valid_arg_length(args: Array<String>, length: IntRange, player: Player, message: String): Boolean {
|
|
||||||
val valid = length.contains(args.size)
|
|
||||||
if (!valid) {
|
|
||||||
player.sendMessage(message)
|
|
||||||
}
|
|
||||||
return valid
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the amount of arguments provided is correct, sending the player the specified
|
|
||||||
* message if not.
|
|
||||||
*/
|
|
||||||
fun valid_arg_length(args: Array<String>, length: Int, player: Player, message: String)
|
|
||||||
= valid_arg_length(args, IntRange(length, length), player, message)
|
|
||||||
Reference in New Issue
Block a user