Class DataMigrator

java.lang.Object
org.sgrewritten.stargate.migration.DataMigrator

public class DataMigrator extends Object
A migrator for migrating legacy data to new formats
  • Constructor Details

    • DataMigrator

      public DataMigrator(@NotNull @NotNull File configurationFile, File pluginFolder, StoredPropertiesAPI storedProperties) throws IOException, org.bukkit.configuration.InvalidConfigurationException
      Instantiates a new data migrator
      Parameters:
      configurationFile -

      The configuration file to migrate to a newer format

      pluginFolder -

      A server object

      Throws:
      IOException -

      If unable to read or write to a file

      org.bukkit.configuration.InvalidConfigurationException -

      If unable to load the given configuration file

  • Method Details

    • isMigrationNecessary

      public boolean isMigrationNecessary()
      Gets whether a migration is necessary
      Returns:

      True if a migration is necessary

    • getUpdatedConfig

      public Map<String,Object> getUpdatedConfig()
      Gets updated configuration values

      Some configuration values may be lost during the config migration

      Returns:

      The update configuration values

    • run

      public boolean run(@NotNull @NotNull SQLDatabaseAPI database, StargateAPI stargateAPI)
      Runs all relevant config migrations
      Parameters:
      database -

      The stargate database

      stargateAPI -

      The stargate API

      Returns:

      Whether data needs to be loaded from the database after migration

    • updateFileConfiguration

      public void updateFileConfiguration(org.bukkit.configuration.file.FileConfiguration config, Map<String,Object> updatedConfig) throws IOException, org.bukkit.configuration.InvalidConfigurationException
      Updates the given file configuration with the given updated config values
      Parameters:
      config -

      The file configuration to update

      updatedConfig -

      The new configuration values to write

      Throws:
      IOException -

      If unable to load the file configuration

      org.bukkit.configuration.InvalidConfigurationException -

      If unable to load the file configuration