Solved "#" comments in config.yml

Discussion in 'Spigot Plugin Development' started by fernandopal, May 31, 2017.

Thread Status:
Not open for further replies.
  1. Hello!

    I have tried to put comments in the config of my plugins (eg: #You can set this to true) but I do not get that when compiling the plugin appear or appear only the first lines.

    Can anyone help me?
     
  2. When you save a config file, all comments are deleted except the header (the command at the top of the file). I don't save my config file (since it's a config file, the player should modify and save it), so the comments I have specified in the config.yml file (in the resources folder, next to the plugin.yml) are preserved.
     
  3. You can actually save all of your comments by using this line of code:
    Code (Text):
    saveDefaultConfig();
    If you do that, then all of your comments will be there. Although I think it's noteworthy enough to mention that if you use saveConfig() then all of your comments, except for the header, will be removed. It's that reason alone that people have more than one config file in their plugins. So if aren't writing anything to your config.yml, then saveDefaultConfig() is just what you are looking for.
     
  4. Nothing, it does not work.

    Code (Text):
    @Override
    public void onEnable() {
            instance = this;
            chatprefix = getConfig().getString("ChatPrefix").replace("&", "§");
         
            registerEvents(this, new ChangeWorld(), new EntityDamage(), new EntityDamageByEntity());
            this.getCommand("fly").setExecutor(new Fly(this));
         
            cs.sendMessage(prefix + ChatColor.GREEN + "Plugin enabled");
            cs.sendMessage(prefix + ChatColor.DARK_AQUA + "Plugin made by fernandopal");
     
            saveDefaultConfig();
         
         
        }

    Code (Text):
    Messages:
      Unknown_command: '{prefix} &cUnknown command. Use &f/fly help &cfor more information.'
      No_permission: '{prefix} &cYou do not have permission to use this command.'
      creloaded: '{prefix} &aConfiguration reloaded'
      Start_fly: '{prefix} &aFlight mode enabled'
      Stop_fly: '{prefix} &cFlight mode disabled'
      Start_fly_others: '{prefix} &aFlight mode enabled for player &e{player}'
      Stop_fly_others: '{prefix} &cFlight mode disabled for player &e{player}'
      Player_is_not_online_or_is_null: '{prefix} &cThe specified player &e"{player}" &cis offline or does not exist'
      Speed_no_number: '{prefix} &cSpeed number can not be less than 1 or more than 10.'
      Int_Numb: '{prefix} &cPlease use a integer number'
      Max_Speed: '{prefix} &cThe number can not be more than 10'
      Min_Speed: '{prefix} &cThe number can not be minor than 1'
      Fly_Speed: '{prefix} &aFly speed set to: &7{speed}'
      Fall_Damage_Removed: '{prefix} &aYou are protected from falling damage while flying'
      You_Cant_Hit_This_Player: '{prefix} &cYou can not hit this player because he is flying'
      Fly_Check_Yes: '{prefix} &7The player &a{player} &7is flying.'
      Fly_Check_No:  '{prefix} &7The player &a{player} &7is not flying.'

    Helpmenu:
      Sfhelp: '&7Show this help menu.'
      Sfreload: '&7Reload the config.'
      Sfffly: '&7Enable/disable flight mode.'
      Sffflyothers: '&7Enable/disable flight mode for others players.'
      Sfspeed: '&7Set your flight speed.'
      Sfcheck: '&7Check if a player has flight mode enabled.'

    #If it set to true, the flight mode has been disabled when the player join other world.
    Disable-Fly-On-World-Change: true
    #If it set to true, the player with the permission "fly.falldamage" will not receive fall damage.
    Disable-Fall-Damage: true
    #If it set to true, the player with the permission "fly.invincible" will be invincible.
    Invincible: true

    ChatPrefix: '&b&lSimpleFly&f&l&m»»&r'
    Code (Text):
    Messages:
      Unknown_command: '{prefix} &cUnknown command. Use &f/fly help &cfor more information.'
      No_permission: '{prefix} &cYou do not have permission to use this command.'
      creloaded: '{prefix} &aConfiguration reloaded'
      Start_fly: '{prefix} &aFlight mode enabled'
      Stop_fly: '{prefix} &cFlight mode disabled'
      Start_fly_others: '{prefix} &aFlight mode enabled for player &e{player}'
      Stop_fly_others: '{prefix} &cFlight mode disabled for player &e{player}'
      Player_is_not_online_or_is_null: '{prefix} &cThe specified player &e"{player}" &cis offline or does not exist'
      Speed_no_number: '{prefix} &cSpeed number can not be less than 1 or more than 10.'
      Int_Numb: '{prefix} &cPlease use a integer number'
      Max_Speed: '{prefix} &cThe number can not be more than 10'
      Min_Speed: '{prefix} &cThe number can not be minor than 1'
      Fly_Speed: '{prefix} &aFly speed set to: &7{speed}'
      Fall_Damage_Removed: '{prefix} &aYou are protected from falling damage while flying'
      You_Cant_Hit_This_Player: '{prefix} &cYou can not hit this player because he is flying'
      Fly_Check_Yes: '{prefix} &7The player &a{player} &7is flying.'
      Fly_Check_No:  '{prefix} &7The player &a{player} &7is not flying.'

    Helpmenu:
      Sfhelp: '&7Show this help menu.'
      Sfreload: '&7Reload the config.'
      Sfffly: '&7Enable/disable flight mode.'
      Sffflyothers: '&7Enable/disable flight mode for others players.'
      Sfspeed: '&7Set your flight speed.'
      Sfcheck: '&7Check if a player has flight mode enabled.'

    #If it set to true, the flight mode has been disabled when the player join other world.
    Disable-Fly-On-World-Change: true
    #If it set to true, the player with the permission "fly.falldamage" will not receive fall damage.
    Disable-Fall-Damage: true
    #If it set to true, the player with the permission "fly.invincible" will be invincible.
    Invincible: true

    ChatPrefix: '&b&lSimpleFly&f&l&m\BB\BB&r'
     
  5. Um, it looks like it worked because in your spoiler for the config.yml (created by the plugin) you have comments. They are near the bottom, but you have them. Did you accidentally copy and paste twice? If not, then it worked.
     
  6. I copied it twice xd that fail, anyway I did not realize when I put the plugin that was the previous version, thanks: D
     
Thread Status:
Not open for further replies.