diff --git a/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdCancel.kt b/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdCancel.kt index 0bc262f..65e6e47 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdCancel.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdCancel.kt @@ -31,10 +31,11 @@ class CmdCancel(private val chunkmaster: Chunkmaster): Subcommand { */ override fun execute(sender: CommandSender, args: List): Boolean { return if (args.isNotEmpty()) { - val index = if (args[0].toIntOrNull() != null) { + val entry = chunkmaster.generationManager.tasks.find { it.generationTask.world.name == args[0] } + val index = if (args[0].toIntOrNull() != null && entry == null) { args[0].toInt() } else { - chunkmaster.generationManager.tasks.find { it.generationTask.world.name == args[0] }?.id + entry?.id } if (index != null && chunkmaster.generationManager.removeTask(index)) { diff --git a/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdGenerate.kt b/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdGenerate.kt index baef0b9..a9eccae 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdGenerate.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/commands/CmdGenerate.kt @@ -55,7 +55,7 @@ class CmdGenerate(private val chunkmaster: Chunkmaster): Subcommand { return false } } - if (args[0].toIntOrNull() != null) { + if (args[0].toIntOrNull() != null && sender.server.worlds.find { it.name == args[0] } == null) { if (sender !is Player) { sender.sendMessage(chunkmaster.langManager.getLocalized("WORLD_NAME_REQUIRED")) return false