Search in sources :

Example 1 with CommandMeta

use of com.velocitypowered.api.command.CommandMeta in project NetworkInterceptor by SlimeDog.

the class VelocityNetworkInterceptor method onProxyInitialization.

@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
    // All you have to do is adding the following two lines in your
    // onProxyInitialization method.
    // You can find the plugin ids of your plugins on the page
    // https://bstats.org/what-is-my-plugin-id
    // check and enable bStats
    this.onEnable();
    boolean useMetrics = getConfiguration().getBoolean("enable-metrics", true);
    if (useMetrics) {
        int pluginId = 12197;
        Metrics metrics = metricsFactory.make(this, pluginId);
        metrics.addCustomChart(new SimplePie("mode", () -> config.getString("mode", "N/A")));
    }
    getLogger().info(useMetrics ? "bStats metrics enabled" : "bStats metrics disabled");
    CommandManager commandManager = server.getCommandManager();
    CommandMeta meta = commandManager.metaBuilder("networkinterceptorvelocity").aliases("niv").build();
    commandManager.register(meta, new NetworkInterceptorCommand<>(this).asVelocityCommand());
    isStartup = false;
    for (RepeatingTaskInfo info : repeatingTasksToSchedule) {
        runRepeatingTask(info.runnable, info.ticks);
    }
    repeatingTasksToSchedule.clear();
}
Also used : Metrics(org.bstats.velocity.Metrics) CommandManager(com.velocitypowered.api.command.CommandManager) SimplePie(org.bstats.charts.SimplePie) NetworkInterceptorCommand(me.lucko.networkinterceptor.NetworkInterceptorCommand) CommandMeta(com.velocitypowered.api.command.CommandMeta) Subscribe(com.velocitypowered.api.event.Subscribe)

Example 2 with CommandMeta

use of com.velocitypowered.api.command.CommandMeta in project Fallback-Server by sasi2006166.

the class FallbackServerVelocity method loadCommands.

private void loadCommands(CommandManager commandManager) {
    CommandMeta commandMeta = commandManager.metaBuilder("").aliases(ConfigurationUtil.getConfig().getStringList("").toArray(new String[0])).build();
    commandManager.register(commandMeta, new HubCommand());
}
Also used : HubCommand(me.candiesjar.fallbackserver.velocity.commands.HubCommand) CommandMeta(com.velocitypowered.api.command.CommandMeta)

Example 3 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 4 with CommandMeta

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

the class VelocityControl method onPluginStart.

public void onPluginStart() {
    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 5 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)

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