Examples of MVPortal


Examples of com.onarandombox.MultiversePortals.MVPortal

        this.plugin.log(Level.FINER, "Fill: ");
        this.plugin.log(Level.FINER, "Block Clicked: " + event.getBlockClicked() + ":" + event.getBlockClicked().getType());
        this.plugin.log(Level.FINER, "Translated Block: " + event.getPlayer().getWorld().getBlockAt(translatedLocation) + ":" + event.getPlayer().getWorld().getBlockAt(translatedLocation).getType());

        PortalPlayerSession ps = this.plugin.getPortalSession(event.getPlayer());
        MVPortal portal = portalManager.getPortal(event.getPlayer(), translatedLocation);
        if (portal != null) {
            if (ps.isDebugModeOn()) {
                ps.showDebugInfo(portal);
                event.setCancelled(true);
            } else {
                Material fillMaterial = Material.AIR;
                this.plugin.log(Level.FINER, "Fill Material: " + fillMaterial);
                this.filler.fillRegion(portal.getLocation().getRegion(), translatedLocation, fillMaterial, event.getPlayer());
            }
        }
    }
View Full Code Here

Examples of com.onarandombox.MultiversePortals.MVPortal

        this.plugin.log(Level.FINER, "Fill: ");
        this.plugin.log(Level.FINER, "Block Clicked: " + event.getBlockClicked() + ":" + event.getBlockClicked().getType());
        this.plugin.log(Level.FINER, "Translated Block: " + event.getPlayer().getWorld().getBlockAt(translatedLocation) + ":" + event.getPlayer().getWorld().getBlockAt(translatedLocation).getType());

        PortalPlayerSession ps = this.plugin.getPortalSession(event.getPlayer());
        MVPortal portal = portalManager.getPortal(event.getPlayer(), translatedLocation);
        if (portal != null) {
            if (ps.isDebugModeOn()) {
                ps.showDebugInfo(portal);
                event.setCancelled(true);
            } else {
                if (!portal.playerCanFillPortal(event.getPlayer())) {
                    event.setCancelled(true);
                    return;
                }
                Material fillMaterial = Material.WATER;
                if (event.getBucket().equals(Material.LAVA_BUCKET)) {
                    fillMaterial = Material.LAVA;
                }

                this.plugin.log(Level.FINER, "Fill Material: " + fillMaterial);
                this.filler.fillRegion(portal.getLocation().getRegion(), translatedLocation, fillMaterial, event.getPlayer());
            }
        }
    }
View Full Code Here

Examples of com.onarandombox.MultiversePortals.MVPortal

            PortalPlayerSession ps = this.plugin.getPortalSession(event.getPlayer());
            Location translatedLocation = this.getTranslatedLocation(event.getClickedBlock(), event.getBlockFace());
            if (!portalManager.isPortal(translatedLocation)) {
                return;
            }
            MVPortal portal = portalManager.getPortal(event.getPlayer(), translatedLocation);
            if (event.getItem() == null) {
                return;
            }
            if (!this.plugin.getCore().getMVPerms().hasPermission(event.getPlayer(), "multiverse.portal.create", true)) {
                return;
            }
            Material inHand = event.getItem().getType();

            // Cancel the event if there was a portal.

            if (portal != null) {

                // Make sure the portal's frame around this point is made out of
                // a valid material.
                if (!portal.isFrameValid(translatedLocation)) {
                    return;
                }

                this.plugin.log(Level.FINER, "Right Clicked: ");
                this.plugin.log(Level.FINER, "Block Clicked: " + event.getClickedBlock() + ":" + event.getClickedBlock().getType());
                this.plugin.log(Level.FINER, "Translated Block: " + event.getPlayer().getWorld().getBlockAt(translatedLocation) + ":" + event.getPlayer().getWorld().getBlockAt(translatedLocation).getType());
                this.plugin.log(Level.FINER, "In Hand: " + inHand);
                if (ps.isDebugModeOn()) {
                    ps.showDebugInfo(portal);
                    event.setCancelled(true);
                } else {
                    Material fillMaterial = Material.PORTAL;
                    if (translatedLocation.getWorld().getBlockAt(translatedLocation).getType() == Material.PORTAL) {
                        fillMaterial = Material.AIR;
                    }
                    this.plugin.log(Level.FINER, "Fill Material: " + fillMaterial);
                    event.setCancelled(this.filler.fillRegion(portal.getLocation().getRegion(), translatedLocation, fillMaterial, event.getPlayer()));
                }
            }
            return;
        }
