mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Cleanup Codes
Former-commit-id: b68da7fc2c7a575f2b7426e6d40b6af32704548c [formerly 368058781c8d63890f22389e9596708f604eaee7] Former-commit-id: ffc8e3c3d7698a728f8dd37c4a61edb7f80e4580
This commit is contained in:
1 parent
71e2728b63
commit
d79dbdaae2
1 file changed
+9
-16
@@ -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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user