Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for folia #126

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 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,17 @@ public Metrics(Plugin plugin, int serviceId) {
boolean logSentData = config.getBoolean("logSentData", false);
boolean logResponseStatusText = config.getBoolean("logResponseStatusText", false);

String minecraftVersion2 = Bukkit.getServer().getName();
boolean folia = (minecraftVersion2.toUpperCase().contains("FOLIA"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't catch forks of folia, you should detect if the class io.papermc.paper.threadedregions.RegionizedServer exists instead.


metricsBase = new MetricsBase(
"bukkit",
serverUUID,
serviceId,
enabled,
this::appendPlatformData,
this::appendServiceData,
submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask),
folia ? null : submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask),
Bastian marked this conversation as resolved.
Show resolved Hide resolved
plugin::isEnabled,
(message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error),
(message) -> this.plugin.getLogger().log(Level.INFO, message),
Expand All @@ -78,6 +81,7 @@ public Metrics(Plugin plugin, int serviceId) {
logResponseStatusText,
false
);

}

/**
Expand Down