<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.traincarts.net/index.php?action=history&amp;feed=atom&amp;title=BKCommonLib%2FConfigurationAPI</id>
	<title>BKCommonLib/ConfigurationAPI - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.traincarts.net/index.php?action=history&amp;feed=atom&amp;title=BKCommonLib%2FConfigurationAPI"/>
	<link rel="alternate" type="text/html" href="https://wiki.traincarts.net/index.php?title=BKCommonLib/ConfigurationAPI&amp;action=history"/>
	<updated>2026-05-09T11:17:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.13</generator>
	<entry>
		<id>https://wiki.traincarts.net/index.php?title=BKCommonLib/ConfigurationAPI&amp;diff=7883&amp;oldid=prev</id>
		<title>RyanDo at 09:53, 12 October 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.traincarts.net/index.php?title=BKCommonLib/ConfigurationAPI&amp;diff=7883&amp;oldid=prev"/>
		<updated>2025-10-12T09:53:35Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:53, 12 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[BKCommonLib|« Go back]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Introduction==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Introduction==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Let&amp;#039;s be honest here...YAML configuration is a pain to work with. The defaults system requires additional files to be added, it is impossible to automatically cast types, and the support for headers is terrible. The Configuration API makes working with configuration a breeze.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Let&amp;#039;s be honest here...YAML configuration is a pain to work with. The defaults system requires additional files to be added, it is impossible to automatically cast types, and the support for headers is terrible. The Configuration API makes working with configuration a breeze.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key pulseco1_mediawiki:diff::1.12:old-90:rev-7883 --&gt;
&lt;/table&gt;</summary>
		<author><name>RyanDo</name></author>
	</entry>
	<entry>
		<id>https://wiki.traincarts.net/index.php?title=BKCommonLib/ConfigurationAPI&amp;diff=90&amp;oldid=prev</id>
		<title>RyanDo: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.traincarts.net/index.php?title=BKCommonLib/ConfigurationAPI&amp;diff=90&amp;oldid=prev"/>
		<updated>2020-11-17T21:36:09Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:36, 17 November 2020&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key pulseco1_mediawiki:diff::1.12:old-89:rev-90 --&gt;
&lt;/table&gt;</summary>
		<author><name>RyanDo</name></author>
	</entry>
	<entry>
		<id>https://wiki.traincarts.net/index.php?title=BKCommonLib/ConfigurationAPI&amp;diff=89&amp;oldid=prev</id>
		<title>Bergerhealer Wiki&gt;Andre601: /* Headers */</title>
		<link rel="alternate" type="text/html" href="https://wiki.traincarts.net/index.php?title=BKCommonLib/ConfigurationAPI&amp;diff=89&amp;oldid=prev"/>
		<updated>2020-09-27T16:53:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Headers&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[BKCommonLib|« Go back]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Let&amp;#039;s be honest here...YAML configuration is a pain to work with. The defaults system requires additional files to be added, it is impossible to automatically cast types, and the support for headers is terrible. The Configuration API makes working with configuration a breeze.&lt;br /&gt;
