fix
This commit is contained in:
parent
ccf696a156
commit
b3f7cee963
@ -4,7 +4,6 @@ import org.apache.logging.log4j.LogManager
|
|||||||
import ru.dbotthepony.kstarbound.defs.MovementParameters
|
import ru.dbotthepony.kstarbound.defs.MovementParameters
|
||||||
import java.util.concurrent.ForkJoinPool
|
import java.util.concurrent.ForkJoinPool
|
||||||
import java.util.concurrent.ForkJoinTask
|
import java.util.concurrent.ForkJoinTask
|
||||||
import java.util.concurrent.Future
|
|
||||||
import kotlin.reflect.KMutableProperty0
|
import kotlin.reflect.KMutableProperty0
|
||||||
|
|
||||||
object GlobalDefaults {
|
object GlobalDefaults {
|
||||||
@ -50,7 +49,6 @@ object GlobalDefaults {
|
|||||||
return listOf(executor.submit {
|
return listOf(executor.submit {
|
||||||
val line = log.line("Loading global defaults...")
|
val line = log.line("Loading global defaults...")
|
||||||
val time = System.nanoTime()
|
val time = System.nanoTime()
|
||||||
tasks.forEach { it.fork() }
|
|
||||||
tasks.forEach { it.join() }
|
tasks.forEach { it.join() }
|
||||||
line.text = "Loaded global defaults in ${((System.nanoTime() - time) / 1_000_000.0).toLong()}ms"
|
line.text = "Loaded global defaults in ${((System.nanoTime() - time) / 1_000_000.0).toLong()}ms"
|
||||||
})
|
})
|
||||||
|
@ -155,24 +155,28 @@ class ObjectRegistry<T : Any>(val clazz: KClass<T>, val name: String, val key: (
|
|||||||
return add(RegistryObject(value, json, file), key)
|
return add(RegistryObject(value, json, file), key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val lock = Any()
|
||||||
|
|
||||||
private fun add(value: RegistryObject<T>, key: String): Boolean {
|
private fun add(value: RegistryObject<T>, key: String): Boolean {
|
||||||
val existing = objects.put(key, value)
|
synchronized(lock) {
|
||||||
|
val existing = objects.put(key, value)
|
||||||
|
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
LOGGER.warn("Registry $name already has object with key $key! Overwriting. (old originated from ${existing.file}, new originate from ${value.file}).")
|
LOGGER.warn("Registry $name already has object with key $key! Overwriting. (old originated from ${existing.file}, new originate from ${value.file}).")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.intKey == null)
|
||||||
|
return existing != null
|
||||||
|
|
||||||
|
val intKey = this.intKey.invoke(value.value)
|
||||||
|
val intExisting = intObjects.put(intKey, value)
|
||||||
|
|
||||||
|
if (intExisting != null) {
|
||||||
|
LOGGER.warn("Registry $name already has object with ID $intKey (new $key, old ${ objects.entries.firstOrNull { it.value === intExisting }?.key })! Overwriting. (old originated from ${intExisting.file}, new originate from ${value.file}).")
|
||||||
|
}
|
||||||
|
|
||||||
|
return existing != null || intExisting != null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.intKey == null)
|
|
||||||
return existing != null
|
|
||||||
|
|
||||||
val intKey = this.intKey.invoke(value.value)
|
|
||||||
val intExisting = intObjects.put(intKey, value)
|
|
||||||
|
|
||||||
if (intExisting != null) {
|
|
||||||
LOGGER.warn("Registry $name already has object with ID $intKey (new $key, old ${ objects.entries.firstOrNull { it.value === intExisting }?.key })! Overwriting. (old originated from ${intExisting.file}, new originate from ${value.file}).")
|
|
||||||
}
|
|
||||||
|
|
||||||
return existing != null || intExisting != null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -67,7 +67,7 @@ annotation class JsonBuilder
|
|||||||
annotation class JsonFactory(
|
annotation class JsonFactory(
|
||||||
val storesJson: Boolean = false,
|
val storesJson: Boolean = false,
|
||||||
val asList: Boolean = false,
|
val asList: Boolean = false,
|
||||||
val logMisses: Boolean = true,
|
val logMisses: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user