From b46473e9fddcc6f161b033c70269413d709f6d8c Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 20 Jun 2020 00:48:27 +0200 Subject: [PATCH] Heavier checks for portals teleporting to real Nether/End --- .../com/songoda/skyblock/listeners/Teleport.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Teleport.java b/src/main/java/com/songoda/skyblock/listeners/Teleport.java index 81c52552..5b39d75f 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Teleport.java +++ b/src/main/java/com/songoda/skyblock/listeners/Teleport.java @@ -61,13 +61,23 @@ public class Teleport implements Listener { islandManager.loadPlayer(player); - // Fix for bug that tp you in the real Nether/End when entering in a portal in an island + // Fix for bug that tp you in the real Nether/End when entering in a portal in an island // TODO Simplify if (event.getTo() != null && (worldManager.isIslandWorld(event.getFrom().getWorld()) && !worldManager.isIslandWorld(event.getTo().getWorld()) && (event.getFrom().getBlock().getType().equals(CompatibleMaterial.END_PORTAL.getMaterial()) - || event.getFrom().getBlock().getType().equals(CompatibleMaterial.NETHER_PORTAL.getMaterial())) && (event.getTo().getWorld() != null + || event.getFrom().getBlock().getType().equals(CompatibleMaterial.NETHER_PORTAL.getMaterial())) + && (event.getTo().getWorld() != null && event.getTo().getWorld().getEnvironment().equals(World.Environment.NETHER) - || event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END)))) { + || event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END))) + || event.getTo() != null + && (worldManager.isIslandWorld(event.getFrom().getWorld()) + && !worldManager.isIslandWorld(event.getTo().getWorld()) + && (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) + || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL) + || event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)) + && (event.getTo().getWorld() != null + && event.getTo().getWorld().getEnvironment().equals(World.Environment.NETHER) + || event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END)))) { event.setCancelled(true); }