Using true and false in config?

Discussion in 'Plugin Development' started by PingschelleMC, Sep 18, 2014.

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

    PingschelleMC

    Hey, I was wondering how I could use true and false in my config-file to enable messages for example.
    I tried this:
    Code:java
    1. getConfig().addDefault("join-message", true);


    ".addDefault" is being underlined. Does anybody have a solution?

    - PingschelleMC
     
  2. Offline

    Epicballzy

    You are on the right track :)
    This is what I usually do for my configs:
    Code:java
    1. public void onEnable() {
    2. setup();
    3. }
    4.  
    5. private void setup() {
    6. if(yourFile.exists)return;
    7. yourFile.set("enabled", true);
    8. }


    This is just an example...
     
  3. Offline

    Unica

    PingschelleMC

    Code:java
    1. getConfig().set("path", boolean);


    if you want to save more data later, you could create a method for that.

    Code:java
    1. public void saveData(String path, Object value){
    2. getConfig().set(path, value);
    3. saveConfig();
    4. }


    Then u can just

    Code:java
    1. saveData("your path", true);
     
  4. Offline

    fireblast709

    PingschelleMC what does it say when you hover over it? That line itself is completely fine.
     
  5. Offline

    PingschelleMC


    Thanks dude. :) Working well!


    Using other method now.


    Using other method now, anyway, thanks.
     
  6. Offline

    fireblast709

    PingschelleMC you do know that the method you are currently using does not add a default, but rather overrides the config, right? (Not saying that the method is incorrect, but this would not allow anyone to turn it off since each reload/restart would enable it again)
     
Thread Status:
Not open for further replies.

Share This Page