diff --git a/src/main/java/org/maxgamer/quickshop/Metrics.java b/src/main/java/org/maxgamer/quickshop/Metrics.java index e9b804bed..ec7b53067 100644 --- a/src/main/java/org/maxgamer/quickshop/Metrics.java +++ b/src/main/java/org/maxgamer/quickshop/Metrics.java @@ -4,6 +4,7 @@ import java.io.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.Callable; import java.util.logging.Level; @@ -134,12 +135,7 @@ public class Metrics { } // Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler // Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;) - Bukkit.getScheduler().runTask(plugin, new Runnable() { - @Override - public void run() { - submitData(); - } - }); + Bukkit.getScheduler().runTask(plugin, () -> submitData()); } }, 1000 * 60 * 5, 1000 * 60 * 30); // Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start @@ -245,15 +241,12 @@ public class Metrics { data.put("plugins", pluginData); // Create a new thread for the connection to the bStats server - new Thread(new Runnable() { - @Override - public void run() { - try { - // Send the data - plugin.getLogger().info("Sending stats data..."); - sendData(data); - } catch (Throwable e) { /*Ignore*/ } - } + new Thread(() -> { + try { + // Send the data + plugin.getLogger().info("Sending stats data..."); + sendData(data); + } catch (Throwable e) { /*Ignore*/ } }).start(); } @@ -309,7 +302,7 @@ public class Metrics { } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(outputStream); - gzip.write(str.getBytes("UTF-8")); + gzip.write(str.getBytes(StandardCharsets.UTF_8)); gzip.close(); return outputStream.toByteArray(); }