Skip to content

Commit

Permalink
Add support for Folia (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricsal1 authored Sep 22, 2024
1 parent 6f97853 commit 388d72a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bukkit/src/main/java/org/bstats/bukkit/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Metrics {
/**
* Creates a new Metrics instance.
*
* @param plugin Your plugin instance.
* @param plugin Your plugin instance.
* @param serviceId The id of the service.
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
*/
Expand Down Expand Up @@ -62,14 +62,20 @@ public Metrics(Plugin plugin, int serviceId) {
boolean logSentData = config.getBoolean("logSentData", false);
boolean logResponseStatusText = config.getBoolean("logResponseStatusText", false);

boolean isFolia = false;
try {
isFolia = Class.forName("io.papermc.paper.threadedregions.RegionizedServer") != null;
} catch (Exception e) {}

metricsBase = new MetricsBase(
"bukkit",
serverUUID,
serviceId,
enabled,
this::appendPlatformData,
this::appendServiceData,
submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask),
// See https://github.com/Bastian/bstats-metrics/pull/126
isFolia ? null : submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask),
plugin::isEnabled,
(message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error),
(message) -> this.plugin.getLogger().log(Level.INFO, message),
Expand All @@ -78,6 +84,7 @@ public Metrics(Plugin plugin, int serviceId) {
logResponseStatusText,
false
);

}

/**
Expand Down

0 comments on commit 388d72a

Please # to comment.