Fix commands for worlds with numeral names

pull/71/head
trivernis 4 years ago
parent 615280a2ed
commit 3dec787d0e

@ -31,10 +31,11 @@ class CmdCancel(private val chunkmaster: Chunkmaster): Subcommand {
*/
override fun execute(sender: CommandSender, args: List<String>): 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)) {

@ -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

Loading…
Cancel
Save