Skip to content

Commit

Permalink
make spigot compatible again
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Mar 27, 2024
1 parent 21ae7f3 commit 24f83a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ These statistics can be accessed via the /worldstats command and PlaceholderAPI

[![BetterWorldStats](https://bstats.org/signatures/bukkit/BetterWorldStats.svg)](https://bstats.org/plugin/bukkit/BetterWorldStats/17204)

### Supports Paper & Folia from 1.12.2 - 1.20.4.
### Supports Spigot, Paper & Folia from 1.12.2 - 1.20.4.

</div>

Expand Down
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ dependencies {
implementation("net.kyori:adventure-text-serializer-legacy:4.16.0")
implementation("net.kyori:adventure-text-logger-slf4j:4.16.0")

implementation("io.papermc:paperlib:1.0.8")
implementation("org.bstats:bstats-bukkit:3.0.2")
implementation("com.github.thatsmusic99:ConfigurationMaster-API:v2.0.0-rc.1")
implementation("com.github.ben-manes.caffeine:caffeine:2.9.3") // 2.X for Java 8 targets
implementation("com.github.thatsmusic99:ConfigurationMaster-API:v2.0.0-rc.1")
}

runPaper.folia.registerTask();
Expand All @@ -64,6 +65,7 @@ tasks {
shadowJar {
archiveFileName.set("BetterWorldStats-${version}.jar")
relocate("net.kyori", "me.xginko.betterworldstats.libs.kyori")
relocate("io.papermc.lib", "me.xginko.betterworldstats.libs.paperlib")
relocate("org.bstats", "me.xginko.betterworldstats.libs.bstats")
relocate("com.github.benmanes.caffeine", "me.xginko.betterworldstats.libs.caffeine")
relocate("io.github.thatsmusic99.configurationmaster", "me.xginko.betterworldstats.libs.configmaster")
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/me/xginko/betterworldstats/stats/FileStats.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.xginko.betterworldstats.stats;

import io.papermc.lib.PaperLib;
import me.xginko.betterworldstats.BetterWorldStats;
import me.xginko.betterworldstats.config.Config;
import net.kyori.adventure.text.Component;
Expand Down Expand Up @@ -48,9 +49,11 @@ private void refresh() {
}
});

for (final World world : BetterWorldStats.getInstance().getServer().getWorlds()) {
this.chunk_count.addAndGet(world.getChunkCount());
this.entity_count.addAndGet(world.getEntityCount());
if (PaperLib.isPaper()) {
for (final World world : BetterWorldStats.getInstance().getServer().getWorlds()) {
this.chunk_count.addAndGet(world.getChunkCount());
this.entity_count.addAndGet(world.getEntityCount());
}
}
}

Expand All @@ -76,12 +79,12 @@ public String getFileCount() {

public String getChunkCount() {
refresh();
return chunk_count.toString();
return PaperLib.isPaper() ? chunk_count.toString() : "unsupported";
}

public String getEntityCount() {
refresh();
return entity_count.toString();
return PaperLib.isPaper() ? entity_count.toString() : "unsupported";
}

private static class FileScanResult {
Expand Down

0 comments on commit 24f83a4

Please sign in to comment.