Package net.aufdemrand.denizen.objects

Examples of net.aufdemrand.denizen.objects.Element


            else if (arg.matchesPrefix("d", "def", "define", "c", "context"))
                scriptEntry.addObject("definitions", arg.asType(dList.class));

            else if (arg.matches("instant", "instantly"))
                scriptEntry.addObject("instant", new Element(true));

            else if (arg.matchesPrefix("delay")
                    && arg.matchesArgumentType(Duration.class))
                scriptEntry.addObject("delay", arg.asType(Duration.class));

            else if (arg.matches("local", "locally"))
                scriptEntry.addObject("local", new Element(true));

            else if (!scriptEntry.hasObject("script")
                    && arg.matchesArgumentType(dScript.class)
                    && !arg.matchesPrefix("p", "path"))
                scriptEntry.addObject("script", arg.asType(dScript.class));
View Full Code Here


            else
                arg.reportUnhandled();
        }

        // Use default values if necessary
        scriptEntry.defaultObject("power", new Element(1.0));
        scriptEntry.defaultObject("location",
                ((BukkitScriptEntryData)scriptEntry.entryData).hasNPC() ? ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getLocation() : null,
                ((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer() ? ((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().getLocation() : null);

        if (!scriptEntry.hasObject("location")) {
View Full Code Here

    @Override
    public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
        // Get objects

        final dLocation location = (dLocation) scriptEntry.getObject("location");
        Element power = (Element) scriptEntry.getObject("power");
        Boolean breakblocks = scriptEntry.hasObject("breakblocks");
        Boolean fire = scriptEntry.hasObject("fire");

        // Report to dB
        dB.report(scriptEntry, getName(),
                (aH.debugObj("location", location.toString()) +
                 aH.debugObj("power", power) +
                 aH.debugObj("breakblocks", breakblocks) +
                 aH.debugObj("fire", fire)));

        location.getWorld().createExplosion
                    (location.getX(), location.getY(), location.getZ(),
                     power.asFloat(), fire, breakblocks);
    }
View Full Code Here

    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

        dLocation copy_location = (dLocation) scriptEntry.getObject("location");
        dLocation destination = (dLocation) scriptEntry.getObject("destination");
        dCuboid copy_cuboid = (dCuboid) scriptEntry.getObject("cuboid");
        Element remove_original = (Element) scriptEntry.getObject("remove"); // TODO: Implement?


        List<Location> locations = new ArrayList<Location>();

        if (copy_location != null) locations.add(copy_location);
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

        Element stop = scriptEntry.getElement("stop");
        Element next = scriptEntry.getElement("next");
        Element callback = scriptEntry.getElement("callback");
        dList list = (dList) scriptEntry.getObject("list");

        if (stop != null && stop.asBoolean()) {
            // Report to dB
            dB.report(scriptEntry, getName(), stop.debug());
            boolean hasnext = false;
            for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
                ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
                List<String> args = entry.getOriginalArguments();
                if (entry.getCommandName().equalsIgnoreCase("foreach") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
                    hasnext = true;
                    break;
                }
            }
            if (hasnext) {
                while (scriptEntry.getResidingQueue().getQueueSize() > 0) {
                    ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(0);
                    List<String> args = entry.getOriginalArguments();
                    if (entry.getCommandName().equalsIgnoreCase("foreach") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
                        scriptEntry.getResidingQueue().removeEntry(0);
                        break;
                    }
                    scriptEntry.getResidingQueue().removeEntry(0);
                }
            }
            else {
                dB.echoError(scriptEntry.getResidingQueue(), "Cannot stop while: not in one!");
            }
            return;
        }
        else if (next != null && next.asBoolean()) {
            // Report to dB
            dB.report(scriptEntry, getName(), next.debug());
            boolean hasnext = false;
            for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
                ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
                List<String> args = entry.getOriginalArguments();
                if (entry.getCommandName().equalsIgnoreCase("foreach") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
                    hasnext = true;
                    break;
                }
            }
            if (hasnext) {
                while (scriptEntry.getResidingQueue().getQueueSize() > 0) {
                    ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(0);
                    List<String> args = entry.getOriginalArguments();
                    if (entry.getCommandName().equalsIgnoreCase("foreach") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
                        break;
                    }
                    scriptEntry.getResidingQueue().removeEntry(0);
                }
            }
            else {
                dB.echoError(scriptEntry.getResidingQueue(), "Cannot stop while: not in one!");
            }
            return;
        }
        else if (callback != null && callback.asBoolean()) {
            if (scriptEntry.getOwner() != null && (scriptEntry.getOwner().getCommandName().equalsIgnoreCase("foreach") ||
                    scriptEntry.getOwner().getBracedSet() == null || scriptEntry.getOwner().getBracedSet().size() == 0 ||
                    scriptEntry.getBracedSet().get("REPEAT").get(scriptEntry.getBracedSet().get("FOREACH").size() - 1) != scriptEntry)) {
                ForeachData data = (ForeachData)scriptEntry.getOwner().getData();
                data.index++;
View Full Code Here

    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

        // Fetch required objects
        Element required_integer = scriptEntry.getElement("required_integer");
        dLocation required_location = scriptEntry.getdObject("required_location");

        // Debug the execution
        dB.report(scriptEntry, getName(), required_integer.debug()
                                          + required_location.debug());

        // Do the execution

        // INSERT
View Full Code Here

        // Check for required information
        if (!scriptEntry.hasObject("world_name"))
            throw new InvalidArgumentsException("Must specify a world name.");

        if (!scriptEntry.hasObject("worldtype"))
            scriptEntry.addObject("worldtype", new Element("NORMAL"));
    }
View Full Code Here

            scriptEntry.addObject("worldtype", new Element("NORMAL"));
    }

    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
        Element World_Name = scriptEntry.getElement("world_name");
        Element Generator = scriptEntry.getElement("generator");
        Element worldType = scriptEntry.getElement("worldtype");

        dB.report(scriptEntry, getName(), World_Name.debug() +
                                          (Generator != null ? Generator.debug(): "") +
                                          worldType.debug());

        World world;

        if (Generator != null)
            world = Bukkit.getServer().createWorld(WorldCreator
                    .name(World_Name.asString())
                    .generator(Generator.asString())
                    .type(WorldType.valueOf(worldType.asString().toUpperCase())));

        else
            world = Bukkit.getServer().createWorld(WorldCreator
                    .name(World_Name.asString())
                    .type(WorldType.valueOf(worldType.asString().toUpperCase())));

        if (world == null)
            dB.echoDebug(scriptEntry, "World is null! :(");

    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

        Element stop = scriptEntry.getElement("stop");
        Element next = scriptEntry.getElement("next");
        Element callback = scriptEntry.getElement("callback");
        Element quantity = scriptEntry.getElement("qty");

        if (stop != null && stop.asBoolean()) {
            // Report to dB
            dB.report(scriptEntry, getName(), stop.debug());
            boolean hasnext = false;
            for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
                ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
                List<String> args = entry.getOriginalArguments();
                if (entry.getCommandName().equalsIgnoreCase("repeat") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
                    hasnext = true;
                    break;
                }
            }
            if (hasnext) {
                while (scriptEntry.getResidingQueue().getQueueSize() > 0) {
                    ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(0);
                    List<String> args = entry.getOriginalArguments();
                    if (entry.getCommandName().equalsIgnoreCase("repeat") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
                        scriptEntry.getResidingQueue().removeEntry(0);
                        break;
                    }
                    scriptEntry.getResidingQueue().removeEntry(0);
                }
            }
            else {
                dB.echoError("Cannot stop while: not in one!");
            }
            return;
        }
        else if (next != null && next.asBoolean()) {
            // Report to dB
            dB.report(scriptEntry, getName(), next.debug());
            boolean hasnext = false;
            for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
                ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
                List<String> args = entry.getOriginalArguments();
                if (entry.getCommandName().equalsIgnoreCase("repeat") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
                    hasnext = true;
                    break;
                }
            }
            if (hasnext) {
                while (scriptEntry.getResidingQueue().getQueueSize() > 0) {
                    ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(0);
                    List<String> args = entry.getOriginalArguments();
                    if (entry.getCommandName().equalsIgnoreCase("repeat") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
                        break;
                    }
                    scriptEntry.getResidingQueue().removeEntry(0);
                }
            }
            else {
                dB.echoError("Cannot stop while: not in one!");
            }
            return;
        }
        else if (callback != null && callback.asBoolean()) {
            if (scriptEntry.getOwner() != null && (scriptEntry.getOwner().getCommandName().equalsIgnoreCase("repeat") ||
                    scriptEntry.getOwner().getBracedSet() == null || scriptEntry.getOwner().getBracedSet().size() == 0 ||
                    scriptEntry.getBracedSet().get("REPEAT").get(scriptEntry.getBracedSet().get("REPEAT").size() - 1) != scriptEntry)) {
                RepeatData data = (RepeatData)scriptEntry.getOwner().getData();
                data.index++;
                if (data.index <= data.target) {
                    dB.echoDebug(scriptEntry, dB.DebugElement.Header, "Repeat loop " + data.index);
                    scriptEntry.getResidingQueue().addDefinition("value", String.valueOf(data.index));
                    ArrayList<ScriptEntry> bracedCommands = BracedCommand.getBracedCommands(scriptEntry.getOwner()).get("REPEAT");
                    ScriptEntry callbackEntry = null;
                    try {
                        callbackEntry = new ScriptEntry("REPEAT", new String[] { "\0CALLBACK" },
                                (scriptEntry.getScript() != null ? scriptEntry.getScript().getContainer(): null));
                        callbackEntry.copyFrom(scriptEntry);
                    }
                    catch (ScriptEntryCreationException e) {
                        dB.echoError(e);
                    }
                    callbackEntry.setOwner(scriptEntry.getOwner());
                    bracedCommands.add(callbackEntry);
                    for (int i = 0; i < bracedCommands.size(); i++) {
                        bracedCommands.get(i).setInstant(true);
                        bracedCommands.get(i).addObject("reqId", scriptEntry.getObject("reqId"));
                    }
                    scriptEntry.getResidingQueue().injectEntries(bracedCommands, 0);
                }
            }
            else {
                dB.echoError("Repeat CALLBACK invalid: not a real callback!");
            }
        }

        else {

            // Get objects
            ArrayList<ScriptEntry> bracedCommandsList =
                    ((LinkedHashMap<String, ArrayList<ScriptEntry>>) scriptEntry.getObject("braces")).get("REPEAT");

            if (bracedCommandsList == null || bracedCommandsList.isEmpty()) {
                dB.echoError("Empty braces!");
                return;
            }

            // Report to dB
            dB.report(scriptEntry, getName(), quantity.debug());

            int target = quantity.asInt();
            if (target <= 0)
            {
                dB.echoDebug(scriptEntry, "Zero count, not looping...");
                return;
            }
View Full Code Here

        if (!scriptEntry.hasObject("text"))
            throw new InvalidArgumentsException("Must specify sign text!");

        // Default to SIGN_POST type
        scriptEntry.defaultObject("type", new Element(Type.AUTOMATIC.name()));
    }
View Full Code Here

TOP

Related Classes of net.aufdemrand.denizen.objects.Element

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.