Add packages to plugins

This commit is contained in:
Major
2017-09-24 22:35:07 +01:00
parent b4e8a7136b
commit 046f373c9e
32 changed files with 398 additions and 366 deletions
+31 -30
View File
@@ -1,48 +1,49 @@
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
/**
* Sends the player's position.
*/
on_command("pos", PrivilegeLevel.MODERATOR)
.then { player ->
player.sendMessage("You are at: ${player.position}.")
}
.then { player ->
player.sendMessage("You are at: ${player.position}.")
}
/**
* 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
}
.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) {
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
}
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))
}
}
if (z in 0..4) {
player.teleport(Position(x, y, z))
}
}