Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.mvplugins.multiverse.netherportals;

import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.external.bstats.bukkit.Metrics;
import org.mvplugins.multiverse.external.jakarta.inject.Inject;

@Service
final class BstatsMetricsConfigurator {

private static final int PLUGIN_ID = 7766;
private final Metrics metrics;

@Inject
private BstatsMetricsConfigurator(MultiverseNetherPortals plugin) {
this.metrics = new Metrics(plugin, PLUGIN_ID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.mvplugins.multiverse.core.command.MVCommandManager;
import org.mvplugins.multiverse.external.jakarta.inject.Inject;
import org.mvplugins.multiverse.external.jakarta.inject.Provider;
import org.mvplugins.multiverse.external.vavr.control.Try;
import org.mvplugins.multiverse.netherportals.utils.customportals.CustomPortalsHandler;

public class MultiverseNetherPortals extends MultiverseModule {
Expand All @@ -38,6 +39,8 @@ public class MultiverseNetherPortals extends MultiverseModule {
private Provider<MVNPCommandCompletions> commandCompletionsProvider;
@Inject
private Provider<CustomPortalsHandler> customPortalsHandlerProvider;
@Inject
private Provider<BstatsMetricsConfigurator> metricsConfiguratorProvider;

@Override
public void onLoad() {
Expand All @@ -63,6 +66,7 @@ public void onEnable() {
commandCompletionsProvider.get();
this.registerCommands(NetherPortalsCommand.class);
this.registerDynamicListeners(MVNPListener.class);
this.setupMetrics();
MultiverseNetherPortalsApi.init(this);

Logging.config("Version %s (API v%s) Enabled - By %s",
Expand All @@ -81,6 +85,17 @@ private boolean setupConfig() {
&& links.isLoaded();
}

/**
* Setup bstats Metrics.
*/
private void setupMetrics() {
Try.of(() -> metricsConfiguratorProvider.get())
.onFailure(e -> {
Logging.severe("Failed to setup metrics");
e.printStackTrace();
});
}

@Override
public void onDisable() {
MultiverseNetherPortalsApi.shutdown();
Expand Down
Loading