Examples of YamlConfiguration


Examples of com.foundationdb.server.service.servicemanager.configuration.yaml.YamlConfiguration

        if (!pluginUrls.isEmpty()) {
            pluginsClassloader = new URLClassLoader(pluginUrls.toArray(new URL[pluginUrls.size()]));
        }
        for (Plugin plugin : plugins) {
            try {
                YamlConfiguration pluginConfig = new YamlConfiguration(
                        plugin.toString(),
                        plugin.getServiceConfigsReader(),
                        pluginsClassloader);
                compositeLoader.add(pluginConfig);
            }
View Full Code Here

Examples of com.tinkerpop.gremlin.util.config.YamlConfiguration

            final String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);

            switch (fileExtension) {
                case "yml":
                case "yaml":
                    return new YamlConfiguration(configurationFile);
                case "xml":
                    return new XMLConfiguration(configurationFile);
                default:
                    return new PropertiesConfiguration(configurationFile);
            }
View Full Code Here

Examples of me.th3pf.plugins.duties.tmp.YamlConfiguration

  private LinkedHashMap<String, String> defaults;

  public Configuration(File cfgFile, String cfgDefaultsFilePath)
  {
    this.cfgDefaultsFilePath = cfgDefaultsFilePath;
    this.yamlHandler = new YamlConfiguration(cfgFile);
    this.defaults = getDefaults();
   
    Upgrade();
  }
View Full Code Here

