feat(dashboard): refine activity telemetry and maps
CI / validate (push) Successful in 5m24s
Release / release (push) Successful in 11m6s

This commit is contained in:
dmg
2026-08-01 20:28:32 -04:00
parent 9116107917
commit ebc7c7df17
32 changed files with 695 additions and 72 deletions
@@ -59,6 +59,43 @@ final class AccountManagerClient {
}
}
boolean reportConnected(UUID minecraftUuid, String username) {
String compactUuid = minecraftUuid.toString().replace("-", "").toLowerCase();
ConnectionRequest payload = new ConnectionRequest(
UUID.randomUUID().toString(),
config.serverId(),
compactUuid,
username,
Instant.now().toString()
);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(config.apiUrl() + "/api/velocity/connection"))
.timeout(config.timeout())
.header("Authorization", "Bearer " + config.apiToken())
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(payload)))
.build();
try {
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
return response.statusCode() == 204;
} catch (InterruptedException exception) {
Thread.currentThread().interrupt();
return false;
} catch (IOException | RuntimeException exception) {
return false;
}
}
private record ConnectionRequest(
String requestId,
String serverId,
String minecraftUuid,
String username,
String occurredAt
) {}
private record AccessRequest(
String requestId,
String serverId,
@@ -5,9 +5,11 @@ import com.velocitypowered.api.event.EventTask;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.event.connection.LoginEvent;
import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import java.io.IOException;
import java.nio.file.Path;
import net.kyori.adventure.text.Component;
@@ -22,13 +24,15 @@ import org.slf4j.Logger;
public final class MinecraftAccountManagerPlugin {
private final Logger logger;
private final Path dataDirectory;
private final ProxyServer proxyServer;
private volatile AccountManagerClient accountManagerClient;
private volatile String fallbackMessage = "Please register your Minecraft account in Discord before joining.";
@Inject
public MinecraftAccountManagerPlugin(Logger logger, @DataDirectory Path dataDirectory) {
public MinecraftAccountManagerPlugin(Logger logger, @DataDirectory Path dataDirectory, ProxyServer proxyServer) {
this.logger = logger;
this.dataDirectory = dataDirectory;
this.proxyServer = proxyServer;
}
@Subscribe
@@ -66,4 +70,19 @@ public final class MinecraftAccountManagerPlugin {
}
});
}
@Subscribe
public void onPostLogin(PostLoginEvent event) {
proxyServer.getScheduler().buildTask(this, () -> {
AccountManagerClient client = accountManagerClient;
if (client == null) return;
boolean recorded = client.reportConnected(
event.getPlayer().getUniqueId(),
event.getPlayer().getUsername()
);
if (!recorded) {
logger.warn("Could not report confirmed Minecraft connection for {} ({})", event.getPlayer().getUsername(), event.getPlayer().getUniqueId());
}
}).schedule();
}
}