Metrics not sent when using bStats 1.7
Bobcat00 opened this issue ยท 0 comments
When Prism uses bStats 1.7 and any other plugin is the bStats "sending" plugin, the statistics for Prism are not sent. The following testing was done with Spigot 1.15.2.
If I run with just Prism build 74 (which uses bStats 1.7) and no other plugins, the stats get sent.
If I add WorldEdit (just WE and Prism), the Prism stats are not sent. WorldEdit is the "sending" plugin and it also uses bStats 1.7.
If I add a third plugin which uses bStats 1.7 (WE is still the "sending" plugin), the stats for WE and the third plugin are sent, but the stats for Prism are not sent.
This is the Metrics code involved in submitData:
Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider());
if (plugin instanceof JsonObject) {
pluginData.add((JsonObject) plugin);
} else { // old bstats version compatibility
try {
Class<?> jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject");
if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) {
Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString");
jsonStringGetter.setAccessible(true);
String jsonString = (String) jsonStringGetter.invoke(plugin);
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
pluginData.add(object);
}
} catch (ClassNotFoundException e) {
// minecraft version 1.14+
if (logFailedRequests) {
this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e);
}
}
}
When the "sending" plugin is processing the Prism data, it fails the test for (plugin instanceof JsonObject)
and goes into the "old bstats version compatibility" part (I don't think it should be there), and then fails the test if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple))
So the problem appears to involve what Prism is returning for provider.getService().getMethod("getPluginData").invoke(provider.getProvider())
Also note that both bStats and Spigot made changes related to JSON. bStats Replaced json-simple with Gson and Spigot removed json-simple from the api in their 1.14 update.