Search in sources :

Example 1 with MPDBMigrator

use of me.william278.husksync.migrator.MPDBMigrator in project HuskSync by WiIIiam278.

the class HuskSyncBungeeCord method onEnable.

@Override
public void onEnable() {
    // Plugin startup logic
    synchronisedServers = new HashSet<>();
    // Load config
    ConfigManager.loadConfig();
    // Load settings from config
    ConfigLoader.loadSettings(Objects.requireNonNull(ConfigManager.getConfig()));
    // Load messages
    ConfigManager.loadMessages();
    // Load locales from messages
    ConfigLoader.loadMessageStrings(Objects.requireNonNull(ConfigManager.getMessages()));
    // Do update checker
    if (Settings.automaticUpdateChecks) {
        new BungeeUpdateChecker(getDescription().getVersion()).logToConsole();
    }
    // Setup data manager
    dataManager = new DataManager(getBungeeLogger(), getDataFolder());
    // Ensure the data manager initialized correctly
    if (dataManager.hasFailedInitialization) {
        getBungeeLogger().severe("Failed to initialize the HuskSync database(s).\n" + "HuskSync will now abort loading itself (" + getProxy().getName() + ") v" + getDescription().getVersion());
    }
    // Setup player data cache
    for (Settings.SynchronisationCluster cluster : Settings.clusters) {
        dataManager.playerDataCache.put(cluster, new DataManager.PlayerDataCache());
    }
    // Initialize the redis listener
    redisListener = new BungeeRedisListener();
    // Register listener
    getProxy().getPluginManager().registerListener(this, new BungeeEventListener());
    // Register command
    getProxy().getPluginManager().registerCommand(this, new BungeeCommand());
    // Prepare the migrator for use if needed
    mpdbMigrator = new MPDBMigrator(getBungeeLogger());
    // Initialize bStats metrics
    try {
        new Metrics(this, METRICS_ID);
    } catch (Exception e) {
        getBungeeLogger().info("Skipped metrics initialization");
    }
    // Log to console
    getBungeeLogger().info("Enabled HuskSync (" + getProxy().getName() + ") v" + getDescription().getVersion());
    // Mark as ready for redis message processing
    readyForRedis = true;
}
Also used : BungeeCommand(me.william278.husksync.bungeecord.command.BungeeCommand) BungeeRedisListener(me.william278.husksync.bungeecord.listener.BungeeRedisListener) Metrics(org.bstats.bungeecord.Metrics) MPDBMigrator(me.william278.husksync.migrator.MPDBMigrator) DataManager(me.william278.husksync.proxy.data.DataManager) BungeeUpdateChecker(me.william278.husksync.bungeecord.util.BungeeUpdateChecker) BungeeEventListener(me.william278.husksync.bungeecord.listener.BungeeEventListener) IOException(java.io.IOException)

Example 2 with MPDBMigrator

use of me.william278.husksync.migrator.MPDBMigrator in project HuskSync by WiIIiam278.

the class HuskSyncVelocity method onProxyInitialization.

@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
    // Set instance
    instance = this;
    // Load dependencies
    fetchDependencies();
    // Setup logger
    velocityLogger = new VelocityLogger(logger);
    // Prepare synchronised servers tracker
    synchronisedServers = new HashSet<>();
    // Load config
    ConfigManager.loadConfig();
    // Load settings from config
    ConfigLoader.loadSettings(Objects.requireNonNull(ConfigManager.getConfig()));
    // Load messages
    ConfigManager.loadMessages();
    // Load locales from messages
    ConfigLoader.loadMessageStrings(Objects.requireNonNull(ConfigManager.getMessages()));
    // Do update checker
    if (Settings.automaticUpdateChecks) {
        new VelocityUpdateChecker(VERSION).logToConsole();
    }
    // Setup data manager
    dataManager = new DataManager(getVelocityLogger(), getDataFolder());
    // Ensure the data manager initialized correctly
    if (dataManager.hasFailedInitialization) {
        getVelocityLogger().severe("Failed to initialize the HuskSync database(s).\n" + "HuskSync will now abort loading itself (Velocity) v" + VERSION);
    }
    // Setup player data cache
    for (Settings.SynchronisationCluster cluster : Settings.clusters) {
        dataManager.playerDataCache.put(cluster, new DataManager.PlayerDataCache());
    }
    // Initialize the redis listener
    redisListener = new VelocityRedisListener();
    // Register listener
    server.getEventManager().register(this, new VelocityEventListener());
    // Register command
    CommandManager commandManager = getProxyServer().getCommandManager();
    CommandMeta meta = commandManager.metaBuilder("husksync").aliases("hs").build();
    commandManager.register(meta, new VelocityCommand());
    // Prepare the migrator for use if needed
    mpdbMigrator = new MPDBMigrator(getVelocityLogger());
    // Initialize bStats metrics
    try {
        metricsFactory.make(this, METRICS_ID);
    } catch (Exception e) {
        getVelocityLogger().info("Skipped metrics initialization");
    }
    // Log to console
    getVelocityLogger().info("Enabled HuskSync (Velocity) v" + VERSION);
    // Mark as ready for redis message processing
    readyForRedis = true;
}
Also used : VelocityEventListener(me.william278.husksync.velocity.listener.VelocityEventListener) DataManager(me.william278.husksync.proxy.data.DataManager) VelocityCommand(me.william278.husksync.velocity.command.VelocityCommand) VelocityRedisListener(me.william278.husksync.velocity.listener.VelocityRedisListener) IOException(java.io.IOException) VelocityLogger(me.william278.husksync.velocity.util.VelocityLogger) CommandManager(com.velocitypowered.api.command.CommandManager) MPDBMigrator(me.william278.husksync.migrator.MPDBMigrator) VelocityUpdateChecker(me.william278.husksync.velocity.util.VelocityUpdateChecker) CommandMeta(com.velocitypowered.api.command.CommandMeta) Subscribe(com.velocitypowered.api.event.Subscribe)

Aggregations

IOException (java.io.IOException)2 MPDBMigrator (me.william278.husksync.migrator.MPDBMigrator)2 DataManager (me.william278.husksync.proxy.data.DataManager)2 CommandManager (com.velocitypowered.api.command.CommandManager)1 CommandMeta (com.velocitypowered.api.command.CommandMeta)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 BungeeCommand (me.william278.husksync.bungeecord.command.BungeeCommand)1 BungeeEventListener (me.william278.husksync.bungeecord.listener.BungeeEventListener)1 BungeeRedisListener (me.william278.husksync.bungeecord.listener.BungeeRedisListener)1 BungeeUpdateChecker (me.william278.husksync.bungeecord.util.BungeeUpdateChecker)1 VelocityCommand (me.william278.husksync.velocity.command.VelocityCommand)1 VelocityEventListener (me.william278.husksync.velocity.listener.VelocityEventListener)1 VelocityRedisListener (me.william278.husksync.velocity.listener.VelocityRedisListener)1 VelocityLogger (me.william278.husksync.velocity.util.VelocityLogger)1 VelocityUpdateChecker (me.william278.husksync.velocity.util.VelocityUpdateChecker)1 Metrics (org.bstats.bungeecord.Metrics)1