Skip to content

Configuration

Amaury Carrade edited this page May 16, 2016 · 15 revisions

This component simplifies the management of commands with sub-commands and aliases.

Documentation JavaDoc
Loader class
(for loadComponents)
See below

The concept

The old way to manage configuration is pretty annoying. You have to access the main plugin class everytime, the data types are limited, the configuration paths are hard-coded...

Using zLib, you transform this...

final Achievement achievement;
try
{
    achievement = Achievement.valueOf(MainPluginClass.get().getConfig().getString("my_section.achievement", "OPEN_INVENTORY");
}
catch (IllegalArgumentException e)
{
    achievement = Achievement.OPEN_INVENTORY;
    MainPluginClass.getInstance().getLogger().warning("Invalid achievement set in config; using default value.");
}

...into this:

final Achievement achievement = Config.MY_SECTION.ACHIEVEMENT.get();

Better, eh?

Clone this wiki locally