Add ModCheckTest to test runtime mod validations and entry point superclass checks. Include Gradle verification metadata for dependency integrity.
This commit is contained in:
1 parent
18ff32b5ce
commit
6761f2d9ea
29 files changed
+1306
-72
No files matched your search
@@ -9,8 +9,9 @@ import java.util.regex.Pattern;
|
||||
/** Project Zomboid version, e.g. 42.21.0 ({@code Core.getGameAndBuildVersion()}). */
|
||||
public record GameVersion(int major, int minor, int build) implements Comparable<GameVersion>
|
||||
{
|
||||
private static final Pattern VERSION = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?");
|
||||
private static final Pattern PREFIX = Pattern.compile("(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?");
|
||||
// At most 9 digits per number, so every number fits an int.
|
||||
private static final Pattern VERSION = Pattern.compile("(\\d{1,9})\\.(\\d{1,9})(?:\\.(\\d{1,9}))?");
|
||||
private static final Pattern PREFIX = Pattern.compile("(\\d{1,9})(?:\\.(\\d{1,9})(?:\\.(\\d{1,9}))?)?");
|
||||
|
||||
private static final Comparator<GameVersion> ORDER = Comparator
|
||||
.comparingInt(GameVersion::major)
|
||||
|
||||
@@ -4,7 +4,8 @@ import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* The mod's tables in {@code zomboidforge.db}, next to the world's save. Every table belongs to
|
||||
* the mod; other mods cannot reach it.
|
||||
* the mod; this interface gives no access to the tables of other mods. It is not a security
|
||||
* boundary: mod code runs with the server's privileges and can open the file directly.
|
||||
*
|
||||
* <p>A record declares a table's columns: {@code String}, {@code long}/{@code int},
|
||||
* {@code double}/{@code float}, {@code boolean}, {@code byte[]}, {@code UUID}, {@code Instant},
|
||||
@@ -26,6 +27,10 @@ public interface ModStorage
|
||||
/**
|
||||
* Runs {@code work} in one transaction: writes of this thread inside it are committed
|
||||
* together, or not at all when {@code work} throws.
|
||||
*
|
||||
* <p>Storage of every mod waits while {@code work} runs, so {@code work} must not wait for
|
||||
* other threads, for example with {@code main().submit(...).join()}. A backup waits at most
|
||||
* 10 seconds for it and then runs without pausing storage.
|
||||
*/
|
||||
void transaction(Runnable work);
|
||||
|
||||
|
||||
@@ -37,7 +37,11 @@ public interface Table<R extends Record>
|
||||
/** Every key, sorted. */
|
||||
List<String> keys();
|
||||
|
||||
/** Calls {@code action} for every row, sorted by key, without loading all rows at once. */
|
||||
/**
|
||||
* Calls {@code action} for every row, sorted by key, without loading all rows at once.
|
||||
* Storage of every mod waits until it returns, so {@code action} must not wait for other
|
||||
* threads.
|
||||
*/
|
||||
void forEach(BiConsumer<String, R> action);
|
||||
|
||||
long count();
|
||||
@@ -45,6 +49,8 @@ public interface Table<R extends Record>
|
||||
/**
|
||||
* Replaces the row under {@code key} with {@code change} applied to it, or to
|
||||
* {@code initial} when there is none, in one transaction: no other write comes in between.
|
||||
* As in {@link ModStorage#transaction}, {@code change} and {@code initial} must not wait for
|
||||
* other threads.
|
||||
*
|
||||
* @return the stored value
|
||||
*/
|
||||
|
||||
@@ -42,6 +42,16 @@ class GameVersionTest
|
||||
assertThrows(IllegalArgumentException.class, () -> version.matches("42.21.3.1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsNumbersOutsideTheIntRange()
|
||||
{
|
||||
GameVersion version = new GameVersion(42, 21, 3);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> GameVersion.parse("42.99999999999"));
|
||||
assertThrows(IllegalArgumentException.class, () -> version.matches("99999999999"));
|
||||
assertFalse(GameVersion.isPrefix("42.99999999999"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void comparesNumerically()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user