summaryrefslogtreewikicommitdiff
path: root/core/src/command/map/set
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2026-03-26 23:15:33 -0400
committerFreya Murphy <freya@freyacat.org>2026-03-27 23:09:23 -0400
commitf8322cd21cde68a72b05efbad3a05b8e67c0bdd0 (patch)
treed7e60bc8fedadc8fa7ae725571cad1f398eaf6dc /core/src/command/map/set
downloadkenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.tar.gz
kenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.tar.bz2
kenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.zip
initial
Diffstat (limited to 'core/src/command/map/set')
-rw-r--r--core/src/command/map/set/Border.kt64
-rw-r--r--core/src/command/map/set/Bounds.kt57
-rw-r--r--core/src/command/map/set/Lobby.kt37
-rw-r--r--core/src/command/map/set/SeekerLobby.kt38
-rw-r--r--core/src/command/map/set/Spawn.kt38
5 files changed, 234 insertions, 0 deletions
diff --git a/core/src/command/map/set/Border.kt b/core/src/command/map/set/Border.kt
new file mode 100644
index 0000000..75a3f27
--- /dev/null
+++ b/core/src/command/map/set/Border.kt
@@ -0,0 +1,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)
+ }
+}
diff --git a/core/src/command/map/set/Bounds.kt b/core/src/command/map/set/Bounds.kt
new file mode 100644
index 0000000..7c13802
--- /dev/null
+++ b/core/src/command/map/set/Bounds.kt
@@ -0,0 +1,57 @@
+package cat.freya.khs.command.map.set
+
+import cat.freya.khs.Khs
+import cat.freya.khs.command.util.Command
+import cat.freya.khs.config.BoundConfig
+import cat.freya.khs.player.Player
+import cat.freya.khs.runChecks
+
+class KhsMapSetBounds : Command {
+ override val label = "bounds"
+ override val usage = listOf("map")
+ override val description = "Sets the map bounds for a map"
+
+ override fun execute(plugin: Khs, player: Player, args: List<String>) {
+ val (name) = args
+ runChecks(plugin, player) {
+ mapExists(name)
+ inMapWorld(name)
+ gameNotInProgress()
+ }
+
+ var map = plugin.maps.get(name) ?: return
+ val config = map.config.bounds
+
+ val pos = player.location.position
+ val num: Int
+
+ if (config.min == null || config.max != null) {
+ config.min = BoundConfig(pos.x, pos.z)
+ config.max == null
+ num = 1
+ } else {
+ val minX = minOf(config.min?.x ?: 0.0, pos.x)
+ val minZ = minOf(config.min?.z ?: 0.0, pos.z)
+ val maxX = maxOf(config.min?.x ?: 0.0, pos.x)
+ val maxZ = maxOf(config.min?.z ?: 0.0, pos.z)
+ config.min = BoundConfig(minX, minZ)
+ config.max = BoundConfig(maxX, maxZ)
+ num = 2
+ }
+
+ runChecks(plugin, player) {
+ // note this is not error, only warn
+ spawnsInRange(map)
+ }
+
+ map.reloadConfig()
+ plugin.saveConfig()
+ player.message(plugin.locale.prefix.default + plugin.locale.map.set.bounds.with(num))
+ }
+
+ override fun autoComplete(plugin: Khs, parameter: String, typed: String): List<String> =
+ when (parameter) {
+ "map" -> plugin.maps.keys.filter { it.startsWith(typed) }
+ else -> listOf()
+ }
+}
diff --git a/core/src/command/map/set/Lobby.kt b/core/src/command/map/set/Lobby.kt
new file mode 100644
index 0000000..a90259a
--- /dev/null
+++ b/core/src/command/map/set/Lobby.kt
@@ -0,0 +1,37 @@
+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 KhsMapSetLobby : Command {
+ override val label = "lobby"
+ override val usage = listOf("map")
+ override val description = "Sets the lobby spawn location for a map"
+
+ override fun execute(plugin: Khs, player: Player, args: List<String>) {
+ val (name) = args
+ runChecks(plugin, player) {
+ mapExists(name)
+ inMapWorld(name)
+ gameNotInProgress()
+ }
+
+ var map = plugin.maps.get(name) ?: return
+ val pos = player.location.position
+
+ runChecks(plugin, player) { spawnInRange(map, pos) }
+
+ map.config.spawns.lobby = pos
+ map.reloadConfig()
+ plugin.saveConfig()
+ player.message(plugin.locale.prefix.default + plugin.locale.map.set.lobby)
+ }
+
+ override fun autoComplete(plugin: Khs, parameter: String, typed: String): List<String> =
+ when (parameter) {
+ "map" -> plugin.maps.keys.filter { it.startsWith(typed) }
+ else -> listOf()
+ }
+}
diff --git a/core/src/command/map/set/SeekerLobby.kt b/core/src/command/map/set/SeekerLobby.kt
new file mode 100644
index 0000000..71122cb
--- /dev/null
+++ b/core/src/command/map/set/SeekerLobby.kt
@@ -0,0 +1,38 @@
+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 KhsMapSetSeekerLobby : Command {
+ override val label = "seekerlobby"
+ override val usage = listOf("map")
+ override val description = "Sets the seeker lobby spawn location for a map"
+
+ override fun execute(plugin: Khs, player: Player, args: List<String>) {
+ val (name) = args
+ runChecks(plugin, player) {
+ mapExists(name)
+ inMapWorld(name)
+ gameNotInProgress()
+ }
+
+ var map = plugin.maps.get(name) ?: return
+ val pos = player.location.position
+
+ runChecks(plugin, player) { spawnInRange(map, pos) }
+
+ map.config.spawns.seeker = pos
+ map.reloadConfig()
+
+ plugin.saveConfig()
+ player.message(plugin.locale.prefix.default + plugin.locale.map.set.seekerSpawn)
+ }
+
+ override fun autoComplete(plugin: Khs, parameter: String, typed: String): List<String> =
+ when (parameter) {
+ "map" -> plugin.maps.keys.filter { it.startsWith(typed) }
+ else -> listOf()
+ }
+}
diff --git a/core/src/command/map/set/Spawn.kt b/core/src/command/map/set/Spawn.kt
new file mode 100644
index 0000000..4eff730
--- /dev/null
+++ b/core/src/command/map/set/Spawn.kt
@@ -0,0 +1,38 @@
+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 KhsMapSetSpawn : Command {
+ override val label = "spawn"
+ override val usage = listOf("map")
+ override val description = "Sets the game spawn location for a map"
+
+ override fun execute(plugin: Khs, player: Player, args: List<String>) {
+ val (name) = args
+ runChecks(plugin, player) {
+ mapExists(name)
+ inMapWorld(name)
+ gameNotInProgress()
+ }
+
+ var map = plugin.maps.get(name) ?: return
+ val pos = player.location.position
+
+ runChecks(plugin, player) { spawnInRange(map, pos) }
+
+ map.config.spawns.game = pos.toLegacy()
+ map.reloadConfig()
+
+ plugin.saveConfig()
+ player.message(plugin.locale.prefix.default + plugin.locale.map.set.gameSpawn)
+ }
+
+ override fun autoComplete(plugin: Khs, parameter: String, typed: String): List<String> =
+ when (parameter) {
+ "map" -> plugin.maps.keys.filter { it.startsWith(typed) }
+ else -> listOf()
+ }
+}