mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 21:27:44 +01:00
Fix loop in nether portals (#1686)
* Fix loop in nether portals Close #1685 * Forgot to import
This commit is contained in:
parent
969b413588
commit
2bc5e59e9a
@ -12,6 +12,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -65,8 +66,9 @@ public class PortalTeleportationListener implements Listener {
|
|||||||
if (!(e.getEntity() instanceof Player)) {
|
if (!(e.getEntity() instanceof Player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Entity entity = e.getEntity();
|
||||||
Material type = e.getLocation().getBlock().getType();
|
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()))) {
|
if (inPortal.contains(uuid) || !plugin.getIWM().inWorld(Util.getWorld(e.getLocation().getWorld()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,8 +77,8 @@ public class PortalTeleportationListener implements Listener {
|
|||||||
// Schedule a time
|
// Schedule a time
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
// Check again if still in portal
|
// Check again if still in portal
|
||||||
if (type.equals(Material.NETHER_PORTAL)) {
|
if (entity.getLocation().getBlock().getType().equals(Material.NETHER_PORTAL)) {
|
||||||
PlayerPortalEvent en = new PlayerPortalEvent((Player)e.getEntity(), e.getLocation(), null, TeleportCause.NETHER_PORTAL, 0, false, 0);
|
PlayerPortalEvent en = new PlayerPortalEvent((Player)entity, e.getLocation(), null, TeleportCause.NETHER_PORTAL, 0, false, 0);
|
||||||
if (!this.onIslandPortal(en)) {
|
if (!this.onIslandPortal(en)) {
|
||||||
// Failed
|
// Failed
|
||||||
inPortal.remove(uuid);
|
inPortal.remove(uuid);
|
||||||
@ -89,7 +91,7 @@ public class PortalTeleportationListener implements Listener {
|
|||||||
}
|
}
|
||||||
// End portals are instant transfer
|
// End portals are instant transfer
|
||||||
if (!Bukkit.getAllowEnd() && (type.equals(Material.END_PORTAL) || type.equals(Material.END_GATEWAY))) {
|
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(),
|
e.getLocation(),
|
||||||
null,
|
null,
|
||||||
type.equals(Material.END_PORTAL) ? TeleportCause.END_PORTAL : TeleportCause.END_GATEWAY,
|
type.equals(Material.END_PORTAL) ? TeleportCause.END_PORTAL : TeleportCause.END_GATEWAY,
|
||||||
|
Loading…
Reference in New Issue
Block a user