Package dev.selena.luacore.utils.config
Class FileManager
java.lang.Object
dev.selena.luacore.utils.config.FileManager
Internally used file manager for loading, creating, and saving files
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic File
Returns the specified filestatic File
Used for getting a folderstatic String
folderPath
(String path) Returns a folder from your Plugins data folderstatic FileManager
get()
Used for getting the instance of this classstatic <T> T
Uses the GSON ConfigLoader class to map the config json to the specified class
-
Constructor Details
-
FileManager
public FileManager()Used for initial class setup
-
-
Method Details
-
file
Returns the specified file- Parameters:
parent
- The parent folderfile
- File name- Returns:
- The file you requested
-
folder
Used for getting a folder- Parameters:
path
- The folder name relative to your plugin data folder- Returns:
- The folder in the form of a Java File
-
folderPath
Returns a folder from your Plugins data folder- Parameters:
path
- Folder name inside the data folder- Returns:
- A string path of the requested folder
-
loadFile
public static <T> T loadFile(Class<T> clazz, File file) throws IOException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException Uses the GSON ConfigLoader class to map the config json to the specified class- Type Parameters:
T
- Class type- Parameters:
clazz
- The class type you want it to be mapped tofile
- The file you are mapping from- Returns:
- Class T mapped with the data from the Json file
- Throws:
IOException
- Thrown when the file can not be foundInstantiationException
- Throwing when the class has an initialization issueIllegalAccessException
- Thrown when trying to access a field without the correct access levelInvocationTargetException
- Thrown when the mapper class has a constructor that does not match the arguments (There should be none)NoSuchMethodException
- Thrown when the class somehow manages not to have a constructor- See Also:
-
get
Used for getting the instance of this class- Returns:
- FileManager instance
-