Skip to content

Commit

Permalink
fix: blocky reload command not reloading inherited prefabs of blockyP…
Browse files Browse the repository at this point in the history
…refabs
  • Loading branch information
Boy0000 committed May 17, 2024
1 parent 56df8f6 commit 47050a8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/kotlin/com/mineinabyss/blocky/BlockyCommandExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" {
Expand Down

0 comments on commit 47050a8

Please sign in to comment.