Skip to content

Comments

Xezard edited this page Oct 10, 2020 · 3 revisions

You can specify comments for your fields in the configuration:

@Getter
public class MessagesConfiguration
extends Configuration
{
    public MessagesConfiguration(Folder folder)
    {
    	super(folder.getAbsolutePath() + File.separator + "messages.yml");
    }
	
    @ConfigurationField("Hello-world.With-comment-above")
    @ConfigurationComments({"# First comment line", "# Second comment line"})
    public String helloWorld = "Hello, world!";
}

After calling the load() method, you will see the following configuration:

# First comment line
# Second comment line
Hello-world:
  With-comment-above: Hello, world!

You can also specify a header for the configuration by simply placing the @ConfigurationComments annotation above the class declaration:

@Getter
@ConfigurationComments({"This is configuration header comment"})
public class MessagesConfiguration
extends Configuration
{
    public MessagesConfiguration(Folder folder)
    {
    	super(folder.getAbsolutePath() + File.separator + "messages.yml");
    }
	
    @ConfigurationField("Hello-world.With-comment-above")
    @ConfigurationComments({"# First comment line", "# Second comment line"})
    public String helloWorld = "Hello, world!";
}

Clone this wiki locally