feat: Implement metrics
This commit is contained in:
parent
0d8630452f
commit
03630dadb0
@ -1,3 +1,11 @@
|
||||
dependencies {
|
||||
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
|
||||
options.release.set(17)
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
@ -18,4 +18,11 @@ tasks {
|
||||
relocate("net.byteflux.libby", "me.adrianed.authmevelocity.libs.libby")
|
||||
relocate("org.spongepowered", "me.adrianed.authmevelocity.libs.sponge")
|
||||
}
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
|
||||
options.release.set(17)
|
||||
}
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
@ -14,6 +14,7 @@ dependencies {
|
||||
compileOnly("com.github.4drian3d:MiniPlaceholders:1.1.1")
|
||||
compileOnly("com.github.games647:fastlogin.velocity:1.11-SNAPSHOT")
|
||||
shadow("net.byteflux:libby-velocity:1.1.5")
|
||||
shadow("org.bstats:bstats-velocity:3.0.0")
|
||||
compileOnly(project(":authmevelocity-common"))
|
||||
compileOnly(project(":authmevelocity-api-velocity"))
|
||||
}
|
||||
@ -28,6 +29,7 @@ tasks {
|
||||
shadowJar {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
relocate("net.byteflux.libby", "me.adrianed.authmevelocity.libs.libby")
|
||||
relocate("org.bstats", "me.adrianed.authmevelocity.libs.bstats")
|
||||
configurations = listOf(project.configurations.shadow.get())
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ import net.byteflux.libby.VelocityLibraryManager;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bstats.velocity.Metrics;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
import java.nio.file.Path;
|
||||
@ -59,15 +61,22 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
||||
private final ProxyServer proxy;
|
||||
private final Logger logger;
|
||||
private final Path pluginDirectory;
|
||||
private final Metrics.Factory metricsFactory;
|
||||
private ConfigurationContainer<ProxyConfiguration> config;
|
||||
|
||||
protected final Set<UUID> loggedPlayers = ConcurrentHashMap.newKeySet();
|
||||
|
||||
@Inject
|
||||
public AuthMeVelocityPlugin(ProxyServer proxy, Logger logger, @DataDirectory Path dataDirectory) {
|
||||
public AuthMeVelocityPlugin(
|
||||
ProxyServer proxy,
|
||||
Logger logger,
|
||||
@DataDirectory Path dataDirectory,
|
||||
Metrics.Factory factory
|
||||
) {
|
||||
this.proxy = proxy;
|
||||
this.logger = logger;
|
||||
this.pluginDirectory = dataDirectory;
|
||||
this.metricsFactory = factory;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@ -81,6 +90,9 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
||||
|
||||
this.config = Loader.loadMainConfig(pluginDirectory, ProxyConfiguration.class, logger);
|
||||
|
||||
final int pluginId = 16128;
|
||||
Metrics metrics = metricsFactory.make(this, pluginId);
|
||||
|
||||
proxy.getChannelRegistrar().register(AUTHMEVELOCITY_CHANNEL);
|
||||
|
||||
List.of(
|
||||
@ -90,12 +102,16 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
||||
).forEach(listener ->
|
||||
proxy.getEventManager().register(this, listener));
|
||||
|
||||
if (proxy.getPluginManager().isLoaded("fastlogin")) {
|
||||
boolean fastlogin = proxy.getPluginManager().isLoaded("fastlogin");
|
||||
metrics.addCustomChart(new SimplePie("fastlogin_compatibility", () -> Boolean.toString(fastlogin)));
|
||||
if (fastlogin) {
|
||||
logDebug("Register FastLogin compatibility");
|
||||
proxy.getEventManager().register(this, new FastLoginListener(proxy, this));
|
||||
}
|
||||
|
||||
if (proxy.getPluginManager().isLoaded("miniplaceholders")) {
|
||||
boolean miniplaceholders = proxy.getPluginManager().isLoaded("miniplaceholders");
|
||||
metrics.addCustomChart(new SimplePie("miniplaceholders_compatibility", () -> Boolean.toString(miniplaceholders)));
|
||||
if (miniplaceholders) {
|
||||
logDebug("Register MiniPlaceholders compatibility");
|
||||
AuthMePlaceholders.getExpansion(this).register();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user