PYML 1.3.2 a homemade config API. It's pretty cool, I guess.

Discussion in 'Resources' started by pyraetos, Jan 27, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    pyraetos

    http://dev.bukkit.org/server-mods/pyml/

    I recently decided to make a configuration API (I don't think it's really a "markup language" but whatever) by myself basically for fun, but also because I enjoy logical reasoning and applications, and this was a good way for me to create something practical and useful. codename_B did a similar thing for his plugins with BML, which I thought was pretty cool.

    This isn't an alternative to YAML as it isn't that far in development; but, its basic functionality works well and is probably faster than using Bukkit's configuration API. It's best at making lists of stuff and the actual full name I'm calling it is Pyraetos List Organizing Markup Language.

    Downloads:

    Libraries: [​IMG] https://github.com/pyraetos/PYML/downloads

    Using the API:

    Use the sources from GitHub in your project to get access to the PYML API. At this point only PymlConfiguration has Javadoc for each method.

    The PymlConfiguration class:

    Construct a new PymlConfiguration using the constructor
    Code:
    public PymlConfiguration(File)
    The File parameter represents the target directory (i.e. example.pyml).

    Use the load() and save() methods in the same way as you would with the old Bukkit configuration, or in the same way as you would with JavaPlugin.reloadConfig() and JavaPlugin.saveConfig().

    Since PYML is list-oriented, the accessors return arrays. No big deal, if there was only one value, the array will only be 1 long. I am planning on adding single-return accessors in the near future though.

    If you need to use any other classes, the methods should be straightforward enough until I make more Javadoc.

    Example:


    Code used:
    Code:
            try{
                File file = new File("C:/Users/Pyraetos/Desktop/PYML" + File.separator + "config.pml");
                PymlConfiguration pyml = new PymlConfiguration(file);
     
                pyml.load();
         
                pyml.set("INTEGER", 1);
                pyml.set("INTEGER.TWO", 2);
                pyml.set("BOOLEAN", true);
         
                List<String> strings = Arrays.asList("string", "thing", "bling", "wring");
                pyml.setList("STRING_LIST", strings);
     
                pyml.save();
            } catch (PymlException e) {
                e.printStackTrace();
            }
    Output config.pml:


    HTML:
    # PYML 1.3.1 by pyraetos. http://www.pyraetos.net
    INTEGER{1, TWO{2}}
    BOOLEAN{true}
    STRING_LIST{string, thing, bling, wring}
    


    Standards:

    The file extension for PYML files should be .pml, .pyml, or .txt

    Typically, keys should be in UPPER_CASE or UpperCamelCase. This is easier to read with the nested list system.

    Change Log:

    PYML v1.3.1
    • Added nested lists
    • Added comment support
    PYML v1.2:
    • Added methods for appending values to nodes.
    PYML v1.1:
    • Added methods for setting the header.
    PYML v1.0:
    • First release, no changes.
    To-Do:

    • Add methods for changing the currently constant header.
    • Add add methods in addition to set methods for ease of use.
    • Add methods for adding comments.
    • Add Javadoc to all classes.
    • Add more subclasses of PymlConfiguration such as short node, char node, etc.
    • Add overloaded methods that take different forms of values besides varargs.
    • Add more config features, such as nested lists.
     
  2. Offline

    hammale

    lol cool idea :D
     
  3. Offline

    DrAgonmoray

    Isn't that PascalCase?
     
  4. Offline

    pyraetos

  5. Offline

    pyraetos

    Big update. 1.3.1
     
  6. Can i help you on this maybe? I was looking for a project to work on beside a plugin :D
    (PS i really want to try coding an API)
     
  7. Offline

    md_5

    I am so gonna post my annotation based one now :p
     
Thread Status:
Not open for further replies.

Share This Page