Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

collapse

Author Topic: built in SnakeYAML  (Read 698 times)

UnknownUser500

  • Member

  • Offline
  • *

  • 30
  • Reputation:
    +1/-0
  • Personal Text
    Who am I?
    • View Profile
    • My Blog
built in SnakeYAML
« on: December 17, 2016, 09:29:44 AM »
Could you add souport for built in yaml?

Fredashay

  • Plug-in Maker
  • Sr. Member

  • Offline
  • ****

  • 268
  • Reputation:
    +26/-1
  • Personal Text
    "Tira mah! This graw is fredashay!"
    • View Profile
    • ClockPie
Re: built in SnakeYAML
« Reply #1 on: December 17, 2016, 11:50:34 AM »
FWIW, my plugins save files between sessions in CSV format.  IMO, that's the easiest, by far, for a human to see at a glance and edit and change...

Bayside308

  • Plug-in Maker
  • Full Member

  • Offline
  • ****

  • 216
  • Reputation:
    +10/-0
    • View Profile
Re: built in SnakeYAML
« Reply #2 on: December 17, 2016, 01:46:24 PM »
FWIW, my plugins save files between sessions in CSV format.  IMO, that's the easiest, by far, for a human to see at a glance and edit and change...

I have to admit, I love Bukkit's way of handling config files (saveDefaultConfig(), etc.), and it'd make it a lot easier for me to add customization to my plugins if Rainbow added a similar function.
Coming out with a Rainbow Network soon!

JD9999

  • Plug-in Maker
  • Hero Member

  • Offline
  • ****

  • 751
  • Reputation:
    +45/-0
    • View Profile
Re: built in SnakeYAML
« Reply #3 on: December 19, 2016, 07:59:17 PM »
FWIW, my plugins save files between sessions in CSV format.  IMO, that's the easiest, by far, for a human to see at a glance and edit and change...

I have to admit, I love Bukkit's way of handling config files (saveDefaultConfig(), etc.), and it'd make it a lot easier for me to add customization to my plugins if Rainbow added a similar function.

When I finish the Shared Packages update (#3 on my list at the moment), it will come wit an EncoderWriter, which writes all content to a file with one of the built in file encoding mechanisms. I could add a way for this to save a config. Your choice whether you want it to be readable by humans or scrambled with two codes.

UnknownUser500

  • Member

  • Offline
  • *

  • 30
  • Reputation:
    +1/-0
  • Personal Text
    Who am I?
    • View Profile
    • My Blog
Re: built in SnakeYAML
« Reply #4 on: January 22, 2017, 08:59:08 AM »
Pull Request for YAML configuration: https://github.com/CodeCrafter47/Rainbow/pull/19

CodeCrafter47

  • Administrator
  • Hero Member

  • Online
  • *****

  • 514
  • Reputation:
    +130/-2
    • View Profile
Re: built in SnakeYAML
« Reply #5 on: January 25, 2017, 03:01:45 AM »
I see that you want a configuration API, but creating random pull requests to add properties, xml and now yaml configuration support is not the proper way to do it.

I know I've been lazy in replying to this issue, so it's also kind of my fault. Point is I think we should first discuss how we want our configuration API to work before we create one.

The way I see it there are several points we have too look at. First is which file format to use. There are several options. We could use YAML (which is used by Bukkit and BungeeCord), HOCON (used by Sponge), plain old Java Properties (very simple) or something else. Each has it's own advantages and disadvantages.

Another thing to decide is whether we want to write the configuration API completely ourselves, which would be a lot of work, not only writing it in the first place, but also maintaining it. The other option is to use an existing API, for example we could add the BungeeCord config module which provides a YAML based config API similar to Bukkit's API.

Bayside308

  • Plug-in Maker
  • Full Member

  • Offline
  • ****

  • 216
  • Reputation:
    +10/-0
    • View Profile
Re: built in SnakeYAML
« Reply #6 on: January 25, 2017, 02:29:06 PM »
I would love a system very similar to Bukkit's. I think YML is the most readable way to have "advanced" configurations, as compared to the "hard to read" XML and "basic" properties.
Coming out with a Rainbow Network soon!

JD9999

  • Plug-in Maker
  • Hero Member

  • Offline
  • ****

  • 751
  • Reputation:
    +45/-0
    • View Profile
Re: built in SnakeYAML
« Reply #7 on: January 25, 2017, 02:31:42 PM »
I agree with Bayside. I could read YML in Notepad. Other formats I can't. Also because Bukkit had so many plugins that all had configs that all loaded fine, we can safely assume that it works and therefore the only trouble would be to implement it in Rainbow.

CodeCrafter47

  • Administrator
  • Hero Member

  • Online
  • *****

  • 514
  • Reputation:
    +130/-2
    • View Profile
Re: built in SnakeYAML
« Reply #8 on: February 16, 2017, 08:18:07 AM »
Rainbow now includes a YAML based config API. Basically we use the BungeeCord config API (have a look at the documentation: https://www.spigotmc.org/wiki/using-the-bungee-configuration-system/) and there are some convenience methods to access the config file.

Here's a code example:
Code: [Select]
public void onStartup(MC_Server server) {
    Configuration config = getConfig();

    // alternatively use the following line to save the default config from the plugin jar
    // Configuration config = getConfig(true);

    // reading config values
    boolean option1 = config.getBoolean("option1");
    int option2 = config.getInt("option2");

    // writing config values
    config.set("option", 47);
    saveConfig();
}

FabioZumbi12

  • Plug-in Maker
  • Hero Member

  • Offline
  • ****

  • 527
  • Reputation:
    +62/-1
  • Personal Text
    Brainnssss
    • View Profile
    • Area Z12 Brasil
Re: built in SnakeYAML
« Reply #9 on: September 21, 2017, 03:00:27 PM »
Seems to be good a yaml parser for Rainbow. If i can suggest, what you think to add comments on yaml files configurations? I have writen a class for my plugin but you can take part of this and add on API.

https://github.com/FabioZumbi12/RedProtect/blob/master/RedProtect-Spigot/src/main/java/br/net/fabiozumbi12/RedProtect/config/RPCommentedConfig.java

Good to see Rainbow still alive ^^

Fredashay

  • Plug-in Maker
  • Sr. Member

  • Offline
  • ****

  • 268
  • Reputation:
    +26/-1
  • Personal Text
    "Tira mah! This graw is fredashay!"
    • View Profile
    • ClockPie
Re: built in SnakeYAML
« Reply #10 on: September 21, 2017, 06:50:28 PM »
Seems to be good a yaml parser for Rainbow. If i can suggest, what you think to add comments on yaml files configurations? I have writen a class for my plugin but you can take part of this and add on API.

https://github.com/FabioZumbi12/RedProtect/blob/master/RedProtect-Spigot/src/main/java/br/net/fabiozumbi12/RedProtect/config/RPCommentedConfig.java

Good to see Rainbow still alive ^^

I would have voted for "plain old Java properties," but since everybody seems to be agreeing on YAML, I can live with that.  My plugins use CSV files for configuration and data storage, anyway :-p

 

* Notifications