From 05a4a5b3817ea3e70662d3834fd56a1b249fa70e Mon Sep 17 00:00:00 2001 From: nea Date: Thu, 4 Aug 2022 04:26:51 +0200 Subject: screen padding --- src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt') diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt index 893b1c0..8deb4c3 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt @@ -4,6 +4,8 @@ import com.mojang.serialization.Dynamic import io.github.moulberry.repo.IReloadable import io.github.moulberry.repo.NEURepository import io.github.moulberry.repo.data.NEUItem +import kotlinx.coroutines.Job +import kotlinx.coroutines.launch import moe.nea.notenoughupdates.NotEnoughUpdates import moe.nea.notenoughupdates.util.LegacyTagParser import moe.nea.notenoughupdates.util.appendLore @@ -70,7 +72,18 @@ object ItemCache : IReloadable { ResourceLocation("skyblockitem", skyblockItemId.lowercase().replace(";", "__")) + var job: Job? = null + override fun reload(repository: NEURepository) { cache.clear() + val j = job + if (j != null && j.isActive) { + j.cancel() + job = NotEnoughUpdates.coroutineScope.launch { + repository.items?.items?.values?.forEach { + it.asItemStack() // Rebuild cache + } + } + } } } -- cgit