diff options
author | nea <romangraef@gmail.com> | 2022-08-27 02:37:34 +0200 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-08-27 02:37:34 +0200 |
commit | 2019473c50dfe3f1c6fd071d123d49d43bc180c4 (patch) | |
tree | 56ae9b81672582bfab2993f6b4a110c8a98e6682 /src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt | |
parent | 973c13e84f8e091a6a920779103d96559dcd32a8 (diff) | |
download | firmament-2019473c50dfe3f1c6fd071d123d49d43bc180c4.tar.gz firmament-2019473c50dfe3f1c6fd071d123d49d43bc180c4.tar.bz2 firmament-2019473c50dfe3f1c6fd071d123d49d43bc180c4.zip |
move commands to its own place
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt index 1cf6efc..19ae606 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt @@ -18,12 +18,19 @@ import net.minecraft.nbt.NbtCompound import net.minecraft.nbt.NbtOps import net.minecraft.text.Text import net.minecraft.util.Identifier +import java.io.PrintWriter +import java.nio.file.Path import java.util.concurrent.ConcurrentHashMap +import kotlin.io.path.absolutePathString +import kotlin.io.path.writer object ItemCache : IReloadable { - val cache: MutableMap<String, ItemStack> = ConcurrentHashMap() - val df = Schemas.getFixer() + val dfuLog = Path.of("logs/dfulog.txt") + private val cache: MutableMap<String, ItemStack> = ConcurrentHashMap() + private val df = Schemas.getFixer() + private val dfuHandle = PrintWriter(dfuLog.writer()) var isFlawless = true + private set private fun NEUItem.get10809CompoundTag(): NbtCompound = NbtCompound().apply { put("tag", LegacyTagParser.parse(nbttag)) @@ -41,8 +48,10 @@ object ItemCache : IReloadable { 2975 ).value as NbtCompound } catch (e: Exception) { - NotEnoughUpdates.logger.error("Failed to datafixer an item", e) + if (isFlawless) + NotEnoughUpdates.logger.error("Failed to run data fixer an item. Check ${dfuLog.absolutePathString()} for more information") isFlawless = false + e.printStackTrace(dfuHandle) null } @@ -76,11 +85,12 @@ object ItemCache : IReloadable { var job: Job? = null override fun reload(repository: NEURepository) { - cache.clear() val j = job if (j != null && j.isActive) { j.cancel() } + cache.clear() + isFlawless = true job = NotEnoughUpdates.coroutineScope.launch { val items = repository.items?.items |