blob: f8aab4f79a7bf51a58f5bdcd9e8143db90b81c23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
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 KhsMapRemove : Command {
override val label = "remove"
override val usage = listOf("map")
override val description = "Remove a map from the plugin"
override fun execute(plugin: Khs, player: Player, args: List<String>) {
val (name) = args
runChecks(plugin, player) {
mapExists(name)
gameNotInProgress()
lobbyEmpty()
}
plugin.maps.remove(name)
plugin.saveConfig()
player.message(plugin.locale.prefix.default + plugin.locale.map.deleted.with(name))
}
override fun autoComplete(plugin: Khs, parameter: String, typed: String): List<String> =
when (parameter) {
"map" -> plugin.maps.keys.filter { it.startsWith(typed) }
else -> listOf()
}
}
|