Package be.dezijwegel.betteryaml
Class OptionalBetterYaml
java.lang.Object
be.dezijwegel.betteryaml.OptionalBetterYaml
- All Implemented Interfaces:
IOptionalConfigReader
public class OptionalBetterYaml extends Object implements IOptionalConfigReader
A wrapper around BetterYaml, handling all Exceptions and working with Optional to show where errors have happened
-
Constructor Summary
Constructors Constructor Description OptionalBetterYaml(String name, ValidationHandler validationHandler, org.bukkit.plugin.java.JavaPlugin plugin)Handles IOException internally for those who want to avoid handling try-catches A File and YamlConfiguration can later be retrieved as an Optional Creates a BetterYaml instance that will handle your config files For the server's file: Missing options will be autocompleted and comments will be updated based on the template No settings will be changed Will not log any messages to the consoleOptionalBetterYaml(String name, ValidationHandler validationHandler, org.bukkit.plugin.java.JavaPlugin plugin, boolean doLogging)Handles IOException internally for those who want to avoid handling try-catches A File and YamlConfiguration can later be retrieved as an Optional Creates a BetterYaml instance that will handle your config files For the server's file: Missing options will be autocompleted and comments will be updated based on the template No settings will be changedOptionalBetterYaml(String name, org.bukkit.plugin.java.JavaPlugin plugin)Handles IOException internally for those who want to avoid handling try-catches A File and YamlConfiguration can later be retrieved as an Optional Creates a BetterYaml instance that will handle your config files For the server's file: Missing options will be autocompleted and comments will be updated based on the template No settings will be changed Will not log any messages to the consoleOptionalBetterYaml(String name, org.bukkit.plugin.java.JavaPlugin plugin, boolean doLogging)Handles IOException internally for those who want to avoid handling try-catches A File and YamlConfiguration can later be retrieved as an Optional Creates a BetterYaml instance that will handle your config files For the server's file: Missing options will be autocompleted and comments will be updated based on the template No settings will be changed -
Method Summary
Modifier and Type Method Description Optional<File>getFile()Get the loaded File.Optional<org.bukkit.configuration.file.YamlConfiguration>getYamlConfiguration()Get the loaded YamlConfiguration.
-
Constructor Details
-
OptionalBetterYaml
Handles IOException internally for those who want to avoid handling try-catches A File and YamlConfiguration can later be retrieved as an Optional Creates a BetterYaml instance that will handle your config files For the server's file: Missing options will be autocompleted and comments will be updated based on the template No settings will be changed Will not log any messages to the console- Parameters:
name- the name of the config file eg. "ourConfig.yml"plugin- the JavaPlugin for which a file is copied
-
OptionalBetterYaml
public OptionalBetterYaml(String name, ValidationHandler validationHandler, org.bukkit.plugin.java.JavaPlugin plugin)Handles IOException internally for those who want to avoid handling try-catches A File and YamlConfiguration can later be retrieved as an Optional Creates a BetterYaml instance that will handle your config files For the server's file: Missing options will be autocompleted and comments will be updated based on the template No settings will be changed Will not log any messages to the console- Parameters:
name- the name of the config file eg. "ourConfig.yml"validationHandler- the validator that can autocorrect options, based on your provided settingsplugin- the JavaPlugin for which a file is copied
-
OptionalBetterYaml
public OptionalBetterYaml(String name, org.bukkit.plugin.java.JavaPlugin plugin, boolean doLogging)Handles IOException internally for those who want to avoid handling try-catches A File and YamlConfiguration can later be retrieved as an Optional Creates a BetterYaml instance that will handle your config files For the server's file: Missing options will be autocompleted and comments will be updated based on the template No settings will be changed- Parameters:
name- the name of the config file eg. "ourConfig.yml"plugin- the JavaPlugin for which a file is copieddoLogging- whether or not basic logging is done in your plugin's name. (Only logs on copying a new file and when missing options are found)
-
OptionalBetterYaml
public OptionalBetterYaml(String name, ValidationHandler validationHandler, org.bukkit.plugin.java.JavaPlugin plugin, boolean doLogging)Handles IOException internally for those who want to avoid handling try-catches A File and YamlConfiguration can later be retrieved as an Optional Creates a BetterYaml instance that will handle your config files For the server's file: Missing options will be autocompleted and comments will be updated based on the template No settings will be changed- Parameters:
name- the name of the config file eg. "ourConfig.yml"validationHandler- the validator that can autocorrect options, based on your provided settingsplugin- the JavaPlugin for which a file is copieddoLogging- whether or not basic logging is done in your plugin's name. (Only logs on copying a new file and when missing options are found)
-
-
Method Details
-
getFile
Get the loaded File. You can check if any error has occurred with Optional#isEmpty(). First, see if it is loaded correctly with Optional#isPresent(), this ensures a non-null value Then, you can get the File instance with Optional#get()- Specified by:
getFilein interfaceIOptionalConfigReader- Returns:
- an optional file, never null. But no value will be present if an Exception was thrown while reading the configuration
-
getYamlConfiguration
Get the loaded YamlConfiguration. You can check if any error has occurred with Optional#isEmpty(). First, see if it is loaded correctly with Optional#isPresent(), this ensures a non-null value Then, you can get the YamlConfiguration instance with Optional#get()- Specified by:
getYamlConfigurationin interfaceIOptionalConfigReader- Returns:
- an optional YamlConfiguration, never null. But no value will be present if an Exception was thrown while reading the configuration
-