From f8322cd21cde68a72b05efbad3a05b8e67c0bdd0 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Thu, 26 Mar 2026 23:15:33 -0400 Subject: initial --- core/src/command/map/GoTo.kt | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 core/src/command/map/GoTo.kt (limited to 'core/src/command/map/GoTo.kt') diff --git a/core/src/command/map/GoTo.kt b/core/src/command/map/GoTo.kt new file mode 100644 index 0000000..20444cc --- /dev/null +++ b/core/src/command/map/GoTo.kt @@ -0,0 +1,40 @@ +package cat.freya.khs.command.map + +import cat.freya.khs.Khs +import cat.freya.khs.command.util.Command +import cat.freya.khs.player.Player +import cat.freya.khs.runChecks + +class KhsMapGoTo : Command { + override val label = "goto" + override val usage = listOf("map", "spawn") + override val description = "Goes to a spawn location for a map" + + override fun execute(plugin: Khs, player: Player, args: List) { + val (name, spawn) = args + runChecks(plugin, player) { mapExists(name) } + + var map = plugin.maps.get(name) ?: return + val loc = + when (spawn) { + "spawn" -> map.gameSpawn + "lobby" -> map.lobbySpawn + "seekerlobby" -> map.seekerLobbySpawn + else -> null + } + + if (loc == null) { + player.message(plugin.locale.prefix.error + plugin.locale.map.error.locationNotSet) + return + } + + loc.teleport(player) + } + + override fun autoComplete(plugin: Khs, parameter: String, typed: String): List = + when (parameter) { + "map" -> plugin.maps.keys.filter { it.startsWith(typed) } + "spawn" -> listOf("spawn", "lobby", "seekerlobby").filter { it.startsWith(typed) } + else -> listOf() + } +} -- cgit v1.2.3-freya