3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-06 00:00:47 +01:00

Update to new bStats revision

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-02-13 12:57:48 -05:00
Ursprung 0c7a995767
Commit 29168ae549

Datei anzeigen

@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger;
public class Metrics { public class Metrics {
// The version of this bStats class // The version of this bStats class
private static final int B_STATS_VERSION = 1; private static final int B_STATS_METRICS_REVISION = 2;
// The url to which the data is sent // The url to which the data is sent
private static final String URL = "https://bstats.org/submitData/server-implementation"; private static final String URL = "https://bstats.org/submitData/server-implementation";
@ -49,6 +49,9 @@ public class Metrics {
// The name of the server software // The name of the server software
private final String name; private final String name;
// The plugin ID for the server software as assigned by bStats.
private final int pluginId;
// The uuid of the server // The uuid of the server
private final String serverUuid; private final String serverUuid;
@ -60,13 +63,15 @@ public class Metrics {
/** /**
* Class constructor. * Class constructor.
* @param name The name of the server software. * @param name The name of the server software.
* @param pluginId The plugin ID for the server software as assigned by bStats.
* @param serverUuid The uuid of the server. * @param serverUuid The uuid of the server.
* @param logFailedRequests Whether failed requests should be logged or not. * @param logFailedRequests Whether failed requests should be logged or not.
* @param server The Velocity server instance. * @param server The Velocity server instance.
*/ */
private Metrics(String name, String serverUuid, boolean logFailedRequests, private Metrics(String name, int pluginId, String serverUuid, boolean logFailedRequests,
VelocityServer server) { VelocityServer server) {
this.name = name; this.name = name;
this.pluginId = pluginId;
this.serverUuid = serverUuid; this.serverUuid = serverUuid;
Metrics.logFailedRequests = logFailedRequests; Metrics.logFailedRequests = logFailedRequests;
this.server = server; this.server = server;
@ -114,6 +119,8 @@ public class Metrics {
JsonObject data = new JsonObject(); JsonObject data = new JsonObject();
data.addProperty("pluginName", name); // Append the name of the server software data.addProperty("pluginName", name); // Append the name of the server software
data.addProperty("id", pluginId);
data.addProperty("metricsRevision", B_STATS_METRICS_REVISION);
JsonArray customCharts = new JsonArray(); JsonArray customCharts = new JsonArray();
for (CustomChart customChart : charts) { for (CustomChart customChart : charts) {
// Add the data of the custom charts // Add the data of the custom charts
@ -569,7 +576,7 @@ public class Metrics {
boolean logFailedRequests = metricsConfig.isLogFailure(); boolean logFailedRequests = metricsConfig.isLogFailure();
// Only start Metrics, if it's enabled in the config // Only start Metrics, if it's enabled in the config
if (metricsConfig.isEnabled()) { if (metricsConfig.isEnabled()) {
Metrics metrics = new Metrics("Velocity", serverUuid, logFailedRequests, server); Metrics metrics = new Metrics("Velocity", 4752, serverUuid, logFailedRequests, server);
metrics.addCustomChart( metrics.addCustomChart(
new Metrics.SingleLineChart("players", server::getPlayerCount) new Metrics.SingleLineChart("players", server::getPlayerCount)