feat(telemetry): add metrics

This commit is contained in:
ineanto 2023-12-11 13:02:32 +01:00
parent a3227dfb94
commit 9fc902aa75
3 changed files with 12 additions and 2 deletions

View file

@ -51,6 +51,7 @@ dependencies {
shadowImplementation("org.mariadb.jdbc:mariadb-java-client:3.3.1")
shadowImplementation("redis.clients:jedis:4.4.3")
shadowImplementation("com.google.code.gson:gson:2.10.1")
shadowImplementation("org.bstats:bstats-bukkit:3.0.2")
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.58.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
@ -89,6 +90,7 @@ tasks {
relocate("redis.clients", "xyz.ineanto.nicko.libs.redis")
relocate("com.google.gson", "xyz.ineanto.nicko.libs.gson")
relocate("org.apache.commons.pool2", "xyz.ineanto.nicko.libs.pool2")
relocate("org.bstats", "xyz.ineanto.nicko.libs.bstats")
// EXCLUSIONS
exclude("colors.bin")
@ -97,7 +99,6 @@ tasks {
exclude("com/google/protobuf/**")
exclude("com/google/errorprone/**")
exclude("org/apache/commons/logging/**")
exclude("org/bstats/**")
exclude("org/jetbrains/**")
exclude("org/intellij/**")
exclude("org/checkerframework/**")

View file

@ -1,6 +1,7 @@
package xyz.ineanto.nicko;
import com.comphenix.protocol.utility.MinecraftVersion;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.PluginCommand;
@ -113,6 +114,7 @@ public class NickoBukkit extends JavaPlugin {
getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this);
getServer().getPluginManager().registerEvents(new PlayerQuitListener(), this);
new Metrics(this, 20483);
}
getLogger().info("Nicko has been enabled.");

View file

@ -7,6 +7,8 @@ import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import xyz.ineanto.nicko.NickoBukkit;
import xyz.ineanto.nicko.config.Configuration;
import xyz.ineanto.nicko.config.DefaultDataSources;
import xyz.ineanto.nicko.config.SQLDataSourceConfiguration;
import static org.junit.jupiter.api.Assertions.assertFalse;
@ -16,7 +18,12 @@ public class ConfigurationTest {
@BeforeAll
public static void setup() {
MockBukkit.mock();
plugin = MockBukkit.load(NickoBukkit.class);
final Configuration config = new Configuration(
DefaultDataSources.SQL_EMPTY,
DefaultDataSources.REDIS_EMPTY,
"",
false);
plugin = MockBukkit.load(NickoBukkit.class, config);
}
@Test