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 reload` Reloads the configuration file.
- `/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
#### Examples

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

@ -14,13 +14,13 @@ commands:
permission: chunkmaster.chunkmaster
usage: |
/<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> pause - pauses all generation tasks
/<command> resume - resumes all generation 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> 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
aliases:
- chm

Loading…
Cancel
Save