/** * Collects the data and sends it afterwards. */ private void submitData() { final JsonObject data = getServerData(); JsonArray pluginData = new JsonArray(); // Search for all other bStats Metrics classes to get their plugin data for (Object metrics : knownMetricsInstances) { try { Object plugin = metrics.getClass().getMethod("getPluginData").invoke(metrics); if (plugin instanceof JsonObject) { pluginData.add((JsonObject) plugin); } } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { } } data.add("plugins", pluginData); // Create a new thread for the connection to the bStats server new Thread(() -> { try { // Send the data sendData(data); } catch (Exception e) { // Something went wrong! :( if (logFailedRequests) { logger.warn("Could not submit plugin stats!", e); } } }).start(); }