From 3dec787d0e8ae1c3b821ccd086854ea5616975b7 Mon Sep 17 00:00:00 2001 From: trivernis Date: Wed, 8 Jul 2020 20:08:41 +0200 Subject: [PATCH] Fix commands for worlds with numeral names --- .../kotlin/net/trivernis/chunkmaster/commands/CmdCancel.kt | 5 +++-- .../kotlin/net/trivernis/chunkmaster/commands/CmdGenerate.kt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) 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