Add option to pass the world name for cancel

- Add the option to pass the world name to chm cancel to cancel
generation tasks
- Fix #46 by adding additional error handling
release/1.0
trivernis 4 years ago
parent fd6b1e9190
commit 29d0f8991e

@ -22,7 +22,7 @@ idea {
}
group "net.trivernis"
version "0.16-beta"
version "1.0"
sourceCompatibility = 1.8

@ -30,14 +30,21 @@ class CmdCancel(private val chunkmaster: Chunkmaster): Subcommand {
* Cancels the generation task if it exists.
*/
override fun execute(sender: CommandSender, args: List<String>): Boolean {
return if (args.isNotEmpty() && args[0].toIntOrNull() != null) {
if (chunkmaster.generationManager.removeTask(args[0].toInt())) {
sender.sendMessage(chunkmaster.langManager.getLocalized("TASK_CANCELED", args[0]))
return if (args.isNotEmpty()) {
val index = if (args[0].toIntOrNull() != null) {
args[0].toInt()
} else {
chunkmaster.generationManager.tasks.find { it.generationTask.world.name == args[0] }?.id
}
if (index != null && chunkmaster.generationManager.removeTask(index)) {
sender.sendMessage(chunkmaster.langManager.getLocalized("TASK_CANCELED", index))
true
} else {
sender.sendMessage(chunkmaster.langManager.getLocalized("TASK_NOT_FOUND", args[0]))
false
}
} else {
sender.sendMessage(chunkmaster.langManager.getLocalized("TASK_ID_REQUIRED"));
false

@ -5,12 +5,13 @@ import net.trivernis.chunkmaster.lib.dynmap.*
import net.trivernis.chunkmaster.lib.shapes.Shape
import org.bukkit.Chunk
import org.bukkit.World
import java.lang.Exception
/**
* Interface for generation tasks.
*/
abstract class GenerationTask(
plugin: Chunkmaster,
private val plugin: Chunkmaster,
startChunk: ChunkCoordinates,
val shape: Shape
) :
@ -69,7 +70,11 @@ abstract class GenerationTask(
protected fun unloadLoadedChunks() {
for (chunk in loadedChunks) {
if (chunk.isLoaded) {
try {
chunk.unload(true)
} catch (e: Exception) {
plugin.logger.severe(e.toString())
}
}
if (dynmapIntegration) {
dynmap?.triggerRenderOfVolume(chunk.getBlock(0, 0, 0).location, chunk.getBlock(15, 255, 15).location)

@ -4,6 +4,7 @@ import net.trivernis.chunkmaster.Chunkmaster
import net.trivernis.chunkmaster.lib.shapes.Shape
import org.bukkit.Chunk
import org.bukkit.World
import java.lang.Exception
import java.util.concurrent.CompletableFuture
class GenerationTaskPaper(
@ -92,7 +93,11 @@ class GenerationTaskPaper(
}
for (chunk in loadedChunks) {
if (chunk.isLoaded) {
chunk.unload(true)
try {
chunk.unload(true);
} catch (e: Exception){
plugin.logger.severe(e.toString())
}
}
}
}

@ -1,6 +1,6 @@
main: net.trivernis.chunkmaster.Chunkmaster
name: Chunkmaster
version: '0.16-beta'
version: '1.0'
description: Chunk commands plugin.
author: Trivernis
website: trivernis.net

Loading…
Cancel
Save