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 console
    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
    OptionalBetterYaml​(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 console
    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
  • 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OptionalBetterYaml

      public OptionalBetterYaml​(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 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 settings
      plugin - 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 copied
      doLogging - 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 settings
      plugin - the JavaPlugin for which a file is copied
      doLogging - 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

      public Optional<File> 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:
      getFile in interface IOptionalConfigReader
      Returns:
      an optional file, never null. But no value will be present if an Exception was thrown while reading the configuration
    • getYamlConfiguration

      public Optional<org.bukkit.configuration.file.YamlConfiguration> 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:
      getYamlConfiguration in interface IOptionalConfigReader
      Returns:
      an optional YamlConfiguration, never null. But no value will be present if an Exception was thrown while reading the configuration