if (portal.getPrice() != 0D && !p.hasPermission(portal.getExempt())) {
final Economy vaultEco = (portal.getCurrency() <= 0 && plugin.getCore().getVaultHandler().getEconomy() != null) ? plugin.getCore().getVaultHandler().getEconomy() : null;
final GenericBank bank = vaultEco == null ? plugin.getCore().getBank() : null;
if (portal.getPrice() < 0D || (vaultEco != null && vaultEco.has(p.getName(), portal.getPrice())) || (bank != null && bank.hasEnough(event.getPlayer(), portal.getPrice(), portal.getCurrency(), "You need " + bank.getFormattedAmount(event.getPlayer(), portal.getPrice(), portal.getCurrency()) + " to enter the " + portal.getName() + " portal."))) {
// call event for other plugins
TravelAgent agent = new MVTravelAgent(this.plugin.getCore(), d, event.getPlayer());
MVPortalEvent portalEvent = new MVPortalEvent(d, event.getPlayer(), agent, portal);
this.plugin.getServer().getPluginManager().callEvent(portalEvent);
if (!portalEvent.isCancelled()) {
if (vaultEco != null) {
if (portal.getPrice() < 0D) {
p.sendMessage(String.format("You have earned %s for using %s.", vaultEco.format(-portal.getPrice()), portal.getName()));
vaultEco.depositPlayer(event.getPlayer().getName(), -portal.getPrice());
} else {
p.sendMessage(String.format("You have been charged %s for using %s.", vaultEco.format(portal.getPrice()), portal.getName()));
vaultEco.withdrawPlayer(event.getPlayer().getName(), portal.getPrice());
}
} else {
if (portal.getPrice() < 0D) {
bank.give(event.getPlayer(), -portal.getPrice(), portal.getCurrency());
} else {
bank.take(event.getPlayer(), portal.getPrice(), portal.getCurrency());
}
}
helper.performTeleport(event.getPlayer(), event.getTo(), ps, d);
}
} else if (vaultEco != null) {
p.sendMessage("You need " + vaultEco.format(portal.getPrice()) + " to enter the " + portal.getName() + " portal.");
}
} else {
// call event for other plugins
TravelAgent agent = new MVTravelAgent(this.plugin.getCore(), d, event.getPlayer());
MVPortalEvent portalEvent = new MVPortalEvent(d, event.getPlayer(), agent, portal);
this.plugin.getServer().getPluginManager().callEvent(portalEvent);
if (!portalEvent.isCancelled()) {
helper.performTeleport(event.getPlayer(), event.getTo(), ps, d);
}