Class DataManager

java.lang.Object
xyz.srnyx.annoyingapi.storage.DataManager

public class DataManager extends Object
The data manager for the plugin, used to manage the connection and data storage
  • Field Details

    • plugin

      @NotNull public final @NotNull AnnoyingPlugin plugin
      The plugin to use for the data manager
    • storageConfig

      @NotNull public final @NotNull StorageConfig storageConfig
      The storage.yml config for the plugin
    • dialect

      @NotNull public final @NotNull Dialect dialect
      The dialect for the database
    • tablePrefix

      @NotNull public final @NotNull String tablePrefix
      The table prefix for the database (only for remote connections)
    • cacheSavingTask

      @Nullable public @Nullable TaskWrapper cacheSavingTask
      The task that saves the cache on an interval
      See Also:
  • Constructor Details

  • Method Details

    • getTableName

      @NotNull public @NotNull String getTableName(@NotNull @NotNull String tableName)
      Get the full name of a table with the prefix
      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

      @NotNull public @NotNull DataManager attemptDatabaseMigration()
      Attempts to migrate data from storage.yml to storage-new.yml
      Returns:
      the new data manager