Class Config

java.lang.Object
io.github.bakedlibs.dough.config.Config

public class Config extends Object
  • Field Details

  • Constructor Details

    • Config

      public Config(@Nonnull Plugin plugin)
      Creates a new Config Object for the config.yml File of the specified Plugin
      Parameters:
      plugin - The Instance of the Plugin, the config.yml is referring to
    • Config

      public Config(@Nonnull Plugin plugin, @Nonnull String name)
    • Config

      public Config(@Nonnull File file, @Nonnull FileConfiguration config)
      Creates a new Config Object for the specified File and FileConfiguration
      Parameters:
      file - The File to save to
      config - The FileConfiguration
    • Config

      public Config(@Nonnull File file)
      Creates a new Config Object for the specified File
      Parameters:
      file - The File for which the Config object is created for
    • Config

      public Config(@Nonnull String path)
      Creates a new Config Object for the File with in the specified Location
      Parameters:
      path - The path of the File which the Config object is created for
  • Method Details

    • getFile

      @Nonnull public File getFile()
    • getHeader

      @Nullable public String getHeader()
    • setHeader

      public void setHeader(@Nullable String header)
    • getConfiguration

      @Nonnull public FileConfiguration getConfiguration()
      Converts this Config Object into a plain FileConfiguration Object
      Returns:
      The converted FileConfiguration Object
    • setLogger

      public void setLogger(@Nonnull Logger logger)
      This sets the Logger instance to be used for this Config.
      Parameters:
      logger - Your Logger instance
    • clear

      public void clear()
    • store

      protected void store(@Nonnull String path, Object value)
    • setValue

      public void setValue(@Nonnull String path, Object value)
      Sets the Value for the specified path
      Parameters:
      path - The path in the Config File
      value - The Value for that path
    • save

      public void save()
      Saves the Config to its File
    • save

      public void save(@Nonnull File file)
      Saves the Config to a File
      Parameters:
      file - The File you are saving this Config to
    • setDefaultValue

      public void setDefaultValue(@Nonnull String path, @Nullable Object value)
      Sets the Value for the specified path (If the path does not yet exist)
      Parameters:
      path - The path in the Config file
      value - The Value for that path
    • getOrSetDefault

      public <T> T getOrSetDefault(@Nonnull String path, T value)
    • contains

      public boolean contains(@Nonnull String path)
      Checks whether the Config contains the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      True/false
    • getValue

      @Nullable public Object getValue(@Nonnull String path)
      Returns the Object at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The Value at that path
    • getValueAs

      @Nonnull public <T> Optional<T> getValueAs(@Nonnull Class<T> c, @Nonnull String path)
    • getItem

      @Nullable public ItemStack getItem(@Nonnull String path)
      Returns the ItemStack at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The ItemStack at that path
    • getString

      @Nullable public String getString(@Nonnull String path)
      Returns the String at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The String at that path
    • getInt

      public int getInt(@Nonnull String path)
      Returns the Integer at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The Integer at that path
    • getBoolean

      public boolean getBoolean(@Nonnull String path)
      Returns the Boolean at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The Boolean at that path
    • getStringList

      @Nonnull public List<String> getStringList(@Nonnull String path)
      Returns the StringList at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The StringList at that path
    • getIntList

      @Nonnull public List<Integer> getIntList(@Nonnull String path)
      Returns the IntegerList at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The IntegerList at that path
    • createFile

      public boolean createFile()
      Recreates the File of this Config
      Returns:
      Returns if the file was successfully created
    • getFloat

      public float getFloat(@Nonnull String path)
      Returns the Float at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The Float at that path
    • getLong

      public long getLong(@Nonnull String path)
      Returns the Long at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The Long at that path
    • getDate

      public Date getDate(@Nonnull String path)
      Returns the Date at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The Date at that path
    • getChunk

      public Chunk getChunk(@Nonnull String path)
      Returns the Chunk at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The Chunk at that path
    • getUUID

      public UUID getUUID(@Nonnull String path)
      Returns the UUID at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The UUID at that path
    • getWorld

      public World getWorld(@Nonnull String path)
      Returns the World at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The World at that path
    • getDouble

      public double getDouble(@Nonnull String path)
      Returns the Double at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The Double at that path
    • getLocation

      @Nonnull public Location getLocation(@Nonnull String path)
      Returns the Location at the specified path
      Parameters:
      path - The path in the Config File
      Returns:
      The Location at that path
    • getInventory

      @Nonnull public Inventory getInventory(@Nonnull String path, int size, @Nonnull String title)
      Gets the Contents of an Inventory at the specified path
      Parameters:
      path - The path in the Config File
      size - The Size of the Inventory
      title - The Title of the Inventory
      Returns:
      The generated Inventory
    • getInventory

      @Nonnull public Inventory getInventory(@Nonnull String path, @Nonnull String title)
      Gets the Contents of an Inventory at the specified path
      Parameters:
      path - The path in the Config File
      title - The title of the inventory, this can accept & for color codes.
      Returns:
      The generated Inventory
    • getKeys

      @Nonnull public Set<String> getKeys()
      Returns all paths in this Config
      Returns:
      All paths in this Config
    • getKeys

      @Nonnull public Set<String> getKeys(@Nonnull String path)
      Returns all sub-paths in this Config
      Parameters:
      path - The path in the Config File
      Returns:
      All sub-paths of the specified path
    • reload

      public void reload()
      Reloads the Configuration File