From 928dfbf264e551cab923d62de791bd961a51e32f Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 28 Jun 2020 21:20:25 +0200 Subject: [PATCH] Fix #61 incorrect progress percentage --- build.gradle | 2 +- src/main/kotlin/net/trivernis/chunkmaster/Chunkmaster.kt | 9 ++++++--- .../chunkmaster/lib/generation/GenerationTaskPaper.kt | 8 ++++---- .../net/trivernis/chunkmaster/lib/shapes/Circle.kt | 3 ++- .../net/trivernis/chunkmaster/lib/shapes/Spiral.kt | 2 +- src/main/resources/plugin.yml | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 0cb7bbe..be69490 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ idea { } group "net.trivernis" -version "1.0" +version "1.0.1" sourceCompatibility = 1.8 diff --git a/src/main/kotlin/net/trivernis/chunkmaster/Chunkmaster.kt b/src/main/kotlin/net/trivernis/chunkmaster/Chunkmaster.kt index 9c709a4..ab5a687 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/Chunkmaster.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/Chunkmaster.kt @@ -1,15 +1,15 @@ package net.trivernis.chunkmaster import io.papermc.lib.PaperLib -import net.trivernis.chunkmaster.commands.* +import net.trivernis.chunkmaster.commands.CommandChunkmaster import net.trivernis.chunkmaster.lib.LanguageManager -import net.trivernis.chunkmaster.lib.generation.GenerationManager import net.trivernis.chunkmaster.lib.SqliteManager +import net.trivernis.chunkmaster.lib.generation.GenerationManager import org.bstats.bukkit.Metrics import org.bukkit.plugin.java.JavaPlugin import org.bukkit.scheduler.BukkitTask import org.dynmap.DynmapAPI -import java.lang.Exception +import java.util.logging.Level class Chunkmaster: JavaPlugin() { lateinit var sqliteManager: SqliteManager @@ -26,6 +26,9 @@ class Chunkmaster: JavaPlugin() { */ override fun onEnable() { PaperLib.suggestPaper(this) + logger.fine("LogLevel: FINE") + logger.finer("LogLevel: FINER") + logger.finest("LogLevel: FINEST") configure() val metrics = Metrics(this) diff --git a/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskPaper.kt b/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskPaper.kt index e68f869..cf3fca0 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskPaper.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/lib/generation/GenerationTaskPaper.kt @@ -106,15 +106,15 @@ class GenerationTaskPaper( * Checks if some chunks have been loaded and adds them to the loaded chunk set. */ private fun checkChunksLoaded() { - val completedEntrys = HashSet>() + val completedEntries = HashSet>() for (pendingChunk in pendingChunks) { if (pendingChunk.isDone) { - completedEntrys.add(pendingChunk) + completedEntries.add(pendingChunk) loadedChunks.add(pendingChunk.get()) } else if (pendingChunk.isCompletedExceptionally || pendingChunk.isCancelled) { - completedEntrys.add(pendingChunk) + completedEntries.add(pendingChunk) } } - pendingChunks.removeAll(completedEntrys) + pendingChunks.removeAll(completedEntries) } } \ No newline at end of file diff --git a/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt b/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt index be03db5..4702635 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Circle.kt @@ -21,7 +21,8 @@ class Circle(center: Pair, start: Pair, radius: Int): Shape( } override fun progress(): Double { - return (PI * r.toFloat().pow(2))/(PI* radius.toFloat().pow(2)) + // TODO: Radius inner progress + return (count/(PI* radius.toFloat().pow(2))).coerceAtMost(100.0) } override fun currentRadius(): Int { diff --git a/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Spiral.kt b/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Spiral.kt index 75ee564..33b7ac3 100644 --- a/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Spiral.kt +++ b/src/main/kotlin/net/trivernis/chunkmaster/lib/shapes/Spiral.kt @@ -14,7 +14,7 @@ class Spiral(center: Pair, start: Pair, radius: Int): Shape( } override fun progress(): Double { - return (currentRadius()*2).toDouble().pow(2) / (radius * 2).toDouble().pow(2) + return (count / (radius * 2).toDouble().pow(2)).coerceAtMost(100.0) } override fun currentRadius(): Int { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 6f73c45..33abf55 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ main: net.trivernis.chunkmaster.Chunkmaster name: Chunkmaster -version: '1.0' +version: '1.0.1' description: Chunk commands plugin. author: Trivernis website: trivernis.net