blob: b7df70d5f8fcb9615b0261591ce3b5975fc74c0c (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package cat.freya.khs.command.map.blockhunt.block
import cat.freya.khs.Khs
import cat.freya.khs.command.util.Command
import cat.freya.khs.player.Player
import cat.freya.khs.runChecks
class KhsMapBlockHuntBlockList : Command {
override val label = "list"
override val usage = listOf("map")
override val description = "List blocks in use on a block hunt map"
override fun execute(plugin: Khs, player: Player, args: List<String>) {
val (name) = args
runChecks(plugin, player) {
blockHuntSupported()
blockHuntEnabled(name)
}
val map = plugin.maps.get(name) ?: return
val blocks = map.config.blockHunt.blocks
if (blocks.isEmpty()) {
player.message(plugin.locale.prefix.default + plugin.locale.blockHunt.block.none)
return
}
val message = buildString {
appendLine(plugin.locale.blockHunt.block.list)
for (block in blocks) {
appendLine("&e- &f$block")
}
}
player.message(message)
}
override fun autoComplete(plugin: Khs, parameter: String, typed: String): List<String> =
when (parameter) {
"map" ->
plugin.maps
.filter { it.value.config.blockHunt.enabled }
.map { it.key }
.filter { it.startsWith(typed) }
else -> listOf()
}
}
|