Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Config set

Comments in 'Plugin Development' started by Samueljh1, Feb 20, 2015.

  1. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Hi, I'm having some issues with configs

    How can I:

    • Save a certain part of a config without deleting everything else,
    • Reload config properly
    Here is my set and reload code:

    PHP:
    $this->getConfig()->set("prefix",$args[1]);
    $this->getConfig()->save();
    $this->reloadConfig();
    This works, but here is the before and after look of my config:

    Before:
    PHP:
    ---
    #Announcer Config File

    ###########################
    #        Announcer        #
    #       By Samueljh1      #
    ###########################

    #Note: All of these settings can be changed IN-Game!
    #It is highly reccomended that you use the commands instead!
    #Do '/announcer help' for a list of commands.

    prefix"!"
    op-onlyfalse
    enabled
    true
    ...
    After:
    PHP:
    ---
    prefix'#'
    op-onlyfalse
    enabled
    true
    ...

    Also, the config doesn't reload!
    Last edited: Feb 20, 2015
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What do you mean the config doesn't reload?
    If you save() it, you don't need to reload it because it must be the same.
    Also, comments of the config are cleared if you do save(). If you want to keep them, don't use save().
  3. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    So how can I save it with comments? Also, what I mean by it not reloading is after I reload and check, it gets the old value, not the new one.
  4. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    nvm I just forgot to reassign a var xD
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    1. You can't retain the contents after using save() AFAIK
    2. You save() it, so values in the config are overwritten.
  6. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    ^^

Share This Page

Advertisement