Skip to content

Commit 03839b6

Browse files
committed
Add Folia platform type and isFolia method to Paper module
1 parent 8874138 commit 03839b6

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

bootstrap/paper/src/main/java/dev/triassic/template/paper/PaperTemplatePlugin.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,25 @@ public void onDisable() {
7474

7575
@Override
7676
public @NonNull PlatformType platformType() {
77-
return PlatformType.PAPER;
77+
return isFolia() ? PlatformType.FOLIA : PlatformType.PAPER;
7878
}
7979

8080
@Override
8181
public @NonNull CommandManager<Commander> commandManager() {
8282
return this.commandManager;
8383
}
84+
85+
/**
86+
* Check if the server is running on Folia.
87+
*
88+
* @return {@code true} if running on Folia, otherwise {@code false}
89+
*/
90+
public static boolean isFolia() {
91+
try {
92+
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
93+
return true;
94+
} catch (ClassNotFoundException e) {
95+
return false;
96+
}
97+
}
8498
}

core/src/main/java/dev/triassic/template/TemplateImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public void initialize() {
6363
this.commandRegistry = new CommandRegistry(this, commandManager);
6464
commandRegistry.registerAll(platformType);
6565

66-
logger.info("Enabled in {}ms", System.currentTimeMillis() - startTime);
66+
logger.info("Enabled on {} in {}ms",
67+
getPlatformType(), System.currentTimeMillis() - startTime);
6768
}
6869

6970
/**

core/src/main/java/dev/triassic/template/util/PlatformType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public enum PlatformType {
2222
BUKKIT("Bukkit", false),
2323
BUNGEECORD("Bungeecord", true),
2424
FABRIC("Fabric", false),
25+
FOLIA("Folia", false),
2526
NEOFORGE("NeoForge", false),
2627
PAPER("Paper", false),
2728
VELOCITY("Velocity", true);

0 commit comments

Comments
 (0)