Package net.aufdemrand.denizen.objects

Examples of net.aufdemrand.denizen.objects.Element


        final dLocation location = scriptEntry.hasObject("location") ?
                                   (dLocation) scriptEntry.getObject("location") :
                ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getLocation();

        Element type = (Element) scriptEntry.getObject("type");
        Element power = (Element) scriptEntry.getObject("power");
        boolean flicker = scriptEntry.hasObject("flicker");
        boolean trail = scriptEntry.hasObject("trail");
        List<dColor> primary = (List<dColor>) scriptEntry.getObject("primary");
        List<dColor> fade = (List<dColor>) scriptEntry.getObject("fade");

        // Report to dB
        dB.report(scriptEntry, getName(), location.debug() +
                             type.debug() +
                             power.debug() +
                             (flicker ? aH.debugObj("flicker", flicker) : "") +
                             (trail ? aH.debugObj("trail", trail) : "") +
                             aH.debugObj("primary colors", primary.toString()) +
                             (fade != null ? aH.debugObj("fade colors", fade.toString()) : ""));

        Firework firework = location.getWorld().spawn(location, Firework.class);
        FireworkMeta fireworkMeta = firework.getFireworkMeta();
        fireworkMeta.setPower(power.asInt());

        Builder fireworkBuilder = FireworkEffect.builder();
        fireworkBuilder.with(FireworkEffect.Type.valueOf(type.asString().toUpperCase()));

                          fireworkBuilder.withColor(Conversion.convertColors(primary));
View Full Code Here


    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

        // Get objects
        Action action = (Action) scriptEntry.getObject("action");
        dLocation location = (dLocation) scriptEntry.getObject("location");
        Element range = (Element) scriptEntry.getObject("range");
        Element id = (Element) scriptEntry.getObject("id");

        // Report to dB
        dB.report(scriptEntry, getName(),
                aH.debugObj("NPC", ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().toString())
                        + action.name() + id.debug()
                        + (location != null ? location.debug() : "")
                        + (range != null ? range.debug() : "" ));

        dNPC npc = ((BukkitScriptEntryData)scriptEntry.entryData).getNPC();

        if (!npc.getCitizen().hasTrait(Anchors.class))
            npc.getCitizen().addTrait(Anchors.class);

        switch (action) {

            case ADD:
                npc.getCitizen().getTrait(Anchors.class).addAnchor(id.asString(), location);
                return;

            case ASSUME:
            {
                Anchor n = npc.getCitizen().getTrait(Anchors.class)
                        .getAnchor(id.asString());
                if (n == null)
                    dB.echoError(scriptEntry.getResidingQueue(), "Invalid anchor name '" + id.asString() + "'");
                else
                    npc.getEntity().teleport(n.getLocation());
            }
                return;

            case WALKNEAR:
            {
                Anchor n = npc.getCitizen().getTrait(Anchors.class)
                        .getAnchor(id.asString());
                if (n == null)
                    dB.echoError(scriptEntry.getResidingQueue(), "Invalid anchor name '" + id.asString() + "'");
                else if (range == null)
                    dB.echoError(scriptEntry.getResidingQueue(), "Must specify a range!");
                else
                    npc.getNavigator().setTarget(
                        Utilities.getWalkableLocationNear(n.getLocation(), range.asInt()));
            }
                return;

            case WALKTO:
            {
                Anchor n = npc.getCitizen().getTrait(Anchors.class)
                        .getAnchor(id.asString());
                if (n == null)
                    dB.echoError(scriptEntry.getResidingQueue(), "Invalid anchor name '" + id.asString() + "'");
                else
                    npc.getNavigator().setTarget(n.getLocation());
            }
                return;

            case REMOVE:
            {
                Anchor n = npc.getCitizen().getTrait(Anchors.class)
                        .getAnchor(id.asString());
                if (n == null)
                    dB.echoError(scriptEntry.getResidingQueue(), "Invalid anchor name '" + id.asString() + "'");
                else
                    npc.getCitizen().getTrait(Anchors.class).removeAnchor(n);
            }
        }
View Full Code Here

        if (!scriptEntry.hasObject("trigger"))
            throw new InvalidArgumentsException("Missing name argument!");

        if (!scriptEntry.hasObject("toggle"))
            scriptEntry.addObject("toggle", new Element("TOGGLE"));

        if (!((BukkitScriptEntryData)scriptEntry.entryData).hasNPC() && !scriptEntry.hasObject("npc"))
            throw new InvalidArgumentsException("This command requires a linked NPC!");

    }
