diff --git a/build.gradle.kts b/build.gradle.kts index 1d3ea65..0df9fb3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,10 +4,9 @@ plugins { id("io.github.goooler.shadow") version "8.1.8" id("io.papermc.paperweight.userdev") version "1.7.4" apply false id("xyz.jpenilla.run-paper") version "2.3.1" - id("org.jetbrains.dokka") version "1.9.20" + id("org.jetbrains.dokka") version "1.9.20" //TODO set this to 2.0.0 when stable version is released. } - val minecraft = "1.21.3" val folia = "1.20.6" // TODO Bumps version. val adventure = "4.17.0" @@ -19,7 +18,7 @@ allprojects { apply(plugin = "kotlin") apply(plugin = "org.jetbrains.dokka") group = "kr.toxicity.healthbar" - version = "3.5.1" + version = "3.5.2" repositories { mavenCentral() maven("https://repo.papermc.io/repository/maven-public/") @@ -164,7 +163,7 @@ val sourceJar by tasks.creating(Jar::class.java) { val dokkaJar by tasks.creating(Jar::class.java) { dependsOn(tasks.dokkaHtmlMultiModule) archiveClassifier = "dokka" - from(layout.buildDirectory.dir("dokka${File.separatorChar}htmlMultiModule").orNull?.asFile) + from(layout.buildDirectory.dir("dokka/htmlMultiModule").orNull?.asFile) } tasks { @@ -173,10 +172,10 @@ tasks { finalizedBy(shadowJar) } runServer { - version("1.21.1") + version("1.21.1") //TODO set this to 'minecraft' when other plugins support the latest version. pluginJars(fileTree("plugins")) downloadPlugins { - modrinth("betterhud2", "1.7.DEV-264") + modrinth("betterhud2", "1.7.DEV-266") hangar("PlaceholderAPI", "2.11.6") hangar("Skript", "2.9.3") } diff --git a/dist/src/main/kotlin/kr/toxicity/healthbar/util/Lists.kt b/dist/src/main/kotlin/kr/toxicity/healthbar/util/Lists.kt index f619487..dc39005 100644 --- a/dist/src/main/kotlin/kr/toxicity/healthbar/util/Lists.kt +++ b/dist/src/main/kotlin/kr/toxicity/healthbar/util/Lists.kt @@ -1,6 +1,7 @@ package kr.toxicity.healthbar.util -import java.util.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executors import kotlin.collections.ArrayList fun List.split(splitSize: Int): List> { @@ -25,14 +26,14 @@ fun List>.sum(): List { fun List.forEachAsync(block: (T) -> Unit) { if (isNotEmpty()) { val available = Runtime.getRuntime().availableProcessors() - val queue = if (available > size) { - LinkedList(map { + val tasks = if (available >= size) { + map { { block(it) } - }) + } } else { - val queue = LinkedList<() -> Unit>() + val queue = ArrayList<() -> Unit>() var i = 0 val add = (size.toDouble() / available).toInt() while (i <= size) { @@ -46,29 +47,13 @@ fun List.forEachAsync(block: (T) -> Unit) { } queue } - object : Thread() { - private val index = TaskIndex(queue.size) - override fun run() { - while (!isInterrupted) { - queue.poll()?.let { - Thread { - runCatching { - it() - }.onFailure { e -> - e.printStackTrace() - } - synchronized(index) { - if (++index.current == index.max) { - interrupt() - } - } - }.start() - } - } - } - }.run { - start() - join() - } + val pool = Executors.newFixedThreadPool(tasks.size) + CompletableFuture.allOf( + *tasks.map { + CompletableFuture.runAsync({ + it() + }, pool) + }.toTypedArray() + ).join() } } \ No newline at end of file