Class BaseOptions<T>
java.lang.Object
net.dillon.dillonlib.util.BaseOptions<T>
- Direct Known Subclasses:
DillonLibOptions.DillonLibOptionsHandler
A base class for registering options on different multiple environment sides. You can customize this however you'd like, by setting instances of options, a custom
Gson setup, config directory, and a update function to directly update your options.- Since:
- 1.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBaseOptions(String fileName) Constructor which initializes the file id and the instance of the options. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears custom directory.Returns the config directory to be resolved.protected abstract TReturns the type to get the options from.com.google.gson.GsonCreates theGSON reader,which reads options correctly.Returns the class to get the options from.Getsthisconfig file.getFile()Gets the instance of options.voidload()Loadsthisconfig.protected voidRuns a safe check through all options to ensure no issues.voidsave()Savesthisconfig.voidsetCustomDirectory(File dir) Creates a new custom directory for the server file.voidsetFileName(String fileName) Sets and creates a new file.voidsetInstance(T instance) Sets current instance to a new option instance.voidUpdates a config option and saves it.
-
Field Details
-
instance
-
-
Constructor Details
-
BaseOptions
Constructor which initializes the file id and the instance of the options.
-
-
Method Details
-
createDefault
Returns the type to get the options from. -
getConfigClass
-
createGson
public com.google.gson.Gson createGson()Creates theGSON reader,which reads options correctly. -
configDir
Returns the config directory to be resolved. Leave blank for default .minecraft/config directory. -
safeCheck
protected void safeCheck()Runs a safe check through all options to ensure no issues.Preforms a
"safe check"on all options, and makes sure that they are valid and safe to run in-game. -
getFileName
- Returns:
- the file name.
-
getFile
- Returns:
- the file.
-
getCustomDir
- Returns:
- the custom directory.
-
getInstance
Gets the instance of options. -
setInstance
Sets current instance to a new option instance. -
setFileName
Sets and creates a new file. -
setCustomDirectory
Creates a new custom directory for the server file. -
clearCustomDirectory
public void clearCustomDirectory()Clears custom directory. -
update
-
save
public void save()Savesthisconfig. -
load
public void load()Loadsthisconfig. -
getConfigFile
Getsthisconfig file.
-