Fix metrics scheduler for Folia (#2449)

This commit is contained in:
Lukas Alt 2023-07-02 23:43:51 +02:00 committed by GitHub
parent ff1d1250d1
commit 6ee4bbfe3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,9 @@
package com.comphenix.protocol.metrics;
import com.comphenix.protocol.ProtocolLib;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority;
import org.json.simple.JSONArray;
@ -56,7 +56,7 @@ public class Metrics {
private static String serverUUID;
// The plugin
private final Plugin plugin;
private final ProtocolLib plugin;
// A list with all custom charts
private final List<CustomChart> charts = new ArrayList<>();
@ -66,7 +66,7 @@ public class Metrics {
*
* @param plugin The plugin which stats should be submitted.
*/
public Metrics(Plugin plugin) {
public Metrics(ProtocolLib plugin) {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null!");
}
@ -151,7 +151,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, Metrics.this::submitData);
plugin.getScheduler().runTask(Metrics.this::submitData);
}
}, 1000L * 60 * 5, 1000L * 60 * 30);
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start