Skip to content

Commit

Permalink
Merge branch 'Slimefun:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
WalshyDev committed Jan 17, 2024
2 parents 5175864 + bcfbd3a commit e76e479
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -383,7 +383,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.8.0</version>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Expand Up @@ -226,9 +226,10 @@ private void callBlockHandler(BlockBreakEvent e, ItemStack item, List<ItemStack>
// 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());
Expand Down
Expand Up @@ -116,7 +116,9 @@ void testCannotOpenInvOfBrokenBlock() {
// 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);
Expand All @@ -129,6 +131,9 @@ void testCannotOpenInvOfBrokenBlock() {
// 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();

Expand Down

0 comments on commit e76e479

Please sign in to comment.