Package net.aufdemrand.denizencore.exceptions

Examples of net.aufdemrand.denizencore.exceptions.InvalidArgumentsException


        scriptEntry.defaultObject("entities",
                ((BukkitScriptEntryData)scriptEntry.entryData).hasNPC() ? Arrays.asList(((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getDenizenEntity()) : null,
                ((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer() ? Arrays.asList(((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().getDenizenEntity()) : null);

        if (!scriptEntry.hasObject("location") || !scriptEntry.hasObject("entities"))
            throw new InvalidArgumentsException("Must specify a location and entity!");
    }
View Full Code Here


        if (entities.isEmpty() && ((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer())
            entities.add(((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().identify());

        if (locations.isEmpty())
            throw new InvalidArgumentsException("Must specify at least one valid location!");

        if (!added_entities && (((BukkitScriptEntryData)scriptEntry.entryData).getPlayer() == null || !((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().isOnline()))
            throw new InvalidArgumentsException("Must have a valid, online player attached!");

        if (entities.isEmpty() && added_entities)
            throw new InvalidArgumentsException("Must specify valid targets!");

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

        scriptEntry.addObject("entities", entities);
        scriptEntry.addObject("locations", locations);
    }
View Full Code Here

            if (((BukkitScriptEntryData)scriptEntry.entryData).getPlayer() != null)
                entities.add(((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().getDenizenEntity());
            else if (((BukkitScriptEntryData)scriptEntry.entryData).getNPC() != null)
                entities.add(((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getDenizenEntity());
            else
                throw new InvalidArgumentsException("No valid target entities found.");
            scriptEntry.addObject("entities", entities);
        }

    }
View Full Code Here

            }

        }

        if (!((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer() || !((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().isValid())
            throw new InvalidArgumentsException("Must have player context!");

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

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

    }
View Full Code Here

            else arg.reportUnhandled();
        }

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

        // Use player or NPC as default entity
        scriptEntry.defaultObject("entities", (((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer() ? Arrays.asList(((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().getDenizenEntity()) : null),
                                              (((BukkitScriptEntryData)scriptEntry.entryData).hasNPC() ? Arrays.asList(((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getDenizenEntity()) : null));
View Full Code Here

        scriptEntry.defaultObject("height", new Element(3));

        // Check to make sure required arguments have been filled

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

        if (!scriptEntry.hasObject("originEntity") && !scriptEntry.hasObject("originLocation"))
            throw new InvalidArgumentsException("Must specify an origin location!");
    }
View Full Code Here

            }

        }

        if (!scriptEntry.hasObject("group") && (!((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer() || !((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().isValid()))
            throw new InvalidArgumentsException("Must have player context or a valid group!");

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

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

    }
View Full Code Here

        for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {

            if (arg.matches("ASPLAYER", "AS_PLAYER", "PLAYER")
                    && !scriptEntry.hasObject("type")) {
                if (!((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer())
                    throw new InvalidArgumentsException("Must have a Player link when using AS_PLAYER.");
                scriptEntry.addObject("type", new Element("AS_PLAYER"));
            }

            else if (arg.matches("ASOPPLAYER", "ASOP", "AS_OP", "AS_OP_PLAYER", "OP")
                    && !scriptEntry.hasObject("type")) {
                if (!((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer())
                    throw new InvalidArgumentsException("Must have a Player link when using AS_OP.");
                scriptEntry.addObject("type", new Element("AS_OP"));
            }

            else if (arg.matches("ASNPC", "AS_NPC", "NPC")
                    && !scriptEntry.hasObject("type")) {
                if (!((BukkitScriptEntryData)scriptEntry.entryData).hasNPC())
                    throw new InvalidArgumentsException("Must have a NPC link when using AS_NPC.");
                scriptEntry.addObject("type", new Element("AS_NPC"));
            }

            else if (arg.matches("ASSERVER", "AS_SERVER", "SERVER")
                    && !scriptEntry.hasObject("type"))
                scriptEntry.addObject("type", new Element("AS_SERVER"));

            else if (!scriptEntry.hasObject("silent")
                    && arg.matches("silent"))
                scriptEntry.addObject("silent", new Element("true"));

            else if (!scriptEntry.hasObject("command"))
                scriptEntry.addObject("command", new Element(arg.raw_value));

            else
                arg.reportUnhandled();
        }

        if (!scriptEntry.hasObject("type"))
            throw new InvalidArgumentsException("Missing execution type!");

        if (!scriptEntry.hasObject("command"))
            throw new InvalidArgumentsException("Missing command text!");

        scriptEntry.defaultObject("silent", new Element("false"));

    }
View Full Code Here

    public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

        // Users tend to forget quotes sometimes on commands like this, so
        // let's check if there are more argument than usual.
        if (scriptEntry.getArguments().size() > 3)
            throw new InvalidArgumentsException("Too many arguments! Did you forget a 'quote'?");

        for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {

            if (!scriptEntry.hasObject("type")
                    && arg.matches("to_ops"))
                scriptEntry.addObject("type", AnnounceType.TO_OPS);

            else if (!scriptEntry.hasObject("type")
                    && arg.matches("to_console"))
                scriptEntry.addObject("type", AnnounceType.TO_CONSOLE);

            else if (!scriptEntry.hasObject("type")
                    && arg.matchesPrefix("to_flagged")) {
                scriptEntry.addObject("type", AnnounceType.TO_FLAGGED);
                scriptEntry.addObject("flag", arg.asElement());
            }

            else if (!scriptEntry.hasObject("format")
                    && arg.matchesPrefix("format")) {
                FormatScriptContainer format = null;
                String formatStr = arg.getValue();
                format = ScriptRegistry.getScriptContainer(formatStr);
                if (format == null) dB.echoError("Could not find format script matching '" + formatStr + '\'');
                scriptEntry.addObject("format", format);
            }

            else if (!scriptEntry.hasObject("text"))
                scriptEntry.addObject("text", new Element(arg.raw_value));

        }

        // If text is missing, alert the console.
        if (!scriptEntry.hasObject("text"))
            throw new InvalidArgumentsException("Missing text argument!");

        scriptEntry.defaultObject("type", AnnounceType.ALL);

    }
View Full Code Here

            else arg.reportUnhandled();
        }

        if (!scriptEntry.hasObject("id"))
            throw new InvalidArgumentsException("Must specify an id");
        if (!scriptEntry.hasObject("object") && !scriptEntry.hasObject("remove"))
            throw new InvalidArgumentsException("Must specify a fetchable-object to note.");
        if (!scriptEntry.hasObject("remove"))
            scriptEntry.addObject("remove", Element.FALSE);

    }
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.