From 336f4e9bd436b95457663b8366963bfbccc2b24a Mon Sep 17 00:00:00 2001 From: tastybento Date: Wed, 20 Nov 2019 17:08:04 -0800 Subject: [PATCH] Explicitly cancels the portal if there is no nether or end. https://github.com/BentoBoxWorld/BentoBox/issues/1036 --- .../PortalTeleportationListener.java | 19 ++++++++++++++++--- .../PortalTeleportationListenerTest.java | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java b/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java index 32106d7e6..f4437efa0 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java @@ -60,11 +60,17 @@ public class PortalTeleportationListener implements Listener { } World fromWorld = e.getFrom().getWorld(); World overWorld = Util.getWorld(fromWorld); - - if (fromWorld == null || !plugin.getIWM().inWorld(overWorld) || !plugin.getIWM().isEndGenerate(overWorld)) { + + if (fromWorld == null || !plugin.getIWM().inWorld(overWorld)) { // Do nothing special return false; } + + // 1.14.4 requires explicit cancellation to prevent teleporting to the normal nether + if (!plugin.getIWM().isEndGenerate(overWorld)) { + e.setCancelled(true); + return false; + } // STANDARD END if (!plugin.getIWM().isEndIslands(overWorld)) { @@ -133,10 +139,17 @@ public class PortalTeleportationListener implements Listener { World fromWorld = e.getFrom().getWorld(); World overWorld = Util.getWorld(fromWorld); - if (fromWorld == null || !plugin.getIWM().inWorld(overWorld) || !plugin.getIWM().isNetherGenerate(overWorld)) { + if (fromWorld == null || !plugin.getIWM().inWorld(overWorld)) { // Do nothing special return false; } + + // 1.14.4 requires explicit cancellation to prevent teleporting to the normal nether + if (!plugin.getIWM().isNetherGenerate(overWorld)) { + e.setCancelled(true); + return false; + } + // STANDARD NETHER if (!plugin.getIWM().isNetherIslands(overWorld)) { if (fromWorld.getEnvironment() != Environment.NETHER) { diff --git a/src/test/java/world/bentobox/bentobox/listeners/PortalTeleportationListenerTest.java b/src/test/java/world/bentobox/bentobox/listeners/PortalTeleportationListenerTest.java index e3bf1a81c..b9a43c191 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/PortalTeleportationListenerTest.java +++ b/src/test/java/world/bentobox/bentobox/listeners/PortalTeleportationListenerTest.java @@ -174,7 +174,7 @@ public class PortalTeleportationListenerTest { PortalTeleportationListener np = new PortalTeleportationListener(plugin); PlayerPortalEvent e = new PlayerPortalEvent(null, from, null, TeleportCause.END_PORTAL); np.onEndIslandPortal(e); - assertFalse(e.isCancelled()); + assertTrue(e.isCancelled()); } /**