-
Notifications
You must be signed in to change notification settings - Fork 0
Using BetterYaml
First, make sure your project meets the setup requirements described in the setup wiki page.
Next, consider using OptionalBetterYaml, this is an improvement upon BetterYaml as it does not require you to catch exceptions. BetterYaml is meant for internal use only but remains public to not break projects that are updating. Note that the BetterYaml is deprecated but will not be removed (it serves as motivation to switch to OptionalBetterYaml).
When using the BetterYaml class to handle our files:
An IOException is thrown when your setup contains errors.
We are assuming that javaPlugin is an instance of your class that extends JavaPlugin. In an instance of that class, you can also pass this instead.
// Auto-updates the config on the server and loads a YamlConfiguration and File
BetterYaml ourConfig = new BetterYaml("ourConfig.yml", javaPlugin);
// Get a YamlConfiguration to do your regular config reading
YamlConfiguration yaml = ourConfig.getYamlConfiguration();
// Not enough? You can also get a File instance
File file = ourConfig.getFile();
Please use OptionalBetterYaml instead.
Auto-correct faulty configuration values! You can create your own, custom validators.