Class ConfigHelper
java.lang.Object
com.kamikazejam.kamicommon.configuration.spigot.ConfigHelper
This is a utility class for creating and saving configurations in a JavaPlugin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FileConfiguration
createConfig
(Plugin plugin, File dataFolder, String fileName) Returns a new configuration after creating and saving the file (does not load defaults)static FileConfiguration
createConfig
(Plugin plugin, File dataFolder, String fileName, boolean defaultsFromResource) Returns a new configuration after creating and saving the filestatic FileConfiguration
createConfig
(Plugin plugin, String fileName) Returns a new configuration after creating and saving the file (does not load defaults)static File
createPluginFile
(Plugin plugin, String folder, String fileName) Creates an empty plugin file at a specified path with a specified namestatic FileConfiguration
reloadConfig
(Plugin plugin, String fileName) Reloads a config object from a file, make sure to set a variable for the returned configurationstatic FileConfiguration
saveConfig
(Plugin plugin, File dataFolder, FileConfiguration config, String fileName) Saves a config to a file, returns only for chaining purposesstatic FileConfiguration
saveConfig
(Plugin plugin, FileConfiguration config, String fileName) Saves a config to a file, returns only for chaining purposes
-
Constructor Details
-
ConfigHelper
public ConfigHelper()
-
-
Method Details
-
createConfig
Returns a new configuration after creating and saving the file (does not load defaults)- Parameters:
plugin
- The JavaPlugin to grab the datafolder fromfileName
- The name of the file for the new configuration- Returns:
- The FileConfiguration which was created and saved to file
-
createConfig
Returns a new configuration after creating and saving the file (does not load defaults)- Parameters:
plugin
- The JavaPlugin for loggingdataFolder
- The datafolder to put the config file infileName
- The name of the file for the new configuration- Returns:
- The FileConfiguration which was created and saved to file
-
createConfig
public static FileConfiguration createConfig(Plugin plugin, File dataFolder, String fileName, boolean defaultsFromResource) Returns a new configuration after creating and saving the file- Parameters:
plugin
- The JavaPlugin to grab the datafolder fromfileName
- The name of the file for the new configurationdefaultsFromResource
- Whether to load defaults from the jar resources folder- Returns:
- The FileConfiguration which was created and saved to file
-
saveConfig
public static FileConfiguration saveConfig(Plugin plugin, FileConfiguration config, String fileName) Saves a config to a file, returns only for chaining purposes- Parameters:
plugin
- The JavaPlugin to get the datafolder forconfig
- The configuration to save to filefileName
- The name of the file to save to
-
saveConfig
public static FileConfiguration saveConfig(Plugin plugin, File dataFolder, FileConfiguration config, String fileName) Saves a config to a file, returns only for chaining purposes- Parameters:
plugin
- The JavaPlugin for loggingdataFolder
- The datafolder to save the file inconfig
- The configuration to save to filefileName
- The name of the file to save to
-
reloadConfig
Reloads a config object from a file, make sure to set a variable for the returned configuration- Parameters:
plugin
- The JavaPlugin to get the datafolder forfileName
- The name of the file to grab- Returns:
- The same config object for chaining
-
createPluginFile
Creates an empty plugin file at a specified path with a specified name
-