Class YamlFile

java.lang.Object
org.bukkit.configuration.MemorySection
org.bukkit.configuration.MemoryConfiguration
org.bukkit.configuration.file.FileConfiguration
org.bukkit.configuration.file.YamlConfiguration
valorless.valorlessutils.file.FileStorage
valorless.valorlessutils.file.YamlFile
All Implemented Interfaces:
org.bukkit.configuration.Configuration, org.bukkit.configuration.ConfigurationSection

public class YamlFile extends FileStorage
  • Field Summary

    Fields inherited from class org.bukkit.configuration.file.YamlConfiguration

    BLANK_CONFIG, COMMENT_PREFIX

    Fields inherited from class org.bukkit.configuration.MemoryConfiguration

    defaults, options

    Fields inherited from class org.bukkit.configuration.MemorySection

    map
  • Constructor Summary

    Constructors
    Constructor
    Description
    YamlFile(File file)
    Constructor for YamlFile class using a File object.
    Constructor for YamlFile class using a file path.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the YamlConfiguration contains a value at the specified path.
    get(String path)
    Gets a value from the YamlConfiguration.
    <T> T
    get(String path, Class<T> clazz)
    Gets a typed value from the YamlConfiguration.
    org.bukkit.configuration.file.YamlConfiguration
    Gets the underlying YamlConfiguration.
    <T> T
    getOrDefault(String path, T defaultValue)
    Gets a value from the YamlConfiguration or a default value if the path does not exist.
    org.bukkit.configuration.ConfigurationSection
    Gets a ConfigurationSection from the YamlConfiguration.
    void
    Reloads the YamlConfiguration from the associated file.
    boolean
    Saves the YamlConfiguration to the associated file.
    void
    set(String path, Object value)
    Sets a value in the YamlConfiguration.
    void
    setIfNull(String path, Object value)
    Sets a value in the YamlConfiguration only if the path does not already exist.

    Methods inherited from class valorless.valorlessutils.file.FileStorage

    createFile, deleteFile, fileExists, getFile, loadConfiguration

    Methods inherited from class org.bukkit.configuration.file.YamlConfiguration

    loadConfiguration, loadFromString, options, saveToString

    Methods inherited from class org.bukkit.configuration.file.FileConfiguration

    buildHeader, load, load, load, save, save

    Methods inherited from class org.bukkit.configuration.MemoryConfiguration

    addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaults

    Methods inherited from class org.bukkit.configuration.MemorySection

    contains, createPath, createPath, createSection, createSection, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isPrimitiveWrapper, isSet, isString, isVector, mapChildrenKeys, mapChildrenValues, setComments, setInlineComments, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.bukkit.configuration.ConfigurationSection

    contains, createSection, createSection, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isSet, isString, isVector, setComments, setInlineComments
  • Constructor Details

    • YamlFile

      public YamlFile(String file)
      Constructor for YamlFile class using a file path.
      Parameters:
      file - The file path as a string.
    • YamlFile

      public YamlFile(File file)
      Constructor for YamlFile class using a File object.
      Parameters:
      file - The File object representing the YAML file.
  • Method Details

    • reload

      public void reload()
      Reloads the YamlConfiguration from the associated file.
    • set

      public void set(String path, Object value)
      Sets a value in the YamlConfiguration.
      Specified by:
      set in interface org.bukkit.configuration.ConfigurationSection
      Overrides:
      set in class org.bukkit.configuration.MemorySection
      Parameters:
      path - The path to the value.
      value - The value to set.
    • get

      public Object get(String path)
      Gets a value from the YamlConfiguration.
      Specified by:
      get in interface org.bukkit.configuration.ConfigurationSection
      Overrides:
      get in class org.bukkit.configuration.MemorySection
      Parameters:
      path - The path to the value.
      Returns:
      The value at the specified path.
    • get

      public <T> T get(String path, Class<T> clazz)
      Gets a typed value from the YamlConfiguration.
      Type Parameters:
      T - The type of the value.
      Parameters:
      path - The path to the value.
      clazz - The class of the value.
      Returns:
      The typed value at the specified path.
    • contains

      public boolean contains(String path)
      Checks if the YamlConfiguration contains a value at the specified path.
      Specified by:
      contains in interface org.bukkit.configuration.ConfigurationSection
      Overrides:
      contains in class org.bukkit.configuration.MemorySection
      Parameters:
      path - The path to check.
      Returns:
      true if the path exists, false otherwise.
    • setIfNull

      public void setIfNull(String path, Object value)
      Sets a value in the YamlConfiguration only if the path does not already exist.
      Parameters:
      path - The path to the value.
      value - The value to set.
    • getOrDefault

      public <T> T getOrDefault(String path, T defaultValue)
      Gets a value from the YamlConfiguration or a default value if the path does not exist.
      Type Parameters:
      T - The type of the value.
      Parameters:
      path - The path to the value.
      defaultValue - The default value to return if the path does not exist.
      Returns:
      The value at the specified path or the default value if the path does not exist.
    • getSection

      public org.bukkit.configuration.ConfigurationSection getSection(String path)
      Gets a ConfigurationSection from the YamlConfiguration.
      Parameters:
      path - The path to the ConfigurationSection.
      Returns:
      The ConfigurationSection at the specified path.
    • save

      public boolean save()
      Saves the YamlConfiguration to the associated file.
      Returns:
      true if the save is successful, false otherwise.
    • getConfig

      public org.bukkit.configuration.file.YamlConfiguration getConfig()
      Gets the underlying YamlConfiguration.
      Returns:
      The YamlConfiguration instance.