mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 06:28:49 +00:00
Start work on Migrators
This commit is contained in:
1 parent
ca9e60394d
commit
bee1c811b2
9 files changed
+416
-7
No files matched your search
@@ -21,6 +21,8 @@ import net.william278.huskhomes.listener.EventListener;
|
||||
import net.william278.huskhomes.messenger.NetworkMessenger;
|
||||
import net.william278.huskhomes.messenger.PluginMessenger;
|
||||
import net.william278.huskhomes.messenger.RedisMessenger;
|
||||
import net.william278.huskhomes.migrator.LegacyMigrator;
|
||||
import net.william278.huskhomes.migrator.Migrator;
|
||||
import net.william278.huskhomes.player.BukkitPlayer;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
@@ -72,6 +74,8 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
private Set<PluginHook> pluginHooks;
|
||||
private List<CommandBase> registeredCommands;
|
||||
|
||||
private List<Migrator> migrators;
|
||||
|
||||
@Nullable
|
||||
private NetworkMessenger networkMessenger;
|
||||
|
||||
@@ -100,11 +104,17 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
this.logger = new BukkitLogger(getLogger());
|
||||
this.resourceReader = new BukkitResourceReader(this);
|
||||
|
||||
// Detect if an upgrade is needed
|
||||
final BukkitUpgradeUtil upgradeData = BukkitUpgradeUtil.detect(this);
|
||||
|
||||
// Load settings and locales
|
||||
getLoggingAdapter().log(Level.INFO, "Loading plugin configuration settings & locales...");
|
||||
initialized.set(reload().join());
|
||||
if (initialized.get()) {
|
||||
logger.showDebugLogs(settings.debugLogging);
|
||||
if (upgradeData != null) {
|
||||
upgradeData.upgradeSettings(settings);
|
||||
}
|
||||
getLoggingAdapter().log(Level.INFO, "Successfully loaded plugin configuration settings & locales");
|
||||
} else {
|
||||
throw new HuskHomesInitializationException("Failed to load plugin configuration settings and/or locales");
|
||||
@@ -229,6 +239,11 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
});
|
||||
getLoggingAdapter().log(Level.INFO, "Successfully registered permissions & commands.");
|
||||
|
||||
// Prepare migrators
|
||||
this.migrators = new ArrayList<>();
|
||||
this.migrators.add(new LegacyMigrator(this));
|
||||
//todo EssentialsX
|
||||
|
||||
// Hook into bStats metrics
|
||||
try {
|
||||
new Metrics(this, METRICS_ID);
|
||||
@@ -244,6 +259,18 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
"An update is available for HuskHomes, v" + newVersion
|
||||
+ " (Currently running v" + getPluginVersion() + ")")));
|
||||
}
|
||||
|
||||
// Perform automatic upgrade if detected
|
||||
if (upgradeData != null) {
|
||||
getLoggingAdapter().log(Level.INFO, "Performing automatic upgrade...");
|
||||
new LegacyMigrator(this, upgradeData).start().thenAccept(result -> {
|
||||
if (result) {
|
||||
getLoggingAdapter().log(Level.INFO, "Successfully performed automatic upgrade.");
|
||||
} else {
|
||||
getLoggingAdapter().log(Level.WARNING, "Failed to perform automatic upgrade.");
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (HuskHomesInitializationException exception) {
|
||||
getLoggingAdapter().log(Level.SEVERE, exception.getMessage());
|
||||
initialized.set(false);
|
||||
@@ -348,6 +375,11 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
||||
return eventDispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Migrator> getMigrators() {
|
||||
return migrators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Spawn> getServerSpawn() {
|
||||
return Optional.ofNullable(serverSpawn);
|
||||
|
||||
Reference in new issue
Block a user