Search in sources :

Example 1 with BungeeEventListener

use of me.william278.husksync.bungeecord.listener.BungeeEventListener 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)

Aggregations

IOException (java.io.IOException)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 MPDBMigrator (me.william278.husksync.migrator.MPDBMigrator)1 DataManager (me.william278.husksync.proxy.data.DataManager)1 Metrics (org.bstats.bungeecord.Metrics)1