mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 16:51:37 +00:00
Convert ::animate command to Kotlin
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
name = "Chat commands"
|
name = "Chat commands"
|
||||||
package = "org.apollo.game.plugin.cmd"
|
package = "org.apollo.game.plugin.cmd"
|
||||||
authors = [ "Graham", "cubeee" ]
|
dependencies = [ "command_utilities" ]
|
||||||
|
authors = [
|
||||||
|
"Graham",
|
||||||
|
"Major",
|
||||||
|
"cubeee"
|
||||||
|
]
|
||||||
|
|
||||||
[config]
|
[config]
|
||||||
srcDir = "src/"
|
srcDir = "src/"
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import org.apollo.game.model.Animation
|
||||||
|
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
||||||
|
|
||||||
|
on_command("animate", PrivilegeLevel.MODERATOR)
|
||||||
|
.then { player ->
|
||||||
|
if(valid_arg_length(arguments, 1, player, "Invalid syntax - ::animate [animation-id]")) {
|
||||||
|
player.playAnimation(Animation(arguments[0].toInt()))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
name = "command utilities"
|
||||||
|
package = "org.apollo.game.plugins.util"
|
||||||
|
|
||||||
|
[config]
|
||||||
|
srcDir = "src/"
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
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: Any, player: Player, message: String): Boolean {
|
||||||
|
val valid = when (length) {
|
||||||
|
is Int -> length == args.size
|
||||||
|
is IntRange -> length.contains(args.size)
|
||||||
|
else -> {
|
||||||
|
throw IllegalArgumentException("length must be one of the following: Int, IntRange")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!valid) {
|
||||||
|
player.sendMessage(message)
|
||||||
|
}
|
||||||
|
return valid
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user