Class FileUtils
java.lang.Object
ua.mcchickenstudio.opencreative.utils.FileUtils
FileUtils
This class contains utils for creating, reading, modifying and removing files for worlds.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddPlayerInPlanetList(Planet planet, String nickname, Planet.PlayersType type) Adds player to list, that located in planet's settings.yml file.static booleanconvertOldPlanetFolder(File folder) Returns a new renamed folder if planet is "plot", otherwise it will return same folder.static voidReturns folders of planets worlds that are stored in server container or /unloadedWorlds/ folder.static booleancopyFilesToDirectory(File input, File output) Copies input files into output directory.static voidcreateCodeScript(@NotNull String path, @NotNull String worldName) Creates planet's codeScript.yml file.static voidcreateWorldSettings(int id, @NotNull org.bukkit.entity.Player owner, org.bukkit.World.Environment environment, @NotNull String generatorID) Creates planet's settings.yml file.static voiddeleteFolder(File directory) Deletes directory and files inside it, if exists.static voiddeleteUnnecessaryWorldFiles(File worldFolder) Deletes Minecraft files, that are interrupting world copying process.static voiddeleteWorldFoldersInPlugins(int planetId) Deletes world folders from other plugins.static voidfillDefaultSettings(@NotNull org.bukkit.configuration.file.FileConfiguration config, int id, @NotNull org.bukkit.entity.Player owner, org.bukkit.World.Environment environment, @NotNull String generatorID) Fills world's settings configuration with default values.static @NotNull org.bukkit.configuration.file.YamlConfigurationstatic FilegetDevPlanetFolder(DevPlanet devPlanet) Returns development planet's folder.static StringgetDevPlanetFolderPath(int id) Returns file path of dev planet's world folder.static longgetFileSize(File file) Returns size of file.static longgetFolderSize(File file) Returns size of folder.static CodeConfigurationgetModuleConfig(Module module) Returns module's configuration.static FilegetModuleConfigFile(int id) Returns module's config file.static File[]Returns folders of all modules yaml files.static FileReturns folder that stores all modules folders.static org.bukkit.configuration.file.FileConfigurationgetPlanetConfig(Planet planet) Returns planet's settings.yml configuration.static FilegetPlanetConfigFile(Planet planet) Returns planet's settings.yml file.static FilegetPlanetFolder(Planet planet) Returns planet's folder, that stores planet's build world data, settings, script and players data.static StringgetPlanetFolderPath(int id) Returns file path of planet's world folder.static @NotNull StringgetPlanetIdFromName(@NotNull String name) Returns planet's ID without other symbols.static FilegetPlanetScriptFile(Planet planet) Returns planet's codeScript.yml file.static FileReturns folder that stores all planets folders.static FilegetPlanetVariablesJson(Planet planet) Returns planet's variables.yml configuration.static @Nullable FilegetPlayerDataJson(@NotNull Planet planet, @NotNull org.bukkit.entity.Player player) Returns player's data json from planet folder.getPlayersFromPlanetList(Planet planet, Planet.PlayersType type) Returns a specified list of players nicknames.static FileReturns temporary folder, that stores temporary files.static @Nullable FilegetWanderJsonFile(@NotNull OfflineWander wander, boolean create) Returns wanders file with his data, located in ./wanders/UUID.json.static FileReturns folder that stores all wanders folders.static File[]Returns folders of all planets worlds.static booleanisOpenCreativeWorldFolder(@NotNull File folder) Checks whether specified folder has similar OpenCreative+ files.static booleanisPlanetFolder(File folder) Checks if specified folder is directory of planet world.static voidLoads localization file from OpenCreative/locales/ folder.static voidLoads all modules to base.static voidLoads all planets to base.static voidremovePlanetConfigParameter(Planet planet, String parameterPath) Removes parameter from planet's config.static voidResets localization file from OpenCreative/locales/ folder.static voidsetModuleConfigParameter(Module module, String parameterPath, Object parameterValue) Sets parameter to Object value in module's settings.static voidsetPlanetConfigParameter(Planet planet, String parameterPath, int parameterValue) Sets parameter to Int value in planet's settings.static voidsetPlanetConfigParameter(Planet planet, String parameterPath, long parameterValue) Sets parameter to Long value in planet's settings.static voidsetPlanetConfigParameter(Planet planet, String parameterPath, Object parameterValue) Sets parameter to Object value in planet's settings.static voidsetPlanetConfigParameter(Planet planet, String parameterPath, String parameterValue) Sets parameter to String value in planet's settings.static voidsetPlanetConfigParameter(Planet planet, String parameterPath, List<String> parameterValue) Sets parameter to List value in planet's settings.static voidsetPlanetConfigParameter(Planet planet, String parameterPath, Set<String> parameterValue) Sets parameter to Set value in planet's settings.static voidUnloads all loaded planets worlds.static booleanChecks whether plugin should store all worlds in/world/dimensions/minecraft/planetsfolder (from 26.1+) instead of/planets/folder (1.21.x).
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
createWorldSettings
public static void createWorldSettings(int id, @NotNull @NotNull org.bukkit.entity.Player owner, @NotNull org.bukkit.World.Environment environment, @NotNull @NotNull String generatorID) Creates planet's settings.yml file.- Parameters:
id- Planet's ID.owner- Owner of new world.environment- Environment of world.generatorID- ID of world generator.
-
fillDefaultSettings
public static void fillDefaultSettings(@NotNull @NotNull org.bukkit.configuration.file.FileConfiguration config, int id, @NotNull @NotNull org.bukkit.entity.Player owner, @NotNull org.bukkit.World.Environment environment, @NotNull @NotNull String generatorID) Fills world's settings configuration with default values.- Parameters:
config- settings configuration.id- world's id.owner- world's owner.environment- environment on world creation.
-
createCodeScript
-
loadLocales
public static void loadLocales()Loads localization file from OpenCreative/locales/ folder. If no localization file was found, then it creates a new one. -
resetLocales
public static void resetLocales()Resets localization file from OpenCreative/locales/ folder. If localization file is detected in folder, then it will be removed and replaced with plugin's new one. -
loadPlanets
public static void loadPlanets()Loads all planets to base. -
loadModules
public static void loadModules()Loads all modules to base. -
getDefaultConfig
@NotNull public static @NotNull org.bukkit.configuration.file.YamlConfiguration getDefaultConfig() -
getPlanetFolder
-
getDevPlanetFolder
-
getPlanetConfig
Returns planet's settings.yml configuration. -
getPlanetConfigFile
-
getPlanetScriptFile
-
getPlanetVariablesJson
-
getWanderJsonFile
@Nullable public static @Nullable File getWanderJsonFile(@NotNull @NotNull OfflineWander wander, boolean create) Returns wanders file with his data, located in ./wanders/UUID.json.- Parameters:
wander- wander to get data.create- create file if it doesn't exist.- Returns:
- file - if exists, otherwise - null.
-
getPlayerDataJson
-
getWorldsFolders
Returns folders of all planets worlds.- Returns:
- planets worlds folders.
-
getModulesFiles
Returns folders of all modules yaml files.- Returns:
- modules files.
-
convertOldPlanetFolders
public static void convertOldPlanetFolders()Returns folders of planets worlds that are stored in server container or /unloadedWorlds/ folder. -
isOpenCreativeWorldFolder
Checks whether specified folder has similar OpenCreative+ files.- Parameters:
folder- folder to check.- Returns:
- true - it's OpenCreative+ folder, false - not.
-
convertOldPlanetFolder
Returns a new renamed folder if planet is "plot", otherwise it will return same folder.- Parameters:
folder- planet folder to convert.- Returns:
- renamed or same planet folder.
-
isPlanetFolder
Checks if specified folder is directory of planet world.- Parameters:
folder- folder to check.- Returns:
- true - if folder is planet world, false - not.
-
unloadPlanets
public static void unloadPlanets()Unloads all loaded planets worlds. -
copyFilesToDirectory
-
deleteUnnecessaryWorldFiles
Deletes Minecraft files, that are interrupting world copying process.- Parameters:
worldFolder- folder of world.
-
deleteWorldFoldersInPlugins
public static void deleteWorldFoldersInPlugins(int planetId) Deletes world folders from other plugins.- Parameters:
planetId- id of planet.
-
deleteFolder
Deletes directory and files inside it, if exists.- Parameters:
directory- path of directory.
-
setPlanetConfigParameter
-
removePlanetConfigParameter
-
setPlanetConfigParameter
-
setPlanetConfigParameter
-
setModuleConfigParameter
-
setPlanetConfigParameter
-
setPlanetConfigParameter
-
setPlanetConfigParameter
-
getPlayersFromPlanetList
Returns a specified list of players nicknames.- Parameters:
planet- planet to get list.type- type of players list.- Returns:
- list of nicknames.
-
addPlayerInPlanetList
public static boolean addPlayerInPlanetList(Planet planet, String nickname, Planet.PlayersType type) Adds player to list, that located in planet's settings.yml file.- Parameters:
planet- planet to add player.nickname- nickname of player.type- id of player list.- Returns:
- true - if successfully added, false - if failed.
-
getFolderSize
Returns size of folder.- Parameters:
file- folder to get size.- Returns:
- size of folder.
-
getModuleConfig
Returns module's configuration. -
getModuleConfigFile
Returns module's config file.- Returns:
- file of module's config.
-
getModulesStorageFolder
Returns folder that stores all modules folders.- Returns:
- modules folder.
-
getFileSize
Returns size of file.- Parameters:
file- file to get size.- Returns:
- size of file.
-
getTempFolder
Returns temporary folder, that stores temporary files.- Returns:
- temporary folder.
-
getPlanetFolderPath
Returns file path of planet's world folder.- Parameters:
id- planet to get folder.- Returns:
- planet's folder path.
-
getDevPlanetFolderPath
Returns file path of dev planet's world folder.- Parameters:
id- planet to get folder.- Returns:
- dev planet's folder path.
-
getPlanetsStorageFolder
Returns folder that stores all planets folders.- Returns:
- planets folder.
-
getWandersStorageFolder
Returns folder that stores all wanders folders.- Returns:
- wanders folder.
-
getPlanetIdFromName
-
usingNewWorldsContainer
public static boolean usingNewWorldsContainer()Checks whether plugin should store all worlds in/world/dimensions/minecraft/planetsfolder (from 26.1+) instead of/planets/folder (1.21.x).- Returns:
- true - planets will be saved in
/world/dimensions/minecraft/planets/, false - planets will be saved in/planets/.
-