View Full Code Here

Examples of com.onarandombox.MultiversePortals.MVPortal

        }
        this.plugin.log(Level.FINER, "onPlayerPortal called!");
        PortalManager pm = this.plugin.getPortalManager();
        Location playerPortalLoc = event.getPlayer().getLocation();
        // Determine if we're in a portal
        MVPortal portal = pm.getPortal(event.getPlayer(), playerPortalLoc);
        Player p = event.getPlayer();
        // Even if the location was null, we still have to see if
        // someone wasn't exactly on (because they can do this).
        if (portal == null) {
            // Check around the player to make sure
            playerPortalLoc = this.plugin.getCore().getSafeTTeleporter().findPortalBlockNextTo(event.getFrom());
            if (playerPortalLoc != null) {
                this.plugin.log(Level.FINER, "Player was outside of portal, The location has been successfully translated.");
                portal = pm.getPortal(event.getPlayer(), playerPortalLoc);
            }
        }
        if (portal != null) {
            this.plugin.log(Level.FINER, "There was a portal found!");
            MVDestination portalDest = portal.getDestination();
            if (portalDest != null && !(portalDest instanceof InvalidDestination)) {
                if (!portal.isFrameValid(playerPortalLoc)) {
                    event.getPlayer().sendMessage("This portal's frame is made of an " + ChatColor.RED + "incorrect material." + ChatColor.RED + " You should exit it now.");
                    event.setCancelled(true);
                    return;
                }
                PortalPlayerSession ps = this.plugin.getPortalSession(event.getPlayer());
                if (portal.getHandlerScript() != null && !portal.getHandlerScript().isEmpty()) {
                    try {
                        if (helper.scriptPortal(event.getPlayer(), portalDest, portal, ps)) {
                            // Portal handled by script
                        } else {
                            event.setCancelled(true);
                        }
                        return;
                    } catch (IllegalStateException ignore) {
                        // Portal not handled by script
                    }
                }
                if (!ps.allowTeleportViaCooldown(new Date())) {
                    event.getPlayer().sendMessage(ps.getFriendlyRemainingTimeMessage());
                    event.setCancelled(true);
                    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)) {
                    this.helper.stateFailure(p.getDisplayName(), portal.getName());
                    event.setCancelled(true);
                    return;
                }
                TravelAgent agent = new MVTravelAgent(this.plugin.getCore(), portalDest, event.getPlayer());
                event.setTo(portalDest.getLocation(event.getPlayer()));
                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

Examples of com.onarandombox.MultiversePortals.MVPortal

            if (this.plugin.getPortalSession(event.getPlayer()).isDebugModeOn()) {
                event.setCancelled(true);
                return;
            }
            // This is a valid portal, and they can use it so far...
            MVPortal p = this.plugin.getPortalManager().getPortal(event.getPlayer(), l);
            if (p == null) {
                // The player can't see this portal, and can't use it.
                this.plugin.log(Level.FINER, String.format("'%s' was DENIED access to this portal event.", event.getPlayer().getName()));
                event.setCanUseThisPortal(false);
            } else if (p.getDestination() == null || !p.getDestination().isValid()) {
                if (this.plugin.getMainConfig().getBoolean("portalsdefaulttonether", false)) {
                    this.plugin.log(Level.FINE, "Allowing MVPortal to act as nether portal.");
                    return;
                }
                // They can see it, is it val
View Full Code Here

Examples of com.onarandombox.MultiversePortals.MVPortal

        // 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)) {
                this.helper.stateFailure(p.getDisplayName(), portal.getName());
                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) {
                    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);
View Full Code Here

Examples of com.onarandombox.MultiversePortals.MVPortal

        return false;
    }

    public boolean addPortal(MultiverseWorld world, String name, String owner, PortalLocation location) {
        if (!this.portals.containsKey(name)) {
            addUniquePortal(world, name, new MVPortal(this.plugin, name, owner, location));
            return true;
        }
        return false;
    }
