Skip to content

Commit 92bd558

Browse files
authored
Merge pull request #49 from faststats-dev/fix/data-folder-resolution
Fix plugin folder resolution for metrics creation
2 parents 032c91b + fbd5684 commit 92bd558

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bukkit/src/main/java/dev/faststats/bukkit/BukkitMetricsImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.jetbrains.annotations.Contract;
1010
import org.jspecify.annotations.Nullable;
1111

12+
import java.io.File;
1213
import java.nio.file.Path;
1314
import java.util.Optional;
1415
import java.util.function.Supplier;
@@ -93,9 +94,17 @@ private <T> Optional<T> tryOrEmpty(Supplier<T> supplier) {
9394
static final class Factory extends SimpleMetrics.Factory<Plugin> {
9495
@Override
9596
public Metrics create(Plugin plugin) throws IllegalStateException {
96-
var dataFolder = plugin.getServer().getPluginsFolder().toPath().resolve("faststats");
97+
var dataFolder = getPluginsFolder(plugin).resolve("faststats");
9798
var config = dataFolder.resolve("config.properties");
9899
return new BukkitMetricsImpl(this, plugin, config);
99100
}
101+
102+
private static Path getPluginsFolder(Plugin plugin) {
103+
try {
104+
return plugin.getServer().getPluginsFolder().toPath();
105+
} catch (NoSuchMethodError e) {
106+
return plugin.getDataFolder().getParentFile().toPath();
107+
}
108+
}
100109
}
101110
}

0 commit comments

Comments
 (0)