Package net.lewmc.essence.utils
Class FileUtil
java.lang.Object
net.lewmc.essence.utils.FileUtil
Essence File Utility.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
close()
Closes the configuration file without saving it.boolean
Creates a file.boolean
Deletes a file.boolean
Checks if a file exists.Gets an object from the configuration file.boolean
getBoolean
(String key) Gets a boolean from the configuration file.double
Gets a double from the configuration file.int
Gets an integer from the configuration file.getKeys
(boolean deep) Gets a List from the configuration file if is root.Gets a List from the configuration file if not root.Gets a string from the configuration file.getStringList
(String key) Gets a String List from the configuration file.boolean
isOpen()
Checks if a file is open.boolean
Opens a configuration file.boolean
loadNoReformat
(File file) Opens a configuration file from root (without checking format).playerDataFile
(UUID uuid) Return the location of the player's data file from the player's UUID.playerDataFile
(org.bukkit.entity.Player player) Return the location of the player's data file from an instance of the player.boolean
Removes a key and it's associated data.boolean
save()
Saves and closes the current configuration file.boolean
Saves and closes the current configuration file to a custom location.boolean
Sets a value in the configuration file.
-
Constructor Details
-
FileUtil
The constructor for the FileUtil class.- Parameters:
plugin
- Reference to the main Essence class.
-
-
Method Details
-
create
Creates a file.- Parameters:
path
- String - Path to the file.- Returns:
- boolean - If the file and directories (if required) were created successfully.
-
exists
Checks if a file exists.- Parameters:
path
- - Path to the file.- Returns:
- boolean - If the file exists
-
load
Opens a configuration file.- Parameters:
path
- String - Path to the file- Returns:
- boolean - If the operation was successful
-
loadNoReformat
Opens a configuration file from root (without checking format).- Parameters:
file
- File - Instance of the file.- Returns:
- boolean - If the operation was successful
-
delete
Deletes a file.- Parameters:
path
- String - The path of the file- Returns:
- boolean - If the operation was successful
-
save
Saves and closes the current configuration file to a custom location.- Parameters:
file
- String - The file.- Returns:
- boolean - If the operation was successful
-
save
public boolean save()Saves and closes the current configuration file.- Returns:
- boolean - If the operation was successful
-
set
Sets a value in the configuration file.- Parameters:
key
- The location of the value.value
- The value to set.- Returns:
- boolean - If the operation was successful
-
get
Gets an object from the configuration file.- Parameters:
key
- The location of the value.- Returns:
- Object - the value.
-
getBoolean
Gets a boolean from the configuration file.- Parameters:
key
- The location of the value.- Returns:
- boolean - the value.
-
getString
Gets a string from the configuration file.- Parameters:
key
- The location of the value.- Returns:
- String - the value.
-
getInt
Gets an integer from the configuration file.- Parameters:
key
- The location of the value.- Returns:
- int - the value.
-
getDouble
Gets a double from the configuration file.- Parameters:
key
- The location of the value.- Returns:
- double - the value.
-
getStringList
Gets a String List from the configuration file.- Parameters:
key
- The location of the value.- Returns:
- List - the value.
-
getKeys
Gets a List from the configuration file if is root.- Parameters:
deep
- Should do deep search?- Returns:
- List - the value.
-
getKeys
Gets a List from the configuration file if not root.- Parameters:
section
- The section of the file.deep
- Should do deep search?- Returns:
- List - the value.
-
close
public boolean close()Closes the configuration file without saving it. Not needed if save() has been used.- Returns:
- boolean - If the operation was successful
-
isOpen
public boolean isOpen()Checks if a file is open.- Returns:
- boolean - If a file is open
-
playerDataFile
Return the location of the player's data file from an instance of the player.- Parameters:
player
- Player - The player.- Returns:
- The data file URI inside the /plugin/essence folder.
-
playerDataFile
Return the location of the player's data file from the player's UUID.- Parameters:
uuid
- UUID - The player's UUID.- Returns:
- The data file URI inside the /plugin/essence folder.
-
remove
Removes a key and it's associated data.- Parameters:
key
- String - The item to remove.- Returns:
- If the operation was successful
-