Class DatabaseStorage

java.lang.Object
ch.njol.skript.variables.VariablesStorage
ch.njol.skript.variables.DatabaseStorage
All Implemented Interfaces:
Closeable

public class DatabaseStorage extends VariablesStorage
TODO create a metadata table to store some properties (e.g. Skript version, Yggdrasil version) -- but what if some variables cannot be converted? move them to a different table? TODO create my own database connector or find a better one
  • Field Details

  • Method Details

    • getTableName

      public String getTableName()
    • setTableName

      public void setTableName(String tableName)
    • getFormattedCreateQuery

      public @Nullable String getFormattedCreateQuery()
      Retrieve the create query with the tableName in it
      Returns:
      the create query with the tableName in it (%s -> tableName)
    • load_i

      protected boolean load_i(SectionNode n)
      Doesn't lock the database for reading (it's not used anywhere else, and locking while loading will interfere with loaded variables being deleted by Variables.variableLoaded(String, Object, VariablesStorage)).
      Specified by:
      load_i in class VariablesStorage
      Returns:
      Whether the database could be loaded successfully, i.e. whether the config is correct and all variables could be loaded
    • allLoaded

      protected void allLoaded()
      Description copied from class: VariablesStorage
      Called after all storages have been loaded, and variables have been redistributed if settings have changed. This should commit the first transaction (which is not empty if variables have been moved from another database to this one or vice versa), and start repeating transactions if applicable.
      Specified by:
      allLoaded in class VariablesStorage
    • requiresFile

      protected boolean requiresFile()
      Specified by:
      requiresFile in class VariablesStorage
    • getFile

      protected File getFile(String file)
      Specified by:
      getFile in class VariablesStorage
    • connect

      protected boolean connect()
      Description copied from class: VariablesStorage
      (Re)connects to the database (not called on the first connect - do this in VariablesStorage.load_i(SectionNode)).
      Specified by:
      connect in class VariablesStorage
      Returns:
      Whether the connection could be re-established. An error should be printed by this method prior to returning false.
    • disconnect

      protected void disconnect()
      Description copied from class: VariablesStorage
      Disconnects from the database.
      Specified by:
      disconnect in class VariablesStorage
    • save

      protected boolean save(String name, @Nullable String type, @org.eclipse.jdt.annotation.Nullable byte[] value)
      Description copied from class: VariablesStorage
      Saves a variable. This is called from the main thread while variables are transferred between databases, and from the VariablesStorage.writeThread afterwards.
      Specified by:
      save in class VariablesStorage
      Returns:
      Whether the variable was saved
    • close

      public void close()
      Description copied from class: VariablesStorage
      Called when Skript gets disabled. The default implementation will wait for all variables to be saved before setting VariablesStorage.closed to true and stopping the write thread, thus super.close() must be called if this method is overridden!
      Specified by:
      close in interface Closeable
      Overrides:
      close in class VariablesStorage
    • checkDatabase

      protected void checkDatabase()