aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-08-07 23:51:45 +0200
committernea <romangraef@gmail.com>2022-08-07 23:51:45 +0200
commit9713b856f8abdb003824fd3d0ef4bc8a8bfc5b06 (patch)
tree72f24e1f42e8449c8fb993aca33d752008a13f7b /src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt
parentdc4755eb79ab78f87b0e1e4ad6dac81912af0ee0 (diff)
downloadfirmament-9713b856f8abdb003824fd3d0ef4bc8a8bfc5b06.tar.gz
firmament-9713b856f8abdb003824fd3d0ef4bc8a8bfc5b06.tar.bz2
firmament-9713b856f8abdb003824fd3d0ef4bc8a8bfc5b06.zip
progress bar
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt20
1 files changed, 16 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 8deb4c3..9255867 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/ItemCache.kt
@@ -1,6 +1,7 @@
package moe.nea.notenoughupdates.repo
import com.mojang.serialization.Dynamic
+import io.github.cottonmc.cotton.gui.client.CottonHud
import io.github.moulberry.repo.IReloadable
import io.github.moulberry.repo.NEURepository
import io.github.moulberry.repo.data.NEUItem
@@ -79,11 +80,22 @@ object ItemCache : IReloadable {
val j = job
if (j != null && j.isActive) {
j.cancel()
- job = NotEnoughUpdates.coroutineScope.launch {
- repository.items?.items?.values?.forEach {
- it.asItemStack() // Rebuild cache
- }
+ }
+
+ job = NotEnoughUpdates.coroutineScope.launch {
+ val items = repository.items?.items
+ if (items == null) {
+ CottonHud.remove(RepoManager.progressBar)
+ return@launch
+ }
+ RepoManager.progressBar.reportProgress("Recache Items", 0, items.size)
+ CottonHud.add(RepoManager.progressBar)
+ var i = 0
+ items.values.forEach {
+ it.asItemStack() // Rebuild cache
+ RepoManager.progressBar.reportProgress("Recache Items", i++, items.size)
}
+ CottonHud.remove(RepoManager.progressBar)
}
}
}