Class FileUtils

java.lang.Object
me.yleoft.zAPI.utils.FileUtils

public class FileUtils extends Object
FileUtils is a utility class for managing configuration files in a Bukkit plugin. It provides methods to load, save, and reload configuration files, as well as to save embedded resources.
  • Constructor Details

    • FileUtils

      public FileUtils(@NotNull @NotNull File file, @NotNull @NotNull String resource)
      Creates a new FileUtils instance.
      Parameters:
      file - The file to be used.
      resource - The resource path.
  • Method Details

    • getConfig

      public org.bukkit.configuration.file.FileConfiguration getConfig()
      Gets the configuration file.
      Returns:
      The configuration file.
    • getResource

      public String getResource()
      Gets the resource path.
      Returns:
      The resource path.
    • getFile

      public File getFile()
      Gets the file.
      Returns:
      The file.
    • reloadConfig

      public void reloadConfig(boolean copyDefaults)
      Reloads the configuration file.
    • reloadConfig

      public void reloadConfig()
    • saveConfig

      public void saveConfig()
      Saves the configuration file.
    • saveDefaultConfig

      public void saveDefaultConfig()
      Saves the default configuration file if it does not exist.
    • saveResource

      public void saveResource(String resourcePath, boolean replace)
      Saves an embedded resource to the plugin's data folder.
      Parameters:
      resourcePath - The path to the resource.
      replace - Whether to replace the existing file if it exists.
      Throws:
      IllegalArgumentException - if the resource path is null or empty.