diff --git a/README.md b/README.md index a8b782c..ed276a3 100644 --- a/README.md +++ b/README.md @@ -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 ` Teleports you to the specified chunk coordinates. -- `/ setCenter [] ` - sets the center chunk of the world +- `/ setCenter [[] ]]` - sets the center chunk of the world - `/ getCenter []` - returns the center chunk of the world #### Examples diff --git a/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdSetCenter.kt b/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdSetCenter.kt index eb09826..8714303 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdSetCenter.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdSetCenter.kt @@ -29,26 +29,30 @@ 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) { - world = sender.world.name - if (args[0].toIntOrNull() == null || args[1].toIntOrNull() == null) { - sender.sendMessage(chunkmaster.langManager.getLocalized("COORD_INVALID", args[0], args[1])) - return false + when { + args.isEmpty() -> { + world = sender.world.name + centerX = sender.location.chunk.x + centerZ = sender.location.chunk.z } - centerX = args[0].toInt() - centerZ = args[1].toInt() - } else { - if (!validateThreeArgs(sender, args)) { - return false + 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])) + 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 { if (args.size < 3) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index d49c8d6..6f73c45 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -14,13 +14,13 @@ commands: permission: chunkmaster.chunkmaster usage: | / generate [] [] - generates chunks starting from the spawn until the chunk-count is reached - / cancel - cancels the generation task with the task-id + / cancel - cancels the generation task with the task-id / list - lists all running and paused generation tasks / pause - pauses all generation tasks / resume - resumes all generation tasks / reload - reloads the configuration and restarts all tasks / tpchunk - teleports you to the chunk with the given chunk coordinates - / setCenter [] - sets the center chunk of the world + / setCenter [[] ]] - sets the center chunk of the world / getCenter [] - returns the center chunk of the world aliases: - chm