Skip to content

Commit

Permalink
2.5.2 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Nov 1, 2024
1 parent d8e6628 commit 348cab5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 35 deletions.
11 changes: 5 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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/")
Expand Down Expand Up @@ -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 {
Expand All @@ -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")
}
Expand Down
43 changes: 14 additions & 29 deletions dist/src/main/kotlin/kr/toxicity/healthbar/util/Lists.kt
Original file line number Diff line number Diff line change
@@ -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 <T> List<T>.split(splitSize: Int): List<List<T>> {
Expand All @@ -25,14 +26,14 @@ fun <T> List<List<T>>.sum(): List<T> {
fun <T> List<T>.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) {
Expand All @@ -46,29 +47,13 @@ fun <T> List<T>.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()
}
}

0 comments on commit 348cab5

Please sign in to comment.