&lt;br /&gt;
Configuration node and value paths are delimited by &amp;#039;.&amp;#039;-characters. To obtain the value of setting in the node settings, you would use path settings.setting.&lt;br /&gt;
&lt;br /&gt;
Usage&lt;br /&gt;
Configuration works using stored nodes in a tree of data, as this is how YAML operates.&lt;br /&gt;
&lt;br /&gt;
Loading and saving configuration&lt;br /&gt;
We will mainly cover configuration reading from file and saving to file. The API is built around the principle to read and write files, so there is little support for anything else. If you wish to read or write to another storage system, you can use the loadFromStream and saveToStream methods found in [https://github.com/bergerkiller/BKCommonLib/blob/master/src/main/java/com/bergerkiller/bukkit/common/config/BasicConfiguration.java BasicConfiguration].&lt;br /&gt;
&lt;br /&gt;
To start a new configuration for a file in, for example, plugin enable, you can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;FileConfiguration config = new FileConfiguration(this, &amp;quot;config.yml&amp;quot;);&lt;br /&gt;
if (config.exists()) {&lt;br /&gt;
    config.load(); // Load the configuration from the file&lt;br /&gt;
} else {&lt;br /&gt;
    config.set(&amp;quot;config1&amp;quot;, 12);&lt;br /&gt;
    config.set(&amp;quot;config2&amp;quot;, 14);&lt;br /&gt;
    config.save(); // Saves the new data to file&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
System.out.println(config.get(&amp;quot;config1&amp;quot;, Integer.class));&lt;br /&gt;
System.out.println(config.get(&amp;quot;config2&amp;quot;, Integer.class));&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Getting values and their defaults==&lt;br /&gt;
There is a major difference in getting values between this API and the default Bukkit implementation. In the Configuration API, the defaults specified are automatically set in the configuration if the value was not found. This makes it tonnes easier to start a (new) configuration. In the example above it first checked if the file exists, but this can be done a lot easier:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;FileConfiguration config = new FileConfiguration(this, &amp;quot;config.yml&amp;quot;);&lt;br /&gt;
config.load();&lt;br /&gt;
System.out.println(config.get(&amp;quot;config1&amp;quot;, 12));&lt;br /&gt;
System.out.println(config.get(&amp;quot;config2&amp;quot;, 14));&lt;br /&gt;
config.save();&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Loading is allowed if the file does not exist, it will simply not load anything in that case. When getting the two values, it will automatically assign &amp;#039;12&amp;#039; to &amp;#039;config1&amp;#039; if such a node was not loaded. When saving, it will automatically update these values.&lt;br /&gt;
&lt;br /&gt;
Various stored types are supported, including all enumeration types (like Material and GameMode). To perform the same as the above but with Lists or Arrays, you can do the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;List&amp;lt;Integer&amp;gt; ints = config.getList(&amp;quot;blockIds&amp;quot;, Integer.class);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will automatically create an empty list in this case if it wasn&amp;#039;t set. If you wish to specify defaults as well: this is possible. Non-integer convertable values are automatically filtered from the list, so no worries of having a String in there.&lt;br /&gt;
&lt;br /&gt;
==Nodes==&lt;br /&gt;
YAML is a tree-based storage system, so support for Configuration Nodes is there as well. You do not have to use node objects to create nodes, but they can make it easier to pass around configuration in your plugin to several components. You can use getNode(path) to get a node. If the node does not yet exist, it is made and returned. For that reason, this method never returns null.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ConfigurationNode entities = config.getNode(&amp;quot;entities&amp;quot;);&lt;br /&gt;
maxCount = entities.get(&amp;quot;maxCount&amp;quot;, 225);&lt;br /&gt;
message = entities.get(&amp;quot;message&amp;quot;, &amp;quot;You have reached the maximum amount of entities&amp;quot;);&lt;br /&gt;
EntityLogic.initialize(entities);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no difference between ConfigurationNode functionality and Configuration functionality - File/Basic Configuration is a node as well. The only difference is that a ConfigurationNode does not store information such as file, indent and other settings.&lt;br /&gt;
&lt;br /&gt;
==Headers==&lt;br /&gt;
The Configuration API adds support for configuration headers, to give useful descriptions of configuration nodes and values. It produces output such as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# This is the configuration of MyAwesomePlugin&lt;br /&gt;
&lt;br /&gt;
# Sets the awesomeness of this plugin&lt;br /&gt;
awesomeness: 85&lt;br /&gt;
&lt;br /&gt;
# Controls what levels of awesomeness are enabled&lt;br /&gt;
enabledLevels:&lt;br /&gt;
  # Whether awesome looks are enabled&lt;br /&gt;
  looks: true&lt;br /&gt;
  # Whether awesome usage is enabled&lt;br /&gt;
  usage: false&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, the first header (the &amp;#039;main&amp;#039; header) has a slightly different syntax. This is to prevent the first node header (awesomeness) from conflicting with the main header. Setting node headers is very easy:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;// Set the top-level header&lt;br /&gt;
config.setHeader(&amp;quot;This is the configuration of MyAwesomePlugin&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Set the header of an option&lt;br /&gt;
config.setHeader(&amp;quot;awesomeness&amp;quot;, &amp;quot;\nSets the awesomeness of this plugin&amp;quot;);&lt;br /&gt;
config.setHeader(&amp;quot;enabledLevels&amp;quot;, &amp;quot;\nControls what levels of awesomeness are enabled&amp;quot;);&lt;br /&gt;
config.setHeader(&amp;quot;enabledLevels.looks&amp;quot;, &amp;quot;Whether awesome looks are enabled&amp;quot;);&lt;br /&gt;
config.setHeader(&amp;quot;enabledLevels.usage&amp;quot;, &amp;quot;Whether awesome usage is enabled&amp;quot;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use the newline character &amp;#039;\n&amp;#039; to have multiple header lines, or to create empty lines (as seen in the example). There is also an addHeader method, which basically appends more text to the current header on a new line. This is somewhat equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;config.setHeader(&amp;quot;awesomeness&amp;quot;, config.getHeader(&amp;quot;awesomeness&amp;quot;) + &amp;quot;\n&amp;quot; + &amp;quot;Something added on a new line&amp;quot;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
By setting defaults while getting data from a configuration, it is a lot easier to perform loading and saving. The addition of per-node headers allows configuration fil&lt;/div&gt;</summary>
		<author><name>Bergerhealer Wiki&gt;Andre601</name></author>
	</entry>
</feed>