Fix the NPE bug from breaking an opened shulker

parent 86d4f871
Pipeline #133 passed with stages
in 1 minute and 1 second
......@@ -99,9 +99,14 @@ class NestedShulkers : JavaPlugin(), Listener {
}
Bukkit.getScheduler().runTask(this, Runnable {
if (temp.viewers.isEmpty()) {
shulker.storageContents = temp.storageContents
shulkers.remove((shulker.holder!! as ShulkerBox).location)
closeShulker(shulker)
//Catch a weird NPE from breaking the block
shulker.let {
it.storageContents = temp.storageContents
(it.holder as? ShulkerBox)?.location?.apply {
shulkers.remove(this)
closeShulker(it)
}
}
}
})
}
......@@ -109,8 +114,7 @@ class NestedShulkers : JavaPlugin(), Listener {
@EventHandler
private fun onShulkerBreak(event: BlockBreakEvent) {
val shulker = shulkers[event.block.location] ?: return
shulker.viewers.forEach { it.closeInventory() }
closeShulker(shulker)
ArrayList(shulker.viewers).forEach { it.closeInventory() }
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment