Make chunk coordinates for setCenter optional

- use the player location if no coordinates have been provided (closes #41)
release/1.0
trivernis 4 years ago
parent 0bc38384b4
commit 3f28c89f8d

@ -38,7 +38,7 @@ All features can be accessed with the command `/chunkmaster` or the aliases `/ch
- `/chunkmaster resume` Resumes all paused generation tasks. - `/chunkmaster resume` Resumes all paused generation tasks.
- `/chunkmaster reload` Reloads the configuration file. - `/chunkmaster reload` Reloads the configuration file.
- `/chunkmaster tpchunk <X> <Z>` Teleports you to the specified chunk coordinates. - `/chunkmaster tpchunk <X> <Z>` Teleports you to the specified chunk coordinates.
- `/<command> setCenter [<world>] <chunkX> <chunkZ>` - sets the center chunk of the world - `/<command> setCenter [[<world>] <chunkX> <chunkZ>]]` - sets the center chunk of the world
- `/<command> getCenter [<world>]` - returns the center chunk of the world - `/<command> getCenter [<world>]` - returns the center chunk of the world
#### Examples #### Examples

@ -29,26 +29,30 @@ class CmdSetCenter(private val chunkmaster: Chunkmaster): Subcommand {
val centerX: Int val centerX: Int
val centerZ: Int val centerZ: Int
if (args.size < 2) {
sender.sendMessage(chunkmaster.langManager.getLocalized("TOO_FEW_ARGUMENTS"))
return false
}
if (sender is Player) { if (sender is Player) {
if (args.size == 2) { when {
world = sender.world.name args.isEmpty() -> {
if (args[0].toIntOrNull() == null || args[1].toIntOrNull() == null) { world = sender.world.name
sender.sendMessage(chunkmaster.langManager.getLocalized("COORD_INVALID", args[0], args[1])) centerX = sender.location.chunk.x
return false centerZ = sender.location.chunk.z
} }
centerX = args[0].toInt() args.size == 2 -> {
centerZ = args[1].toInt() world = sender.world.name
} else { if (args[0].toIntOrNull() == null || args[1].toIntOrNull() == null) {
if (!validateThreeArgs(sender, args)) { sender.sendMessage(chunkmaster.langManager.getLocalized("COORD_INVALID", args[0], args[1]))
return false return false
}
centerX = args[0].toInt()
centerZ = args[1].toInt()
}
else -> {
if (!validateThreeArgs(sender, args)) {
return false
}
world = args[0]
centerX = args[1].toInt()
centerZ = args[2].toInt()
} }
world = args[0]
centerX = args[1].toInt()
centerZ = args[2].toInt()
} }
} else { } else {
if (args.size < 3) { if (args.size < 3) {

@ -14,13 +14,13 @@ commands:
permission: chunkmaster.chunkmaster permission: chunkmaster.chunkmaster
usage: | usage: |
/<command> generate [<world>] <radius> [<shape>] - generates chunks starting from the spawn until the chunk-count is reached /<command> generate [<world>] <radius> [<shape>] - generates chunks starting from the spawn until the chunk-count is reached
/<command> cancel <task-id> - cancels the generation task with the task-id /<command> cancel <task-id|world> - cancels the generation task with the task-id
/<command> list - lists all running and paused generation tasks /<command> list - lists all running and paused generation tasks
/<command> pause - pauses all generation tasks /<command> pause - pauses all generation tasks
/<command> resume - resumes all generation tasks /<command> resume - resumes all generation tasks
/<command> reload - reloads the configuration and restarts all tasks /<command> reload - reloads the configuration and restarts all tasks
/<command> tpchunk <chunkX> <chunkZ> - teleports you to the chunk with the given chunk coordinates /<command> tpchunk <chunkX> <chunkZ> - teleports you to the chunk with the given chunk coordinates
/<command> setCenter [<world>] <chunkX> <chunkZ> - sets the center chunk of the world /<command> setCenter [[<world>] <chunkX> <chunkZ>]] - sets the center chunk of the world
/<command> getCenter [<world>] - returns the center chunk of the world /<command> getCenter [<world>] - returns the center chunk of the world
aliases: aliases:
- chm - chm

Loading…
Cancel
Save