feat(platform): support Purpur 26.3
CI / build (pull_request) Successful in 49s
CI / build (push) Successful in 1m7s

This commit is contained in:
dmg committed 2026-10-16 23:49:39 -04:00
1 parent 4abddb5d4d
commit 7496564b94
4 files changed
+231 -10

No files matched your search

@@ -21,11 +21,27 @@ class PurpurDistributionTest {
assertEquals(version, metadata.get("version"));
assertEquals("SpigotQuestBoard", metadata.get("name"), "Retain the data directory and persistent namespace");
assertEquals("games.dmg.spigotquestboard.SpigotQuestBoardPlugin", metadata.get("main"));
assertEquals("1.20", metadata.get("api-version"), "Retain the deliberate compatibility floor");
assertEquals(java.util.Set.of("quests", "questadmin"), ((Map<?, ?>) metadata.get("commands")).keySet());
assertTrue(((Map<?, ?>) metadata.get("permissions")).containsKey("spigotquestboard.admin"));
assertNull(metadata.get("depend"));
assertNull(metadata.get("softdepend"));
assertNull(metadata.get("loadbefore"));
var description = new org.bukkit.plugin.PluginDescriptionFile(jar.getInputStream(jar.getJarEntry("plugin.yml")));
assertEquals("spigotquestboard", description.namespace());
assertFalse(jar.stream().anyMatch(entry -> entry.getName().startsWith("org/bukkit/")
|| entry.getName().startsWith("org/purpurmc/") || entry.getName().endsWith("Test.class")));
assertFalse(jar.stream().anyMatch(entry -> {
String name = entry.getName();
return name.startsWith("org/bukkit/")
|| name.startsWith("org/purpurmc/")
|| name.startsWith("io/papermc/")
|| name.startsWith("com/destroystokyo/paper/")
|| name.startsWith("net/minecraft/")
|| name.startsWith("com/comphenix/protocol/")
|| name.startsWith("org/junit/")
|| name.startsWith("org/mockito/")
|| name.endsWith("Test.class")
|| name.contains("/test/");
}));
}
}
@@ -43,7 +59,8 @@ class PurpurDistributionTest {
@Test
void releaseAndCiAgreeWithThePurpurDistributionNameAndToolchain() throws Exception {
String build = Files.readString(Path.of("build.gradle.kts"));
assertTrue(build.contains("purpur-api:26.2.build.2618-stable"));
assertTrue(build.contains("purpur-api:26.3.build.2651-stable"));
assertFalse(build.contains("26.2.build.2618"));
assertFalse(build.contains("org.spigotmc:spigot-api"));
for (String workflow : new String[] {"ci.yml", "release.yml"}) {
String content = Files.readString(Path.of(".gitea/workflows", workflow));
@@ -0,0 +1,112 @@
package games.dmg.spigotquestboard;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
class PurpurRuntimeLifecycleTest {
private static final Duration STARTUP_TIMEOUT = Duration.ofMinutes(3);
@TempDir
Path serverDirectory;
@Test
void loadsEnablesAndDisablesOnExactSupportedPurpurRuntime() throws Exception {
Path runtimeJar = requiredPath("purpur.runtime.jar");
Path pluginJar = requiredPath("distribution.jar");
String version = System.getProperty("purpur.runtime.version");
String build = System.getProperty("purpur.runtime.build");
Path plugins = Files.createDirectories(serverDirectory.resolve("plugins"));
Files.copy(pluginJar, plugins.resolve(pluginJar.getFileName()), StandardCopyOption.REPLACE_EXISTING);
Files.writeString(serverDirectory.resolve("eula.txt"), "eula=true\n", UTF_8);
Files.writeString(serverDirectory.resolve("server.properties"), String.join("\n",
"level-name=runtime-world",
"online-mode=false",
"server-port=0",
"spawn-protection=0",
"sync-chunk-writes=true",
"") , UTF_8);
Process process = new ProcessBuilder(List.of(
javaExecutable().toString(),
"-Xms256M",
"-Xmx768M",
"-jar",
runtimeJar.toString(),
"--nogui"
)).directory(serverDirectory.toFile()).redirectErrorStream(true).start();
StringBuffer output = new StringBuffer();
AtomicBoolean stopSent = new AtomicBoolean();
try (var readerExecutor = Executors.newSingleThreadExecutor(
Thread.ofPlatform().name("purpur-runtime-output").factory())) {
var outputRead = readerExecutor.submit(() -> readOutputAndStop(process, output, stopSent));
boolean exited = process.waitFor(STARTUP_TIMEOUT.toSeconds(), TimeUnit.SECONDS);
if (!exited) {
process.destroyForcibly();
process.waitFor(30, TimeUnit.SECONDS);
}
outputRead.get(30, TimeUnit.SECONDS);
String log = output.toString();
assertTrue(exited, () -> "Purpur did not stop within " + STARTUP_TIMEOUT + "\n" + log);
assertEquals(0, process.exitValue(), log);
assertTrue(stopSent.get(), () -> "Purpur never completed startup\n" + log);
assertTrue(log.contains("Purpur") && log.contains(version) && log.contains(build),
() -> "Expected Purpur " + version + " build " + build + " identity\n" + log);
assertTrue(log.contains("Enabling SpigotQuestBoard"), log);
assertTrue(log.contains("Disabling SpigotQuestBoard"), log);
assertFalse(log.contains("Could not load plugin"), log);
assertFalse(log.contains("Error occurred while enabling SpigotQuestBoard"), log);
} finally {
if (process.isAlive()) {
process.destroyForcibly();
process.waitFor(30, TimeUnit.SECONDS);
}
}
}
private static Void readOutputAndStop(Process process, StringBuffer output, AtomicBoolean stopSent)
throws IOException {
try (var reader = new BufferedReader(new InputStreamReader(process.getInputStream(), UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
output.append(line).append('\n');
if (line.contains("Done (") && stopSent.compareAndSet(false, true)) {
process.getOutputStream().write("stop\n".getBytes(UTF_8));
process.getOutputStream().flush();
}
}
}
return null;
}
private static Path requiredPath(String property) {
String value = System.getProperty(property);
assertFalse(value == null || value.isBlank(), property + " must be configured");
Path path = Path.of(value);
assertTrue(Files.isRegularFile(path), () -> property + " does not exist: " + path);
return path;
}
private static Path javaExecutable() {
String executable = System.getProperty("os.name").startsWith("Windows") ? "java.exe" : "java";
return Path.of(System.getProperty("java.home"), "bin", executable);
}
}