Package net.aufdemrand.denizen.objects

Examples of net.aufdemrand.denizen.objects.Element


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

        // Get objects
        String direction = scriptEntry.hasObject("direction") ? ((Element) scriptEntry.getObject("direction")).asString() : null;
        Element typeElement = scriptEntry.getElement("type");
        dList text = (dList) scriptEntry.getObject("text");
        dLocation location = (dLocation) scriptEntry.getObject("location");

        // Report to dB
        dB.report(scriptEntry, getName(), typeElement.debug()
                                          + location.debug()
                                          + text.debug());

        Type type = Type.valueOf(typeElement.asString().toUpperCase());
        Block sign = location.getBlock();
        if (type != Type.AUTOMATIC
                || (sign.getType() != Material.WALL_SIGN
                && sign.getType() != Material.SIGN_POST))
            sign.setType(type == Type.WALL_SIGN ? Material.WALL_SIGN: Material.SIGN_POST);
View Full Code Here


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

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

    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
        if (!Settings.allowLogging()) {
            dB.echoError("Logging disabled by administrator.");
            return;
        }
        Element message =  scriptEntry.getElement("message");
        Element fileName = scriptEntry.getElement("file");
        Element typeElement = scriptEntry.getElement("type");

         dB.report(scriptEntry, getName(),
                 message.debug() + fileName.debug() + typeElement.debug());

        Type type = Type.valueOf(typeElement.asString().toUpperCase());

        String directory = URLDecoder.decode(System.getProperty("user.dir"));
        File file = new File(directory, fileName.asString());

        String output = TagManager.cleanOutputFully(message.asString());
View Full Code Here

        // Get objects
        List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
        dLocation location = (dLocation) scriptEntry.getObject("location");
        dEntity target = (dEntity) scriptEntry.getObject("target");
        Element spread = scriptEntry.getElement("spread");
        boolean persistent = scriptEntry.hasObject("persistent");

        // Report to dB
        dB.report(scriptEntry, getName(), aH.debugObj("entities", entities.toString()) +
                              location.debug() +
                             (spread != null  ?spread.debug() : "") +
                             (target != null ? target.debug() : "") +
                             (persistent ? aH.debugObj("persistent", "true") : ""));

        // Keep a dList of entities that can be called using <entry[name].spawned_entities>
        // later in the script queue

        dList entityList = new dList();

        // Go through all the entities and spawn them or teleport them,
        // then set their targets if applicable

        for (dEntity entity : entities) {
            Location loc = location.clone();
            if (spread != null) {
                loc.add(CoreUtilities.getRandom().nextInt(spread.asInt() * 2) - spread.asInt(),
                        0,
                        CoreUtilities.getRandom().nextInt(spread.asInt() * 2) - spread.asInt());
            }

            entity.spawnAt(loc);

            // Only add to entityList after the entities have been
View Full Code Here

    // TODO: Why are we doing this... we're just forcing sync-chat.
    @EventHandler(priority = EventPriority.LOWEST)
    public void asyncPlayerChat(final AsyncPlayerChatEvent event) {

        final Map<String, dObject> context = new HashMap<String, dObject>();
        context.put("message", new Element(event.getMessage()));
        context.put("format", new Element(event.getMessage()));

        final dPlayer player = new dPlayer(event.getPlayer());

        Callable<String> call = new Callable<String>() {
            @Override
View Full Code Here

    }

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

        Element name = (Element) scriptEntry.getObject("name");

        dB.report(scriptEntry, getName(), name.debug());

        NPC npc = ((BukkitScriptEntryData)scriptEntry.entryData).getNPC().getCitizen();

        Location prev = npc.isSpawned() ? npc.getEntity().getLocation() : null;
        npc.despawn(DespawnReason.PENDING_RESPAWN);
        npc.setName(name.asString().length() > 100 ? name.asString().substring(0, 100): name.asString());
        if (prev != null)
            npc.spawn(prev);

    }
View Full Code Here

            else arg.reportUnhandled();
        }

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

        if (!specified_targets) {
            List<dEntity> entities = new ArrayList<dEntity>();
            if (((BukkitScriptEntryData)scriptEntry.entryData).getPlayer() != null)
                entities.add(((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().getDenizenEntity());
View Full Code Here

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

        List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
        dEntity source = (dEntity) scriptEntry.getObject("source");
        Element amountElement = scriptEntry.getElement("amount");

        dB.report(scriptEntry, getName(), amountElement.debug()
                                          + aH.debugList("entities", entities)
                                          + (source == null ? "" : source.debug()));

        double amount = amountElement.asDouble();
        for (dEntity entity : entities) {
            if (entity.getLivingEntity() == null) {
                dB.echoDebug(scriptEntry, entity + " is not a living entity!");
                continue;
            }
View Full Code Here

    //
    // -->
    @EventHandler
    public void onListPing(ServerListPingEvent event) {
        Map<String, dObject> context = new HashMap<String, dObject>();
        context.put("motd", new Element(event.getMotd()));
        context.put("max_players", new Element(event.getMaxPlayers()));
        context.put("num_players", new Element(event.getNumPlayers()));
        context.put("address", new Element(event.getAddress().toString()));
        String determination = EventManager.doEvents(Arrays.asList("server list ping"), null, null, context);
        String[] values = determination.split("[\\|" + dList.internal_escape + "]", 2);
        if (new Element(values[0]).isInt())
            event.setMaxPlayers(new Element(values[0]).asInt());
        if (determination.length() > 0 && !determination.equalsIgnoreCase("none")) {
            if (values.length == 2)
                event.setMotd(values[1]);
            else
                event.setMotd(determination);
View Full Code Here


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

        Element qty = scriptEntry.getElement("qty");
        Element action = scriptEntry.getElement("action");
        List<dEntity> targets = (List<dEntity>) scriptEntry.getObject("target");

        dB.report(scriptEntry, getName(), (qty != null ? qty.debug() : "") +
                                          (action != null ? action.debug() : "") +
                                          aH.debugObj("target", targets.toString()));

        if (qty == null && action == null)
            dB.echoError(scriptEntry.getResidingQueue(), "Null quantity!");

        if (action == null)
            action = Element.TRUE;

        for (dEntity target: targets) {
            if (target.isNPC()) {
                if (action.asString().equalsIgnoreCase("true"))
                    target.getDenizenNPC().getCitizen().addTrait(HealthTrait.class);
                else if (action.asString().equalsIgnoreCase("false"))
                    target.getDenizenNPC().getCitizen().removeTrait(HealthTrait.class);
                else if (target.getDenizenNPC().getCitizen().hasTrait(HealthTrait.class))
                    target.getDenizenNPC().getCitizen().removeTrait(HealthTrait.class);
                else
                    target.getDenizenNPC().getCitizen().addTrait(HealthTrait.class);
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.