/** * This method is called to adjust the portal location to the actual portal location (and not * right outside of it. * @param event The Event that was fired. */ @EventHandler(priority = EventPriority.LOWEST) public void playerPortalCheck(PlayerPortalEvent event) { if (event.isCancelled() || event.getFrom() == null) { return; } // REMEMBER! getTo MAY be NULL HERE!!! // If the player was actually outside of the portal, adjust the from location if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.NETHER_PORTAL) { Location newloc = this.plugin.getSafeTTeleporter().findPortalBlockNextTo(event.getFrom()); // TODO: Fix this. Currently, we only check for PORTAL blocks. I'll have to figure out what // TODO: we want to do here. if (newloc != null) { event.setFrom(newloc); } } // Wait for the adjust, then return! if (event.getTo() == null) { return; } } /**
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerPortal(PlayerPortalEvent e) { if (e.getCause().equals(TeleportCause.NETHER_PORTAL)) { checkIsland(e, e.getFrom(), Flags.NETHER_PORTAL); } else if (e.getCause().equals(TeleportCause.END_PORTAL)) { checkIsland(e, e.getFrom(), Flags.END_PORTAL); } } }
/** * Handle end portals * @param e - event */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEndIslandPortal(PlayerPortalEvent e) { if (!e.getCause().equals(TeleportCause.END_PORTAL) || !plugin.getIWM().inWorld(e.getFrom())) { return; } World overWorld = Util.getWorld(e.getFrom().getWorld()); // If entering a portal in the end, teleport home if you have one, else do nothing if (e.getFrom().getWorld().getEnvironment().equals(Environment.THE_END)) { if (plugin.getIslands().hasIsland(overWorld, e.getPlayer().getUniqueId())) { e.setCancelled(true); plugin.getIslands().homeTeleport(overWorld, e.getPlayer()); } return; } // Going to the end, then go to the same location in the end world if (plugin.getIWM().isEndGenerate(overWorld) && plugin.getIWM().isEndIslands(overWorld)) { World endWorld = plugin.getIWM().getEndWorld(overWorld); // End exists and end islands are being used Location to = plugin.getIslands().getIslandAt(e.getFrom()).map(i -> i.getSpawnPoint(Environment.THE_END)).orElse(e.getFrom().toVector().toLocation(endWorld)); e.setCancelled(true); new SafeSpotTeleport.Builder(plugin) .entity(e.getPlayer()) .location(to) .build(); } }
@EventHandler public void onPlayerPortal(PlayerPortalEvent event) { Block block1 = event.getFrom().getBlock(); Block block2 = block1.getRelative(BlockFace.UP); Block block3 = block2.getRelative(BlockFace.UP); Block block4 = block1.getRelative(BlockFace.DOWN); if (isPortalInNearBy(block1) || isPortalInNearBy(block2) || isPortalInNearBy(block3) || isPortalInNearBy(block4)) { event.setCancelled(true); } }
if (e.getFrom() == null) { return false; World fromWorld = e.getFrom().getWorld(); if (!e.getCause().equals(TeleportCause.NETHER_PORTAL) || !plugin.getIWM().inWorld(e.getFrom()) || !plugin.getIWM().isNetherGenerate(fromWorld)) { Location to = plugin.getIslands().getIslandAt(e.getFrom()).map(i -> i.getSpawnPoint(Environment.NORMAL)).orElse(e.getFrom().toVector().toLocation(overWorld)); e.setCancelled(true); Location to = plugin.getIslands().getIslandAt(e.getFrom()).map(i -> i.getSpawnPoint(Environment.NETHER)).orElse(e.getFrom().toVector().toLocation(nether)); e.setCancelled(true);
/** * When returning from the standard nether, teleport to the player's island * @param e */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onNetherPortalStandardNether(PlayerPortalEvent e) { World fromWorld = e.getFrom().getWorld(); if (e.getCause().equals(TeleportCause.NETHER_PORTAL) && plugin.getIWM().inWorld(Util.getWorld(fromWorld)) && !plugin.getIWM().isNetherIslands(fromWorld) && fromWorld.getEnvironment().equals(Environment.NETHER) && plugin.getPlayers().isKnown(e.getPlayer().getUniqueId())) { e.setCancelled(true); plugin.getIslands().homeTeleport(Util.getWorld(fromWorld), e.getPlayer()); } }
if (event.isCancelled() || (event.getFrom() == null)) { return; return; MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName()); MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName()); if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {