Add autostart config parameter (closes #78) (#84)

pull/85/head
Trivernis 4 years ago committed by GitHub
parent af875aaca0
commit ac6a80ed86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -112,6 +112,10 @@ generation:
# very laggy and can cause it to crash.
# The value should be a posivitve integer > 1.
pause-on-player-count: 1
# if the generation should automatically start on server startup
# the value should be a boolean
autostart: true
```
### Spigot and Paper

@ -80,6 +80,7 @@ class Chunkmaster: JavaPlugin() {
config.addDefault("generation.max-loaded-chunks", 1000)
config.addDefault("generation.unloading-period", 50L)
config.addDefault("generation.ignore-worldborder", false)
config.addDefault("generation.autostart", true)
config.addDefault("database.filename", "chunkmaster.db")
config.addDefault("language", "en")
config.addDefault("dynmap", true)

@ -85,7 +85,6 @@ class DefaultGenerationTask(
do {
lastChunkCoords = nextChunkCoordinates
count = shape.count
println(count)
} while (PaperLib.isChunkGenerated(world, lastChunkCoords.x, lastChunkCoords.z) && !borderReached())
}

@ -17,7 +17,18 @@ class GenerationManager(private val chunkmaster: Chunkmaster, private val server
val worldProperties = chunkmaster.sqliteManager.worldProperties
private val pendingChunksTable = chunkmaster.sqliteManager.pendingChunks
private val generationTasks = chunkmaster.sqliteManager.generationTasks
private val unloadingPeriod = chunkmaster.config.getLong("generation.unloading-period")
private val unloadingPeriod: Long
get() {
return chunkmaster.config.getLong("generation.unloading-period")
}
private val pauseOnPlayerCount: Int
get () {
return chunkmaster.config.getInt("generation.pause-on-player-count")
}
private val autostart: Boolean
get () {
return chunkmaster.config.getBoolean("generation.autostart")
}
val loadedChunkCount: Int
get() {
@ -30,7 +41,7 @@ class GenerationManager(private val chunkmaster: Chunkmaster, private val server
get() {
if (this.tasks.isEmpty() && this.pausedTasks.isEmpty()) {
this.startAll()
if (server.onlinePlayers.size >= chunkmaster.config.getInt("generation.pause-on-player-count")) {
if (server.onlinePlayers.size >= pauseOnPlayerCount) {
this.pauseAll()
}
}
@ -155,7 +166,10 @@ class GenerationManager(private val chunkmaster: Chunkmaster, private val server
}, 600, 600)
server.scheduler.runTaskLater(chunkmaster, Runnable {
this.startAll()
if (!server.onlinePlayers.isEmpty()) {
if (server.onlinePlayers.count() >= pauseOnPlayerCount || !autostart) {
if (!autostart) {
chunkmaster.logger.info(chunkmaster.langManager.getLocalized("NO_AUTOSTART"))
}
this.pauseAll()
}
}, 20)

@ -76,4 +76,5 @@ STATS_LOADED_CHUNKS = - §2%d§r Loaded Chunks
STATS_PLUGIN_LOADED_CHUNKS = - §2%d§r Chunks Loaded by Chunkmaster
SAVING_CHUNKS = Saving %d loaded chunks...
CANCEL_FAIL = Failed to cancel task #%d in the given timeout!
CANCEL_FAIL = Failed to cancel task #%d in the given timeout!
NO_AUTOSTART = Autostart set to §2false§r. Pausing...

@ -76,4 +76,5 @@ STATS_LOADED_CHUNKS = - §2%d§r Geladene Chunks
STATS_PLUGIN_LOADED_CHUNKS = - §2%d§r von Chunkmaster geladene Chunks
SAVING_CHUNKS = Speichere %d geladene Chunks...
CANCEL_FAIL = Konnte Aufgabe #%d nicht im angegebenen Timeout stoppen!
CANCEL_FAIL = Konnte Aufgabe #%d nicht im angegebenen Timeout stoppen!
NO_AUTOSTART = Autostart ist auf §2false§r gesetzt. Pausiere...

@ -74,4 +74,5 @@ STATS_LOADED_CHUNKS = - §2%d§r Loaded Chunks
STATS_PLUGIN_LOADED_CHUNKS = - §2%d§r Chunks Loaded by Chunkmaster
SAVING_CHUNKS = Saving %d loaded chunks...
CANCEL_FAIL = Failed to cancel task #%d in the given timeout!
CANCEL_FAIL = Failed to cancel task #%d in the given timeout!
NO_AUTOSTART = Autostart set to §2false§r. Pausing...
Loading…
Cancel
Save