aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-08-04 04:26:51 +0200
committernea <romangraef@gmail.com>2022-08-04 04:26:51 +0200
commit05a4a5b3817ea3e70662d3834fd56a1b249fa70e (patch)
treea02169948679be5a748a3255e99738133bf8f83c /src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt
parentc83890afc8304fc0a1b1d0ea8da791c6d9b90439 (diff)
downloadFirmament-05a4a5b3817ea3e70662d3834fd56a1b249fa70e.tar.gz
Firmament-05a4a5b3817ea3e70662d3834fd56a1b249fa70e.tar.bz2
Firmament-05a4a5b3817ea3e70662d3834fd56a1b249fa70e.zip
screen padding
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt13
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
+ }
+ }
+ }
}
}