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

adde Folia support #3617

Merged
merged 14 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions Plan/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def buildVersion = determineBuildVersion()
allprojects {

group "com.djrapitops"
version "5.6-SNAPSHOT"
version "5.7-SNAPSHOT"
AuroraLS3 marked this conversation as resolved.
Show resolved Hide resolved

ext.majorVersion = '5'
ext.minorVersion = '6'
ext.minorVersion = '7'
AuroraLS3 marked this conversation as resolved.
Show resolved Hide resolved
ext.buildVersion = buildVersion
ext.fullVersion = project.ext.majorVersion + '.' + project.ext.minorVersion + ' build ' + project.ext.buildVersion
ext.fullVersionFilename = project.ext.majorVersion + '.' + project.ext.minorVersion + '-build-' + project.ext.buildVersion
Expand Down Expand Up @@ -71,7 +71,7 @@ subprojects {
ext {
daggerVersion = "2.51.1"

palVersion = "5.1.0"
palVersion = "5.2.0"

bukkitVersion = "1.13.2-R0.1-SNAPSHOT"
spigotVersion = "1.13.2-R0.1-SNAPSHOT"
Expand Down Expand Up @@ -112,6 +112,7 @@ subprojects {
}

repositories {
mavenLocal()
AuroraLS3 marked this conversation as resolved.
Show resolved Hide resolved
mavenCentral()
google()
maven { url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } // Spigot
Expand Down
32 changes: 30 additions & 2 deletions Plan/bukkit/src/main/java/com/djrapitops/plan/Plan.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.lang.reflect.Constructor;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand All @@ -62,7 +63,18 @@ public class Plan extends JavaPlugin implements PlanPlugin {

@Override
public void onLoad() {
abstractionLayer = new BukkitPlatformLayer(this);
if (isJava17OrLater() && isFolia()) {
AuroraLS3 marked this conversation as resolved.
Show resolved Hide resolved
try {
// Attempt to load and use the Folia library for Java 17+
Class<?> foliaPlatformLayer = Class.forName("net.playeranalytics.plugin.FoliaPlatformLayer");
abstractionLayer = (PlatformAbstractionLayer) foliaPlatformLayer.getConstructor(JavaPlugin.class).newInstance(this);
} catch (Exception e) {
this.getLogger().log(Level.SEVERE, "Failed to load FoliaPlatformLayer", e);
abstractionLayer = new BukkitPlatformLayer(this);
}
} else {
abstractionLayer = new BukkitPlatformLayer(this);
}
pluginLogger = abstractionLayer.getPluginLogger();
runnableFactory = abstractionLayer.getRunnableFactory();
}
Expand Down Expand Up @@ -167,7 +179,23 @@ private void storeSessionsOnShutdown() {

public void cancelAllTasks() {
runnableFactory.cancelAllKnownTasks();
Bukkit.getScheduler().cancelTasks(this);
if (!isFolia()) {
Bukkit.getScheduler().cancelTasks(this);
}
}

private static boolean isFolia() {
try {
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}

private static boolean isJava17OrLater() {
String version = System.getProperty("java.version");
return version.startsWith("17") || version.compareTo("17") > 0;
AuroraLS3 marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public class Contributors {
new Contributor("liuzhen932", LANG),
new Contributor("Sniper_TVmc", LANG),
new Contributor("mcmdev", CODE),
new Contributor("ZhangYuheng", CODE)
};

private Contributors() {
Expand Down
1 change: 1 addition & 0 deletions Plan/common/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ author: AuroraLS3
main: com.djrapitops.plan.Plan
version: @version@
api-version: 1.13
folia-supported: true
softdepend:
- AAC
- ASkyBlock
Expand Down
15 changes: 15 additions & 0 deletions Plan/folia/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
compileJava {
options.release = 17
}

javadoc {
enabled = false
}

dependencies {
shadow "net.playeranalytics:platform-abstraction-layer-folia:$palVersion"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
}


shadowJar {
configurations = [project.configurations.shadow]
}
1 change: 1 addition & 0 deletions Plan/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies {
shadow project(path: ":sponge")
shadow project(path: ":bungeecord")
shadow project(path: ":velocity")
shadow project(path: ":folia")
testImplementation project(path: ":common", configuration: 'testArtifacts')
testImplementation project(path: ":bukkit", configuration: 'testArtifacts')
testImplementation project(path: ":nukkit", configuration: 'testArtifacts')
Expand Down
1 change: 1 addition & 0 deletions Plan/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ include 'plugin'
include 'extensions'
include 'extensions:adventure'
include 'fabric'
include 'folia'