Examples of FormatScriptContainer


Examples of net.aufdemrand.denizen.scripts.containers.core.FormatScriptContainer

            return;
        if (determination.toUpperCase().startsWith("CANCELLED"))
            event.setCancelled(true);
        else if (determination.toUpperCase().startsWith("FORMAT:")) {
            String name = determination.substring(7);
            FormatScriptContainer format = ScriptRegistry.getScriptContainer(name);
            if (format == null) dB.echoError("Could not find format script matching '" + name + '\'');
            else event.setFormat(format.getFormattedText(event.getMessage(), null, player));
        }
        else if (!determination.equals("none")) {
            event.setMessage(determination);
        }
    }
View Full Code Here

Examples of net.aufdemrand.denizen.scripts.containers.core.FormatScriptContainer

        if (determination.toUpperCase().startsWith("CANCELLED"))
            event.setCancelled(true);
        else if (determination.toUpperCase().startsWith("FORMAT:")) {
            String name = determination.substring(7);
            FormatScriptContainer format = ScriptRegistry.getScriptContainer(name);
            if (format == null) dB.echoError("Could not find format script matching '" + name + '\'');
            else event.setFormat(format.getFormattedText(event.getMessage(), null, player));
        }
        else if (!determination.equals("none")) {
            event.setMessage(determination);
        }
View Full Code Here

Examples of net.aufdemrand.denizen.scripts.containers.core.FormatScriptContainer

        // Iterate through arguments
        for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {
            if (!scriptEntry.hasObject("format")
                    && arg.matchesPrefix("format", "f")) {
                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);
            }
View Full Code Here

Examples of net.aufdemrand.denizen.scripts.containers.core.FormatScriptContainer

    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
        // Get objects
        List<dPlayer> targets = (List<dPlayer>) scriptEntry.getObject("targets");
        String text = scriptEntry.getElement("text").asString();
        FormatScriptContainer format = (FormatScriptContainer) scriptEntry.getObject("format");

        // Report to dB
        dB.report(scriptEntry, getName(),
                aH.debugObj("Narrating", text)
                        + aH.debugList("Targets", targets)
                        + (format != null ? aH.debugObj("Format", format.getName()) : ""));

        if (targets == null) {
            Bukkit.getServer().getConsoleSender().sendMessage(format != null ? format.getFormattedText(scriptEntry) : text);
            return;
        }

        for (dPlayer player : targets) {
            if (player != null && player.isOnline())
                player.getPlayerEntity().sendMessage(format != null ? format.getFormattedText(scriptEntry) : text);
            else
                dB.echoError("Narrated to non-existent or offline player!");
        }
    }
View Full Code Here

Examples of net.aufdemrand.denizen.scripts.containers.core.FormatScriptContainer

                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);
            }
View Full Code Here

Examples of net.aufdemrand.denizen.scripts.containers.core.FormatScriptContainer

    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
        // Fetch objects
        Element text = scriptEntry.getElement("text");
        AnnounceType type = (AnnounceType) scriptEntry.getObject("type");
        FormatScriptContainer format = (FormatScriptContainer) scriptEntry.getObject("format");
        Element flag = scriptEntry.getElement("flag");

        // Report to dB
        dB.report(scriptEntry, getName(),
                aH.debugObj("Message", text)
                        + (format != null ? aH.debugObj("Format", format.getName()) : "")
                        + aH.debugObj("Type", type.name())
                        + (flag != null? aH.debugObj("Flag_Name", flag) : ""));

        String message = format != null ? format.getFormattedText(scriptEntry) : text.asString();

        // Use Bukkit to broadcast the message to everybody in the server.
        if (type == AnnounceType.ALL) {
            DenizenAPI.getCurrentInstance().getServer().broadcastMessage(message);
        }
View Full Code Here

Examples of net.aufdemrand.denizen.scripts.containers.core.FormatScriptContainer

        // Returns the text re-formatted according to a format script.
        // See <@link example using format scripts>.
        // -->
        if (attribute.startsWith("format")
                && attribute.hasContext(1)) {
            FormatScriptContainer format = ScriptRegistry.getScriptContainer(attribute.getContext(1));
            if (format == null) {
                dB.echoError("Could not find format script matching '" + attribute.getContext(1) + "'");
                return null;
            }
            else {
                return new Element(format.getFormattedText(element,
                        attribute.getScriptEntry() != null ? attribute.getScriptEntry().getNPC(): null,
                        attribute.getScriptEntry() != null ? attribute.getScriptEntry().getPlayer(): null))
                        .getAttribute(attribute.fulfill(1));
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.