Package net.aufdemrand.denizencore.exceptions

Examples of net.aufdemrand.denizencore.exceptions.InvalidArgumentsException


        }

        // Check to make sure required arguments have been filled

        if ((!scriptEntry.hasObject("value")))
            throw new InvalidArgumentsException("Must specify a value!");

        // If the world has not been specified, try to use the NPC's or player's
        // world, or default to "world" if necessary
        scriptEntry.defaultObject("world",
                ((BukkitScriptEntryData)scriptEntry.entryData).hasNPC() ? new dWorld(((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getWorld()) : null,
View Full Code Here


                    break;
                }

        // Check if the object has been filled. If not, throw new Invalid Arguments Exception.
        // TODO: Should this be here? Most checks are done separately.
        if (!hasObject(key)) throw new InvalidArgumentsException("Missing '" + key + "' argument!");
        else
            return this;
    }
View Full Code Here

        boolean keepGoing = true;

        try {

            // Throw exception if arguments are required for this command, but not supplied.
            if (command.getOptions().REQUIRED_ARGS > scriptEntry.getArguments().size()) throw new InvalidArgumentsException("");

            if (scriptEntry.has_tags)
                scriptEntry.setArguments(TagManager.fillArguments(scriptEntry.getArguments(), scriptEntry, true)); // Replace tags

            /*  If using NPC:# or PLAYER:Name arguments, these need to be changed out immediately because...
View Full Code Here

        }

        // Check to make sure required arguments have been filled

        if (!scriptEntry.hasObject("entities"))
            throw new InvalidArgumentsException("Must specify entity/entities!");

        // If the world has not been specified, try to use the NPC's or player's
        // world, or default to the specified world in the server properties if necessary

        scriptEntry.defaultObject("world",
View Full Code Here

            }

        }

        if (!scriptEntry.hasObject("action"))
            throw new InvalidArgumentsException("Must specify a valid action!");

        if (!scriptEntry.hasObject("statistic"))
            throw new InvalidArgumentsException("Must specify a valid Statistic!");

        if (!scriptEntry.hasObject("amount"))
            scriptEntry.addObject("amount", new Element(1));

        Statistic.Type type = Statistic.valueOf(scriptEntry.getElement("statistic").asString().toUpperCase()).getType();
        if (type != Statistic.Type.UNTYPED) {
            if ((type == Statistic.Type.BLOCK || type == Statistic.Type.ITEM) && !scriptEntry.hasObject("material"))
                throw new InvalidArgumentsException("Must specify a valid " + type.name() + " MATERIAL!");
            else if (type == Statistic.Type.ENTITY && !scriptEntry.hasObject("entity"))
                throw new InvalidArgumentsException("Must specify a valid ENTITY!");
        }

        if (!scriptEntry.hasObject("players") && ((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer() && !specified_players)
            scriptEntry.addObject("players", new dList(((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().identify()));

        if (!scriptEntry.hasObject("players"))
            throw new InvalidArgumentsException("Must specify valid players!");

    }
View Full Code Here

        if (!scriptEntry.hasObject("talkers") && ((BukkitScriptEntryData)scriptEntry.entryData).hasNPC() && !specified_talker)
            scriptEntry.defaultObject("talkers", new dList(((BukkitScriptEntryData)scriptEntry.entryData).getNPC().identify()));

        // Verify essential fields are set
        if (!scriptEntry.hasObject("targets"))
            throw new InvalidArgumentsException("Must specify valid targets!");

        if (!scriptEntry.hasObject("talkers"))
            throw new InvalidArgumentsException("Must specify valid talkers!");

        if (!scriptEntry.hasObject("message"))
            throw new InvalidArgumentsException("Must specify a message!");

        scriptEntry.defaultObject("range", new Element(Settings.chatBystandersRange()));

    }
View Full Code Here

            else arg.reportUnhandled();
        }

        // Check required args
        if (!scriptEntry.hasObject("item"))
            throw new InvalidArgumentsException("Must specify an item to display.");

        if (!scriptEntry.hasObject("location"))
            throw new InvalidArgumentsException("Must specify a location!");

        if (!scriptEntry.hasObject("duration"))
            scriptEntry.addObject("duration", Duration.valueOf("1m"));
    }
View Full Code Here

        scriptEntry.defaultObject("id", new Element(UUID.randomUUID().toString()));

        // Check for type (if using NEW) -- it's required
        if (!scriptEntry.hasObject("type")
                && scriptEntry.getElement("action").asString().equalsIgnoreCase("new"))
            throw new InvalidArgumentsException("Must specify a listener type!");

        // Player listeners require a player!
        if (((BukkitScriptEntryData)scriptEntry.entryData).getPlayer() == null)
            throw new InvalidArgumentsException("Must specify a player!");

        // Add arguments
        scriptEntry.addObject("args", arguments);

    }
View Full Code Here

            if (((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer())
                scriptEntry.addObject("targetplayer", ((BukkitScriptEntryData)scriptEntry.entryData).getPlayer());
            else if (((BukkitScriptEntryData)scriptEntry.entryData).hasNPC())
                scriptEntry.addObject("targetnpc", ((BukkitScriptEntryData)scriptEntry.entryData).getNPC());
            else
                throw new InvalidArgumentsException("Must specify a player!");
        }

        if (!scriptEntry.hasObject("amount"))
            scriptEntry.addObject("amount", new Element(9999)); // TODO: 9999?
    }
View Full Code Here

            else arg.reportUnhandled();
        }

        // Check to make sure required arguments have been filled
        if (!scriptEntry.hasObject("actions"))
            throw new InvalidArgumentsException("Must specify an Inventory action!");

        scriptEntry.defaultObject("slot", new Element(1)).defaultObject("destination",
                        ((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer() ? ((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().getDenizenEntity().getInventory() : null);
    }
View Full Code Here

TOP

Related Classes of net.aufdemrand.denizencore.exceptions.InvalidArgumentsException

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.