Search in sources :

Example 1 with NetworkInterceptorCommand

use of me.lucko.networkinterceptor.NetworkInterceptorCommand 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)

Aggregations

CommandManager (com.velocitypowered.api.command.CommandManager)1 CommandMeta (com.velocitypowered.api.command.CommandMeta)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 NetworkInterceptorCommand (me.lucko.networkinterceptor.NetworkInterceptorCommand)1 SimplePie (org.bstats.charts.SimplePie)1 Metrics (org.bstats.velocity.Metrics)1