mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 06:28:54 +00:00
Revert inferring on Metrics
This commit is contained in:
1 file changed
+20
-22
@@ -10,8 +10,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.ServicePriority;
|
import org.bukkit.plugin.ServicePriority;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@@ -65,10 +63,10 @@ public class Metrics {
|
|||||||
private static boolean logResponseStatusText;
|
private static boolean logResponseStatusText;
|
||||||
|
|
||||||
// The uuid of the server
|
// The uuid of the server
|
||||||
private static @Nullable String serverUUID;
|
private static String serverUUID;
|
||||||
|
|
||||||
// The plugin
|
// The plugin
|
||||||
private final @Nullable Plugin plugin;
|
private final Plugin plugin;
|
||||||
|
|
||||||
// The plugin id
|
// The plugin id
|
||||||
private final int pluginId;
|
private final int pluginId;
|
||||||
@@ -83,7 +81,7 @@ public class Metrics {
|
|||||||
* @param pluginId The id of the plugin.
|
* @param pluginId The id of the plugin.
|
||||||
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
|
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
|
||||||
*/
|
*/
|
||||||
public Metrics(@Nullable Plugin plugin, int pluginId) {
|
public Metrics(Plugin plugin, int pluginId) {
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
||||||
throw new IllegalArgumentException("Plugin cannot be null!");
|
throw new IllegalArgumentException("Plugin cannot be null!");
|
||||||
}
|
}
|
||||||
@@ -161,7 +159,7 @@ public class Metrics {
|
|||||||
*
|
*
|
||||||
* @param chart The chart to add.
|
* @param chart The chart to add.
|
||||||
*/
|
*/
|
||||||
public void addCustomChart(@Nullable CustomChart chart) {
|
public void addCustomChart(CustomChart chart) {
|
||||||
if (chart == null) {
|
if (chart == null) {
|
||||||
throw new IllegalArgumentException("Chart cannot be null!");
|
throw new IllegalArgumentException("Chart cannot be null!");
|
||||||
}
|
}
|
||||||
@@ -196,7 +194,7 @@ public class Metrics {
|
|||||||
*
|
*
|
||||||
* @return The plugin specific data.
|
* @return The plugin specific data.
|
||||||
*/
|
*/
|
||||||
public @NonNull JsonObject getPluginData() {
|
public JsonObject getPluginData() {
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
|
|
||||||
String pluginName = plugin.getDescription().getName();
|
String pluginName = plugin.getDescription().getName();
|
||||||
@@ -224,7 +222,7 @@ public class Metrics {
|
|||||||
*
|
*
|
||||||
* @return The server specific data.
|
* @return The server specific data.
|
||||||
*/
|
*/
|
||||||
private @NonNull JsonObject getServerData() {
|
private JsonObject getServerData() {
|
||||||
// Minecraft specific data
|
// Minecraft specific data
|
||||||
int playerAmount;
|
int playerAmount;
|
||||||
try {
|
try {
|
||||||
@@ -300,7 +298,7 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (@NonNull NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
|
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
|
||||||
}
|
}
|
||||||
} catch (NoSuchFieldException ignored) { }
|
} catch (NoSuchFieldException ignored) { }
|
||||||
}
|
}
|
||||||
@@ -328,7 +326,7 @@ public class Metrics {
|
|||||||
* @param data The data to send.
|
* @param data The data to send.
|
||||||
* @throws Exception If the request failed.
|
* @throws Exception If the request failed.
|
||||||
*/
|
*/
|
||||||
private static void sendData(@NonNull Plugin plugin, @Nullable JsonObject data) throws Exception {
|
private static void sendData(Plugin plugin, JsonObject data) throws Exception {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
throw new IllegalArgumentException("Data cannot be null!");
|
throw new IllegalArgumentException("Data cannot be null!");
|
||||||
}
|
}
|
||||||
@@ -378,7 +376,7 @@ public class Metrics {
|
|||||||
* @return The gzipped String.
|
* @return The gzipped String.
|
||||||
* @throws IOException If the compression failed.
|
* @throws IOException If the compression failed.
|
||||||
*/
|
*/
|
||||||
private static byte @Nullable [] compress(final @Nullable String str) throws IOException {
|
private static byte[] compress(final String str) throws IOException {
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -395,21 +393,21 @@ public class Metrics {
|
|||||||
public static abstract class CustomChart {
|
public static abstract class CustomChart {
|
||||||
|
|
||||||
// The id of the chart
|
// The id of the chart
|
||||||
final @Nullable String chartId;
|
final String chartId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor.
|
* Class constructor.
|
||||||
*
|
*
|
||||||
* @param chartId The id of the chart.
|
* @param chartId The id of the chart.
|
||||||
*/
|
*/
|
||||||
CustomChart(@Nullable String chartId) {
|
CustomChart(String chartId) {
|
||||||
if (chartId == null || chartId.isEmpty()) {
|
if (chartId == null || chartId.isEmpty()) {
|
||||||
throw new IllegalArgumentException("ChartId cannot be null or empty!");
|
throw new IllegalArgumentException("ChartId cannot be null or empty!");
|
||||||
}
|
}
|
||||||
this.chartId = chartId;
|
this.chartId = chartId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable JsonObject getRequestJsonObject() {
|
private JsonObject getRequestJsonObject() {
|
||||||
JsonObject chart = new JsonObject();
|
JsonObject chart = new JsonObject();
|
||||||
chart.addProperty("chartId", chartId);
|
chart.addProperty("chartId", chartId);
|
||||||
try {
|
try {
|
||||||
@@ -428,7 +426,7 @@ public class Metrics {
|
|||||||
return chart;
|
return chart;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract @Nullable JsonObject getChartData() throws Exception;
|
protected abstract JsonObject getChartData() throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +449,7 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable JsonObject getChartData() throws Exception {
|
protected JsonObject getChartData() throws Exception {
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
String value = callable.call();
|
String value = callable.call();
|
||||||
if (value == null || value.isEmpty()) {
|
if (value == null || value.isEmpty()) {
|
||||||
@@ -482,7 +480,7 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable JsonObject getChartData() throws Exception {
|
protected JsonObject getChartData() throws Exception {
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
JsonObject values = new JsonObject();
|
JsonObject values = new JsonObject();
|
||||||
Map<String, Integer> map = callable.call();
|
Map<String, Integer> map = callable.call();
|
||||||
@@ -526,7 +524,7 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable JsonObject getChartData() throws Exception {
|
public JsonObject getChartData() throws Exception {
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
JsonObject values = new JsonObject();
|
JsonObject values = new JsonObject();
|
||||||
Map<String, Map<String, Integer>> map = callable.call();
|
Map<String, Map<String, Integer>> map = callable.call();
|
||||||
@@ -575,7 +573,7 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable JsonObject getChartData() throws Exception {
|
protected JsonObject getChartData() throws Exception {
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
int value = callable.call();
|
int value = callable.call();
|
||||||
if (value == 0) {
|
if (value == 0) {
|
||||||
@@ -607,7 +605,7 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable JsonObject getChartData() throws Exception {
|
protected JsonObject getChartData() throws Exception {
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
JsonObject values = new JsonObject();
|
JsonObject values = new JsonObject();
|
||||||
Map<String, Integer> map = callable.call();
|
Map<String, Integer> map = callable.call();
|
||||||
@@ -652,7 +650,7 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable JsonObject getChartData() throws Exception {
|
protected JsonObject getChartData() throws Exception {
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
JsonObject values = new JsonObject();
|
JsonObject values = new JsonObject();
|
||||||
Map<String, Integer> map = callable.call();
|
Map<String, Integer> map = callable.call();
|
||||||
@@ -690,7 +688,7 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable JsonObject getChartData() throws Exception {
|
protected JsonObject getChartData() throws Exception {
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
JsonObject values = new JsonObject();
|
JsonObject values = new JsonObject();
|
||||||
Map<String, int[]> map = callable.call();
|
Map<String, int[]> map = callable.call();
|
||||||
|
|||||||
Reference in new issue
Block a user