diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index 11b2e5cd..e95c5f65 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -30,6 +30,7 @@ import com.onarandombox.MultiverseCore.placeholders.MultiverseCorePlaceholders; import com.onarandombox.MultiverseCore.utils.TestingMode; import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator; import com.onarandombox.MultiverseCore.world.WorldProperties; +import io.vavr.control.Try; import jakarta.inject.Inject; import jakarta.inject.Provider; import me.main__.util.SerializationConfig.SerializationConfig; @@ -205,7 +206,9 @@ public class MultiverseCore extends JavaPlugin implements MVCore { private void setupMetrics() { if (TestingMode.isDisabled()) { // Load metrics - serviceLocator.getService(MetricsConfigurator.class); + serviceLocator.createAndInitialize(MetricsConfigurator.class); + } else { + Logging.info("Metrics are disabled in testing mode."); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/metrics/MetricsConfigurator.java b/src/main/java/com/onarandombox/MultiverseCore/utils/metrics/MetricsConfigurator.java index 879d126e..b25077fc 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/metrics/MetricsConfigurator.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/metrics/MetricsConfigurator.java @@ -8,13 +8,12 @@ import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.MVWorld; +import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; import org.apache.commons.lang.WordUtils; import org.bstats.bukkit.Metrics; import org.bukkit.World; -import org.jvnet.hk2.annotations.Service; -@Service public class MetricsConfigurator { private static final int PLUGIN_ID = 7765; @@ -37,6 +36,7 @@ public class MetricsConfigurator { return getWorldManager().getMVWorlds(); } + @PostConstruct private void initMetrics() { try { addCustomGeneratorsMetric();