Package com.fernferret.allpay.multiverse.commons

Examples of com.fernferret.allpay.multiverse.commons.GenericBank


                if (portalDest.useSafeTeleporter()) {
                    SafeTTeleporter teleporter = this.plugin.getCore().getSafeTTeleporter();
                    event.setTo(teleporter.getSafeLocation(event.getPlayer(), portalDest));
                }
                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;
                boolean canAfford = false;
                boolean shouldPay = false;
                if (portal.getPrice() != 0D && !p.hasPermission(portal.getExempt())) {
                    shouldPay = true;
                    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."))) {
                        canAfford = true;
                    } else if (vaultEco != null) {
                        p.sendMessage("You need " + vaultEco.format(portal.getPrice()) + " to enter the " + portal.getName() + " portal.");
                        event.setCancelled(true);
                        return;
                    } else if (bank != null) {
                        event.setCancelled(true);
                        return;
                    }
                } else {
                    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) {
                            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());
                                }
                            }
                        }
                    }
                    this.plugin.log(Level.FINE, "Sending player to a location via our Sexy Travel Agent!");
View Full Code Here


                return;
            }

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

TOP

Related Classes of com.fernferret.allpay.multiverse.commons.GenericBank

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.