diff --git a/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java b/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java index d3af64304..ded1804a5 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/PortalTeleportationListener.java @@ -12,6 +12,7 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -65,8 +66,9 @@ public class PortalTeleportationListener implements Listener { if (!(e.getEntity() instanceof Player)) { return; } + Entity entity = e.getEntity(); Material type = e.getLocation().getBlock().getType(); - UUID uuid = e.getEntity().getUniqueId(); + UUID uuid = entity.getUniqueId(); if (inPortal.contains(uuid) || !plugin.getIWM().inWorld(Util.getWorld(e.getLocation().getWorld()))) { return; } @@ -75,8 +77,8 @@ public class PortalTeleportationListener implements Listener { // Schedule a time Bukkit.getScheduler().runTaskLater(plugin, () -> { // Check again if still in portal - if (type.equals(Material.NETHER_PORTAL)) { - PlayerPortalEvent en = new PlayerPortalEvent((Player)e.getEntity(), e.getLocation(), null, TeleportCause.NETHER_PORTAL, 0, false, 0); + if (entity.getLocation().getBlock().getType().equals(Material.NETHER_PORTAL)) { + PlayerPortalEvent en = new PlayerPortalEvent((Player)entity, e.getLocation(), null, TeleportCause.NETHER_PORTAL, 0, false, 0); if (!this.onIslandPortal(en)) { // Failed inPortal.remove(uuid); @@ -89,7 +91,7 @@ public class PortalTeleportationListener implements Listener { } // End portals are instant transfer if (!Bukkit.getAllowEnd() && (type.equals(Material.END_PORTAL) || type.equals(Material.END_GATEWAY))) { - PlayerPortalEvent en = new PlayerPortalEvent((Player)e.getEntity(), + PlayerPortalEvent en = new PlayerPortalEvent((Player)entity, e.getLocation(), null, type.equals(Material.END_PORTAL) ? TeleportCause.END_PORTAL : TeleportCause.END_GATEWAY,