diff options
Diffstat (limited to 'core/src/command/map/Save.kt')
| -rw-r--r-- | core/src/command/map/Save.kt | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/src/command/map/Save.kt b/core/src/command/map/Save.kt new file mode 100644 index 0000000..a68b6cc --- /dev/null +++ b/core/src/command/map/Save.kt @@ -0,0 +1,31 @@ +package cat.freya.khs.command.map + +import cat.freya.khs.Khs +import cat.freya.khs.command.util.Command +import cat.freya.khs.game.mapSave +import cat.freya.khs.player.Player +import cat.freya.khs.runChecks + +class KhsMapSave : Command { + override val label = "save" + override val usage = listOf("map") + override val description = "Save the map backup used for gameplay" + + override fun execute(plugin: Khs, player: Player, args: List<String>) { + val (name) = args + runChecks(plugin, player) { + mapExists(name) + gameNotInProgress() + lobbyEmpty() + } + + var map = plugin.maps.get(name) ?: return + mapSave(plugin, map) + } + + override fun autoComplete(plugin: Khs, parameter: String, typed: String): List<String> = + when (parameter) { + "map" -> plugin.maps.keys.filter { it.startsWith(typed) } + else -> listOf() + } +} |