Introduce gradle-plugin and mod-tools modules. Add ZomboidForge Gradle plugin for building, checking, and packaging mods. Include support for local test servers, automated game jar downloads, and mod descriptor generation. Add mod-tools for runtime mod checks and validations.

This commit is contained in:
Overlord committed 2026-10-02 15:36:10 +02:00
1 parent 68cd9fc4f9
commit 063ad8a3e1
27 files changed
+1976 -30

No files matched your search

@@ -22,11 +22,11 @@ public final class GameClasses implements AutoCloseable
private static final String CLASS_SUFFIX = ".class";
private static final Pattern VERSIONED = Pattern.compile("META-INF/versions/\\d+/(.+)");
private final JarFile file;
private final Set<String> classes;
private final Set<String> packages;
private final @Nullable JarFile file;
private final Set<String> classes;
private final Set<String> packages;
private GameClasses(JarFile file, Set<String> classes, Set<String> packages)
private GameClasses(@Nullable JarFile file, Set<String> classes, Set<String> packages)
{
this.file = file;
this.classes = Set.copyOf(classes);
@@ -56,6 +56,9 @@ public final class GameClasses implements AutoCloseable
return new GameClasses(file, classes, packages);
}
/** No game classes, for checking a mod that declares no {@code game} versions without a game jar. */
public static GameClasses none() { return new GameClasses(null, Set.of(), Set.of()); }
/** Whether the jar contains the class with this internal name, e.g. {@code zombie/core/Core}. */
public boolean contains(String internalName) { return this.classes.contains(internalName); }
@@ -65,14 +68,21 @@ public final class GameClasses implements AutoCloseable
/** The class file for the running Java version, or {@code null} when the jar has none. */
byte @Nullable [] read(String internalName) throws IOException
{
JarEntry entry = this.file.getJarEntry(internalName + GameClasses.CLASS_SUFFIX);
JarFile file = this.file;
if (file == null) return null;
JarEntry entry = file.getJarEntry(internalName + GameClasses.CLASS_SUFFIX);
if (entry == null) return null;
try (InputStream in = this.file.getInputStream(entry)) { return in.readAllBytes(); }
try (InputStream in = file.getInputStream(entry)) { return in.readAllBytes(); }
}
@Override
public void close() throws IOException { this.file.close(); }
public void close() throws IOException
{
JarFile file = this.file;
if (file != null) file.close();
}
static String packageOf(String internalName)
{
@@ -67,9 +67,10 @@ public final class ModVerifier
/**
* @param ordered mods in load order, as returned by {@link ModResolver#resolve}
* @param version the version of {@code game}, for messages; {@code null} with {@link GameClasses#none()}
* @throws ModLoadException listing every problem of every mod
*/
public static void verify(List<ModDiscovery.Candidate> ordered, GameClasses game, GameVersion version) throws ModLoadException
public static void verify(List<ModDiscovery.Candidate> ordered, GameClasses game, @Nullable GameVersion version) throws ModLoadException
{
Hierarchy hierarchy = new Hierarchy(game);
Map<String, Set<String>> ownByMod = new HashMap<>();
@@ -139,7 +140,7 @@ public final class ModVerifier
}
if (!linkage.isEmpty())
problems.add("'" + id + "': uses " + ModVerifier.examples(linkage) + ", which " + (linkage.size() == 1 ? "does" : "do") + " not exist in Project Zomboid " + version + ".");
problems.add("'" + id + "': uses " + ModVerifier.examples(linkage) + ", which " + (linkage.size() == 1 ? "does" : "do") + " not exist in " + (version == null ? "the game jar" : "Project Zomboid " + version) + ".");
}
if (!problems.isEmpty()) throw new ModLoadException(problems);