diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt | 13 |
1 files changed, 13 insertions, 0 deletions
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 + } + } + } } } |