Package net.aufdemrand.denizen.objects

Examples of net.aufdemrand.denizen.objects.Element


        }

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

        scriptEntry.defaultObject("catch", new Element("NONE"))
                .defaultObject("stop", Element.FALSE)
                .defaultObject("percent", new Element(65));

        if (!((BukkitScriptEntryData)scriptEntry.entryData).hasNPC() || !((BukkitScriptEntryData)scriptEntry.entryData).getNPC().isSpawned())
            throw new InvalidArgumentsException("This command requires a linked and spawned NPC!");

    }
View Full Code Here


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

        dLocation location = scriptEntry.getdObject("location");
        Element katch = scriptEntry.getElement("catch");
        Element stop = scriptEntry.getElement("stop");
        Element percent = scriptEntry.getElement("percent");

        dNPC npc = ((BukkitScriptEntryData)scriptEntry.entryData).getNPC();
        FishingTrait trait = npc.getFishingTrait();

        dB.report(scriptEntry, getName(), location.debug() + katch.debug() + percent.debug() + stop.debug());

        if (stop.asBoolean()) {
            trait.stopFishing();
            return;
        }

        npc.getEquipmentTrait().set(0, new ItemStack(Material.FISHING_ROD));

        trait.setCatchPercent(percent.asInt());
        trait.setCatchType(FishingTrait.CatchType.valueOf(katch.asString().toUpperCase()));
        trait.startFishing(location);

    }
View Full Code Here

        // Check to make sure required arguments have been filled
        if (!scriptEntry.hasObject("entities"))
            throw new InvalidArgumentsException("No valid entities specified.");

        // Use default age if one is not specified
        scriptEntry.defaultObject("age", new Element(1));

    }
View Full Code Here

        scriptEntry.defaultObject("origin",
                ((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer() ? ((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().getLocation() : null,
                ((BukkitScriptEntryData)scriptEntry.entryData).hasNPC() ? ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getLocation() : null);

        // Use a default speed and rotation threshold if they are not specified
        scriptEntry.defaultObject("speed", new Element(1.2));
        scriptEntry.defaultObject("rotationThreshold", new Element(15));

        // Check to make sure required arguments have been filled
        if (!scriptEntry.hasObject("entities"))
            throw new InvalidArgumentsException("Must specify entity/entities!");
        if (!scriptEntry.hasObject("origin"))
View Full Code Here

        // No potion specified? Problem!
        if (!scriptEntry.hasObject("effect"))
            throw new InvalidArgumentsException("Must specify a valid PotionType!");

        scriptEntry.defaultObject("duration", new Duration(60));
        scriptEntry.defaultObject("amplifier", new Element(1));
        scriptEntry.defaultObject("remove", Element.FALSE);

    }
View Full Code Here

            else
                arg.reportUnhandled();
        }

        if (!scriptEntry.hasObject("state"))
            scriptEntry.addObject("state", new Element("TRUE"));

        if (!scriptEntry.hasObject("target") || !((dEntity)scriptEntry.getdObject("target")).isValid())
            throw new InvalidArgumentsException("Must specify a valid target!");
    }
View Full Code Here

    }

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

        // Report to dB
        dB.report(scriptEntry, getName(), state.debug() + target.debug());

        if (target.isNPC()) {
            NPC npc = target.getDenizenNPC().getCitizen();
            if (!npc.hasTrait(InvisibleTrait.class))
                npc.addTrait(InvisibleTrait.class);
            InvisibleTrait trait = npc.getTrait(InvisibleTrait.class);
            switch (Action.valueOf(state.asString().toUpperCase())) {
                case FALSE:
                    trait.setInvisible(false);
                    break;
                case TRUE:
                    trait.setInvisible(true);
                    break;
                case TOGGLE:
                    trait.toggle();
                    break;
            }
        }
        else {
            switch (Action.valueOf(state.asString().toUpperCase())) {
                case FALSE:
                    target.getLivingEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
                    break;
                case TRUE:
                    new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1).apply(target.getLivingEntity());
View Full Code Here

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

            if (!scriptEntry.hasObject("state")
                    && arg.matchesPrefix("state", "s")
                    && arg.matchesEnum(Toggle.values()))
                scriptEntry.addObject("state", new Element(arg.getValue().toUpperCase()));

            else if (!scriptEntry.hasObject("trait"))
                scriptEntry.addObject("trait", new Element(arg.getValue()));

        }

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

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

        scriptEntry.defaultObject("state", new Element("TOGGLE"));

    }
