Search in sources :

Example 6 with CommandMeta

use of com.velocitypowered.api.command.CommandMeta 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)

Example 7 with CommandMeta

use of com.velocitypowered.api.command.CommandMeta in project VelocityControl by kangarko.

the class VelocityControl method onPluginStart.

public void onPluginStart() {
    ServerCache.getInstance();
    Settings.load();
    velocityControl = new VelocityControlListener();
    server.getChannelRegistrar().register(CHANNEL);
    server.getEventManager().register(this, new SwitchListener());
    server.getEventManager().register(this, new ChatListener());
    server.getEventManager().register(this, new CommandListener());
    server.getEventManager().register(this, new PlayerListener());
    server.getEventManager().register(this, velocityControl);
    this.onReloadablesStart();
    CommandMeta commandMeta = server.getCommandManager().metaBuilder("vcreload").build();
    server.getCommandManager().register(commandMeta, new ReloadCommand());
}
Also used : ReloadCommand(org.mineacademy.velocitycontrol.command.ReloadCommand) CommandMeta(com.velocitypowered.api.command.CommandMeta)

Example 8 with CommandMeta

use of com.velocitypowered.api.command.CommandMeta in project OneVersionRemake by Andre601.

the class VelocityCore method loadCommands.

// PluginCore stuff
@Override
public void loadCommands() {
    CommandMeta commandMeta = getProxy().getCommandManager().metaBuilder("oneversionremake").aliases("ovr").build();
    getProxy().getCommandManager().register(commandMeta, new CmdOneVersionRemake(this));
}
Also used : CmdOneVersionRemake(com.andre601.oneversionremake.velocity.commands.CmdOneVersionRemake) CommandMeta(com.velocitypowered.api.command.CommandMeta)

Example 9 with CommandMeta

use of com.velocitypowered.api.command.CommandMeta in project commands by aikar.

the class VelocityCommandManager method registerCommand.

public void registerCommand(BaseCommand command, boolean force) {
    command.onRegister(this);
    for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) {
        String commandName = entry.getKey().toLowerCase(Locale.ENGLISH);
        VelocityRootCommand velocityCommand = (VelocityRootCommand) entry.getValue();
        if (!velocityCommand.isRegistered) {
            if (force) {
                proxy.getCommandManager().unregister(commandName);
            }
            CommandMeta meta = proxy.getCommandManager().metaBuilder(commandName).build();
            proxy.getCommandManager().register(meta, velocityCommand);
        }
        velocityCommand.isRegistered = true;
        registeredCommands.put(commandName, velocityCommand);
    }
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) CommandMeta(com.velocitypowered.api.command.CommandMeta)

Example 10 with CommandMeta

use of com.velocitypowered.api.command.CommandMeta in project MiraiMC by DreamVoid.

the class VelocityPlugin method onProxyInitialization.

