Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 21
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '21'
java-version: '25'
distribution: 'temurin'
- name: Cache Maven packages
uses: actions/cache@v4
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<artifactId>CoreProtect</artifactId>
<version>23.1</version>
<properties>
<project.branch></project.branch>
<project.branch>development</project.branch>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTests>true</skipTests>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
</properties>
<build>
<resources>
Expand All @@ -28,8 +28,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<source>25</source>
<target>25</target>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -59,7 +59,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.6.1</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -216,7 +216,7 @@
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.11-R0.1-SNAPSHOT</version>
<version>26.1.1.build.15-alpha</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class BukkitAdapter implements BukkitInterface {
public static final int BUKKIT_V1_19 = 19;
public static final int BUKKIT_V1_20 = 20;
public static final int BUKKIT_V1_21 = 21;
public static final int BUKKIT_V26 = 26;

/**
* Initializes the appropriate Bukkit adapter based on the server version.
Expand All @@ -84,9 +85,12 @@ public static void loadAdapter() {
ADAPTER = new Bukkit_v1_20();
break;
case BUKKIT_V1_21:
default:
ADAPTER = new Bukkit_v1_21();
break;
case BUKKIT_V26:
default:
ADAPTER = new Bukkit_v26();
break;
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/coreprotect/bukkit/Bukkit_v26.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.coreprotect.bukkit;

/**
* Bukkit adapter for Minecraft 26.x.
*
* <p>26.1.x keeps the feature surface CoreProtect uses from 1.21, so this adapter
* currently reuses the 1.21 implementation while version detection and adapter
* selection move to the new release-number format.
*/
public final class Bukkit_v26 extends Bukkit_v1_21 {
}
3 changes: 2 additions & 1 deletion src/main/java/net/coreprotect/config/ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ public enum CacheType {
public static final String EDITION_NAME = VersionUtils.getPluginName();
public static final String COMMUNITY_EDITION = "Community Edition";
public static final String JAVA_VERSION = "11.0";
public static final String JAVA_VERSION_26 = "25.0";
public static final String MINECRAFT_VERSION = "1.16";
public static final String PATCH_VERSION = "23.1";
public static final String LATEST_VERSION = "1.21.11";
public static final String LATEST_VERSION = "26.1.1";
public static String path = "plugins/CoreProtect/";
public static String sqlite = "database.db";
public static String host = "127.0.0.1";
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/coreprotect/paper/PaperAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class PaperAdapter implements PaperInterface {
public static final int PAPER_V1_19 = BukkitAdapter.BUKKIT_V1_19;
public static final int PAPER_V1_20 = BukkitAdapter.BUKKIT_V1_20;
public static final int PAPER_V1_21 = BukkitAdapter.BUKKIT_V1_21;
public static final int PAPER_V26 = BukkitAdapter.BUKKIT_V26;

public static void loadAdapter() {
int paperVersion = ConfigHandler.SERVER_VERSION;
Expand All @@ -51,9 +52,12 @@ public static void loadAdapter() {
break;
case PAPER_V1_20:
case PAPER_V1_21:
default:
PaperAdapter.ADAPTER = new Paper_v1_20();
break;
case PAPER_V26:
default:
PaperAdapter.ADAPTER = new Paper_v26();
break;
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/coreprotect/paper/Paper_v26.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package net.coreprotect.paper;

/**
* Paper adapter for 26.x.
*
* <p>Paper 26.1.x remains compatible with the Paper-specific APIs currently used
* by CoreProtect, so this adapter reuses the 1.20+ implementation path.
*/
public final class Paper_v26 extends Paper_v1_20 {
}
51 changes: 43 additions & 8 deletions src/main/java/net/coreprotect/services/VersionCheckService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package net.coreprotect.services;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.bukkit.Bukkit;

import net.coreprotect.config.ConfigHandler;
Expand All @@ -14,6 +17,8 @@
*/
public class VersionCheckService {

private static final Pattern MINECRAFT_VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?");

private VersionCheckService() {
throw new IllegalStateException("Utility class");
}
Expand All @@ -26,21 +31,24 @@ private VersionCheckService() {
public static boolean performVersionChecks() {
try {
// Check Minecraft version compatibility
String[] bukkitVersion = Bukkit.getServer().getBukkitVersion().split("[-.]");
if (VersionUtils.newVersion(bukkitVersion[0] + "." + bukkitVersion[1], ConfigHandler.MINECRAFT_VERSION)) {
String bukkitVersion = Bukkit.getServer().getBukkitVersion();
String minecraftVersion = parseMinecraftVersion(bukkitVersion);
if (minecraftVersion == null || VersionUtils.newVersion(minecraftVersion, ConfigHandler.MINECRAFT_VERSION)) {
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Minecraft", ConfigHandler.MINECRAFT_VERSION));
return false;
}

if (VersionUtils.newVersion(ConfigHandler.LATEST_VERSION, bukkitVersion[0] + "." + bukkitVersion[1] + (bukkitVersion.length > 2 && bukkitVersion[2].matches("\\d+") ? "." + bukkitVersion[2] : "")) && VersionUtils.isCommunityEdition()) {
Chat.console(Phrase.build(Phrase.VERSION_INCOMPATIBLE, "Minecraft", bukkitVersion[0] + "." + bukkitVersion[1] + (bukkitVersion.length > 2 ? "." + bukkitVersion[2] : "")));
if (VersionUtils.newVersion(ConfigHandler.LATEST_VERSION, minecraftVersion) && VersionUtils.isCommunityEdition()) {
Chat.console(Phrase.build(Phrase.VERSION_INCOMPATIBLE, "Minecraft", minecraftVersion));
return false;
}

String requiredJavaVersion = parseCompatibilityVersion(minecraftVersion) >= 26 ? ConfigHandler.JAVA_VERSION_26 : ConfigHandler.JAVA_VERSION;

// Check Java version compatibility
String[] javaVersion = (System.getProperty("java.version").replaceAll("[^0-9.]", "") + ".0").split("\\.");
if (VersionUtils.newVersion(javaVersion[0] + "." + javaVersion[1], ConfigHandler.JAVA_VERSION)) {
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Java", ConfigHandler.JAVA_VERSION));
if (VersionUtils.newVersion(javaVersion[0] + "." + javaVersion[1], requiredJavaVersion)) {
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Java", requiredJavaVersion));
return false;
}

Expand All @@ -59,8 +67,8 @@ public static boolean performVersionChecks() {
return false;
}

// Store Minecraft server version for later use
ConfigHandler.SERVER_VERSION = Integer.parseInt(bukkitVersion[1]);
// Support both legacy 1.x versioning and the new year-based 26.x/26.1.x format.
ConfigHandler.SERVER_VERSION = parseCompatibilityVersion(minecraftVersion);
}
catch (Exception e) {
e.printStackTrace();
Expand All @@ -69,4 +77,31 @@ public static boolean performVersionChecks() {

return true;
}

private static String parseMinecraftVersion(String bukkitVersion) {
Matcher matcher = MINECRAFT_VERSION_PATTERN.matcher(bukkitVersion);
if (!matcher.find()) {
return null;
}

StringBuilder version = new StringBuilder(matcher.group(1)).append('.').append(matcher.group(2));
if (matcher.group(3) != null) {
version.append('.').append(matcher.group(3));
}

return version.toString();
}

private static int parseCompatibilityVersion(String minecraftVersion) {
String[] versionParts = minecraftVersion.split("\\.");
if (versionParts.length < 2) {
throw new IllegalArgumentException("Unsupported Minecraft version: " + minecraftVersion);
}

if ("1".equals(versionParts[0])) {
return Integer.parseInt(versionParts[1]);
}

return Integer.parseInt(versionParts[0]);
}
}
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/spigot/SpigotAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class SpigotAdapter implements SpigotInterface {
public static final int SPIGOT_V1_19 = BukkitAdapter.BUKKIT_V1_19;
public static final int SPIGOT_V1_20 = BukkitAdapter.BUKKIT_V1_20;
public static final int SPIGOT_V1_21 = BukkitAdapter.BUKKIT_V1_21;
public static final int SPIGOT_V26 = BukkitAdapter.BUKKIT_V26;

public static void loadAdapter() {
int spigotVersion = ConfigHandler.SERVER_VERSION;
Expand All @@ -42,6 +43,7 @@ public static void loadAdapter() {
case SPIGOT_V1_19:
case SPIGOT_V1_20:
case SPIGOT_V1_21:
case SPIGOT_V26:
default:
SpigotAdapter.ADAPTER = new SpigotHandler();
break;
Expand Down