View Full Code Here

Examples of com.onarandombox.MultiversePortals.MVPortal

            FileConfiguration config = this.plugin.getPortalsConfig();
            config.set("portals." + portalName, null);
            this.plugin.savePortalsConfig();
        }

        MVPortal removed = this.portals.remove(portalName);
        MultiverseWorld world = this.plugin.getCore().getMVWorldManager().getMVWorld(removed.getWorld());
        removeFromWorldChunkPortals(world, removed);

        removed.removePermission();
        Permission portalAccess = this.plugin.getServer().getPluginManager().getPermission("multiverse.portal.access.*");
        Permission exemptAccess = this.plugin.getServer().getPluginManager().getPermission("multiverse.portal.exempt.*");
        Permission portalFill = this.plugin.getServer().getPluginManager().getPermission("multiverse.portal.fill.*");
        if (exemptAccess != null) {
            exemptAccess.getChildren().remove(removed.getExempt().getName());
            this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(exemptAccess);
        }
        if (portalAccess != null) {
            portalAccess.getChildren().remove(removed.getPermission().getName());
            this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(portalAccess);
        }
        if (portalFill != null) {
            portalFill.getChildren().remove(removed.getFillPermission().getName());
            this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(portalFill);
        }
        if (MultiversePortals.ClearOnRemove) {
            // Replace portal blocks in the portal with air. This keeps us from
            // leaving behind portal blocks (which would take an unsuspecting
            // player to the nether instead of their expected destination).

            MultiverseRegion region = removed.getLocation().getRegion();
            replaceInRegion(removed.getWorld(), region, Material.PORTAL, Material.AIR);
        }
        this.plugin.getServer().getPluginManager().removePermission(removed.getPermission());
        this.plugin.getServer().getPluginManager().removePermission(removed.getExempt());
        this.plugin.getServer().getPluginManager().removePermission(removed.getFillPermission());
        return removed;
    }
View Full Code Here

Examples of com.onarandombox.MultiversePortals.MVPortal

            }

            // Teleport the Player
            teleportVehicle(p, v, event.getTo());
        } else {
            MVPortal portal = this.plugin.getPortalManager().getPortal(event.getFrom());
            if ((portal != null) && (portal.getTeleportNonPlayers())) {
                MVDestination dest = portal.getDestination();
                if (dest == null || dest instanceof InvalidDestination)
                    return;

                // Check the portal's frame.
                if (!portal.isFrameValid(event.getVehicle().getLocation())) {
                    return;
                }

                Vector vehicleVec = event.getVehicle().getVelocity();
                Location target = dest.getLocation(event.getVehicle());
View Full Code Here

Examples of com.onarandombox.MultiversePortals.MVPortal

        }
    }

    private boolean teleportVehicle(Player p, Vehicle v, Location to) {
        PortalPlayerSession ps = this.plugin.getPortalSession(p);
        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.VEHICLE_MOVE) && !ps.showDebugInfo()) {
            if (!ps.allowTeleportViaCooldown(new Date())) {
                p.sendMessage(ps.getFriendlyRemainingTimeMessage());
                return false;
            }
            // TODO: Money
            MVDestination d = portal.getDestination();
            if (d == null || d instanceof InvalidDestination) {
                return false;
            }

            // Check the portal's frame.
            if (!portal.isFrameValid(v.getLocation())) {
                return false;
            }

            Location l = d.getLocation(p);
            Vector vehicleVec = v.getVelocity();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.