Package com.onarandombox.MultiverseCore.api

Examples of com.onarandombox.MultiverseCore.api.MVDestination


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


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

            // 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());
                if (dest instanceof PortalDestination) {
                    PortalDestination pd = (PortalDestination) dest;
                    // Translate the direction of travel.
                    vehicleVec = this.locationManipulation.getTranslatedVector(vehicleVec, pd.getOrientationString());
                }
View Full Code Here

            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();

            // 0 Yaw in dest = 0,X
            if (d instanceof PortalDestination) {
                PortalDestination pd = (PortalDestination) d;
View Full Code Here

                destinationName = "i:invalid";
            }

        }
        DestinationFactory df = this.plugin.getDestFactory();
        MVDestination d = df.getDestination(destinationName);


        MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true);
        this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
        if (teleportEvent.isCancelled()) {
            this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!");
            return;
        }

        if (d != null && d instanceof InvalidDestination) {
            this.messaging.sendMessage(sender, String.format("Multiverse does not know how to take you to %s%s",
                    ChatColor.RED, destinationName), false);
            return;
        }

        if (!this.checkSendPermissions(teleporter, teleportee, d)) {
            return;
        }

        if (plugin.getMVConfig().getEnforceAccess() && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
            if (teleportee.equals(teleporter)) {
                teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
            } else {
                teleporter.sendMessage("Doesn't look like you're allowed to send " + ChatColor.GOLD
                        + teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
            }
            return;
        } else if (teleporter != null && !this.plugin.getMVPerms().canTravelFromLocation(teleporter, d.getLocation(teleportee))) {
            if (teleportee.equals(teleporter)) {
                this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like you can get to %s%s %sfrom where you are...",
                        ChatColor.GREEN, d.toString(), ChatColor.WHITE), false);
            } else {
                this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like %s%s %scan get to %sTHERE from where they are...",
                        ChatColor.GREEN, ((Player) teleporter).getWorld().getName(), ChatColor.WHITE, ChatColor.RED), false);
            }
            return;
        }

        // Special check to verify if players are tryint to teleport to the same
        // WORLDDestination as the world they're in, that they ALSO have multiverse.core.spawn.self

        if (d instanceof WorldDestination) {
            World w = d.getLocation(teleportee).getWorld();
            if (teleportee.getWorld().equals(w)) {
                if (teleporter.equals(teleportee)) {
                    if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.self", true)) {
                        this.messaging.sendMessages(teleporter, new String[]{
                                String.format("Sorry you don't have permission to go to the world spawn!"),
                                String.format("%s  (multiverse.core.spawn.self)",
                                        ChatColor.RED) }, false);
                        return;
                    }
                } else {
                    if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.other", true)) {
                        this.messaging.sendMessages(teleporter, new String[]{
                                String.format("Sorry you don't have permission to send %s to the world spawn!",
                                        teleportee.getDisplayName()),
                                String.format("%s  (multiverse.core.spawn.other)",
                                        ChatColor.RED) }, false);
                        return;
                    }
                }
            }
        }

        if (d.getLocation(teleportee) == null) {
            this.messaging.sendMessage(teleporter, "Sorry Boss, I tried everything, but just couldn't teleport ya there!", false);
            return;
        }
        Teleporter teleportObject = (d instanceof CustomTeleporterDestination) ?
                ((CustomTeleporterDestination)d).getTeleporter() : this.playerTeleporter;
        TeleportResult result = teleportObject.teleport(teleporter, teleportee, d);
        if (result == TeleportResult.FAIL_UNSAFE) {
            this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName()
                    + " to " + plugin.getLocationManipulation().strCoordsRaw(d.getLocation(teleportee)));
            this.plugin.log(Level.FINE, "Queueing Command");
            Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class };
            List<Object> items = new ArrayList<Object>();
            items.add(teleporter);
            items.add(teleportee);
            items.add(d.getLocation(teleportee));
            String player = "you";
            if (!teleportee.equals(teleporter)) {
                player = teleportee.getName();
            }
            String message = String.format("%sMultiverse %sdid not teleport %s%s %sto %s%s %sbecause it was unsafe.",
                    ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, player, ChatColor.WHITE, ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE);
            this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items,
                    paramTypes, message, "Would you like to try anyway?", "", "", UNSAFE_TELEPORT_EXPIRE_DELAY);
        }
        // else: Player was teleported successfully (or the tp event was fired I should say)
    }
View Full Code Here

        if (p == null) {
            sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0));
            sender.sendMessage("Are they online?");
            return;
        }
        MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1));
        if (dest instanceof InvalidDestination) {
            sender.sendMessage(String.format("You asked if '%s' could go to %s%s%s,",
                    args.get(0), ChatColor.GREEN, args.get(0), ChatColor.WHITE));
            sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?");
            return;
View Full Code Here

        }

        if (this.destList.containsKey(idenChar)) {
            Class<? extends MVDestination> myClass = this.destList.get(idenChar);
            try {
                MVDestination mydest = myClass.newInstance();
                if (!mydest.isThisType(this.plugin, destination)) {
                    return new InvalidDestination();
                }
                mydest.setDestination(this.plugin, destination);
                return mydest;
            } catch (InstantiationException e) {
            } catch (IllegalAccessException e) {
            }
        }
View Full Code Here

TOP

Related Classes of com.onarandombox.MultiverseCore.api.MVDestination

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.