Class DataMigrator
java.lang.Object
org.sgrewritten.stargate.migration.DataMigrator
A migrator for migrating legacy data to new formats
-
Constructor Summary
ConstructorDescriptionDataMigrator
(@NotNull File configurationFile, File pluginFolder, StoredPropertiesAPI storedProperties) Instantiates a new data migrator -
Method Summary
Modifier and TypeMethodDescriptionGets updated configuration valuesboolean
Gets whether a migration is necessaryboolean
run
(@NotNull SQLDatabaseAPI database, StargateAPI stargateAPI) Runs all relevant config migrationsvoid
updateFileConfiguration
(org.bukkit.configuration.file.FileConfiguration config, Map<String, Object> updatedConfig) Updates the given file configuration with the given updated config values
-
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
Gets updated configuration valuesSome configuration values may be lost during the config migration
- Returns:
The update configuration values
-
run
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.InvalidConfigurationExceptionUpdates 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
-