From 47050a8006f6dd5b29a175b03c5da3adf44de4c5 Mon Sep 17 00:00:00 2001 From: Boy Date: Fri, 17 May 2024 20:32:24 +0200 Subject: [PATCH] fix: blocky reload command not reloading inherited prefabs of blockyPrefabs --- .../mineinabyss/blocky/BlockyCommandExecutor.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/mineinabyss/blocky/BlockyCommandExecutor.kt b/src/main/kotlin/com/mineinabyss/blocky/BlockyCommandExecutor.kt index cb213fa..68efde4 100644 --- a/src/main/kotlin/com/mineinabyss/blocky/BlockyCommandExecutor.kt +++ b/src/main/kotlin/com/mineinabyss/blocky/BlockyCommandExecutor.kt @@ -8,7 +8,6 @@ import com.mineinabyss.blocky.helpers.gearyInventory import com.mineinabyss.blocky.menus.BlockyMainMenu import com.mineinabyss.blocky.systems.blockPrefabs import com.mineinabyss.blocky.systems.megFurniturePrefabs -import com.mineinabyss.geary.annotations.optin.UnsafeAccessors import com.mineinabyss.geary.papermc.tracking.items.gearyItems import com.mineinabyss.geary.prefabs.PrefabKey import com.mineinabyss.geary.prefabs.prefabs @@ -34,10 +33,20 @@ class BlockyCommandExecutor : IdofrontCommandExecutor(), TabCompleter { "reload" { action { blocky.plugin.createBlockyContext() - blocky.plugin.launch { blocky.prefabQuery.entities().forEach { prefabs.loader.reload(it) } } + blocky.plugin.launch { + val blockyPrefabs = blocky.prefabQuery.entities() + val inheritedPrefabs = blockyPrefabs.asSequence().flatMap { it.prefabs } + .filter { it !in blockyPrefabs }.toSet().sortedBy { it.prefabs.size } + + // Reload all prefabs that arent blockyPrefabs + inheritedPrefabs.forEach { prefabs.loader.reload(it) } + + // Reload all blockyPrefabs that aren't in inheritedPrefabs + blockyPrefabs.filter { it !in inheritedPrefabs }.sortedBy { it.prefabs.size } + .forEach { prefabs.loader.reload(it) } + } ResourcepackGeneration().generateDefaultAssets() sender.success("Blocky has been reloaded!") - } } "give" {