mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-04 06:21:28 +01:00
Adds null check for world in portal teleport listener
This should not occur, but apparently, it can sometimes. https://github.com/BentoBoxWorld/BentoBox/issues/583
This commit is contained in:
parent
b5a657de52
commit
2664acbe47
@ -52,7 +52,7 @@ public class PortalTeleportationListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
World fromWorld = e.getFrom().getWorld();
|
||||
if (e.getCause() != TeleportCause.END_PORTAL || !plugin.getIWM().isEndGenerate(fromWorld)) {
|
||||
if (fromWorld == null || e.getCause() != TeleportCause.END_PORTAL || !plugin.getIWM().isEndGenerate(fromWorld)) {
|
||||
// Do nothing special
|
||||
return false;
|
||||
}
|
||||
|
@ -207,6 +207,31 @@ public class PortalTeleportationListenerTest {
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link PortalTeleportationListener#onEndIslandPortal(org.bukkit.event.player.PlayerPortalEvent)}.
|
||||
*/
|
||||
@Test
|
||||
public void testOnEndIslandPortalNullLocation() {
|
||||
PortalTeleportationListener np = new PortalTeleportationListener(plugin);
|
||||
Location loc = null;
|
||||
PlayerPortalEvent e = new PlayerPortalEvent(null, loc, null, null, TeleportCause.END_PORTAL);
|
||||
assertFalse(np.onEndIslandPortal(e));
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link PortalTeleportationListener#onEndIslandPortal(org.bukkit.event.player.PlayerPortalEvent)}.
|
||||
*/
|
||||
@Test
|
||||
public void testOnEndIslandPortalNullWorld() {
|
||||
PortalTeleportationListener np = new PortalTeleportationListener(plugin);
|
||||
Location loc = mock(Location.class);
|
||||
when(loc.getWorld()).thenReturn(null);
|
||||
PlayerPortalEvent e = new PlayerPortalEvent(null, loc, null, null, TeleportCause.END_PORTAL);
|
||||
assertFalse(np.onEndIslandPortal(e));
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link PortalTeleportationListener#onEndIslandPortal(org.bukkit.event.player.PlayerPortalEvent)}.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user