From a4115ebdf76e342fbe5a24c1739f71c57a95ee3e Mon Sep 17 00:00:00 2001 From: Trivernis Date: Wed, 5 Feb 2020 17:31:33 +0100 Subject: [PATCH] Add ETA to periodic reports Closes #17 --- .../lib/generation/GenerationManager.kt | 14 +++++++++++++- src/main/resources/i18n/DEFAULT.i18n.properties | 2 +- src/main/resources/i18n/de.i18n.properties | 2 +- src/main/resources/i18n/en.i18n.properties | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationManager.kt b/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationManager.kt index 81b69ab..b9e0bfb 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationManager.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationManager.kt @@ -215,16 +215,28 @@ class GenerationManager(private val chunkmaster: Chunkmaster, private val server for (task in tasks) { try { val genTask = task.generationTask + val speed = task.generationSpeed!! val percentage = if (genTask.stopAfter > 0) "(${"%.2f".format( (genTask.count.toDouble() / genTask.stopAfter.toDouble()) * 100 )}%)" else "" + val eta = if (genTask.stopAfter > 0 && speed > 0) { + val etaSeconds = (genTask.stopAfter - genTask.count).toDouble()/speed + chunkmaster.logger.info(""+etaSeconds) + val hours: Int = (etaSeconds/3600).toInt() + val minutes: Int = ((etaSeconds % 3600) / 60).toInt() + val seconds: Int = (etaSeconds % 60).toInt() + ", ETA: %d:%02d:%02d".format(hours, minutes, seconds) + } else { + "" + } chunkmaster.logger.info(chunkmaster.langManager.getLocalized( "TASK_PERIODIC_REPORT", task.id, genTask.world.name, genTask.count, percentage, - task.generationSpeed!!, + eta, + speed, genTask.lastChunk.x, genTask.lastChunk.z)) chunkmaster.sqliteManager.executeStatement( diff --git a/src/main/resources/i18n/DEFAULT.i18n.properties b/src/main/resources/i18n/DEFAULT.i18n.properties index f79da32..e0771de 100644 --- a/src/main/resources/i18n/DEFAULT.i18n.properties +++ b/src/main/resources/i18n/DEFAULT.i18n.properties @@ -5,7 +5,7 @@ TASK_LOAD_FAILED = \u00A7cFailed to load task #%d. TASK_LOAD_SUCCESS = %d saved tasks loaded. TASK_NOT_FOUND = \u00A7cTask %s not found! CREATE_DELAYED_LOAD = Creating task to load chunk generation Tasks later... -TASK_PERIODIC_REPORT = Task #%d running for '%s'. Progress: %d chunks %s, Speed: %.1f ch/s, Last Chunk: %d, %d +TASK_PERIODIC_REPORT = Task #%d running for '%s'. Progress: %d chunks %s %s, Speed: %.1f ch/s, Last Chunk: %d, %d TASK_SAVE_FAILED = \u00A7cException when saving tasks: %s WORLD_NAME_REQUIRED = \u00A7cYou need to provide a world name! diff --git a/src/main/resources/i18n/de.i18n.properties b/src/main/resources/i18n/de.i18n.properties index 14aa4d3..e1ee078 100644 --- a/src/main/resources/i18n/de.i18n.properties +++ b/src/main/resources/i18n/de.i18n.properties @@ -5,7 +5,7 @@ TASK_LOAD_FAILED = \u00A7cAufgabe #%d konnte nicht geladen werden. TASK_LOAD_SUCCESS = %d gespeicherte Aufgaben wurden geladen. TASK_NOT_FOUND = \u00A7cAufgabe %s konnte nicht gefunden werden! CREATE_DELAYED_LOAD = Erstelle einen Bukkit-Task zum verz\u00f6gerten Laden von Aufgaben... -TASK_PERIODIC_REPORT = Aufgabe #%d f\u00fcr Welt '%s'. Fortschritt: %d chunks %s, Geschwindigkeit: %.1f ch/s, Letzer Chunk: %d, %d +TASK_PERIODIC_REPORT = Aufgabe #%d f\u00fcr Welt '%s'. Fortschritt: %d chunks %s %s, Geschwindigkeit: %.1f ch/s, Letzer Chunk: %d, %d TASK_SAVE_FAILED = \u00A7cFehler beim Speichern der Aufgaben: %s WORLD_NAME_REQUIRED = \u00A7cDu musst einen Weltennamen angeben! diff --git a/src/main/resources/i18n/en.i18n.properties b/src/main/resources/i18n/en.i18n.properties index f79da32..e0771de 100644 --- a/src/main/resources/i18n/en.i18n.properties +++ b/src/main/resources/i18n/en.i18n.properties @@ -5,7 +5,7 @@ TASK_LOAD_FAILED = \u00A7cFailed to load task #%d. TASK_LOAD_SUCCESS = %d saved tasks loaded. TASK_NOT_FOUND = \u00A7cTask %s not found! CREATE_DELAYED_LOAD = Creating task to load chunk generation Tasks later... -TASK_PERIODIC_REPORT = Task #%d running for '%s'. Progress: %d chunks %s, Speed: %.1f ch/s, Last Chunk: %d, %d +TASK_PERIODIC_REPORT = Task #%d running for '%s'. Progress: %d chunks %s %s, Speed: %.1f ch/s, Last Chunk: %d, %d TASK_SAVE_FAILED = \u00A7cException when saving tasks: %s WORLD_NAME_REQUIRED = \u00A7cYou need to provide a world name!