View Full Code Here

    }

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

        Element toggle = scriptEntry.getElement("toggle");
        Element trigger = scriptEntry.getElement("trigger");
        Element radius = scriptEntry.getElement("radius");
        Duration cooldown = (Duration) scriptEntry.getObject("cooldown");
        dNPC npc = scriptEntry.hasObject("npc") ? (dNPC) scriptEntry.getObject("npc") : ((BukkitScriptEntryData)scriptEntry.entryData).getNPC();

        dB.report(scriptEntry, getName(),
                trigger.debug() + toggle.debug() +
                        (radius != null ? radius.debug(): "") +
                        (cooldown != null ? cooldown.debug(): "") +
                        npc.debug());

        // Add trigger trait
        if (!npc.getCitizen().hasTrait(TriggerTrait.class)) npc.getCitizen().addTrait(TriggerTrait.class);

        TriggerTrait trait = npc.getCitizen().getTrait(TriggerTrait.class);

        switch (Toggle.valueOf(toggle.asString().toUpperCase())) {

            case TOGGLE:
                trait.toggleTrigger(trigger.asString());
                break;

            case TRUE:
                trait.toggleTrigger(trigger.asString(), true);
                break;

            case FALSE:
                trait.toggleTrigger(trigger.asString(), false);
                break;
        }

        if (radius != null)
            trait.setLocalRadius(trigger.asString(), radius.asInt());

        if (cooldown != null && cooldown.getSeconds() > 0)
            trait.setLocalCooldown(trigger.asString(), cooldown.getSeconds());
    }
View Full Code Here

        //

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

            if (arg.matches("passive", "passively"))
                scriptEntry.addObject("passively", new Element(true));

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

            else arg.reportUnhandled();
        }

        //
        // Set defaults
        //

        scriptEntry.defaultObject("passively", new Element(false));
        scriptEntry.defaultObject("outcome", new Element(DETERMINE_NONE));
    }
View Full Code Here

                    new dWorld(((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getWorld()) :
                    (((BukkitScriptEntryData) scriptEntry.entryData).hasPlayer() ?
                    new dWorld(((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().getWorld()) : null));
        }

        scriptEntry.defaultObject("type", new Element("GLOBAL"));

        if (!scriptEntry.hasObject("world"))
            throw new InvalidArgumentsException("Must specify a valid world!");
    }
View Full Code Here

    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
        // Fetch objects
        Duration value = (Duration) scriptEntry.getObject("value");
        dWorld world = (dWorld) scriptEntry.getObject("world");
        Element type_element = scriptEntry.getElement("type");
        Type type = Type.valueOf(type_element.asString().toUpperCase());

        // Report to dB
        dB.report(scriptEntry, getName(), type_element.debug()
                                          + value.debug()
                                          + world.debug());

        if (type.equals(Type.GLOBAL)) {
            world.getWorld().setTime(value.getTicks());
View Full Code Here

    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
        // Get objects
        Boolean stop = (Boolean) scriptEntry.getObject("stop");
        Element lead = (Element) scriptEntry.getObject("lead");
        dEntity target = (dEntity) scriptEntry.getObject("target");

        // Report to dB
        dB.report(scriptEntry, getName(),
                        (((BukkitScriptEntryData)scriptEntry.entryData).getPlayer() != null ? ((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().debug() : "")
                        + (stop == null ? aH.debugObj("Action", "FOLLOW")
                        : aH.debugObj("Action", "STOP"))
                        + (lead != null ? aH.debugObj("Lead", lead.toString()) : "")
                        + target.debug());

        if (lead != null)
            ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getNavigator().getLocalParameters().distanceMargin(lead.asDouble());

        if (stop != null)
            ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getNavigator()
                    .cancelNavigation();
        else
View Full Code Here

                    arg.matchesArgumentType(Duration.class))
                scriptEntry.addObject("duration", arg.asType(Duration.class));

            else if (!scriptEntry.hasObject("state") &&
                    arg.matchesEnum(SwitchState.values()))
                scriptEntry.addObject("switchstate", new Element(arg.getValue().toUpperCase()));

            else arg.reportUnhandled();
        }

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

        scriptEntry.defaultObject("duration", new Duration(0));
        scriptEntry.defaultObject("switchstate", new Element("TOGGLE"));
    }
View Full Code Here

                else if (arg.equals("<")) arg = "LESS";
                else if (arg.equals(">")) arg = "MORE";
                else if (arg.equals("||")) arg = "OR";
                else if (arg.equals("&&")) arg = "AND";

                Element elArg = new Element(arg);

                // Set bridge
                if (elArg.matchesEnum(Comparable.BridgeValues)) {
                    // new Comparable to add to the list
                    comparables.add(new Comparable());
                    comparables.get(comparables.size() - 1).bridge =
                            Comparable.Bridge.valueOf(arg.toUpperCase());
                }

                // Set operator (Optional, default is EQUALS)
                else if (elArg.matchesEnum(Comparable.OperatorValues)) {
                    comparables.get(comparables.size() - 1).operator =
                            Comparable.Operator.valueOf(arg.toUpperCase());
                    usedOperator = true;
                }
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.