Fix unique world sql error

Fix error thrown by unique constrain for the world name in the sql table. The error occurs because the data from the database is loaded lazily after several seconds. If a task was started before that it wouldn't be checked against the existing tasks since they haven't been loaded yet. Fixed by loading the tasks if none exists when the generate command is invoked.
pull/29/head
Trivernis 5 years ago
parent a09bebb6fa
commit bdac496ce2

@ -12,6 +12,12 @@ class GenerationManager(private val chunkmaster: Chunkmaster, private val server
val pausedTasks: HashSet<PausedTaskEntry> = HashSet() val pausedTasks: HashSet<PausedTaskEntry> = HashSet()
val allTasks: HashSet<TaskEntry> val allTasks: HashSet<TaskEntry>
get() { get() {
if (this.tasks.isEmpty() && this.pausedTasks.isEmpty()) {
this.startAll()
if (!server.onlinePlayers.isEmpty()) {
this.pauseAll()
}
}
val all = HashSet<TaskEntry>() val all = HashSet<TaskEntry>()
all.addAll(pausedTasks) all.addAll(pausedTasks)
all.addAll(tasks) all.addAll(tasks)
@ -141,8 +147,9 @@ class GenerationManager(private val chunkmaster: Chunkmaster, private val server
saveProgress() // save progress every 30 seconds saveProgress() // save progress every 30 seconds
}, 600, 600) }, 600, 600)
server.scheduler.runTaskLater(chunkmaster, Runnable { server.scheduler.runTaskLater(chunkmaster, Runnable {
if (server.onlinePlayers.isEmpty()) { this.startAll()
startAll() // run startAll after 10 seconds if empty if (!server.onlinePlayers.isEmpty()) {
this.pauseAll()
} }
}, 600) }, 600)
} }

Loading…
Cancel
Save