Config file with tips

Discussion in 'Plugin Development' started by mig4ng, Nov 8, 2012.

Thread Status:
Not open for further replies.
  1. Hi, i'm developing MoreThanFish, but i'm having a little insiginficant problem for me, but it can help the users of it.
    I want to create a config file like this:
    Code:
    #Configuration of MoreThanFish Plugin created by mig4ng
     
    #General Options
    options:
    #If you want a different number of rarecatches be sure you change this for whatever is the number of rarecatches you want.
      rarecatches: 3
     
    #Each rare drop options
    #This plugin uses the following ids: http://jd.bukkit.org/apidocs/org/bukkit/Material.html
    #You can use decimals in percentage like '2.5' or '1.3'...
    '1':
      percentage: 2.5
      itemid: DIAMOND
      message: '&eYou''ve caught a &bdiamond&e, Lucky You!'
    '2':
      percentage: 2.5
      itemid: EMERALD
      message: '&eYou''ve caught a &aEmerald&e!'
    '3':
      percentage: 12.3
      itemid: LEATHER_BOOTS
      message: '&eBah... You''ve caught some old &cBoots&e, probably it was from a fisherman.'
    #'4';
    #  percentage: 12.3
    #  itemid: TNT
    #  message: '&eThis water is so polluted that you caught a &cTNT.'
    But when i put the plugin on plugins folder it creates a config.yml file like this:
    Code:
    #
    #  percentage: 12.3
    #  itemid: TNT
    #  message: '&eThis water is so polluted that you caught a &cTNT.'
     
    options:
      rarecatches: 3
    '1':
      percentage: 2.5
      itemid: DIAMOND
      message: '&eYou''ve caught a &bdiamond&e, Lucky You!'
    '2':
      percentage: 2.5
      itemid: EMERALD
      message: '&eYou''ve caught a &aEmerald&e!'
    '3':
      percentage: 12.3
      itemid: LEATHER_BOOTS
      message: '&eBah... You''ve caught some old &cBoots&e, probably it was from a fisherman.'
    I'm using this to create the file:
    Code:
        @Override
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info("[" + pdfFile.getName() + "] " + " Plugin disabled.");
            saveConfig();
        }
       
        @Override
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info("[" + pdfFile.getName() + "] " + "Plugin Enabled. " + " Version " + pdfFile.getVersion());
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents(this.pl, this);
            getConfig().options().copyDefaults(true);
            saveConfig();
        }
    Also i wanna know why the file can't be modificated while server is oppened, it needs to be off, save and then start the server, so this way i can't use reload for changes.
     
  2. Offline

    fireblast709

    partial answer to the first: reading the actual config and what you want, try a ' ' after the # (without ')

    question about the second: where is the config.yml you want to edit located? (just asking)
     
  3. MoreThanFish/config.yml
     
Thread Status:
Not open for further replies.

Share This Page