View Full Code Here

    }

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

        Element toggle = scriptEntry.getElement("state");
        Element traitName = scriptEntry.getElement("trait");
        NPC npc = ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getCitizen();

        dB.report(scriptEntry, getName(),
                    traitName.debug() +
                    toggle.debug() +
                    ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().debug());

        Class<? extends Trait> trait = CitizensAPI.getTraitFactory().getTraitClass(traitName.asString());

        if (trait == null) {
            dB.echoError(scriptEntry.getResidingQueue(), "Trait not found: " + traitName.asString());
            return;
        }

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

            case TRUE:
            case ON:
                if (npc.hasTrait(trait))
                    dB.echoError(scriptEntry.getResidingQueue(), "NPC already has trait '" + traitName.asString() + "'");
                else
                    npc.addTrait(trait);
                break;

            case FALSE:
            case OFF:
                if (!npc.hasTrait(trait))
                    dB.echoError(scriptEntry.getResidingQueue(), "NPC does not have trait '" + traitName.asString() + "'");
                else
                    npc.removeTrait(trait);
                break;

            case TOGGLE:
View Full Code Here

                scriptEntry.addObject("location", arg.asType(dLocation.class));
            }

            else if (!scriptEntry.hasObject("type")
                     && arg.matches("random")) {
                scriptEntry.addObject("type", new Element(FireworkEffect.Type.values()[CoreUtilities.getRandom().nextInt(FireworkEffect.Type.values().length)].name()));
            }

            else if (!scriptEntry.hasObject("type")
                     && arg.matchesEnum(FireworkEffect.Type.values())) {
                scriptEntry.addObject("type", arg.asElement());
            }

            else if (!scriptEntry.hasObject("power")
                     && arg.matchesPrimitive(aH.PrimitiveType.Integer)) {
                scriptEntry.addObject("power", arg.asElement());
            }

            else if (!scriptEntry.hasObject("flicker")
                     && arg.matches("flicker")) {
                scriptEntry.addObject("flicker", "");
            }

            else if (!scriptEntry.hasObject("trail")
                     && arg.matches("trail")) {
                scriptEntry.addObject("trail", "");
            }

            else if (!scriptEntry.hasObject("primary")
                     && arg.matchesPrefix("primary")
                     && arg.matchesArgumentList(dColor.class)) {
                scriptEntry.addObject("primary", arg.asType(dList.class).filter(dColor.class));
            }

            else if (!scriptEntry.hasObject("fade")
                     && arg.matchesPrefix("fade")
                     && arg.matchesArgumentList(dColor.class)) {
                scriptEntry.addObject("fade", arg.asType(dList.class).filter(dColor.class));
            }

            else
                arg.reportUnhandled();
        }

        // Use the NPC or player's locations as the location if one is not specified
        scriptEntry.defaultObject("location",
                ((BukkitScriptEntryData)scriptEntry.entryData).hasNPC() ? ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getLocation() : null,
                ((BukkitScriptEntryData)scriptEntry.entryData).hasPlayer() ? ((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().getLocation() : null);

        scriptEntry.defaultObject("type", new Element("ball"));
        scriptEntry.defaultObject("power", new Element(1));
        scriptEntry.defaultObject("primary", Arrays.asList(dColor.valueOf("yellow")));
    }
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.