Doors are not safe ground blocks.

https://github.com/BentoBoxWorld/BentoBox/issues/1517
This commit is contained in:
tastybento 2020-09-06 16:16:06 -07:00
parent a6d1acf59d
commit 450c459350
2 changed files with 19 additions and 1 deletions

View File

@ -245,6 +245,7 @@ public class IslandsManager {
* @return {@code true} if the location is considered safe, {@code false} otherwise.
*/
public boolean checkIfSafe(@Nullable World world, @NonNull Material ground, @NonNull Material space1, @NonNull Material space2) {
plugin.logDebug(ground + " " + space1 + " " + space2);
// Ground must be solid, space 1 and 2 must not be solid
if (world == null || !ground.isSolid()
|| (space1.isSolid() && !space1.name().contains("SIGN"))
@ -274,6 +275,10 @@ public class IslandsManager {
|| ground.name().contains("BOAT"))) {
return false;
}
// Signs on doors
if (ground.name().contains("DOOR")) {
return false;
}
// Known unsafe blocks
switch (ground) {
// Unsafe

View File

@ -365,6 +365,19 @@ public class IslandsManagerTest {
assertFalse(manager.isSafeLocation(location));
}
@Test
public void testCheckIfSafeTrapdoor() {
for (Material d : Material.values()) {
if (d.name().contains("DOOR")) {
for (Material s : Material.values()) {
if (s.name().contains("_SIGN")) {
assertFalse("Fail " + d.name() + " " + s.name(), manager.checkIfSafe(world, d, s, Material.AIR));
}
}
}
}
}
/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#isSafeLocation(org.bukkit.Location)}.
*/
@ -508,7 +521,7 @@ public class IslandsManagerTest {
when(ground.getState()).thenReturn(blockState);
// Negative value = full island scan
// No island here yet
// No island here yet
assertNull(manager.bigScan(location, -1));
}