diff options
author | Dico <dico.karssiens@gmail.com> | 2018-08-04 00:13:09 +0100 |
---|---|---|
committer | Dico <dico.karssiens@gmail.com> | 2018-08-04 00:13:09 +0100 |
commit | 3573f9ade67010e3e538151375faecbec32825c4 (patch) | |
tree | fd838b5d2a333730e62d4ae0ebf452dba5822696 /src/main/kotlin/io/dico/parcels2/ParcelsPlugin.kt | |
parent | 703e02d6b23165003835692b0213a20f0a627e9d (diff) |
work on plotme migration
Diffstat (limited to 'src/main/kotlin/io/dico/parcels2/ParcelsPlugin.kt')
-rw-r--r-- | src/main/kotlin/io/dico/parcels2/ParcelsPlugin.kt | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/main/kotlin/io/dico/parcels2/ParcelsPlugin.kt b/src/main/kotlin/io/dico/parcels2/ParcelsPlugin.kt index ffa11c7..f0b5fbc 100644 --- a/src/main/kotlin/io/dico/parcels2/ParcelsPlugin.kt +++ b/src/main/kotlin/io/dico/parcels2/ParcelsPlugin.kt @@ -85,25 +85,32 @@ class ParcelsPlugin : JavaPlugin() { fun loadOptions(): Boolean { when { optionsFile.exists() -> optionsMapper.readerForUpdating(options).readValue<Options>(optionsFile) - optionsFile.tryCreate() -> { + else -> run { options.addWorld("parcels") - try { - optionsMapper.writeValue(optionsFile, options) - } catch (ex: Throwable) { - optionsFile.delete() - throw ex + if (saveOptions()) { + plogger.warn("Created options file with a world template. Please review it before next start.") + } else { + plogger.error("Failed to save options file ${optionsFile.canonicalPath}") } - plogger.warn("Created options file with a world template. Please review it before next start.") - return false - } - else -> { - plogger.error("Failed to save options file ${optionsFile.canonicalPath}") return false } } return true } + fun saveOptions(): Boolean { + if (optionsFile.tryCreate()) { + try { + optionsMapper.writeValue(optionsFile, options) + } catch (ex: Throwable) { + optionsFile.delete() + throw ex + } + return true + } + return false + } + override fun getDefaultWorldGenerator(worldName: String, generatorId: String?): ChunkGenerator? { return parcelProvider.getWorldGenerator(worldName) } @@ -119,6 +126,8 @@ class ParcelsPlugin : JavaPlugin() { listeners = ParcelListeners(parcelProvider, entityTracker) registrator.registerListeners(listeners!!) } + + functionHelper.scheduleRepeating(100, 5, entityTracker::tick) } }
\ No newline at end of file |