Class FileManager

java.lang.Object
com.github.pinont.singularitylib.api.manager.FileManager

public class FileManager extends Object
Manages file operations for the plugin. Provides utilities for file and folder management within the plugin's data directory.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final org.bukkit.plugin.Plugin
    The plugin instance for accessing the data folder.
  • Constructor Summary

    Constructors
    Constructor
    Description
    FileManager(org.bukkit.plugin.Plugin plugin)
    Default constructor for FileManager.
  • Method Summary

    Modifier and Type
    Method
    Description
    getFile(String fileName)
    Gets a file from the plugin's data folder.
    getFile(String subfolder, String fileName)
    Gets a file from a specific subfolder within the plugin's data folder.
    Gets all files from a specific subfolder.
    boolean
    Checks if a subfolder exists within the plugin's data directory.
    void
    save(String subfolder, File file)
    Saves a file to a specific subfolder within the plugin's data directory.

    Methods inherited from class Object

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

    • plugin

      public final org.bukkit.plugin.Plugin plugin
      The plugin instance for accessing the data folder.
  • Constructor Details

    • FileManager

      public FileManager(org.bukkit.plugin.Plugin plugin)
      Default constructor for FileManager.
  • Method Details

    • getFile

      public File getFile(String fileName)
      Gets a file from the plugin's data folder.
      Parameters:
      fileName - the name of the file to get
      Returns:
      the File object
    • getFile

      public File getFile(String subfolder, String fileName)
      Gets a file from a specific subfolder within the plugin's data folder.
      Parameters:
      subfolder - the subfolder path
      fileName - the name of the file to get
      Returns:
      the File object
    • getFileFromFolder

      public List<File> getFileFromFolder(String subfolder)
      Gets all files from a specific subfolder.
      Parameters:
      subfolder - the subfolder to get files from
      Returns:
      a list of files in the subfolder, or empty list if folder doesn't exist or is empty
    • isFolderExists

      public boolean isFolderExists(String subfolder)
      Checks if a subfolder exists within the plugin's data directory.
      Parameters:
      subfolder - the subfolder path to check
      Returns:
      true if the folder exists, false otherwise
    • save

      public void save(String subfolder, File file)
      Saves a file to a specific subfolder within the plugin's data directory.
      Parameters:
      subfolder - the subfolder to save the file to
      file - the file to save