Class WbsSettings

java.lang.Object
wbs.utils.util.plugin.WbsSettings

public abstract class WbsSettings extends Object
Contains all configuration settings that aren't universal to WbsPlugin and provides methods to access them. Includes methods for logging configuration errors and safely loading configs.
Author:
Weber588
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ArrayList<String>
     
    protected Logger
     
    protected WbsPlugin
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected File
    Retrieve a file from the plugin data folder.
     
    protected org.bukkit.configuration.file.YamlConfiguration
    A version of YamlConfiguration.loadConfiguration(File) that also logs yaml parsing errors.
    protected org.bukkit.configuration.file.YamlConfiguration
     
    protected void
    loadMessageFormat(org.bukkit.configuration.file.YamlConfiguration config)
     
    void
    logError(String error, String directory)
    Log an error both in console and in the errors list that may be used to display errors in a command
    abstract void
    To be called during initialization, and allows the configs to be reloaded without restarting the server/reloading the whole plugin.
    protected org.bukkit.configuration.file.YamlConfiguration
    saveYamlData(@Nullable org.bukkit.configuration.file.YamlConfiguration config, @NotNull String fileName, @NotNull String dataName, @NotNull Consumer<org.bukkit.configuration.file.YamlConfiguration> delegate)
    Runs an operation on a YamlConfiguration as defined in the delegate after guaranteeing that the config is non-null and corresponding file exists in the given plugins folder.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • WbsSettings

      protected WbsSettings(WbsPlugin plugin)
  • Method Details

    • reload

      public abstract void reload()
      To be called during initialization, and allows the configs to be reloaded without restarting the server/reloading the whole plugin.
    • loadDefaultConfig

      protected org.bukkit.configuration.file.YamlConfiguration loadDefaultConfig(String configName)
    • loadMessageFormat

      protected void loadMessageFormat(org.bukkit.configuration.file.YamlConfiguration config)
    • getErrors

      public ArrayList<String> getErrors()
      Returns:
      The errors from the last reload/initial load
    • logError

      public void logError(String error, String directory)
      Log an error both in console and in the errors list that may be used to display errors in a command
      Parameters:
      error - The error message
      directory - The directory in which the error took place
    • loadConfigSafely

      protected org.bukkit.configuration.file.YamlConfiguration loadConfigSafely(File file)
      A version of YamlConfiguration.loadConfiguration(File) that also logs yaml parsing errors.
      Parameters:
      file - The file to parse
      Returns:
      The YamlConfiguration
    • genConfig

      protected File genConfig(String path)
      Retrieve a file from the plugin data folder. If it does not exist, it will be created from the jar
      Parameters:
      path - The path of the file within the plugins data folder
      Returns:
      The new file, or the file that was present at the path.
    • saveYamlData

      protected org.bukkit.configuration.file.YamlConfiguration saveYamlData(@Nullable @Nullable org.bukkit.configuration.file.YamlConfiguration config, @NotNull @NotNull String fileName, @NotNull @NotNull String dataName, @NotNull @NotNull Consumer<org.bukkit.configuration.file.YamlConfiguration> delegate)
      Runs an operation on a YamlConfiguration as defined in the delegate after guaranteeing that the config is non-null and corresponding file exists in the given plugins folder. Automatically logs errors, formatted with the given dataName.
      Parameters:
      config - Optionally, the configuration to write to and save. Leave as null to automatically load from the given
      fileName - The file to save to and read from if config is null
      dataName - The name of the thing being saved. For example, using "Player" will make the file created message say "Player file created."
      delegate - The function to run on the YamlConfiguration before saving
      Returns:
      The used YamlConfiguration; this is config if non-null.