mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
fix slimefun block turning into a vanilla block if there are viewers (#4101)
This commit is contained in:
parent
9fba3f6b05
commit
bcfbd3a598
@ -226,9 +226,10 @@ public class BlockListener implements Listener {
|
||||
// The main fix is in SlimefunItemInteractListener preventing opening to begin with
|
||||
// Close the inventory for all viewers of this block
|
||||
BlockMenu inventory = BlockStorage.getInventory(e.getBlock());
|
||||
// TODO(future): Remove this check when MockBukkit supports viewers
|
||||
if (inventory != null && !Slimefun.instance().isUnitTest()) {
|
||||
inventory.toInventory().getViewers().forEach(HumanEntity::closeInventory);
|
||||
if (inventory != null) {
|
||||
for (HumanEntity human : new ArrayList<>(inventory.toInventory().getViewers())) {
|
||||
human.closeInventory();
|
||||
}
|
||||
}
|
||||
// Remove the block data
|
||||
BlockStorage.clearBlockInfo(e.getBlock());
|
||||
|
@ -116,7 +116,9 @@ class TestSlimefunItemInteractListener {
|
||||
// TODO: Create an event for open inventory so this isn't guess work
|
||||
Assertions.assertTrue(BlockMenuPreset.isInventory(electricFurnace.getId()));
|
||||
Assertions.assertTrue(BlockStorage.getStorage(block.getWorld()).hasInventory(block.getLocation()));
|
||||
// TODO(future): Check viewers - MockBukkit does not implement this today
|
||||
|
||||
// Assert player has the inventory open
|
||||
Assertions.assertEquals(1, BlockStorage.getInventory(block).toInventory().getViewers().size());
|
||||
|
||||
// Break the block
|
||||
BlockBreakEvent blockBreakEvent = new BlockBreakEvent(block, player);
|
||||
@ -129,6 +131,9 @@ class TestSlimefunItemInteractListener {
|
||||
// Assert the block is queued for removal
|
||||
Assertions.assertTrue(Slimefun.getTickerTask().isDeletedSoon(block.getLocation()));
|
||||
|
||||
// Assert that the inventory was closed
|
||||
Assertions.assertEquals(0, BlockStorage.getInventory(block).toInventory().getViewers().size());
|
||||
|
||||
// Clear event queue since we'll be running duplicate events
|
||||
server.getPluginManager().clearEvents();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user