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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package cat.freya.khs.command.map.set
import cat.freya.khs.Khs
import cat.freya.khs.command.util.Command
import cat.freya.khs.player.Player
import cat.freya.khs.runChecks
class KhsMapSetBorder : Command {
override val label = "border"
override val usage = listOf("map", "size", "delay", "move")
override val description = "Enable the world border for a map"
override fun execute(plugin: Khs, player: Player, args: List<String>) {
val (name, sizeS, delayS, moveS) = args
runChecks(plugin, player) {
mapExists(name)
inMapWorld(name)
gameNotInProgress()
}
val size = sizeS.toULong()
val delay = delayS.toULong()
val move = moveS.toULong()
if (size < 100u) {
player.message(plugin.locale.prefix.error + plugin.locale.worldBorder.minSize)
return
}
if (move < 1u) {
player.message(plugin.locale.prefix.error + plugin.locale.worldBorder.minChange)
return
}
var map = plugin.maps.get(name) ?: return
val config = map.config.worldBorder
config.enabled = true
config.pos = player.location.position
config.size = size
config.delay = delay
config.move = move
runChecks(plugin, player) {
// note this is not error, only warn
spawnsInRange(map)
}
map.reloadConfig()
plugin.saveConfig()
player.message(
plugin.locale.prefix.default + plugin.locale.worldBorder.enable.with(size, delay, move)
)
val loc = player.location.position
map.world?.border?.move(loc.x, loc.z, size, 0UL)
}
override fun autoComplete(plugin: Khs, parameter: String, typed: String): List<String> =
when (parameter) {
"map" -> plugin.maps.keys.filter { it.startsWith(typed) }
else -> listOf(parameter)
}
}
|