Package net.aufdemrand.denizen.scripts.containers

Examples of net.aufdemrand.denizen.scripts.containers.ScriptContainer


        // New Paginator to display script names
        Paginator paginator = new Paginator().header("Scripts");
        paginator.addLine("<e>Key: <a>Type  <b>Name");
        // Add scripts to Paginator
        for (String script : scripts) {
            ScriptContainer scriptContainer = ScriptRegistry.getScriptContainer(script);
            // If a --type has been specified...
            if (type != null) {
                if (scriptContainer.getContainerType().equalsIgnoreCase(type))
                    if (filter != null) {
                        if (script.contains(filter.toUpperCase()))
                            paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + "  <b>" + script);
                    }
                    else paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + "  <b>" + script);
                // If a --filter has been specified...
            } else if (filter != null) {
                if (script.contains(filter.toUpperCase()))
                    paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + "  <b>" + script);
            } else paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + "  <b>" + script);
        }
        // Send the contents of the Paginator to the Player (or Console)
        if (!paginator.sendPage(sender, args.getInteger(1, 1)))
            throw new CommandException("The page " + args.getInteger(1, 1) + " does not exist.");
    }
View Full Code Here


        return scriptContainers.containsKey(id.toUpperCase());
    }

    public static boolean containsScript(String id, Class scriptContainerType) {
        if (!scriptContainers.containsKey(id.toUpperCase())) return false;
        ScriptContainer script = (ScriptContainer) scriptContainers.get(id.toUpperCase());
        String type = null;
        for (Map.Entry<String, Class<? extends ScriptContainer>> entry : scriptContainerTypes.entrySet()) {
            if (entry.getValue() == scriptContainerType)
                type = entry.getKey();
        }
        return type != null && (script.getContainerType().equalsIgnoreCase(type));
    }
View Full Code Here

        // @description
        // Returns the value of the script's YAML as either an Element or dList.
        // -->
        if (attribute.startsWith("yaml_key")
                && attribute.hasContext(1)) {
            ScriptContainer container = getContainer();
            if (container == null) {
                dB.echoError("Missing script container?!");
                return new Element(identify()).getAttribute(attribute);
            }
            YamlConfiguration section = container.getConfigurationSection("");
            if (section == null) {
                dB.echoError("Missing YAML section?!");
                return new Element(identify()).getAttribute(attribute);
            }
            Object obj = section.get(attribute.getContext(1).toUpperCase());
            if (obj == null) return null;

            if (obj instanceof List) {
                dList list = new dList();
                for (Object each : (List<Object>) obj)
                    list.add(TagManager.tag(attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getPlayer(),
                            attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getNPC(), each.toString(), false, attribute.getScriptEntry()));
                return list.getAttribute(attribute.fulfill(1));

            }
            else return new Element(TagManager.tag(attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getPlayer(),
                    attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getNPC(), obj.toString(), false, attribute.getScriptEntry()))
                    .getAttribute(attribute.fulfill(1));
        }

        // <--[tag]
        // @attribute <s@script.list_keys[<constant_name>]>
        // @returns dList
        // @description
        // Returns a list of all keys within a script.
        // -->
        if (attribute.startsWith("list_keys")) {
            return new dList(getContainer().getConfigurationSection(attribute.hasContext(1) ? attribute.getContext(1): "").getKeys(false))
                    .getAttribute(attribute.fulfill(1));
        }

        // <--[tag]
        // @attribute <s@script.list_deep_keys[<constant_name>]>
        // @returns dList
        // @description
        // Returns a list of all keys within a script, searching recursively.
        // -->
        if (attribute.startsWith("list_deep_keys")) {
            return new dList(getContainer().getConfigurationSection(attribute.hasContext(1) ? attribute.getContext(1): "").getKeys(true))
                    .getAttribute(attribute.fulfill(1));
        }

        // <--[tag]
        // @attribute <s@script.to_json>
        // @returns Element
        // @description
        // Converts the YAML Script Container to a JSON array.
        // Best used with 'yaml data' type scripts.
        // -->
        if (attribute.startsWith("to_json")) {
            JSONObject jsobj = new JSONObject(container.getConfigurationSection("").getMap());
            jsobj.remove("TYPE");
            return new Element(jsobj.toString()).getAttribute(attribute.fulfill(1));
        }

        /////////////////
View Full Code Here

TOP

Related Classes of net.aufdemrand.denizen.scripts.containers.ScriptContainer

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.