Config question.

Discussion in 'Plugin Development' started by MrMag518, Dec 29, 2011.

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

    MrMag518

    I've used the old Configuration method
    PHP:
    public Configuration config;
    but as it's covered with a line , I suppose bukkit will delete/remove it completly soon. I can copy/paste some code here:
    This is my defined config methods:
    PHP:
    public Configuration config;
            public 
    Boolean configBoolean;
            public 
    String configString;
            public 
    Integer configInt;
    But if I use
    PHP:
    public FileConfiguration config;
    and still keep this:
    PHP:
    configBoolean config.getBoolean("La.lo-la"true);
    Will it work?
    And how would I then load the config?
    as
    PHP:
    config.load();
    Is getting a red line, and I don't seem to find how to load it.
    Anyone?
     
  2. Offline

    theguynextdoor

    Code:java
    1.  
    2.  
    3. final FileConfiguration config = this.getConfig();
    4.  
    5. config.options().header("Yo this is a header example");
    6. config.addDefault("Example.Boolean", true);
    7. config.addDefault("Example.String", "Exampling it up");
    8. config.addDefault("Example.Int", 5);
    9.  
    10. config.options().copyDefaults(true);
    11. saveConfig();


    Note: You need the
    Code:java
    1. config.options().copyDefaults(true);
    2. saveConfig();

    For it to make the config file.

    And to get those booleans, strings and ints.

    Code:java
    1.  
    2. config.getBoolean("Example.Boolean");
    3. config.getInt("Example.Int");
    4. config.getString("Example.String");


    And example use for the boolean
    Code:java
    1. if (config.getBoolean("Example.Boolean")) {
    2. //Do stuff if boolean is true
    3. }else{
    4. //Do other stuff instead
    5. }


    And to set things like in a command or whatever.

    Code:java
    1. config.set("Example.String", "Changing it to another example string");
    2. saveConfig();
     
  3. Offline

    MrMag518

    @theguynextdoor
    Damnit, means I have to change the whole f'ing plugin then.. this can take some time..
     
  4. Offline

    theguynextdoor

    Dont worry, i rather like the new config, and it is rather simple when you get the hang of it. But then again, i only recently starting developing plugins, and so i only started using the new config stuff when it was new.
     
Thread Status:
Not open for further replies.

Share This Page