Config #

Discussion in 'Plugin Development' started by MetaSurvival, Sep 22, 2013.

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

    MetaSurvival

    In my config how would I do this: (for example):
    Code:
    #####Created by MetaSurvival#####
    ##Go to [website]##
    etc
    
     
  2. Offline

    kreashenz

    MetaSurvival
    Create a config and put the comments inside of it, then in your onEnable method use saveDefaultConfig();. That should work.
     
    MetaSurvival likes this.
  3. Offline

    MetaSurvival

  4. Offline

    kreashenz

    MetaSurvival What does it print out in the config when you use it?
     
    MetaSurvival likes this.
  5. Offline

    MetaSurvival

    kreashenz
    In the config it sets nicknames of players
     
  6. Offline

    kreashenz

    Any errors in console?
     
    MetaSurvival likes this.
  7. Offline

    MetaSurvival

  8. Offline

    kreashenz

    MetaSurvival What is in your config? Post the contents of it.
     
    MetaSurvival likes this.
  9. Offline

    MetaSurvival

    kreashenz
    ##Do not touch nicknames!##

    Then when a player does /nickname &bHello.. It sets the values of:
    {PLAYER} = &bHello
     
  10. Offline

    kreashenz

    MetaSurvival So it is printing out "## Do not touch nicknames! ##" when you're using saveDefaultConfig()?
     
    MetaSurvival likes this.
  11. Offline

    MetaSurvival

    kreashenz
    No, I just have ## Do not touch nicknames! ## in my config in Eclipse. But when I export it, it dosen't show in the config.
     
  12. Offline

    kreashenz

    MetaSurvival
    getConfig().options().copyDefaults(true);
    saveConfig();

    or

    saveResource("config.yml", false);

    Try using them..
     
    MetaSurvival likes this.
  13. Offline

    FurmigaHumana

    Try "getConfig().options().copyHeader(true);"
     
    MetaSurvival likes this.
  14. Offline

    MetaSurvival

    kreashenz
    This is my onEnable:
    Code:
    @Override
    public void onEnable(){
    saveDefaultConfig();
    getConfig().options().copyDefaults(true);
    saveConfig();
    this.getServer().getPluginManager().registerEvents((this), this);
    }
    
     
  15. Offline

    kreashenz

    MetaSurvival I think use saveResource("config.yml", false);.
     
    MetaSurvival likes this.
  16. Offline

    MetaSurvival

    FurmigaHumana
    It's still not working.. ;s I think maybe my nicknames is overriding it something...?

    This is how I'm setting the nicknames in the config:
    this.getConfig().set(target.getName(), target.getDisplayName());

    kreashenz
    Nope ;3

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  17. Offline

    FurmigaHumana

    Before using the 'saveConfig', use the getConfig().options().header("the stuff here"); first, then the copyHeader(true). then saveConfig().. see if that works
     
    MetaSurvival likes this.
  18. Offline

    MetaSurvival

  19. Offline

    kreashenz

    MetaSurvival I'm using saveResource("config.yml", false); and it's working fine.. Even test for yourself.

    https://www.dropbox.com/s/6kl0byvjivunous/Test.jar

    source:
    Code:java
    1. package me.kreashenz.potato;
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4.  
    5. public class Tsest extends JavaPlugin {
    6.  
    7. public void onEnable(){
    8. saveResource("config.yml", false);
    9. }
    10.  
    11. }


    [EDIT] Oh wait, all the posts popped up after I posted this.
     
    MetaSurvival likes this.
  20. Offline

    MetaSurvival

    FurmigaHumana
    What would I do to add more than 1 line with ## ?
    This is the on enable:
    Code:
    @Override
    public void onEnable(){
    saveDefaultConfig();
    getConfig().options().copyDefaults(true);
    getConfig().options().header("## Do not touch nicknames! ##").copyHeader(true);
    saveConfig();
    this.getServer().getPluginManager().registerEvents((this), this);
    }
    
     
  21. Offline

    FurmigaHumana

    Use \n to set new lines.
    getConfig().options().header("## line 1 ## \n ## line 2 ## \n # lin3..... ").copyHeader(true);
     
Thread Status:
Not open for further replies.

Share This Page