@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
    // load 阶段2
    try {
        new VelocityConfig(this).loadConfig();
        if (Config.Gen_MiraiCoreVersion.equalsIgnoreCase("latest")) {
            MiraiLoader.loadMiraiCore();
        } else {
            MiraiLoader.loadMiraiCore(Config.Gen_MiraiCoreVersion);
        }
        MiraiEvent = new MiraiEvent(this);
    } catch (Exception e) {
        getLogger().warn("An error occurred while loading plugin.");
        e.printStackTrace();
    }
    // enable
    getLogger().info("Mirai working dir: " + Config.Gen_MiraiWorkingDir);
    if (Config.Gen_AddProperties_MiraiNoDesktop)
        System.setProperty("mirai.no-desktop", "MiraiMC");
    if (Config.Gen_AddProperties_MiraiSliderCaptchaSupported)
        System.setProperty("mirai.slider.captcha.supported", "MiraiMC");
    getLogger().info("Starting Mirai-Events listener.");
    MiraiEvent.startListenEvent();
    // getLogger().info("Loading auto-login file.");
    // MiraiAutoLogin.loadFile();
    // MiraiAutoLogin.doStartUpAutoLogin(); // 服务器启动完成后执行自动登录机器人
    getLogger().info("Registering commands.");
    CommandManager manager = server.getCommandManager();
    CommandMeta mirai = manager.metaBuilder("mirai").build();
    CommandMeta miraimc = manager.metaBuilder("miraimc").build();
    CommandMeta miraiverify = manager.metaBuilder("miraiverify").build();
    manager.register(mirai, new MiraiCommand(this));
    manager.register(miraimc, new MiraiMcCommand(this));
    manager.register(miraiverify, new MiraiVerifyCommand());
    if (Config.Bot_LogEvents) {
        getLogger().info("Registering events.");
        server.getEventManager().register(this, new Events());
    }
    switch(Config.DB_Type.toLowerCase()) {
        case "sqlite":
        default:
            {
                getLogger().info("Initializing SQLite database.");
                try {
                    Utils.initializeSQLite();
                } catch (SQLException | ClassNotFoundException ex) {
                    getLogger().warn("Failed to initialize SQLite database, reason: " + ex);
                }
                break;
            }
        case "mysql":
            {
                getLogger().info("Initializing MySQL database.");
                Utils.initializeMySQL();
                break;
            }
    }
    // bStats统计
    if (Config.Gen_AllowBStats) {
        getLogger().info("Initializing bStats metrics.");
        int pluginId = 13887;
        metricsFactory.make(this, pluginId);
    }
    // 安全警告
    if (!(Config.Gen_DisableSafeWarningMessage)) {
        getLogger().warn("确保您正在使用开源的MiraiMC插件,未知来源的插件可能会盗取您的账号!");
        getLogger().warn("请始终从Github或作者指定的其他途径下载插件: https://github.com/DreamVoid/MiraiMC");
    }
    pluginContainer = server.getPluginManager().getPlugin("miraimc").orElse(null);
    getLogger().info("All tasks done. Welcome to use MiraiMC!");
}
Also used : CommandManager(com.velocitypowered.api.command.CommandManager) MiraiCommand(me.dreamvoid.miraimc.velocity.commands.MiraiCommand) MiraiMcCommand(me.dreamvoid.miraimc.velocity.commands.MiraiMcCommand) MiraiVerifyCommand(me.dreamvoid.miraimc.velocity.commands.MiraiVerifyCommand) CommandMeta(com.velocitypowered.api.command.CommandMeta) SQLException(java.sql.SQLException) Subscribe(com.velocitypowered.api.event.Subscribe)

Aggregations

CommandMeta (com.velocitypowered.api.command.CommandMeta)12 Subscribe (com.velocitypowered.api.event.Subscribe)6 CommandManager (com.velocitypowered.api.command.CommandManager)4 SimplePie (org.bstats.charts.SimplePie)3 Metrics (org.bstats.velocity.Metrics)3 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 HashMap (java.util.HashMap)2 ADPVelocityBootstrap (com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap)1 CmdOneVersionRemake (com.andre601.oneversionremake.velocity.commands.CmdOneVersionRemake)1 EncryptionHandler (com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler)1 DataValueString (com.bencodez.advancedcore.api.user.usercache.value.DataValueString)1 ClientHandler (com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler)1 SocketHandler (com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler)1 SocketReceiver (com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver)1 OfflineBungeeVote (com.bencodez.votingplugin.bungee.OfflineBungeeVote)1 TimeHandle (com.bencodez.votingplugin.bungee.TimeHandle)1 RegisteredServer (com.velocitypowered.api.proxy.server.RegisteredServer)1 VelocityCloudCommand (de.polocloud.plugin.bootstrap.velocity.commands.VelocityCloudCommand)1 VelocityCloudListener (de.polocloud.plugin.bootstrap.velocity.listener.VelocityCloudListener)1