Examples of net.aufdemrand.denizencore.utilities.YamlConfiguration

                    continue;
                }

                // ...and through each event inside the script.
                if (script.contains("EVENTS")) {
                    YamlConfiguration configSection = script.getConfigurationSection("EVENTS");
                    if (configSection == null) {
                        dB.echoError("Script '" + script.getName() + "' has an invalid events block!");
                        break;
                    }
                    Set<String> keys = configSection.getKeys(false);
                    if (keys == null) {
                        dB.echoError("Script '" + script.getName() + "' has an empty events block!");
                        break;
                    }
                    for (String eventName : keys) {
View Full Code Here

Examples of net.aufdemrand.denizencore.utilities.YamlConfiguration

        // Returns the value of the constant as either an Element or dList.
        // -->
        if (attribute.startsWith("cons")) {
            if (!attribute.hasContext(1)) return null;

            YamlConfiguration section = getContainer().getConfigurationSection("constants");
            if (section == null) return null;
            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.yaml_key[<constant_name>]>
        // @returns Element or dList
        // @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)
View Full Code Here

Examples of net.aufdemrand.denizencore.utilities.YamlConfiguration

        Element split = scriptEntry.getElement("split");
        YAML_Action yaml_action = (YAML_Action) scriptEntry.getObject("yaml_action");
        Element actionElement = scriptEntry.getElement("action");
        Element idElement = scriptEntry.getElement("id");

        YamlConfiguration yamlConfiguration;

        dB.report(scriptEntry, getName(),
                        idElement.debug()
                        + actionElement.debug()
                        + (filename != null ? filename.debug() : "")
                        + (yaml_action != null ? aH.debugObj("yaml_action", yaml_action.name()): "")
                        + (key != null ? key.debug() : "")
                        + (value != null ? value.debug() : "")
                        + (split != null ? split.debug() : ""));

        // Do action
        Action action = Action.valueOf(actionElement.asString().toUpperCase());
        String id = idElement.asString().toUpperCase();

        switch (action) {

            case LOAD:
                File file = new File(DenizenAPI.getCurrentInstance().getDataFolder(), filename.asString());
                if (!file.exists()) {
                    dB.echoError("File cannot be found!");
                    return;
                }
                try {
                    FileInputStream fis = new FileInputStream(file);
                    yamlConfiguration = YamlConfiguration.load(ScriptHelper.convertStreamToString(fis));
                    fis.close();
                }
                catch (Exception e) {
                    dB.echoError(e);
                    return;
                }
                if (yamls.containsKey(id))
                    yamls.remove(id);
                if (yamlConfiguration != null)
                    yamls.put(id, yamlConfiguration);
                break;

            case UNLOAD:
                if (yamls.containsKey(id))
                    yamls.remove(id);
                else
                    dB.echoError("Unknown YAML ID '" + id + "'");
                break;

            case SAVE:
                if (yamls.containsKey(id)) {
                    try {
                        if (!Settings.allowStrangeYAMLSaves()) {
                            File fileObj = new File(DenizenAPI.getCurrentInstance().
                                    getDataFolder().getAbsolutePath() + "/" + filename.asString());
                            String directory = URLDecoder.decode(System.getProperty("user.dir"));
                            if (!fileObj.getCanonicalPath().startsWith(directory)) {
                                dB.echoError("Outside-the-main-folder YAML saves disabled by administrator.");
                                return;
                            }
                        }
                        File fileObj = new File(DenizenAPI.getCurrentInstance().
                                getDataFolder().getAbsolutePath() + "/" + filename.asString());
                        fileObj.getParentFile().mkdirs();
                        FileWriter fw = new FileWriter(DenizenAPI.getCurrentInstance()
                                .getDataFolder().getAbsolutePath() + "/" + filename.asString());
                        BufferedWriter writer = new BufferedWriter(fw);
                        writer.write(yamls.get(id).saveToString());
                        writer.close();
                        fw.close();
                    } catch (IOException e) {
                        dB.echoError(e);
                    }
                }
                else
                    dB.echoError("Unknown YAML ID '" + id + "'");
                break;

            case WRITE:
                if (yamls.containsKey(id)) {
                    if (value instanceof Element)
                        yamls.get(id).set(key.asString(), ((Element) value).asString());
                    else if (split != null && split.asBoolean())
                        yamls.get(id).set(key.asString(), value);
                    else
                        yamls.get(id).set(key.asString(), value.identify());
                }
                else
                    dB.echoError("Unknown YAML ID '" + id + "'");
                break;

            case SET:
                if (yamls.containsKey(id)) {
                    if (yaml_action == null || key == null || value == null) {
                        dB.echoError("Must specify a YAML action and value!");
                        return;
                    }
                    YamlConfiguration yaml = yamls.get(id);

                    int index = -1;
                    if (key.asString().contains("[")) {
                        try {
                            index = Integer.valueOf(key.asString().split("\\[")[1].replace("]", "")) - 1;
                        } catch (Exception e) { index = -1; }
                        key = Element.valueOf(key.asString().split("\\[")[0]);
                    }

                    String keyStr = key.asString();
                    String valueStr = value.identify();

                    switch (yaml_action) {
                        case INCREASE:
                            Set(yaml, index, keyStr, String.valueOf(aH.getIntegerFrom(Get(yaml, index, keyStr, "0")) + aH.getIntegerFrom(valueStr)));
                            break;
                        case DECREASE:
                            Set(yaml, index, keyStr, String.valueOf(aH.getIntegerFrom(Get(yaml, index, keyStr, "0")) - aH.getIntegerFrom(valueStr)));
                            break;
                        case MULTIPLY:
                            Set(yaml, index, keyStr, String.valueOf(aH.getIntegerFrom(Get(yaml, index, keyStr, "1")) * aH.getIntegerFrom(valueStr)));
                            break;
                        case DIVIDE:
                            Set(yaml, index, keyStr, String.valueOf(aH.getIntegerFrom(Get(yaml, index, keyStr, "1")) / aH.getIntegerFrom(valueStr)));
                            break;
                        case DELETE:
                            yaml.set(keyStr, null);
                            break;
                        case SET_VALUE:
                            Set(yaml, index, keyStr, valueStr);
                            break;
                        case INSERT:
                        {
                            List<String> list = yaml.getStringList(keyStr);
                            if (list == null)
                                list = new ArrayList<String>();
                            list.add(valueStr);
                            yaml.set(keyStr, list);
                            break;
                        }
                        case REMOVE:
                        {
                            List<String> list = yaml.getStringList(keyStr);
                            if (list == null)
                                break;
                            if (index > -1 && index < list.size()) {
                                list.remove(index);
                            }
                            else {
                                for (int i = 0; i < list.size(); i++) {
                                    if (list.get(i).equalsIgnoreCase(valueStr)) {
                                        list.remove(i);
                                        break;
                                    }
                                }
                                yaml.set(keyStr, list);
                                break;
                            }
                        }
                        case SPLIT:
                        {
                            List<String> list = yaml.getStringList(keyStr);
                            if (list == null)
                                list = new ArrayList<String>();
                            list.addAll(dList.valueOf(valueStr));
                            yaml.set(keyStr, list);
                            break;
                        }
                    }
                }
                else
                    dB.echoError("Unknown YAML ID '" + id + "'");
                break;

            case CREATE:
                if (yamls.containsKey(id))
                    yamls.remove(id);
                yamlConfiguration = new YamlConfiguration();
                yamls.put(id.toUpperCase(), yamlConfiguration);
                break;
        }

    }
View Full Code Here

Examples of net.aufdemrand.denizencore.utilities.YamlConfiguration

        // Returns a dList of all the keys at the path and all subpaths.
        // -->
        if (attribute.startsWith("list_deep_keys")) {
            Set<String> keys;
            if (path != null && path.length() > 0) {
                YamlConfiguration section = getYaml(id).getConfigurationSection(path);
                if (section == null) {
                    return;
                }
                keys = section.getKeys(true);
            }
            else {
                keys = getYaml(id).getKeys(true);
            }
            if (keys == null) {
                return;

            } else {
                ArrayList<String> list = new ArrayList<String>();
                list.addAll(keys);
                event.setReplaced(new dList(list).getAttribute(attribute.fulfill(1)));
                return;
            }
        }

        // <--[tag]
        // @attribute <yaml[<id>].list_keys[<path>]>
        // @returns dList
        // @description
        // Returns a dList of all the keys at the path.
        // -->
        if (attribute.startsWith("list_keys")) {
            Set<String> keys;
            if (path != null && path.length() > 0) {
                YamlConfiguration section = getYaml(id).getConfigurationSection(path);
                if (section == null) {
                    return;
                }
                keys = section.getKeys(false);
            }
            else {
                keys = getYaml(id).getKeys(false);
            }
            if (keys == null) {
View Full Code Here

Examples of net.aufdemrand.denizencore.utilities.YamlConfiguration

            if (keys.isEmpty())
                throw new ExceptionInInitializerError("Could not find any STEPS in " + getName() + "! Is the type on this script correct?");

            for (String step : keys) {
                if (step.contains("*")) {
                    YamlConfiguration defaultStepSection = getConfigurationSection("STEPS." + step);
                    step = step.replace("*", "");
                    set("STEPS." + step, defaultStepSection);
                    set("STEPS." + step + "*", null);
                    defaultStep = step;
                }
View Full Code Here

Examples of net.zurvanlabs.math.configuration.file.YamlConfiguration

    }
  }
 
  public static void main(String[] args)
      throws SlickException, FileNotFoundException, IOException, InvalidConfigurationException {
    yamlSettings = new YamlConfiguration();
   
    try {
      yamlSettings.load("settings.yml");
    } catch (FileNotFoundException e) {
      yamlSettings.set("settings.yamlGridX", 20);
      yamlSettings.set("settings.yamlGridY", 20);
      yamlSettings.set("settings.yamlGridW", 20);
      yamlSettings.set("settings.yamlGridH", 20);
      yamlSettings.set("settings.title", "Title");
      yamlSettings.set("settings.gui.yamlGuiFilename", "grid.yml");
      yamlSettings.set("settings.gui.yamlElementPrefix", "e_");
      yamlSettings.set("settings.gui.yamlLastID", "lid");
     
      yamlSettings.save("settings.yml");
      yamlSettings.load("settings.yml");
    }
   
    Source.yamlGridX = yamlSettings.getInt("settings.yamlGridX");
    Source.yamlGridY = yamlSettings.getInt("settings.yamlGridY");
    GuiElement.yamlGridW = yamlSettings.getInt("settings.yamlGridW");
    GuiElement.yamlGridH = yamlSettings.getInt("settings.yamlGridH");
    GuiElement.yamlGuiFilename = yamlSettings.getString("settings.gui.yamlGuiFilename");
    GuiElement.yamlPrefix = yamlSettings.getString("settings.gui.yamlElementPrefix");
    GuiElement.yamlLastID = yamlSettings.getString("settings.gui.yamlLastID");
    String title = yamlSettings.getString("settings.title");
   
    yamlElements = new YamlConfiguration();
   
    try {
      yamlElements.load(GuiElement.yamlGuiFilename);
    } catch (FileNotFoundException e) {
      yamlElements.set(GuiElement.yamlLastID, 0);
View Full Code Here

Examples of org.bukkit.configuration.file.YamlConfiguration

      data = YamlConfiguration.loadConfiguration(dataFile);
  
      // Look for defaults in the jar
      InputStream defConfigStream = getResource("data.yml");
      if (defConfigStream != null) {
          YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
          data.setDefaults(defConfig);
      }
  }
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.