Search in sources :

Example 1 with VelocityEventListener

use of me.william278.husksync.velocity.listener.VelocityEventListener 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

CommandManager (com.velocitypowered.api.command.CommandManager)1 CommandMeta (com.velocitypowered.api.command.CommandMeta)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 IOException (java.io.IOException)1 MPDBMigrator (me.william278.husksync.migrator.MPDBMigrator)1 DataManager (me.william278.husksync.proxy.data.DataManager)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