Skip to content

Commit

Permalink
Merge pull request #2501 from BentoBoxWorld/2500_Admin_purge_command_…
Browse files Browse the repository at this point in the history
…error

Prevent null island worlds from blocking purging. #2500
  • Loading branch information
tastybento authored Sep 13, 2024
2 parents 6896a45 + 8240484 commit ab8f3a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Set<String> getOldIslands(int days) {
// Process islands in one pass, logging and adding to the set if applicable
getPlugin().getIslands().getIslands().stream()
.filter(i -> !i.isSpawn()).filter(i -> !i.getPurgeProtected())
.filter(i -> i.getWorld() != null) // to handle currently unloaded world islands
.filter(i -> i.getWorld().equals(this.getWorld())).filter(Island::isOwned).filter(
i -> i.getMemberSet().stream()
.allMatch(member -> (currentTimeMillis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -364,4 +365,15 @@ public void testSetUser() {
verify(user, Mockito.times(1)).sendMessage(any());
}

/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.purge.AdminPurgeCommand#getOldIslands(int)}
*/
@Test
public void testGetOldIslands() {
assertTrue(apc.getOldIslands(10).isEmpty());
Island island2 = mock(Island.class);
when(im.getIslands()).thenReturn(Set.of(island, island2));
assertTrue(apc.getOldIslands(10).isEmpty());
}

}

0 comments on commit ab8f3a7

Please sign in to comment.