Let ::pos return other players positions (#422)

Rework ::pos to allow a user to return another player's position
This commit is contained in:
KeepBotting
2019-03-29 18:36:07 -04:00
committed by Major
parent a0c78ced90
commit 9c1944c969
2 changed files with 46 additions and 4 deletions
@@ -6,6 +6,7 @@ import org.apollo.game.model.entity.Player
import org.apollo.game.model.entity.setting.PrivilegeLevel
import org.apollo.game.plugin.testing.assertions.contains
import org.apollo.game.plugin.testing.junit.ApolloTestingExtension
import org.apollo.game.plugin.testing.junit.api.annotations.Name
import org.apollo.game.plugin.testing.junit.api.annotations.TestMock
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
@@ -22,6 +23,10 @@ class TeleportCommandTests {
@TestMock
lateinit var player: Player
@TestMock
@Name("player_two")
lateinit var player_two: Player
@Test
fun `Teleport to given coordinates`() {
player.privilegeLevel = PrivilegeLevel.ADMINISTRATOR
@@ -50,6 +55,27 @@ class TeleportCommandTests {
}
}
@Test
fun `Shows another players current position information`() {
player.privilegeLevel = PrivilegeLevel.ADMINISTRATOR
player_two.position = Position(1, 2, 3)
world.commandDispatcher.dispatch(player, Command("pos", arrayOf("player_two")))
verify {
player.sendMessage(contains("1, 2, 3"))
}
}
@Test
fun `Shows no position information for a nonexistent player`() {
player.privilegeLevel = PrivilegeLevel.ADMINISTRATOR
world.commandDispatcher.dispatch(player, Command("pos", arrayOf("player999")))
verify {
player.sendMessage(contains("offline"))
}
}
@ParameterizedTest(name = "::tele {0}")
@ValueSource(strings = [
"1 2 <garbage>",