Package com.burchard36.api
Class PluginJsonWriter
java.lang.Object
com.burchard36.api.data.json.writer.PluginJsonWriter
A Json writer, uses class serialization to write/read from files from
Gson
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateFile(JsonDataFile dataFile)
Asynchronously/Synchronously creates aJsonDataFile
This will ONLY create a new file if one doesn't exist,deleteDataFile(JsonDataFile dataFile)
getDataFromFile(File file, Class<? extends JsonDataFile> clazz)
Gets a data from a filewriteDataToFile(JsonDataFile config)
Writes data to a file asynchronously
-
Field Details
-
gson
protected final com.google.gson.Gson gson
-
-
Constructor Details
-
PluginJsonWriter
protected PluginJsonWriter(com.google.gson.Gson gson)
-
-
Method Details
-
createFile
Asynchronously/Synchronously creates aJsonDataFile
This will ONLY create a new file if one doesn't exist,- Parameters:
dataFile
- AJsonDataFile
to create- Returns:
CompletableFuture<Boolean>
true if new file was created, false if not.
-
writeDataToFile
Writes data to a file asynchronously- Parameters:
config
- class extending JsonDataFile to save- Returns:
- true when successfully, false if error (If this method gets a File that does not exist, this method will always return true)
-
getDataFromFile
public CompletableFuture<JsonDataFile> getDataFromFile(File file, Class<? extends JsonDataFile> clazz)Gets a data from a file- Parameters:
file
-File
A fileclazz
-Class
The Class file of the data you are trying to get- Returns:
- instance of your class extending
JsonDataFile
-
deleteDataFile
-