Fix metrics scheduler for Folia (#2449)
This commit is contained in:
parent
ff1d1250d1
commit
6ee4bbfe3d
|
@ -1,9 +1,9 @@
|
||||||
package com.comphenix.protocol.metrics;
|
package com.comphenix.protocol.metrics;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.ProtocolLib;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
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.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
|
@ -56,7 +56,7 @@ public class Metrics {
|
||||||
private static String serverUUID;
|
private static String serverUUID;
|
||||||
|
|
||||||
// The plugin
|
// The plugin
|
||||||
private final Plugin plugin;
|
private final ProtocolLib plugin;
|
||||||
|
|
||||||
// A list with all custom charts
|
// A list with all custom charts
|
||||||
private final List<CustomChart> charts = new ArrayList<>();
|
private final List<CustomChart> charts = new ArrayList<>();
|
||||||
|
@ -66,7 +66,7 @@ public class Metrics {
|
||||||
*
|
*
|
||||||
* @param plugin The plugin which stats should be submitted.
|
* @param plugin The plugin which stats should be submitted.
|
||||||
*/
|
*/
|
||||||
public Metrics(Plugin plugin) {
|
public Metrics(ProtocolLib plugin) {
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
||||||
throw new IllegalArgumentException("Plugin cannot be 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
|
// 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 ;)
|
// 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);
|
}, 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
|
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
|
||||||
|
|
Loading…
Reference in New Issue