Package xyz.srnyx.annoyingapi.storage
Class DataManager
java.lang.Object
xyz.srnyx.annoyingapi.storage.DataManager
The data manager for the plugin, used to manage the connection and data storage
-
Field Summary
FieldsModifier and TypeFieldDescription@Nullable TaskWrapperThe task that saves the cache on an intervalfinal @NotNull DialectThedialectfor the databasefinal @NotNull AnnoyingPluginThepluginto use for the data managerfinal @NotNull StorageConfigThestorage.yml configfor the pluginfinal @NotNull StringThe table prefix for the database (only for remote connections) -
Constructor Summary
ConstructorsConstructorDescriptionDataManager(@NotNull StorageConfig config) Connect to the configured database and create the pre-defined tables/columns -
Method Summary
Modifier and TypeMethodDescription@NotNull DataManagerAttempts to migrate data fromstorage.ymltostorage-new.yml@NotNull StringgetTableName(@NotNull String tableName) Get the full name of a table with theprefix
This just returns the table name if it's a local database or there isn't prefixvoidIf saving the cache on an interval is enabled, this will start the asynchronous task to do that
If the feature is disabled, this will cancel the task if it exists
-
Field Details
-
plugin
Thepluginto use for the data manager -
storageConfig
Thestorage.yml configfor the plugin -
dialect
Thedialectfor the database -
tablePrefix
The table prefix for the database (only for remote connections) -
cacheSavingTask
The task that saves the cache on an interval- See Also:
-
-
Constructor Details
-
DataManager
Connect to the configured database and create the pre-defined tables/columns- Parameters:
config- thestorage.yml configto use for the data manager- Throws:
ConnectionException- if the connection to the database fails for any reason
-
-
Method Details
-
getTableName
Get the full name of a table with theprefix
This just returns the table name if it's a local database or there isn't prefix- Parameters:
tableName- the name of the table to get- Returns:
- the full name of the table
-
toggleIntervalCacheSaving
public void toggleIntervalCacheSaving()If saving the cache on an interval is enabled, this will start the asynchronous task to do that
If the feature is disabled, this will cancel the task if it exists -
attemptDatabaseMigration
Attempts to migrate data fromstorage.ymltostorage-new.yml- Returns:
- the new data manager
-