Package com.sk89q.minecraft.util.commands

Examples of com.sk89q.minecraft.util.commands.CommandException


            try {
                player.setFlySpeed(flightSpeed);
            } catch (IllegalArgumentException e) { // We gave an invalid value, tell the user nicely
                if (flightSpeed < DEFAULT_WALK_SPEED) {
                    throw new CommandException("Speed multiplier too low: " + flightMultiplier);
                } else if (flightSpeed > DEFAULT_WALK_SPEED) {
                    throw new CommandException("Speed multiplier too high: " + flightMultiplier);
                }
            }

            player.sendMessage(ChatColor.YELLOW + "Your flight speed has been set to " + flightMultiplier + "x");
            if (sender != player) {
View Full Code Here


            try {
                player.setWalkSpeed(walkSpeed);
            } catch (IllegalArgumentException e) { // We gave an invalid value, tell the user nicely
                if (walkSpeed < DEFAULT_WALK_SPEED) {
                    throw new CommandException("Speed multiplier too low: " + walkMultiplier);
                } else if (walkSpeed > DEFAULT_WALK_SPEED) {
                    throw new CommandException("Speed multiplier too high: " + walkMultiplier);
                }
            }

            player.sendMessage(ChatColor.YELLOW + "Your walking speed has been set to " + walkMultiplier + "x");
            if (sender != player) {
View Full Code Here

    }

    public void remove(String name, World world, CommandSender sender) throws CommandException {
        NamedLocation loc = getManager().get(world, name);
        if (loc == null) {
            throw new CommandException("No " + this.name.toLowerCase() + " by that name could be found in " + world.getName() + ".");
        }
        if (!(sender instanceof Player) || !((Player) sender).getUniqueId().equals(loc.getCreatorID())) {
            CommandBook.inst().checkPermission(sender, "commandbook." + this.name.toLowerCase() + ".remove.other");
        }
View Full Code Here

            if (args.hasFlag('w')) {
                world = InputUtil.LocationParser.matchWorld(sender, args.getFlag('w'));
            } else {
                world = PlayerUtil.checkPlayer(sender).getWorld();
            }
            if (world == null) throw new CommandException("Error finding world to use!");
        }
        getListResult().display(sender, getManager().getLocations(world), args.getInteger(0, 1));
    }
View Full Code Here

                player.sendMessage(ChatColor.YELLOW + "You've been unfrozen by "
                        + ChatUtil.toColoredName(sender, ChatColor.YELLOW));
                sender.sendMessage(ChatColor.YELLOW + "You've unfrozen "
                        + ChatUtil.toColoredName(player, ChatColor.YELLOW));
            } else {
                throw new CommandException(ChatUtil.toName(player) + " was not frozen");
            }
        }
View Full Code Here

    public void display(CommandSender sender, Collection<? extends T> results, int page) throws CommandException {
        display(sender, new ArrayList<T>(results), page);
    }
   
    public void display(CommandSender sender, List<? extends T> results, int page) throws CommandException {
        if (results.size() == 0) throw new CommandException("No results match!");
        --page;

        int maxPages = results.size() / PER_PAGE;

        // If the content divides perfectly, eg (18 entries, and 9 per page)
View Full Code Here

    public void checkLastTeleportRequest(Player target) throws CommandException {
        long now = System.currentTimeMillis();
        Long time = teleportRequests.remove(target.getName());
        if (time != null && (now - time) < TP_REQUEST_WAIT_TIME) {
            throw new CommandException(component.getConfig().callMessageTooSoon);
        }
        teleportRequests.put(target.getName(), now);
    }
View Full Code Here

                loc = new Location(world, x, y, z);
                if (loc.getX() == loc.getBlockX()) loc.add(0.5, 0, 0);
                if (loc.getZ() == loc.getBlockZ()) loc.add(0, 0, 0.5);

            } else { // this can't actually happen unless someone constructs their own CommandContext
                throw new CommandException("Invalid number of args.");
            }

            boolean hasTeleOtherCurrent = CommandBook.inst().hasPermission(sender, "commandbook.teleport.other");
            boolean hasTeleOtherTo = CommandBook.inst().hasPermission(sender, loc.getWorld(), "commandbook.teleport.other");
View Full Code Here

                    }).iterate(Lists.newArrayList(target));
                    return;
                } else if (!CommandBook.inst().hasPermission(sender, "commandbook.teleport.other")) {
                    // There was a single player match, but, the target was not bringable, and the player
                    // does not have permission to teleport players in his/her current world.
                    throw new CommandException(config.bringMessageNoPerm);
                }
            }

            Location loc = player.getLocation();
View Full Code Here

     */
    public void checkAllowedItem(CommandSender sender, int id, int damage)
            throws CommandException {

        if (Material.getMaterial(id) == null || id == 0) {
            throw new CommandException("Non-existent item specified.");
        }

        // Check if the user has an override
        if (CommandBook.inst().hasPermission(sender, "commandbook.override.any-item")) {
            return;
        }

        boolean hasPermissions = CommandBook.inst().hasPermission(sender, "commandbook.items." + id)
                || CommandBook.inst().hasPermission(sender, "commandbook.items." + id + "." + damage);

        // Also check the permissions system
        if (hasPermissions) {
            return;
        }

        if (config.useItemPermissionsOnly) {
            throw new CommandException("That item is not allowed.");
        }

        if (config.allowedItems.size() > 0) {
            if (!config.allowedItems.contains(id)) {
                throw new CommandException("That item is not allowed.");
            }
        }

        if (config.disallowedItems.contains((id))) {
            throw new CommandException("That item is disallowed.");
        }
    }
View Full Code Here

TOP

Related Classes of com.sk89q.minecraft.util.commands.CommandException

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.