Player p = event.getPlayer(); // Grab Player
Location loc = p.getLocation(); // Grab Location
/**
* Check the Player has actually moved a block to prevent unneeded calculations... This is to prevent huge performance drops on high player count servers.
*/
PortalPlayerSession ps = this.plugin.getPortalSession(event.getPlayer());
ps.setStaleLocation(loc, MoveType.PLAYER_MOVE);
// If the location is stale, ie: the player isn't actually moving xyz coords, they're looking around
if (ps.isStaleLocation()) {
return;
}
MVPortal portal = ps.getStandingInPortal();
// If the portal is not null
// AND if we did not show debug info, do the stuff
// The debug is meant to toggle.
if (portal != null && ps.doTeleportPlayer(MoveType.PLAYER_MOVE) && !ps.showDebugInfo()) {
MVDestination d = portal.getDestination();
if (d == null) {
return;
}
p.setFallDistance(0);
if (d instanceof InvalidDestination) {
this.plugin.log(Level.FINE, "Invalid Destination!");
return;
}
MultiverseWorld world = this.plugin.getCore().getMVWorldManager().getMVWorld(d.getLocation(p).getWorld().getName());
if (world == null) {
return;
}
if (!portal.isFrameValid(loc)) {
//event.getPlayer().sendMessage("This portal's frame is made of an " + ChatColor.RED + "incorrect material." + ChatColor.RED + " You should exit it now.");
return;
}
if (portal.getHandlerScript() != null && !portal.getHandlerScript().isEmpty()) {
try {
if (helper.scriptPortal(event.getPlayer(), d, portal, ps)) {
// Portal handled by script
helper.performTeleport(event.getPlayer(), event.getTo(), ps, d);
}
return;
} catch (IllegalStateException ignore) {
// Portal not handled by script
}
}
if (!ps.allowTeleportViaCooldown(new Date())) {
p.sendMessage(ps.getFriendlyRemainingTimeMessage());
return;
}
// If they're using Access and they don't have permission and they're NOT excempt, return, they're not allowed to tp.
// No longer checking exemption status
if (MultiversePortals.EnforcePortalAccess && !this.plugin.getCore().getMVPerms().hasPermission(event.getPlayer(), portal.getPermission().getName(), true)) {