Explicitly cancels the portal if there is no nether or end.

https://github.com/BentoBoxWorld/BentoBox/issues/1036
This commit is contained in:
tastybento 2019-11-20 17:08:04 -08:00
parent 46bd8c04e2
commit 336f4e9bd4
2 changed files with 17 additions and 4 deletions

View File

@ -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) {

View File

@ -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());
}
/**