Package com.onarandombox.MultiversePortals.event

Examples of com.onarandombox.MultiversePortals.event.MVPortalEvent


                    canAfford = true;
                }
                if (canAfford) {
                    event.setPortalTravelAgent(agent);
                    event.useTravelAgent(true);
                    MVPortalEvent portalEvent = new MVPortalEvent(portalDest, event.getPlayer(), agent, portal);
                    this.plugin.getServer().getPluginManager().callEvent(portalEvent);
                    if (portalEvent.isCancelled()) {
                        event.setCancelled(true);
                        this.plugin.log(Level.FINE, "Someone cancelled the MVPlayerPortal Event!");
                        return;
                    } else {
                        if (shouldPay) {
View Full Code Here


            buscript.getGlobalScope().put("portalSession", buscript.getGlobalScope(), null);
            Object allowObject = buscript.getGlobalScope().get("allowPortal", buscript.getGlobalScope());
            buscript.getGlobalScope().put("allowPortal", buscript.getGlobalScope(), null);
            if (allowObject instanceof Boolean) {
                if (((Boolean) allowObject)) {
                    MVPortalEvent portalEvent = new MVPortalEvent(d, player, agent, portal);
                    this.plugin.getServer().getPluginManager().callEvent(portalEvent);
                    if (!portalEvent.isCancelled()) {
                        return true;
                    }
                    plugin.log(Level.FINE, "A plugin cancelled the portal after script handling.");
                    return false;
                } else {
View Full Code Here

                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);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.onarandombox.MultiversePortals.event.MVPortalEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.