Solved Command that edit config

Discussion in 'Plugin Development' started by RojoTheDev, Apr 2, 2014.

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

    RojoTheDev

    So i'm making an anti-swear plugin, and it's working already :D.
    But i want a command in my plugin, adding an command is not hard to make but an command that add something in the config is something harder. This is what i want:

    /badwordadd (badword)

    Then the badwords comes into my config that's look like this:

    Code:java
    1.  
    2. badwords:
    3. - badword1
    4. - badword2
    5. - //here comes the badword that you add with the command
    6.  


    Is this possible?
     
  2. Offline

    viper_monster

    RojoTheDev

    List<String> badWords = getConfig().getStringList("badwords");

    badWords.add("badword3");
    badWords.add("badword4");
    badWords.add("badword5");

    getConfig().set("badwords", badWords);
     
    The Fancy Whale likes this.
  3. Offline

    The Fancy Whale

    Possibly the most vulgar plugin I have seen in my entire life.
    Lol jk, I know its just for removing the bad words, but do as spoljo666 said
     
  4. Offline

    RojoTheDev

    spoljo666 The Fancy Whale Removing? I want that the command add an badword. And with badword1 i mean a word like noob or something.
    So when you do /badwordadd whale
    It comes:
    Code:java
    1.  
    2. badwords:
    3. - badword1
    4. - badword2
    5. - //HERE
    6.  
     
  5. Offline

    MistPhizzle

    Don't forget plugin.saveConfig(), otherwise the data wont persist through a reload.
     
    spoljo666 likes this.
  6. Offline

    The Fancy Whale

    I meant the plugin functionality is probably for removing badwords, not talking about the current code. (It was a joke)
     
  7. Offline

    RojoTheDev

Thread Status:
Not open for further replies.

Share This Page