Skip to content

Configuration

Rick van Sloten edited this page Apr 22, 2022 · 3 revisions

Configuration

This wiki page is all about the configuration features! Many plugins use configuration and/or database files. TabuuCore helps with managing and creating multiple of these files, and parsing their contents.

Configuration manager

To manage configuration files you can make use of the ConfigurationManager. You can either create a new instance of this class yourself, or use TabuuCorePlugin instead of JavaPlugin as your main command. When using the TabuuCorePlugin class you can make use of the #getConfigurationManager() method.

You can now add a new configuration by doing:

getConfigurationManager().addConfiguration("config");

This will automatically add the config.yml file from your resource folder to the ConfigurationManager. This function will also return the created IConfiguration.

You can now get the IConfiguration by doing:

IConfiguration config = getConfigurationManager().getConfiguration("config");

IConfiguration

The IConfiguration interface is the abstract interpretation of a configuration file. It is implemented by TabuuCore's version of YamlConfiguration, which is also the default configuration type of the ConfigurationManager.

YamlConfiguration has the all methods of the Spigot/Bukkit variant, but with addition of the IConfiguration methods, most of which are self-explanatory.

Here is an example of one of the more advanced methods:

Map<OfflinePlayer, Location> locations;
locations = config.getMap("PlayerLocations", Serializer.OFFLINE_PLAYER, Serializer.LOCATION);

This method can create a HashMap from a simple configuration, like the one bellow:

PlayerLocations:
  5c9a9384-6c2d-432f-a2b5-d662b22cfee9: world 0 0 0
  b8700b43-31b0-4e0a-bc0b-9d67f0eff26d: world 0 0 1
  069a79f4-44e9-4726-a5be-fca90e38aaf5: the_end 23454 65 1.32 0.5 8.32

Clone this wiki locally