Compare commits
9
Commits
36df4a46b9
..
v0.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0cd30a0d7 | ||
|
|
a351fc237c | ||
|
|
af7174e128 | ||
|
|
22077514fe | ||
|
|
6761f2d9ea | ||
|
|
18ff32b5ce | ||
|
|
67530d35e9 | ||
|
|
26ca1b90a2 | ||
|
|
c529b04ff0 |
No files matched your search
@@ -15,12 +15,12 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
# One entry per supported version; add older Steam version branches
|
# One entry per supported version; add older Steam version branches
|
||||||
# (e.g. pz_version 42.19, steam_branch 42.19) to keep them building.
|
# (e.g. pz_version 42.19, steam_branch 42.19) to keep them building.
|
||||||
- pz_version: "42.21"
|
- pz_version: "42"
|
||||||
steam_branch: public
|
steam_branch: public
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||||
with:
|
with:
|
||||||
# release.sh derives the version from the newest v* tag
|
# release.sh derives the version from the v* tags
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Build and verify
|
- name: Build and verify
|
||||||
|
|||||||
@@ -9,25 +9,27 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
maven:
|
maven:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||||
with:
|
with:
|
||||||
# publish.sh derives the version from the newest v* tag
|
# publish.sh derives the version from the v* tag on HEAD
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: actions/setup-java@v4
|
- uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: "25"
|
java-version: "25"
|
||||||
|
|
||||||
- name: Test and publish
|
# The tests run without the registry credentials; only the publish step gets them.
|
||||||
|
- name: Test
|
||||||
|
run: ci/publish.sh test
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
env:
|
env:
|
||||||
ORG_GRADLE_PROJECT_giteaUsername: ${{ secrets.REGISTRY_USER }}
|
ORG_GRADLE_PROJECT_giteaUsername: ${{ secrets.REGISTRY_USER }}
|
||||||
ORG_GRADLE_PROJECT_giteaPassword: ${{ secrets.REGISTRY_TOKEN }}
|
ORG_GRADLE_PROJECT_giteaPassword: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
PUBLISH: "true"
|
run: ci/publish.sh publish
|
||||||
run: ci/publish.sh
|
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
# Publishes an image for every new Steam build of each supported Project Zomboid
|
# Publishes an image for every new Project Zomboid version (hotfixes included) of each
|
||||||
# version. Immutable tags are never overwritten (see ci/release.sh).
|
# matrix entry and every new ZomboidForge release; full version tags are never overwritten
|
||||||
|
# (see ci/release.sh).
|
||||||
# Requires the repository secrets REGISTRY_USER and REGISTRY_TOKEN (a token with
|
# Requires the repository secrets REGISTRY_USER and REGISTRY_TOKEN (a token with
|
||||||
# package write access) and a runner with a Docker (or Podman) CLI.
|
# package write access) and a runner with a Docker (or Podman) CLI.
|
||||||
name: release
|
name: release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
# Every 2.5 hours; cron cannot divide a day into 2.5-hour steps, so the gap
|
||||||
|
# from 22:30 to 00:00 is 1.5 hours.
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 */6 * * *"
|
- cron: "0 0,5,10,15,20 * * *"
|
||||||
|
- cron: "30 2,7,12,17,22 * * *"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -16,13 +20,13 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- pz_version: "42.21"
|
- pz_version: "42"
|
||||||
steam_branch: public
|
steam_branch: public
|
||||||
latest: "true"
|
latest: "true"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||||
with:
|
with:
|
||||||
# release.sh derives the version from the newest v* tag
|
# release.sh derives the version from the v* tags
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Log in to the registry
|
- name: Log in to the registry
|
||||||
@@ -39,3 +43,8 @@ jobs:
|
|||||||
PUBLISH: "true"
|
PUBLISH: "true"
|
||||||
LATEST: ${{ matrix.latest }}
|
LATEST: ${{ matrix.latest }}
|
||||||
run: ci/release.sh
|
run: ci/release.sh
|
||||||
|
|
||||||
|
# Removes the stored registry token, also when a step failed, in case the runner is reused.
|
||||||
|
- name: Log out of the registry
|
||||||
|
if: always()
|
||||||
|
run: docker logout git.security-command.org
|
||||||
+43
-6
@@ -6,6 +6,10 @@
|
|||||||
# podman build --platform linux/amd64 -t zomboidforge .
|
# podman build --platform linux/amd64 -t zomboidforge .
|
||||||
# podman build --build-arg PZ_BRANCH=42.19 --build-arg PZ_VERSION=42.19 ...
|
# podman build --build-arg PZ_BRANCH=42.19 --build-arg PZ_VERSION=42.19 ...
|
||||||
#
|
#
|
||||||
|
# The stage game-version (--target game-version) downloads only the server jar of
|
||||||
|
# PZ_BRANCH and writes its game version to /game-version; ci/release.sh uses it to
|
||||||
|
# name the image before the full build.
|
||||||
|
#
|
||||||
# Build arguments:
|
# Build arguments:
|
||||||
# PZ_BRANCH Steam branch of app 380870: public, unstable, or a version branch (42.19, ...)
|
# PZ_BRANCH Steam branch of app 380870: public, unstable, or a version branch (42.19, ...)
|
||||||
# PZ_VERSION Expected Project Zomboid version; the build fails when the downloaded
|
# PZ_VERSION Expected Project Zomboid version; the build fails when the downloaded
|
||||||
@@ -14,7 +18,8 @@
|
|||||||
# files with steamcmd's newer copies
|
# files with steamcmd's newer copies
|
||||||
# FORGE_VERSION ZomboidForge version (jar manifest, image label); set by ci/release.sh.
|
# FORGE_VERSION ZomboidForge version (jar manifest, image label); set by ci/release.sh.
|
||||||
# Default: 0.0.0-prerelease
|
# Default: 0.0.0-prerelease
|
||||||
# STEAM_BUILDID Image label only; set by ci/release.sh
|
# STEAM_BUILDID Image label; in the stage game-version it keeps the cached result until
|
||||||
|
# Steam publishes a new build. Set by ci/release.sh
|
||||||
# DISABLED_PATCHES Comma-separated simple class names of build-time patches to skip
|
# DISABLED_PATCHES Comma-separated simple class names of build-time patches to skip
|
||||||
# (debug builds only; ci/release.sh never sets it)
|
# (debug builds only; ci/release.sh never sets it)
|
||||||
|
|
||||||
@@ -24,8 +29,11 @@ ARG STEAMCLIENT=bundled
|
|||||||
ARG FORGE_VERSION="0.0.0-prerelease"
|
ARG FORGE_VERSION="0.0.0-prerelease"
|
||||||
ARG STEAM_BUILDID=""
|
ARG STEAM_BUILDID=""
|
||||||
|
|
||||||
|
# Base images are pinned by digest; the tag in front of the digest is for readers only.
|
||||||
|
# The same steamcmd image is in ci/steam-buildid.sh and the Gradle plugin's DownloadGame.
|
||||||
|
|
||||||
# --- Stage 1: vanilla dedicated server -----------------------------------------
|
# --- Stage 1: vanilla dedicated server -----------------------------------------
|
||||||
FROM docker.io/steamcmd/steamcmd:debian-13 AS server
|
FROM docker.io/steamcmd/steamcmd:debian-13@sha256:b0b49ef3101c304ed6e3fbc3ea930b2940d7c489563a1ebac524ad5bb46d336d AS server
|
||||||
|
|
||||||
# steamcmd updates itself on its first run. This runs in its own layer so the
|
# steamcmd updates itself on its first run. This runs in its own layer so the
|
||||||
# update is cached and separate from the app installation.
|
# update is cached and separate from the app installation.
|
||||||
@@ -36,8 +44,8 @@ ARG STEAMCLIENT
|
|||||||
COPY docker/install-server.sh /usr/local/bin/install-server
|
COPY docker/install-server.sh /usr/local/bin/install-server
|
||||||
RUN install-server /server "${PZ_BRANCH}" "${STEAMCLIENT}"
|
RUN install-server /server "${PZ_BRANCH}" "${STEAMCLIENT}"
|
||||||
|
|
||||||
# --- Stage 2: ZomboidForge build and server jar patching -----------------------
|
# --- Stage 2: ZomboidForge sources and Gradle -----------------------------------
|
||||||
FROM docker.io/library/eclipse-temurin:25-jdk AS build
|
FROM docker.io/library/eclipse-temurin:25-jdk@sha256:8c0a84ea11c8f6ed52600fc19f1040121f2a162998e9f50a5faebbbad9172dcc AS sources
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# Gradle distribution download, cached independently of the sources.
|
# Gradle distribution download, cached independently of the sources.
|
||||||
@@ -53,6 +61,35 @@ COPY agent agent
|
|||||||
COPY patcher patcher
|
COPY patcher patcher
|
||||||
COPY mod-tools mod-tools
|
COPY mod-tools mod-tools
|
||||||
COPY gradle-plugin gradle-plugin
|
COPY gradle-plugin gradle-plugin
|
||||||
|
|
||||||
|
# --- Game version of a Steam branch, from its server jar alone ------------------
|
||||||
|
# Not part of the image; built on its own by ci/release.sh.
|
||||||
|
FROM sources AS game-version
|
||||||
|
|
||||||
|
# DepotDownloader downloads single files of a depot; steamcmd only whole apps.
|
||||||
|
ADD --checksum=sha256:a999dec66b4850fc961bd50366696d23c2d0fad7b18790e6a5647b2f19097a53 \
|
||||||
|
https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_3.4.0/DepotDownloader-linux-x64.zip \
|
||||||
|
/opt/depotdownloader/depotdownloader.zip
|
||||||
|
RUN cd /opt/depotdownloader \
|
||||||
|
&& jar xf depotdownloader.zip \
|
||||||
|
&& chmod +x DepotDownloader \
|
||||||
|
&& rm depotdownloader.zip
|
||||||
|
|
||||||
|
# FORGE_VERSION only keeps Gradle from asking git (not in this stage) for the version.
|
||||||
|
ARG PZ_BRANCH
|
||||||
|
ARG STEAM_BUILDID
|
||||||
|
ARG FORGE_VERSION
|
||||||
|
RUN echo java/projectzomboid.jar > /tmp/files \
|
||||||
|
&& /opt/depotdownloader/DepotDownloader \
|
||||||
|
-app 380870 -depot 380871 -branch "${PZ_BRANCH}" -filelist /tmp/files -dir /pz \
|
||||||
|
&& ./gradlew --no-daemon --quiet \
|
||||||
|
-Ppz.jar=/pz/java/projectzomboid.jar \
|
||||||
|
-Pversion=${FORGE_VERSION} \
|
||||||
|
:patcher:printGameVersion > /game-version
|
||||||
|
|
||||||
|
# --- Stage 3: ZomboidForge build and server jar patching -----------------------
|
||||||
|
FROM sources AS build
|
||||||
|
|
||||||
COPY --from=server /server/java/projectzomboid.jar /pz/projectzomboid.jar
|
COPY --from=server /server/java/projectzomboid.jar /pz/projectzomboid.jar
|
||||||
|
|
||||||
# An empty PZ_VERSION keeps pz.version from gradle.properties. FORGE_VERSION always has a
|
# An empty PZ_VERSION keeps pz.version from gradle.properties. FORGE_VERSION always has a
|
||||||
@@ -67,8 +104,8 @@ RUN ./gradlew --no-daemon \
|
|||||||
${DISABLED_PATCHES:+-Pzf.disabledPatches=${DISABLED_PATCHES}} \
|
${DISABLED_PATCHES:+-Pzf.disabledPatches=${DISABLED_PATCHES}} \
|
||||||
build -x :gradle-plugin:test :patcher:patchServerJar
|
build -x :gradle-plugin:test :patcher:patchServerJar
|
||||||
|
|
||||||
# --- Stage 3: runtime ------------------------------------------------------------
|
# --- Stage 4: runtime ------------------------------------------------------------
|
||||||
FROM docker.io/library/debian:trixie-slim
|
FROM docker.io/library/debian:trixie-slim@sha256:a99cfc517144bc59b1978475ec53b46ecabec7e43635402ee5b77cc54cd1b20a
|
||||||
|
|
||||||
# ca-certificates: required by steamclient.so to connect to Steam.
|
# ca-certificates: required by steamclient.so to connect to Steam.
|
||||||
# sqlite3: the entrypoint checks the admin account in the server database.
|
# sqlite3: the entrypoint checks the admin account in the server database.
|
||||||
|
|||||||
+140
-19
@@ -40,7 +40,7 @@ version = "1.2.0"
|
|||||||
zomboidForge {
|
zomboidForge {
|
||||||
id = "shop"
|
id = "shop"
|
||||||
entrypoint = "com.example.shop.ShopMod"
|
entrypoint = "com.example.shop.ShopMod"
|
||||||
game("42.21") // only when the mod uses game classes
|
game("42") // only when the mod uses game classes
|
||||||
dependsOn("economy", "2.1") // other mods: id and minimum version
|
dependsOn("economy", "2.1") // other mods: id and minimum version
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,8 @@ game jar for mods that declare `game` versions. Default settings go into
|
|||||||
| `gameJar` | see below | the `projectzomboid.jar` to compile and check against |
|
| `gameJar` | see below | the `projectzomboid.jar` to compile and check against |
|
||||||
| `steamBranch` | `public` | Steam branch for the download: `public`, `unstable`, or a version such as `42.19` |
|
| `steamBranch` | `public` | Steam branch for the download: `public`, `unstable`, or a version such as `42.19` |
|
||||||
| `serverImage` | the ZomboidForge image, `latest` | image for `runServer` |
|
| `serverImage` | the ZomboidForge image, `latest` | image for `runServer` |
|
||||||
| `adminPassword` | `admin` | admin password of the `runServer` server |
|
| `adminPassword` | random, generated once per volume | admin password of the `runServer` server (see below) |
|
||||||
|
| `serverAddress` | `127.0.0.1` | host address `runServer` publishes the game ports on; `0.0.0.0` for the network |
|
||||||
| `dataVolume` | `zomboidforge-<id>` | volume for the `runServer` world and server config |
|
| `dataVolume` | `zomboidforge-<id>` | volume for the `runServer` world and server config |
|
||||||
| `containerEngine` | podman or docker, whichever is installed | for `runServer` and the download |
|
| `containerEngine` | podman or docker, whichever is installed | for `runServer` and the download |
|
||||||
| `deployDirectory` | none | a server's mods directory for `deployMod` |
|
| `deployDirectory` | none | a server's mods directory for `deployMod` |
|
||||||
@@ -77,6 +78,10 @@ game jar for mods that declare `game` versions. Default settings go into
|
|||||||
The plugin generates `META-INF/zomboidforge/mod.toml` from these settings; a hand-written one
|
The plugin generates `META-INF/zomboidforge/mod.toml` from these settings; a hand-written one
|
||||||
fails the build.
|
fails the build.
|
||||||
|
|
||||||
|
Declare a minor version in `game(...)` only when the mod needs it. A mod declaring `"42.21"`
|
||||||
|
stops the server after an update to 42.22, while the server checks every game member a mod uses
|
||||||
|
against the running jar anyway.
|
||||||
|
|
||||||
### The game jar
|
### The game jar
|
||||||
|
|
||||||
Mods that declare `game` versions compile against `projectzomboid.jar`, which cannot be
|
Mods that declare `game` versions compile against `projectzomboid.jar`, which cannot be
|
||||||
@@ -100,9 +105,15 @@ The game jar has to be one of the declared `game` versions; the check below fail
|
|||||||
| `modFolder` | `build/mod/<id>/` with `<id>.jar` and `lib/`, as a server expects it in `<forge>/mods` |
|
| `modFolder` | `build/mod/<id>/` with `<id>.jar` and `lib/`, as a server expects it in `<forge>/mods` |
|
||||||
| `modZip` | the same as `build/distributions/<id>-<version>.zip` |
|
| `modZip` | the same as `build/distributions/<id>-<version>.zip` |
|
||||||
| `runServer` | a ZomboidForge server in a container with the mod; Ctrl+C stops it after it saved the world |
|
| `runServer` | a ZomboidForge server in a container with the mod; Ctrl+C stops it after it saved the world |
|
||||||
| `deployMod` | copies the mod folder into `deployDirectory` |
|
| `deployMod` | copies the mod folder into `deployDirectory`; keeps the server's `config.toml` of the mod |
|
||||||
| `downloadGame` | installs the dedicated server for its game jar; runs only when needed |
|
| `downloadGame` | installs the dedicated server for its game jar; runs only when needed |
|
||||||
|
|
||||||
|
`runServer` is reachable from this machine only, unless `serverAddress` says otherwise. Without
|
||||||
|
`adminPassword`, the first run generates a random admin password for the volume, prints it, and
|
||||||
|
keeps it in `<Gradle user home>/zomboidforge/admin-passwords/<volume>`. The server uses the
|
||||||
|
password only when it creates the admin account, on the volume's first start; a later change
|
||||||
|
needs a new volume (`dataVolume`, or remove the old one).
|
||||||
|
|
||||||
### Working on ZomboidForge itself
|
### Working on ZomboidForge itself
|
||||||
|
|
||||||
To build a mod against a local ZomboidForge checkout instead of a published version, include it
|
To build a mod against a local ZomboidForge checkout instead of a published version, include it
|
||||||
@@ -153,19 +164,21 @@ public final class ShopMod extends Mod
|
|||||||
|
|
||||||
Methods of `Mod`, usable from the constructor on (also in field initializers):
|
Methods of `Mod`, usable from the constructor on (also in field initializers):
|
||||||
|
|
||||||
| Method | Returns | Use |
|
| Method | Returns | Use |
|
||||||
|-----------------|-----------------|---------------------------------------------------------------|
|
|--------------------|------------------|---------------------------------------------------------------|
|
||||||
| `id()` | `String` | the mod's id from `mod.toml` |
|
| `id()` | `String` | the mod's id from `mod.toml` |
|
||||||
| `version()` | `String` | the mod's version from `mod.toml` |
|
| `version()` | `String` | the mod's version from `mod.toml` |
|
||||||
| `gameVersion()` | `GameVersion` | the running Project Zomboid version |
|
| `gameVersion()` | `GameVersion` | the running Project Zomboid version |
|
||||||
| `config()` | `ModConfig` | settings from `config.toml`, bound to records or read by path |
|
| `config()` | `ModConfig` | settings from `config.toml`, bound to records or read by path |
|
||||||
| `logger()` | `System.Logger` | messages in the Project Zomboid log, marked with the mod's id |
|
| `logger()` | `System.Logger` | messages in the Project Zomboid log, marked with the mod's id |
|
||||||
| `directory()` | `Path` | the mod's folder, `<forge>/mods/<id>` |
|
| `directory()` | `Path` | the mod's folder, `<forge>/mods/<id>` |
|
||||||
| `events()` | `Events` | event listeners |
|
| `events()` | `Events` | event listeners |
|
||||||
| `main()` | `MainThread` | code that touches game objects |
|
| `main()` | `MainThread` | code that touches game objects |
|
||||||
| `modThread()` | `ModThread` | the mod's own work, one task at a time |
|
| `modThread()` | `ModThread` | the mod's own work, one task at a time |
|
||||||
| `async()` | `AsyncExecutor` | blocking work such as HTTP calls or file I/O |
|
| `async()` | `AsyncExecutor` | blocking work such as HTTP calls or file I/O |
|
||||||
| `storage()` | `ModStorage` | the mod's tables in the world's `zomboidforge.db` |
|
| `storage()` | `ModStorage` | the mod's tables in the world's `zomboidforge.db` |
|
||||||
|
| `commands()` | `Commands` | admin commands for chat, the server console, and RCON |
|
||||||
|
| `clientCommands()` | `ClientCommands` | server commands to clients, received by their Lua mods |
|
||||||
|
|
||||||
## Threads
|
## Threads
|
||||||
|
|
||||||
@@ -199,11 +212,110 @@ Listeners are matched by the event's exact class. Events that carry live game ob
|
|||||||
removed after ten failures; both `onMain` and `onModThread` return a `Subscription` to remove
|
removed after ten failures; both `onMain` and `onModThread` return a `Subscription` to remove
|
||||||
it earlier.
|
it earlier.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
Admin commands work wherever Project Zomboid's own commands work: in the in-game chat
|
||||||
|
(`/zfhello`), the server console, and RCON. They use Project Zomboid's command framework, so the
|
||||||
|
mod declares `game` versions. In Build 42 a command is a subclass of
|
||||||
|
`zombie.commands.CommandBase`:
|
||||||
|
|
||||||
|
```java
|
||||||
|
@CommandName(name = "zfhello")
|
||||||
|
@CommandArgs(optional = "(.+)")
|
||||||
|
@CommandHelp(helpText = "zfhello [name]: greets", shouldTranslated = false)
|
||||||
|
@RequiredCapability(requiredCapability = Capability.LoginOnServer)
|
||||||
|
public class HelloCommand extends CommandBase
|
||||||
|
{
|
||||||
|
public HelloCommand(String username, Role role, String command, UdpConnection connection) { super(username, role, command, connection); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String Command()
|
||||||
|
{
|
||||||
|
String name = this.getCommandArg(0);
|
||||||
|
return "Hello " + (name == null ? this.getExecutorUsername() : name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```java
|
||||||
|
@Override
|
||||||
|
public void onLoad() { this.commands().register(HelloCommand.class); }
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Registration** happens in the entry point's constructor or `onLoad()`; later calls throw.
|
||||||
|
`register` checks the class and throws `IllegalArgumentException` listing every problem,
|
||||||
|
which stops the server like any other exception in `onLoad()`.
|
||||||
|
- **The class** is public and not abstract, with one public constructor
|
||||||
|
`(String, Role, String, UdpConnection)`.
|
||||||
|
- **Names** (`@CommandName`, repeatable for aliases) consist of letters, digits, and `_` and
|
||||||
|
differ, ignoring case, from the names of Project Zomboid's commands and other mods' commands.
|
||||||
|
A name matches when it is the first word of the input, ignoring case.
|
||||||
|
- **`@RequiredCapability`** is required: Project Zomboid refuses to run a command without one.
|
||||||
|
RCON and the server console run commands with the default admin role.
|
||||||
|
- **`@CommandArgs`** (regular expressions for the arguments; the capture groups become
|
||||||
|
`getCommandArg(n)`) and **`@CommandHelp`** (`help zfhello` and the `help` list; with
|
||||||
|
`shouldTranslated = false` the text is used as written) are optional.
|
||||||
|
- **`Command()`** runs on the main thread, for every use on a new instance; its return value
|
||||||
|
is the reply. Long work belongs on `modThread()` or `async()`; the reply then only confirms
|
||||||
|
that the work started.
|
||||||
|
- Project Zomboid's commands are looked up first; mods' commands follow in load order.
|
||||||
|
|
||||||
|
## Client commands
|
||||||
|
|
||||||
|
A Java mod on the server and a Lua mod on the client (for example from the Workshop) talk
|
||||||
|
through Project Zomboid's command channel, so players keep the official client.
|
||||||
|
|
||||||
|
Client to server: the Lua mod calls `sendClientCommand`, and the server posts
|
||||||
|
`ClientCommandEvent` on the main thread.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
sendClientCommand(getPlayer(), "Shop", "buy", { item = "Base.Axe", count = 2 })
|
||||||
|
```
|
||||||
|
|
||||||
|
```java
|
||||||
|
this.events().onMain(ClientCommandEvent.class, event ->
|
||||||
|
{
|
||||||
|
if (!event.module().equals("Shop")) return;
|
||||||
|
event.cancel(); // Lua's OnClientCommand does not see it
|
||||||
|
|
||||||
|
String item = (String) event.args().get("item");
|
||||||
|
int count = ((Double) event.args().get("count")).intValue();
|
||||||
|
// ...
|
||||||
|
this.clientCommands().send(event.player(), "Shop", "bought", Map.of("item", item, "count", count));
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Server to client: `clientCommands().send(player, ...)` and `sendToAll(...)`; the Lua mod
|
||||||
|
receives them in `Events.OnServerCommand`.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
Events.OnServerCommand.Add(function(module, command, args)
|
||||||
|
if module == "Shop" and command == "bought" then print(args.item, args.count) end
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Every** client command is posted, including those of Project Zomboid (`vehicle`,
|
||||||
|
`player`, ...) and of other mods; filter by `module()`. The event is a `MainThreadEvent`.
|
||||||
|
- **`cancel()`** stops Project Zomboid from passing the command to Lua's `OnClientCommand`.
|
||||||
|
Every listener still runs; `isCancelled()` tells whether another one cancelled.
|
||||||
|
- **`args()`** is the Lua table as an unmodifiable map: keys are `String` or `Double` (Lua
|
||||||
|
arrays have the keys `1.0`, `2.0`, ...); values are `String`, `Double` (every Lua number),
|
||||||
|
`Boolean`, nested maps, or game objects (inventory items, directions, dead bodies). It is
|
||||||
|
empty when the client sent no table.
|
||||||
|
- **`player()`** is a `PlayerRef` (online id and username), a value that stays valid on other
|
||||||
|
threads and after the player left. Sending to a player who left sends nothing.
|
||||||
|
- **Sending** works from any thread. The arguments are copied and checked at once
|
||||||
|
(`IllegalArgumentException` for unsupported types, `null`, or cycles); numbers become Lua
|
||||||
|
numbers, lists become Lua arrays. The command is sent on the main thread: at once when
|
||||||
|
called there, otherwise as one of the mod's queued main-thread tasks.
|
||||||
|
- Client commands come from players and can be forged by a modified client. Check every
|
||||||
|
argument and the player's rights before acting on it.
|
||||||
|
|
||||||
## Storage
|
## Storage
|
||||||
|
|
||||||
Mod data belongs in `storage()`: tables in `zomboidforge.db`, a SQLite database in the world's
|
Mod data belongs in `storage()`: tables in `zomboidforge.db`, a SQLite database in the world's
|
||||||
save folder. Vanilla backups include it, and deleting the world deletes it. Each mod only
|
save folder. Vanilla backups include it, and deleting the world deletes it. Through the API,
|
||||||
reaches its own tables.
|
each mod only reaches its own tables.
|
||||||
|
|
||||||
A record declares a table's columns; each row has a `String` key:
|
A record declares a table's columns; each row has a `String` key:
|
||||||
|
|
||||||
@@ -216,7 +328,7 @@ balances.set("player1", new Balance(250, Instant.now()));
|
|||||||
Optional<Balance> balance = balances.get("player1");
|
Optional<Balance> balance = balances.get("player1");
|
||||||
balances.update("player1", old -> new Balance(old.coins() + 10, Instant.now()), () -> new Balance(0, null));
|
balances.update("player1", old -> new Balance(old.coins() + 10, Instant.now()), () -> new Balance(0, null));
|
||||||
|
|
||||||
this.storage().transaction(() -> { // all or nothing
|
this.storage().transaction(() -> { // all or nothing, also when nested
|
||||||
balances.update("player1", old -> new Balance(old.coins() - 5, old.lastPaid()), () -> new Balance(0, null));
|
balances.update("player1", old -> new Balance(old.coins() - 5, old.lastPaid()), () -> new Balance(0, null));
|
||||||
balances.update("player2", old -> new Balance(old.coins() + 5, old.lastPaid()), () -> new Balance(0, null));
|
balances.update("player2", old -> new Balance(old.coins() + 5, old.lastPaid()), () -> new Balance(0, null));
|
||||||
});
|
});
|
||||||
@@ -257,6 +369,10 @@ Things to know:
|
|||||||
world goes back to its last save, but the mod data keeps later writes.
|
world goes back to its last save, but the mod data keeps later writes.
|
||||||
3. When a mod's id changes, list the old ids in `mod.toml` as `previous_ids`; their tables
|
3. When a mod's id changes, list the old ids in `mod.toml` as `previous_ids`; their tables
|
||||||
move to the new id once.
|
move to the new id once.
|
||||||
|
4. While a `transaction`, `update`, or `forEach` callback runs, the storage of every mod waits.
|
||||||
|
These callbacks must not wait for other threads, for example with
|
||||||
|
`main().submit(...).join()`. A backup waits at most 10 seconds for them and then runs
|
||||||
|
without pausing storage, so its copy of `zomboidforge.db` may be incomplete.
|
||||||
|
|
||||||
## Checks at startup
|
## Checks at startup
|
||||||
|
|
||||||
@@ -282,6 +398,11 @@ Every problem of every mod is listed in the log.
|
|||||||
| game jar (game code and its bundled libraries) | only with `game` declared |
|
| game jar (game code and its bundled libraries) | only with `game` declared |
|
||||||
| ZomboidForge internals | no |
|
| ZomboidForge internals | no |
|
||||||
|
|
||||||
|
These rules keep mods from linking against the wrong classes by accident. They are not a
|
||||||
|
sandbox: a mod runs with the full privileges of the server process. Through reflection or the
|
||||||
|
file system it can reach anything the server can, including other mods' data in
|
||||||
|
`zomboidforge.db`.
|
||||||
|
|
||||||
## Profiling
|
## Profiling
|
||||||
|
|
||||||
Main-thread tasks and event listener calls appear in JFR recordings as the event
|
Main-thread tasks and event listener calls appear in JFR recordings as the event
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ podman build --platform linux/amd64 -t zomboidforge . # or: docker build ...
|
|||||||
| `FORGE_VERSION` | `0.0.0-prerelease` | ZomboidForge version (jar manifest, image label). The build stage has no `git`, so the version is never read from a tag there; `ci/release.sh` passes it |
|
| `FORGE_VERSION` | `0.0.0-prerelease` | ZomboidForge version (jar manifest, image label). The build stage has no `git`, so the version is never read from a tag there; `ci/release.sh` passes it |
|
||||||
| `DISABLED_PATCHES` | | Comma-separated simple class names of build-time patches to skip (debug builds only), e.g. `IsoZombieVehiclePerformancePatch` |
|
| `DISABLED_PATCHES` | | Comma-separated simple class names of build-time patches to skip (debug builds only), e.g. `IsoZombieVehiclePerformancePatch` |
|
||||||
|
|
||||||
Published images are tagged `<forge>-pz<pz>-build<steam buildid>` (immutable),
|
Published images are tagged `<forge>-pz<major.minor.build>` (never overwritten),
|
||||||
`<forge>-pz<pz>`, and `latest`.
|
`<forge>-pz<major.minor>` (the newest hotfix of that minor version), and `latest`. A new image
|
||||||
|
is built for every ZomboidForge release and every Project Zomboid version, hotfixes included:
|
||||||
|
the server only admits clients with the same version.
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
@@ -93,6 +95,11 @@ forge/
|
|||||||
podman run ... -v ./forge:/forge zomboidforge
|
podman run ... -v ./forge:/forge zomboidforge
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Mods are trusted code. They run inside the server process with its full privileges: they can
|
||||||
|
read and write any file the server can, open network connections, and stop the server. The
|
||||||
|
class loader isolation and the startup checks catch mistakes; they do not contain a malicious
|
||||||
|
mod. Install only mods whose authors you trust.
|
||||||
|
|
||||||
A mod's settings live in its `config.toml`. When the file is missing, it is created from the
|
A mod's settings live in its `config.toml`. When the file is missing, it is created from the
|
||||||
mod's defaults if the folder is writable by UID 1000; otherwise the defaults are used without a
|
mod's defaults if the folder is writable by UID 1000; otherwise the defaults are used without a
|
||||||
file. Keys missing from `config.toml` take the default. `enabled = false` in its `[forge]`
|
file. Keys missing from `config.toml` take the default. `enabled = false` in its `[forge]`
|
||||||
|
|||||||
+15
-7
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("zomboidforge.java-conventions")
|
id("zomboidforge.java-conventions")
|
||||||
|
alias(libs.plugins.shadow)
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -11,12 +12,19 @@ dependencies {
|
|||||||
compileOnly(files(projectZomboid.serverJar))
|
compileOnly(files(projectZomboid.serverJar))
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.jar {
|
// The agent jar is appended to the system class path behind the game jar and includes api,
|
||||||
archiveBaseName = "zomboidforge-agent"
|
// core, compat runtime, and their libraries. The libraries are relocated, so a copy of the same
|
||||||
|
// library in the game jar cannot replace them.
|
||||||
|
tasks.shadowJar {
|
||||||
|
archiveBaseName = "zomboidforge-agent"
|
||||||
|
archiveClassifier = ""
|
||||||
manifest.attributes("Premain-Class" to "dev.overlord.zomboidforge.agent.ForgeAgent")
|
manifest.attributes("Premain-Class" to "dev.overlord.zomboidforge.agent.ForgeAgent")
|
||||||
// The agent jar is appended to the system class path and includes api, core and compat runtime.
|
|
||||||
// Mapping the classpath to zip trees loses its task dependencies; the input restores them.
|
relocate("org.objectweb.asm", "dev.overlord.zomboidforge.shaded.asm")
|
||||||
inputs.files(configurations.runtimeClasspath)
|
relocate("com.electronwill.nightconfig", "dev.overlord.zomboidforge.shaded.nightconfig")
|
||||||
from(configurations.runtimeClasspath.map { classpath -> classpath.map { zipTree(it) } })
|
}
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
||||||
|
// Only the shadow jar is used; the plain jar would match the same file name pattern.
|
||||||
|
tasks.jar {
|
||||||
|
enabled = false
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package dev.overlord.zomboidforge.api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event whose default action, what Project Zomboid does after the event, can be prevented.
|
||||||
|
* Only listeners on the main thread can cancel: the default action runs once every main-thread
|
||||||
|
* listener returned. Every listener is called, also after one cancelled.
|
||||||
|
*/
|
||||||
|
public interface Cancellable
|
||||||
|
{
|
||||||
|
/** Prevents the default action. */
|
||||||
|
void cancel();
|
||||||
|
|
||||||
|
boolean isCancelled();
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package dev.overlord.zomboidforge.api;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A client command arrived: a client called Lua's {@code sendClientCommand(module, command, args)}.
|
||||||
|
* Posted on the main thread for every client command, including those of Project Zomboid and of
|
||||||
|
* Lua mods, so listeners filter by {@link #module()}.
|
||||||
|
*
|
||||||
|
* <p>Default action: Project Zomboid passes the command to Lua's {@code Events.OnClientCommand}.
|
||||||
|
* {@link #cancel()} prevents that, for example when a Java mod handles the module itself.
|
||||||
|
*
|
||||||
|
* <p>{@link #args()} is the Lua table converted to Java: keys are {@code String} or
|
||||||
|
* {@code Double} (Lua arrays have the keys {@code 1.0}, {@code 2.0}, ...), values are
|
||||||
|
* {@code String}, {@code Double}, {@code Boolean}, a nested {@code Map} of the same kind, or a
|
||||||
|
* game object that Project Zomboid sends with commands (in Build 42 an inventory item, an
|
||||||
|
* {@code IsoDirections}, or a dead body). The maps cannot be modified.
|
||||||
|
*/
|
||||||
|
public final class ClientCommandEvent implements MainThreadEvent, Cancellable
|
||||||
|
{
|
||||||
|
private final PlayerRef player;
|
||||||
|
private final String module;
|
||||||
|
private final String command;
|
||||||
|
private final Map<Object, Object> args;
|
||||||
|
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
/** @param args the converted arguments; empty when the client sent none */
|
||||||
|
public ClientCommandEvent(PlayerRef player, String module, String command, Map<Object, Object> args)
|
||||||
|
{
|
||||||
|
this.player = Objects.requireNonNull(player, "player");
|
||||||
|
this.module = Objects.requireNonNull(module, "module");
|
||||||
|
this.command = Objects.requireNonNull(command, "command");
|
||||||
|
this.args = Objects.requireNonNull(args, "args");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The player who sent the command. */
|
||||||
|
public PlayerRef player() { return this.player; }
|
||||||
|
|
||||||
|
public String module() { return this.module; }
|
||||||
|
|
||||||
|
public String command() { return this.command; }
|
||||||
|
|
||||||
|
public Map<Object, Object> args() { return this.args; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancel() { this.cancelled = true; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() { return this.cancelled; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() { return "ClientCommandEvent[" + this.player + ", " + this.module + "." + this.command + ", " + this.args + (this.cancelled ? ", cancelled" : "") + "]"; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package dev.overlord.zomboidforge.api;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server commands to clients, the reply channel to {@link ClientCommandEvent}: a client receives
|
||||||
|
* them in Lua's {@code Events.OnServerCommand(module, command, args)}. Together, a Java mod on the
|
||||||
|
* server and a Lua mod on the client exchange commands while players keep the official client.
|
||||||
|
*
|
||||||
|
* <p>{@code args} becomes a Lua table: keys are {@code String} or a {@code Number} (sent as a
|
||||||
|
* Lua number), values are {@code String}, {@code Number}, {@code Boolean}, a nested {@code Map}, a
|
||||||
|
* {@code List} (a Lua array, indexed from 1), or a game object that Project Zomboid sends with
|
||||||
|
* commands (see {@link ClientCommandEvent}). {@code null} keys or values, and cycles, are not
|
||||||
|
* allowed. An empty map sends no arguments; the client then receives {@code nil}.
|
||||||
|
*
|
||||||
|
* <p>The methods can be called on any thread. The arguments are checked at once; the command is
|
||||||
|
* sent on the main thread, at once when called there, otherwise with the mod's queued
|
||||||
|
* main-thread tasks.
|
||||||
|
*/
|
||||||
|
public interface ClientCommands
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Sends a command to {@code player}. Nothing is sent when the player is no longer connected.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException when {@code args} contains a key or value that cannot be sent
|
||||||
|
*/
|
||||||
|
void send(PlayerRef player, String module, String command, Map<?, ?> args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a command to every connected client.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException when {@code args} contains a key or value that cannot be sent
|
||||||
|
*/
|
||||||
|
void sendToAll(String module, String command, Map<?, ?> args);
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package dev.overlord.zomboidforge.api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registration of admin commands. A registered command works wherever Project Zomboid's own
|
||||||
|
* admin commands work: in the in-game chat ({@code /name}), the server console, and RCON. It
|
||||||
|
* is looked up after the commands of Project Zomboid and runs on the main thread.
|
||||||
|
*
|
||||||
|
* <p>A command is a class of the running Project Zomboid version's command framework, so a mod
|
||||||
|
* that registers commands declares {@code game} versions in {@code mod.toml}. In Build 42 it is
|
||||||
|
* a public, non-abstract subclass of {@code zombie.commands.CommandBase} with:
|
||||||
|
* <ul>
|
||||||
|
* <li>one public constructor {@code (String username, Role role, String command, UdpConnection connection)},
|
||||||
|
* which passes its arguments to {@code super};</li>
|
||||||
|
* <li>at least one {@code @CommandName}; names consist of letters, digits, and {@code _}, and
|
||||||
|
* differ (ignoring case) from every name of Project Zomboid and of other mods;</li>
|
||||||
|
* <li>at least one {@code @RequiredCapability}; Project Zomboid refuses to run a command
|
||||||
|
* without one;</li>
|
||||||
|
* <li>optionally {@code @CommandArgs} (argument patterns) and {@code @CommandHelp}
|
||||||
|
* ({@code help <name>} and the {@code help} list).</li>
|
||||||
|
* </ul>
|
||||||
|
* Project Zomboid creates a new instance for every use and calls its {@code Command()}, whose
|
||||||
|
* result is the reply.
|
||||||
|
*/
|
||||||
|
public interface Commands
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Registers {@code command}. Only on the main thread while the mod loads: in the entry point's
|
||||||
|
* constructor or {@link Mod#onLoad()}.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException when {@code command} does not meet the rules above, or is
|
||||||
|
* registered already
|
||||||
|
* @throws IllegalStateException when called later or on another thread
|
||||||
|
*/
|
||||||
|
void register(Class<?> command);
|
||||||
|
}
|
||||||
@@ -9,8 +9,9 @@ import java.util.regex.Pattern;
|
|||||||
/** Project Zomboid version, e.g. 42.21.0 ({@code Core.getGameAndBuildVersion()}). */
|
/** Project Zomboid version, e.g. 42.21.0 ({@code Core.getGameAndBuildVersion()}). */
|
||||||
public record GameVersion(int major, int minor, int build) implements Comparable<GameVersion>
|
public record GameVersion(int major, int minor, int build) implements Comparable<GameVersion>
|
||||||
{
|
{
|
||||||
private static final Pattern VERSION = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?");
|
// At most 9 digits per number, so every number fits an int.
|
||||||
private static final Pattern PREFIX = Pattern.compile("(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?");
|
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
|
private static final Comparator<GameVersion> ORDER = Comparator
|
||||||
.comparingInt(GameVersion::major)
|
.comparingInt(GameVersion::major)
|
||||||
|
|||||||
@@ -84,4 +84,10 @@ public abstract class Mod
|
|||||||
|
|
||||||
/** The mod's tables in the world's {@code zomboidforge.db}; not on the main thread once the server runs. */
|
/** The mod's tables in the world's {@code zomboidforge.db}; not on the main thread once the server runs. */
|
||||||
protected final ModStorage storage() { return this.context.storage(); }
|
protected final ModStorage storage() { return this.context.storage(); }
|
||||||
|
|
||||||
|
/** Admin command registration. */
|
||||||
|
protected final Commands commands() { return this.context.commands(); }
|
||||||
|
|
||||||
|
/** Server commands to clients, received by their Lua mods. */
|
||||||
|
protected final ClientCommands clientCommands() { return this.context.clientCommands(); }
|
||||||
}
|
}
|
||||||
@@ -42,4 +42,10 @@ public interface ModContext
|
|||||||
|
|
||||||
/** The mod's tables in the world's {@code zomboidforge.db}. */
|
/** The mod's tables in the world's {@code zomboidforge.db}. */
|
||||||
ModStorage storage();
|
ModStorage storage();
|
||||||
|
|
||||||
|
/** Admin command registration. */
|
||||||
|
Commands commands();
|
||||||
|
|
||||||
|
/** Server commands to clients, received by their Lua mods. */
|
||||||
|
ClientCommands clientCommands();
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package dev.overlord.zomboidforge.api;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A connected player, by value: usable on any thread and after the player left. Project
|
||||||
|
* Zomboid reuses online ids of players who left, so ZomboidForge matches both the id and the
|
||||||
|
* username before it acts on a player.
|
||||||
|
*
|
||||||
|
* @param onlineId the player's online id while connected
|
||||||
|
* @param username the player's account name
|
||||||
|
*/
|
||||||
|
public record PlayerRef(int onlineId, String username)
|
||||||
|
{
|
||||||
|
public PlayerRef
|
||||||
|
{
|
||||||
|
Objects.requireNonNull(username, "username");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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'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},
|
* <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},
|
* {@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
|
* Runs {@code work} in one transaction: writes of this thread inside it are committed
|
||||||
* together, or not at all when {@code work} throws.
|
* 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);
|
void transaction(Runnable work);
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ public interface Table<R extends Record>
|
|||||||
/** Every key, sorted. */
|
/** Every key, sorted. */
|
||||||
List<String> keys();
|
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);
|
void forEach(BiConsumer<String, R> action);
|
||||||
|
|
||||||
long count();
|
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
|
* 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.
|
* {@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
|
* @return the stored value
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -42,6 +42,16 @@ class GameVersionTest
|
|||||||
assertThrows(IllegalArgumentException.class, () -> version.matches("42.21.3.1"));
|
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
|
@Test
|
||||||
void comparesNumerically()
|
void comparesNumerically()
|
||||||
{
|
{
|
||||||
|
|||||||
+44
-25
@@ -2,15 +2,18 @@
|
|||||||
#
|
#
|
||||||
# Publishes the mod API (dev.overlord.zomboidforge:api), the mod tools (mod-tools), and the
|
# Publishes the mod API (dev.overlord.zomboidforge:api), the mod tools (mod-tools), and the
|
||||||
# Gradle plugin (dev.overlord.zomboidforge.mod) to the Maven registry of the ZomboidForge Gitea,
|
# Gradle plugin (dev.overlord.zomboidforge.mod) to the Maven registry of the ZomboidForge Gitea,
|
||||||
# in the version of the newest v* git tag reachable from HEAD, without the "v".
|
# in the version of the v* git tag on HEAD, without the "v".
|
||||||
#
|
#
|
||||||
# A pre-release version (containing "-", e.g. 0.3.0-rc.1) is built and tested but never
|
# A pre-release version (containing "-", e.g. 0.3.0-rc.1) is built and tested but never
|
||||||
# published. Without any v* tag nothing is published.
|
# published. Without a v* tag on HEAD nothing is published.
|
||||||
#
|
#
|
||||||
# Environment:
|
# Usage:
|
||||||
|
# ci/publish.sh test runs the checks of the published modules; needs no credentials
|
||||||
|
# ci/publish.sh publish publishes them without running the checks again
|
||||||
|
#
|
||||||
|
# Environment (publish only):
|
||||||
# ORG_GRADLE_PROJECT_giteaUsername Gitea user with package write access
|
# ORG_GRADLE_PROJECT_giteaUsername Gitea user with package write access
|
||||||
# ORG_GRADLE_PROJECT_giteaPassword Token of that user
|
# ORG_GRADLE_PROJECT_giteaPassword Token of that user
|
||||||
# PUBLISH true: publish after the tests. Default: false (test only)
|
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
@@ -19,8 +22,6 @@ set -o pipefail
|
|||||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
readonly REPO_ROOT
|
readonly REPO_ROOT
|
||||||
|
|
||||||
readonly REQUESTED_PUBLISH="${PUBLISH:-false}"
|
|
||||||
|
|
||||||
readonly MODULES=(
|
readonly MODULES=(
|
||||||
api
|
api
|
||||||
mod-tools
|
mod-tools
|
||||||
@@ -31,11 +32,11 @@ log() {
|
|||||||
echo "[publish] $*" >&2
|
echo "[publish] $*" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prints the newest v* tag reachable from HEAD without its "v", or nothing.
|
# Prints the v* tag on HEAD without its "v", or nothing.
|
||||||
release_tag_version() {
|
release_tag_version() {
|
||||||
local tag
|
local tag
|
||||||
|
|
||||||
if tag="$(git -C "${REPO_ROOT}" describe --tags --abbrev=0 --match 'v*' 2> /dev/null)"; then
|
if tag="$(git -C "${REPO_ROOT}" describe --tags --exact-match --match 'v*' 2> /dev/null)"; then
|
||||||
echo "${tag#v}"
|
echo "${tag#v}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -61,36 +62,54 @@ run_gradle() {
|
|||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
run_tests() {
|
||||||
local version
|
local version="$1"
|
||||||
local publish="${REQUESTED_PUBLISH}"
|
|
||||||
local check_tasks
|
local check_tasks
|
||||||
local publish_tasks
|
|
||||||
|
|
||||||
version="$(release_tag_version)"
|
|
||||||
if [[ -z "${version}" ]]; then
|
|
||||||
log "No v* git tag found (shallow clone without tags?); nothing to publish."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ "${version}" == *-* ]]; then
|
|
||||||
publish=false
|
|
||||||
log "${version} is a pre-release version; nothing will be published."
|
|
||||||
fi
|
|
||||||
|
|
||||||
mapfile -t check_tasks < <(module_tasks check)
|
mapfile -t check_tasks < <(module_tasks check)
|
||||||
mapfile -t publish_tasks < <(module_tasks publishAllPublicationsToGiteaRepository)
|
|
||||||
|
|
||||||
log "Testing ZomboidForge ${version}: ${MODULES[*]}"
|
log "Testing ZomboidForge ${version}: ${MODULES[*]}"
|
||||||
run_gradle "${version}" :core:check "${check_tasks[@]}"
|
run_gradle "${version}" :core:check "${check_tasks[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
if [[ "${publish}" != "true" ]]; then
|
publish() {
|
||||||
log "Not publishing (PUBLISH=${REQUESTED_PUBLISH})."
|
local version="$1"
|
||||||
|
local publish_tasks
|
||||||
|
|
||||||
|
if [[ "${version}" == *-* ]]; then
|
||||||
|
log "${version} is a pre-release version; nothing is published."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mapfile -t publish_tasks < <(module_tasks publishAllPublicationsToGiteaRepository)
|
||||||
|
|
||||||
log "Publishing ZomboidForge ${version}"
|
log "Publishing ZomboidForge ${version}"
|
||||||
run_gradle "${version}" "${publish_tasks[@]}"
|
run_gradle "${version}" "${publish_tasks[@]}"
|
||||||
log "Published ${MODULES[*]} ${version}"
|
log "Published ${MODULES[*]} ${version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local step="${1:-}"
|
||||||
|
local version
|
||||||
|
|
||||||
|
version="$(release_tag_version)"
|
||||||
|
if [[ -z "${version}" ]]; then
|
||||||
|
log "HEAD has no v* git tag (not a release commit, or a shallow clone without tags?); nothing to publish."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "${step}" in
|
||||||
|
test)
|
||||||
|
run_tests "${version}"
|
||||||
|
;;
|
||||||
|
publish)
|
||||||
|
publish "${version}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log "Usage: ci/publish.sh test|publish"
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
+61
-26
@@ -1,22 +1,29 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Builds the ZomboidForge image for one Project Zomboid version and optionally
|
# Builds the ZomboidForge image for the current build of a Steam branch and optionally
|
||||||
# publishes it. Published tags:
|
# publishes it. Published tags:
|
||||||
#
|
#
|
||||||
# <forge>-pz<pz>-build<steam_buildid> immutable; never overwritten
|
# <forge>-pz<major.minor.build> written once per ZomboidForge and Project Zomboid version
|
||||||
# <forge>-pz<pz> moves to the newest Steam build of that version
|
# <forge>-pz<major.minor> moves to the newest hotfix of that minor version
|
||||||
# latest only with LATEST=true
|
# latest only with LATEST=true
|
||||||
#
|
#
|
||||||
# <forge> is the newest v* git tag reachable from HEAD, without the "v" (v0.2.0 -> 0.2.0).
|
# <major.minor.build> is the version the branch's server jar reports, read before the full
|
||||||
# A pre-release version (containing "-", e.g. 0.2.0-rc.1) is built and verified but never
|
# build (Dockerfile stage game-version, which downloads only the jar).
|
||||||
# published. Without any v* tag the version is "0.0.0-prerelease".
|
|
||||||
#
|
#
|
||||||
# Nothing is built when the immutable tag already exists in the registry.
|
# <forge> is the v* git tag on HEAD, without the "v" (v0.2.0 -> 0.2.0). When HEAD has no such
|
||||||
|
# tag, it is the git describe version of HEAD (0.2.0-3-g1a2b3c4: 3 commits after v0.2.0).
|
||||||
|
# A pre-release version (containing "-", e.g. 0.2.0-rc.1 or 0.2.0-3-g1a2b3c4) is built and
|
||||||
|
# verified but never published. Without any v* tag the version is "0.0.0-prerelease".
|
||||||
|
#
|
||||||
|
# Nothing is built when <forge>-pz<major.minor.build> already exists in the registry. The
|
||||||
|
# server only admits clients with the same major.minor.build, so every hotfix (42.21.1 ->
|
||||||
|
# 42.21.2) gets an image; a new Steam build with an unchanged version does not.
|
||||||
#
|
#
|
||||||
# Environment:
|
# Environment:
|
||||||
# IMAGE Image name without tag, e.g. git.security-command.org/overlord/zomboidforge
|
# IMAGE Image name without tag, e.g. git.security-command.org/overlord/zomboidforge
|
||||||
# PZ_BRANCH Steam branch. Default: public
|
# PZ_BRANCH Steam branch. Default: public
|
||||||
# PZ_VERSION Expected Project Zomboid version. Default: pz.version in gradle.properties
|
# PZ_VERSION Accepted Project Zomboid versions ("42": every Build 42 version).
|
||||||
|
# Default: pz.version in gradle.properties
|
||||||
# PUBLISH true: push the tags (not for pre-release versions). Default: false (build and verify only)
|
# PUBLISH true: push the tags (not for pre-release versions). Default: false (build and verify only)
|
||||||
# LATEST true: also push "latest". Default: false
|
# LATEST true: also push "latest". Default: false
|
||||||
# CONTAINER_ENGINE docker or podman. Default: docker if installed, else podman
|
# CONTAINER_ENGINE docker or podman. Default: docker if installed, else podman
|
||||||
@@ -63,12 +70,15 @@ gradle_property() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prints the forge version: the newest v* tag reachable from HEAD without its "v",
|
# Prints the forge version without the "v": the v* tag on HEAD, else the git describe version
|
||||||
# or nothing when the repository has no such tag.
|
# of HEAD relative to the newest reachable v* tag (v0.2.0-3-g1a2b3c4), or nothing when the
|
||||||
|
# repository has no such tag.
|
||||||
release_tag_version() {
|
release_tag_version() {
|
||||||
local tag
|
local tag
|
||||||
|
|
||||||
if tag="$(git -C "${REPO_ROOT}" describe --tags --abbrev=0 --match 'v*' 2> /dev/null)"; then
|
if tag="$(git -C "${REPO_ROOT}" describe --tags --exact-match --match 'v*' 2> /dev/null)"; then
|
||||||
|
echo "${tag#v}"
|
||||||
|
elif tag="$(git -C "${REPO_ROOT}" describe --tags --match 'v*' 2> /dev/null)"; then
|
||||||
echo "${tag#v}"
|
echo "${tag#v}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -78,6 +88,22 @@ image_exists() {
|
|||||||
"$(container_engine)" manifest inspect "${reference}" > /dev/null 2>&1
|
"$(container_engine)" manifest inspect "${reference}" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Prints the game version of the branch's current server jar, e.g. 42.21.0. Downloads only
|
||||||
|
# the jar; the result stays cached until the build ID changes.
|
||||||
|
read_game_version() {
|
||||||
|
local build_id="$1"
|
||||||
|
local image
|
||||||
|
|
||||||
|
image="$("$(container_engine)" build --quiet \
|
||||||
|
--platform linux/amd64 \
|
||||||
|
--target game-version \
|
||||||
|
--build-arg "PZ_BRANCH=${PZ_BRANCH}" \
|
||||||
|
--build-arg "STEAM_BUILDID=${build_id}" \
|
||||||
|
"${REPO_ROOT}")"
|
||||||
|
|
||||||
|
"$(container_engine)" run --rm --entrypoint cat "${image}" /game-version
|
||||||
|
}
|
||||||
|
|
||||||
build_image() {
|
build_image() {
|
||||||
local reference="$1"
|
local reference="$1"
|
||||||
local forge_version="$2"
|
local forge_version="$2"
|
||||||
@@ -119,8 +145,9 @@ push_as() {
|
|||||||
main() {
|
main() {
|
||||||
local forge_version
|
local forge_version
|
||||||
local publish="${REQUESTED_PUBLISH}"
|
local publish="${REQUESTED_PUBLISH}"
|
||||||
local pz_version
|
local pz_prefix
|
||||||
local build_id
|
local build_id
|
||||||
|
local game_version
|
||||||
|
|
||||||
forge_version="$(release_tag_version)"
|
forge_version="$(release_tag_version)"
|
||||||
if [[ -z "${forge_version}" ]]; then
|
if [[ -z "${forge_version}" ]]; then
|
||||||
@@ -132,31 +159,39 @@ main() {
|
|||||||
log "${forge_version} is a pre-release version; nothing will be published."
|
log "${forge_version} is a pre-release version; nothing will be published."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pz_version="${PZ_VERSION:-$(gradle_property pz.version)}"
|
pz_prefix="${PZ_VERSION:-$(gradle_property pz.version)}"
|
||||||
build_id="$("${REPO_ROOT}/ci/steam-buildid.sh" "${PZ_BRANCH}")"
|
build_id="$("${REPO_ROOT}/ci/steam-buildid.sh" "${PZ_BRANCH}")"
|
||||||
|
game_version="$(read_game_version "${build_id}")"
|
||||||
|
log "ZomboidForge ${forge_version}, Project Zomboid ${game_version}, Steam branch ${PZ_BRANCH} build ${build_id}"
|
||||||
|
|
||||||
local immutable_tag="${IMAGE}:${forge_version}-pz${pz_version}-build${build_id}"
|
# Checked here as well as by the patcher, to fail before the full download.
|
||||||
local version_tag="${IMAGE}:${forge_version}-pz${pz_version}"
|
if [[ "${game_version}" != "${pz_prefix}" && "${game_version}" != "${pz_prefix}."* ]]; then
|
||||||
log "ZomboidForge ${forge_version}, Project Zomboid ${pz_version}, Steam branch ${PZ_BRANCH} build ${build_id}"
|
log "Steam branch ${PZ_BRANCH} has Project Zomboid ${game_version}; the build accepts ${pz_prefix}."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${publish}" == true ]] && image_exists "${immutable_tag}"; then
|
local version_tag="${IMAGE}:${forge_version}-pz${game_version}"
|
||||||
log "${immutable_tag} is already published; nothing to do."
|
# 42.21.2 -> 42.21
|
||||||
|
local minor_tag="${IMAGE}:${forge_version}-pz${game_version%.*}"
|
||||||
|
|
||||||
|
if [[ "${publish}" == true ]] && image_exists "${version_tag}"; then
|
||||||
|
log "${version_tag} is already published; nothing to do."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build_image "${immutable_tag}" "${forge_version}" "${pz_version}" "${build_id}"
|
build_image "${version_tag}" "${forge_version}" "${game_version}" "${build_id}"
|
||||||
verify_build_id "${immutable_tag}" "${build_id}"
|
verify_build_id "${version_tag}" "${build_id}"
|
||||||
|
|
||||||
if [[ "${publish}" != true ]]; then
|
if [[ "${publish}" != true ]]; then
|
||||||
log "Built ${immutable_tag} (not published)"
|
log "Built ${version_tag} (not published)"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"$(container_engine)" push "${immutable_tag}"
|
"$(container_engine)" push "${version_tag}"
|
||||||
log "Pushed ${immutable_tag}"
|
log "Pushed ${version_tag}"
|
||||||
push_as "${immutable_tag}" "${version_tag}"
|
push_as "${version_tag}" "${minor_tag}"
|
||||||
if [[ "${LATEST}" == true ]]; then
|
if [[ "${LATEST}" == true ]]; then
|
||||||
push_as "${immutable_tag}" "${IMAGE}:latest"
|
push_as "${version_tag}" "${IMAGE}:latest"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ set -o nounset
|
|||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
readonly APP_ID="380870"
|
readonly APP_ID="380870"
|
||||||
readonly STEAMCMD_IMAGE="docker.io/steamcmd/steamcmd:debian-13"
|
readonly STEAMCMD_IMAGE="docker.io/steamcmd/steamcmd:debian-13@sha256:b0b49ef3101c304ed6e3fbc3ea930b2940d7c489563a1ebac524ad5bb46d336d"
|
||||||
|
|
||||||
readonly BRANCH="$1"
|
readonly BRANCH="$1"
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ public final class B42PatchSet implements PatchSet
|
|||||||
new ServerTickPatch(),
|
new ServerTickPatch(),
|
||||||
new ServerStoppingPatch(),
|
new ServerStoppingPatch(),
|
||||||
new BackupStoragePatch(),
|
new BackupStoragePatch(),
|
||||||
|
new CommandLookupPatch(),
|
||||||
|
new CommandListPatch(),
|
||||||
|
new ClientCommandPatch(),
|
||||||
new IsoZombieVehiclePerformancePatch(),
|
new IsoZombieVehiclePerformancePatch(),
|
||||||
new IsoZombieNetworkComponentPerformancePatch(),
|
new IsoZombieNetworkComponentPerformancePatch(),
|
||||||
new IsoZombieSpotChancePerformancePatch(),
|
new IsoZombieSpotChancePerformancePatch(),
|
||||||
|
|||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
package dev.overlord.zomboidforge.compat.b42.patches;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.patcher.Anchor;
|
||||||
|
import dev.overlord.zomboidforge.patcher.Hook;
|
||||||
|
import dev.overlord.zomboidforge.patcher.HookArgument;
|
||||||
|
import dev.overlord.zomboidforge.patcher.Patches.CancellableHookPatch;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes the Lua event {@code OnClientCommand} in {@code GameServer.receiveClientCommand} depend on
|
||||||
|
* {@code ClientCommandHooks.onClientCommand(module, command, player, tbl)}:
|
||||||
|
*
|
||||||
|
* <pre>{@code
|
||||||
|
* if (!ClientCommandHooks.onClientCommand(module, command, player, tbl))
|
||||||
|
* LuaEventManager.triggerEvent("OnClientCommand", module, command, player, tbl);
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* The arguments are the method's local variables of these names.
|
||||||
|
*/
|
||||||
|
public final class ClientCommandPatch extends CancellableHookPatch
|
||||||
|
{
|
||||||
|
private static final Anchor.Call ANCHOR = new Anchor.Call(
|
||||||
|
new Anchor.Method("receiveClientCommand", "(Lzombie/core/network/ByteBufferReader;Lzombie/core/raknet/UdpConnection;S)V"),
|
||||||
|
"zombie/Lua/LuaEventManager", "triggerEvent", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V"
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final Hook HOOK = new Hook(
|
||||||
|
"dev/overlord/zomboidforge/compat/b42/hooks/ClientCommandHooks", "onClientCommand",
|
||||||
|
"(Ljava/lang/String;Ljava/lang/String;Lzombie/characters/IsoPlayer;Lse/krka/kahlua/vm/KahluaTable;)Z"
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final List<HookArgument> ARGUMENTS = List.of(
|
||||||
|
new HookArgument.Local("module"),
|
||||||
|
new HookArgument.Local("command"),
|
||||||
|
new HookArgument.Local("player"),
|
||||||
|
new HookArgument.Local("tbl")
|
||||||
|
);
|
||||||
|
|
||||||
|
public ClientCommandPatch() {
|
||||||
|
super("zombie/network/GameServer", ClientCommandPatch.ANCHOR, ClientCommandPatch.HOOK, ClientCommandPatch.ARGUMENTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package dev.overlord.zomboidforge.compat.b42.patches;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.patcher.Anchor;
|
||||||
|
import dev.overlord.zomboidforge.patcher.Hook;
|
||||||
|
import dev.overlord.zomboidforge.patcher.Patches.ReturnHookPatch;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes {@code CommandBase.getSubClasses()} return
|
||||||
|
* {@code CommandHooks.listCommands(childrenClasses)}: Project Zomboid's command classes followed
|
||||||
|
* by the mods'. The {@code help} command lists commands through this method.
|
||||||
|
*/
|
||||||
|
public final class CommandListPatch extends ReturnHookPatch
|
||||||
|
{
|
||||||
|
/** The whole method: {@code getstatic childrenClasses}, {@code areturn}. */
|
||||||
|
private static final Anchor.Sequence ANCHOR = new Anchor.Sequence(
|
||||||
|
new Anchor.Method("getSubClasses", "()[Ljava/lang/Class;"),
|
||||||
|
new Anchor.Instruction.Opcode(Opcodes.GETSTATIC),
|
||||||
|
new Anchor.Instruction.Opcode(Opcodes.ARETURN)
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final Hook HOOK = new Hook(
|
||||||
|
"dev/overlord/zomboidforge/compat/b42/hooks/CommandHooks", "listCommands", "([Ljava/lang/Class;)[Ljava/lang/Class;"
|
||||||
|
);
|
||||||
|
|
||||||
|
public CommandListPatch() {
|
||||||
|
super("zombie/commands/CommandBase", CommandListPatch.ANCHOR, CommandListPatch.HOOK, List.of());
|
||||||
|
}
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package dev.overlord.zomboidforge.compat.b42.patches;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.patcher.Anchor;
|
||||||
|
import dev.overlord.zomboidforge.patcher.Hook;
|
||||||
|
import dev.overlord.zomboidforge.patcher.HookArgument;
|
||||||
|
import dev.overlord.zomboidforge.patcher.Patches.ReturnHookPatch;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes {@code CommandBase.findCommandCls(command)} return
|
||||||
|
* {@code CommandHooks.findCommand(null, command)} where it returns {@code null}: when no command
|
||||||
|
* of Project Zomboid matches, the mods' commands are searched. The server console, RCON, chat
|
||||||
|
* commands, and {@code help <name>} look commands up through this method.
|
||||||
|
*/
|
||||||
|
public final class CommandLookupPatch extends ReturnHookPatch
|
||||||
|
{
|
||||||
|
private static final Anchor.Sequence ANCHOR = new Anchor.Sequence(
|
||||||
|
new Anchor.Method("findCommandCls", "(Ljava/lang/String;)Ljava/lang/Class;"),
|
||||||
|
new Anchor.Instruction.Opcode(Opcodes.ACONST_NULL),
|
||||||
|
new Anchor.Instruction.Opcode(Opcodes.ARETURN)
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final Hook HOOK = new Hook(
|
||||||
|
"dev/overlord/zomboidforge/compat/b42/hooks/CommandHooks", "findCommand", "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Class;"
|
||||||
|
);
|
||||||
|
|
||||||
|
public CommandLookupPatch() {
|
||||||
|
super("zombie/commands/CommandBase", CommandLookupPatch.ANCHOR, CommandLookupPatch.HOOK, List.of(new HookArgument.Parameter(0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ dependencies {
|
|||||||
implementation(project(":api"))
|
implementation(project(":api"))
|
||||||
compileOnly(files(projectZomboid.serverJar))
|
compileOnly(files(projectZomboid.serverJar))
|
||||||
|
|
||||||
|
// ModCommandsTest checks command classes against the game's command framework.
|
||||||
|
testImplementation(files(projectZomboid.serverJar))
|
||||||
testImplementation(platform(libs.junit.bom))
|
testImplementation(platform(libs.junit.bom))
|
||||||
testImplementation(libs.junit.jupiter)
|
testImplementation(libs.junit.jupiter)
|
||||||
testRuntimeOnly(libs.junit.platform.launcher)
|
testRuntimeOnly(libs.junit.platform.launcher)
|
||||||
|
|||||||
+5
-1
@@ -1,11 +1,15 @@
|
|||||||
package dev.overlord.zomboidforge.compat.b42;
|
package dev.overlord.zomboidforge.compat.b42;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.compat.b42.commands.ClientCommandChannel;
|
||||||
|
import dev.overlord.zomboidforge.compat.b42.commands.ModCommands;
|
||||||
import dev.overlord.zomboidforge.core.Forge;
|
import dev.overlord.zomboidforge.core.Forge;
|
||||||
|
|
||||||
/** The one {@link Forge} of the server, shared by the hook classes. */
|
/** The one {@link Forge} of the server, shared by the hook classes. */
|
||||||
public final class ForgeInstance
|
public final class ForgeInstance
|
||||||
{
|
{
|
||||||
public static final Forge FORGE = Forge.fromSystemProperties();
|
public static final Forge FORGE = Forge.fromSystemProperties(
|
||||||
|
ModCommands::check, ClientCommandChannel::prepare
|
||||||
|
);
|
||||||
|
|
||||||
private ForgeInstance() {}
|
private ForgeInstance() {}
|
||||||
}
|
}
|
||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
package dev.overlord.zomboidforge.compat.b42.commands;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.api.PlayerRef;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import se.krka.kahlua.vm.KahluaTable;
|
||||||
|
|
||||||
|
import zombie.Lua.LuaManager;
|
||||||
|
import zombie.characters.IsoPlayer;
|
||||||
|
import zombie.network.GameServer;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/** Client commands in Build 42: players as {@link PlayerRef}s, and server commands to clients. */
|
||||||
|
public final class ClientCommandChannel
|
||||||
|
{
|
||||||
|
private ClientCommandChannel() {}
|
||||||
|
|
||||||
|
public static PlayerRef ref(IsoPlayer player) { return new PlayerRef(player.getOnlineID(), player.getUsername()); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies {@code args} at once and returns the action that sends the command with
|
||||||
|
* {@code GameServer.sendServerCommand}, to every connection when {@code player} is
|
||||||
|
* {@code null}. The action runs on the main thread and sends nothing when the player is no
|
||||||
|
* longer connected.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException naming a key or value that cannot be sent
|
||||||
|
*/
|
||||||
|
public static Runnable prepare(@Nullable PlayerRef player, String module, String command, Map<?, ?> args)
|
||||||
|
{
|
||||||
|
Map<Object, Object> copy = LuaTables.copy(args);
|
||||||
|
|
||||||
|
return () ->
|
||||||
|
{
|
||||||
|
KahluaTable table = copy.isEmpty() ? null : LuaTables.toLua(copy, LuaManager.platform::newTable);
|
||||||
|
|
||||||
|
if (player == null) {
|
||||||
|
GameServer.sendServerCommand(module, command, table);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IsoPlayer target = ClientCommandChannel.find(player);
|
||||||
|
if (target != null) GameServer.sendServerCommand(target, module, command, table);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The connected player with the online id and the username of {@code player}, or {@code null}. Main thread. */
|
||||||
|
private static @Nullable IsoPlayer find(PlayerRef player)
|
||||||
|
{
|
||||||
|
Object connected = GameServer.IDToPlayerMap.get((short) player.onlineId());
|
||||||
|
|
||||||
|
return connected instanceof IsoPlayer target && player.username().equals(target.getUsername()) ? target : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+134
@@ -0,0 +1,134 @@
|
|||||||
|
package dev.overlord.zomboidforge.compat.b42.commands;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import se.krka.kahlua.vm.KahluaTable;
|
||||||
|
import se.krka.kahlua.vm.KahluaTableIterator;
|
||||||
|
|
||||||
|
import zombie.inventory.InventoryItem;
|
||||||
|
import zombie.iso.IsoDirections;
|
||||||
|
import zombie.iso.objects.IsoDeadBody;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversion between the Kahlua tables of command arguments and the Java maps of the API. The
|
||||||
|
* types are those {@code TableNetworkUtils} sends: {@code String} and {@code Double} keys;
|
||||||
|
* {@code String}, {@code Double}, {@code Boolean}, table, {@code InventoryItem},
|
||||||
|
* {@code IsoDirections}, and {@code IsoDeadBody} values.
|
||||||
|
*/
|
||||||
|
public final class LuaTables
|
||||||
|
{
|
||||||
|
private LuaTables() {}
|
||||||
|
|
||||||
|
/** {@code table} as an unmodifiable map, nested tables as nested maps; empty for {@code null}. */
|
||||||
|
public static Map<Object, Object> toJava(@Nullable KahluaTable table)
|
||||||
|
{
|
||||||
|
if (table == null) return Map.of();
|
||||||
|
|
||||||
|
Map<Object, Object> map = new LinkedHashMap<>();
|
||||||
|
KahluaTableIterator iterator = table.iterator();
|
||||||
|
|
||||||
|
while (iterator.advance())
|
||||||
|
{
|
||||||
|
Object value = iterator.getValue();
|
||||||
|
map.put(iterator.getKey(), value instanceof KahluaTable nested ? LuaTables.toJava(nested) : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A deep, unmodifiable copy of {@code args} in Lua's types: number keys and values become
|
||||||
|
* {@code Double}, lists become maps with the keys {@code 1.0}, {@code 2.0}, ....
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException naming the first key or value that cannot be sent, or a
|
||||||
|
* map or list that contains itself
|
||||||
|
*/
|
||||||
|
public static Map<Object, Object> copy(Map<?, ?> args) { return LuaTables.copy(args, "args", Collections.newSetFromMap(new IdentityHashMap<>())); }
|
||||||
|
|
||||||
|
/** A new table with the entries of {@code args}, a result of {@link #copy}; nested maps become nested tables. */
|
||||||
|
public static KahluaTable toLua(Map<Object, Object> args, Supplier<KahluaTable> newTable)
|
||||||
|
{
|
||||||
|
KahluaTable table = newTable.get();
|
||||||
|
|
||||||
|
for (Map.Entry<Object, Object> entry : args.entrySet())
|
||||||
|
{
|
||||||
|
Object value = entry.getValue();
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Object luaValue = value instanceof Map<?, ?> nested ? LuaTables.toLua((Map<Object, Object>) nested, newTable) : value;
|
||||||
|
|
||||||
|
table.rawset(entry.getKey(), luaValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<Object, Object> copy(Map<?, ?> map, String path, Set<Object> open)
|
||||||
|
{
|
||||||
|
if (!open.add(map)) throw new IllegalArgumentException("'" + path + "' contains itself.");
|
||||||
|
|
||||||
|
Map<Object, Object> copy = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
for (Map.Entry<?, ?> entry : map.entrySet())
|
||||||
|
{
|
||||||
|
Object key = LuaTables.key(entry.getKey(), path);
|
||||||
|
String here = path + "[" + key + "]";
|
||||||
|
|
||||||
|
copy.put(key, LuaTables.value(entry.getValue(), here, open));
|
||||||
|
}
|
||||||
|
|
||||||
|
open.remove(map);
|
||||||
|
|
||||||
|
return Collections.unmodifiableMap(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<Object, Object> copy(List<?> list, String path, Set<Object> open)
|
||||||
|
{
|
||||||
|
if (!open.add(list)) throw new IllegalArgumentException("'" + path + "' contains itself.");
|
||||||
|
|
||||||
|
Map<Object, Object> copy = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); i++) copy.put((double) (i + 1), LuaTables.value(list.get(i), path + "[" + (i + 1) + "]", open));
|
||||||
|
|
||||||
|
open.remove(list);
|
||||||
|
|
||||||
|
return Collections.unmodifiableMap(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Object key(@Nullable Object key, String path)
|
||||||
|
{
|
||||||
|
if (key instanceof String) return key;
|
||||||
|
if (key instanceof Number number) return number.doubleValue();
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("'" + path + "' has the key '" + key + "'" + LuaTables.typeOf(key) + "; keys are strings or numbers.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Object value(@Nullable Object value, String path, Set<Object> open)
|
||||||
|
{
|
||||||
|
return switch (value)
|
||||||
|
{
|
||||||
|
case String string -> string;
|
||||||
|
case Boolean bool -> bool;
|
||||||
|
case Number number -> number.doubleValue();
|
||||||
|
case Map<?, ?> map -> LuaTables.copy(map, path, open);
|
||||||
|
case List<?> list -> LuaTables.copy(list, path, open);
|
||||||
|
case InventoryItem item -> item;
|
||||||
|
case IsoDirections direction -> direction;
|
||||||
|
case IsoDeadBody body -> body;
|
||||||
|
case null -> throw new IllegalArgumentException("'" + path + "' is null.");
|
||||||
|
default -> throw new IllegalArgumentException(
|
||||||
|
"'" + path + "' is a '" + value.getClass().getName() + "'; values are strings, numbers, booleans, maps, lists, inventory items, directions, or dead bodies."
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String typeOf(@Nullable Object value) { return value == null ? "" : " ('" + value.getClass().getName() + "')"; }
|
||||||
|
}
|
||||||
+111
@@ -0,0 +1,111 @@
|
|||||||
|
package dev.overlord.zomboidforge.compat.b42.commands;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import zombie.characters.Role;
|
||||||
|
import zombie.commands.CommandBase;
|
||||||
|
import zombie.commands.CommandName;
|
||||||
|
import zombie.commands.RequiredCapability;
|
||||||
|
import zombie.core.raknet.UdpConnection;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command classes of mods in Build 42: subclasses of {@code CommandBase}, which
|
||||||
|
* {@code GameServer.handleServerCommand} creates through {@code getConstructors()[0]} with
|
||||||
|
* {@code (username, role, command, connection)}.
|
||||||
|
*/
|
||||||
|
public final class ModCommands
|
||||||
|
{
|
||||||
|
private static final Class<?>[] CONSTRUCTOR = {String.class, Role.class, String.class, UdpConnection.class};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Names are inserted into a regular expression by {@code findCommandCls}, so they are limited
|
||||||
|
* to word characters. With such names, {@code ^name\b} matches the input exactly when its first
|
||||||
|
* word equals the name, ignoring case.
|
||||||
|
*/
|
||||||
|
private static final Pattern NAME = Pattern.compile("\\w+");
|
||||||
|
|
||||||
|
private ModCommands() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fails unless {@code command} is a usable Build 42 command whose names are not taken by
|
||||||
|
* Project Zomboid's commands or by {@code registered}.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException listing every problem
|
||||||
|
*/
|
||||||
|
public static void check(Class<?> command, List<Class<?>> registered)
|
||||||
|
{
|
||||||
|
List<String> problems = new ArrayList<>();
|
||||||
|
int modifiers = command.getModifiers();
|
||||||
|
|
||||||
|
if (!CommandBase.class.isAssignableFrom(command)) problems.add("it does not extend '" + CommandBase.class.getName() + "'");
|
||||||
|
if (!Modifier.isPublic(modifiers)) problems.add("it is not public");
|
||||||
|
if (Modifier.isAbstract(modifiers)) problems.add("it is abstract");
|
||||||
|
|
||||||
|
Constructor<?>[] constructors = command.getConstructors();
|
||||||
|
if (constructors.length != 1 || !Arrays.equals(constructors[0].getParameterTypes(), ModCommands.CONSTRUCTOR))
|
||||||
|
problems.add("it needs exactly one public constructor '(String, Role, String, UdpConnection)'");
|
||||||
|
|
||||||
|
if (command.getAnnotationsByType(RequiredCapability.class).length == 0)
|
||||||
|
problems.add("it has no @RequiredCapability, and Project Zomboid runs no command without one");
|
||||||
|
|
||||||
|
CommandName[] names = command.getAnnotationsByType(CommandName.class);
|
||||||
|
if (names.length == 0) problems.add("it has no @CommandName");
|
||||||
|
|
||||||
|
for (CommandName name : names)
|
||||||
|
{
|
||||||
|
if (!ModCommands.NAME.matcher(name.name()).matches()) {
|
||||||
|
problems.add("the name '" + name.name() + "' contains characters other than letters, digits, and '_'");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Class<?> owner = ModCommands.owner(name.name(), registered);
|
||||||
|
if (owner != null) problems.add("the name '" + name.name() + "' is taken by '" + owner.getName() + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!problems.isEmpty()) throw new IllegalArgumentException("'" + command.getName() + "' cannot be a command: " + String.join("; ", problems) + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The first class of {@code commands} that is not disabled and has a name that {@code input}
|
||||||
|
* starts with, matched like {@code CommandBase.findCommandCls} matches Project Zomboid's
|
||||||
|
* commands; {@code null} when there is none.
|
||||||
|
*/
|
||||||
|
public static @Nullable Class<?> find(List<Class<?>> commands, String input)
|
||||||
|
{
|
||||||
|
for (Class<?> command : commands)
|
||||||
|
{
|
||||||
|
if (CommandBase.isDisabled(command)) continue;
|
||||||
|
|
||||||
|
for (CommandName name : command.getAnnotationsByType(CommandName.class)) {
|
||||||
|
if (Pattern.compile("^" + name.name() + "\\b", Pattern.CASE_INSENSITIVE).matcher(input).find()) return command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The class among Project Zomboid's commands and {@code registered} that has {@code name}, ignoring case. */
|
||||||
|
private static @Nullable Class<?> owner(String name, List<Class<?>> registered)
|
||||||
|
{
|
||||||
|
Set<Class<?>> taken = new LinkedHashSet<>(Arrays.<Class<?>>asList(CommandBase.getSubClasses()));
|
||||||
|
taken.addAll(registered);
|
||||||
|
|
||||||
|
for (Class<?> command : taken)
|
||||||
|
{
|
||||||
|
for (CommandName existing : command.getAnnotationsByType(CommandName.class)) {
|
||||||
|
if (existing.name().equalsIgnoreCase(name)) return command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Commands of mods in Build 42: checks for registered admin command classes and the lookup that
|
||||||
|
* mirrors {@code zombie.commands.CommandBase.findCommandCls}; client commands and the conversion
|
||||||
|
* of their Lua tables.
|
||||||
|
*
|
||||||
|
* @noinspection UnstableApiUsage, RedundantSuppression
|
||||||
|
*/
|
||||||
|
@NotNullByDefault
|
||||||
|
package dev.overlord.zomboidforge.compat.b42.commands;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNullByDefault;
|
||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
package dev.overlord.zomboidforge.compat.b42.hooks;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.api.ClientCommandEvent;
|
||||||
|
import dev.overlord.zomboidforge.compat.b42.ForgeInstance;
|
||||||
|
import dev.overlord.zomboidforge.compat.b42.commands.ClientCommandChannel;
|
||||||
|
import dev.overlord.zomboidforge.compat.b42.commands.LuaTables;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import se.krka.kahlua.vm.KahluaTable;
|
||||||
|
|
||||||
|
import zombie.characters.IsoPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hooks called by patched {@code zombie.network.GameServer.receiveClientCommand} code, on the main
|
||||||
|
* thread (client commands are queued for the main loop). Exceptions are caught here; the command
|
||||||
|
* then reaches Lua as in vanilla.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("CallToPrintStackTrace")
|
||||||
|
public final class ClientCommandHooks
|
||||||
|
{
|
||||||
|
private ClientCommandHooks() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called directly before {@code LuaEventManager.triggerEvent("OnClientCommand", module, command, player, args)},
|
||||||
|
* after the vanilla checks (the player exists; {@code vehicle.remove} only with permission).
|
||||||
|
* Posts {@link ClientCommandEvent} when a mod listens for it.
|
||||||
|
*
|
||||||
|
* @param args {@code null} when the client sent no arguments
|
||||||
|
* @return {@code true} when a listener cancelled the event, which skips the Lua event
|
||||||
|
*/
|
||||||
|
public static boolean onClientCommand(String module, String command, IsoPlayer player, @Nullable KahluaTable args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!ForgeInstance.FORGE.hasListeners(ClientCommandEvent.class)) return false;
|
||||||
|
|
||||||
|
ClientCommandEvent event = new ClientCommandEvent(
|
||||||
|
ClientCommandChannel.ref(player),
|
||||||
|
module, command,
|
||||||
|
LuaTables.toJava(args)
|
||||||
|
);
|
||||||
|
|
||||||
|
ForgeInstance.FORGE.post(event);
|
||||||
|
|
||||||
|
return event.isCancelled();
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
t.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
package dev.overlord.zomboidforge.compat.b42.hooks;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.compat.b42.ForgeInstance;
|
||||||
|
import dev.overlord.zomboidforge.compat.b42.commands.ModCommands;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hooks called by patched {@code zombie.commands.CommandBase} code, on the main thread: the
|
||||||
|
* server console, RCON, and chat commands all run there. Exceptions are caught here, and the
|
||||||
|
* vanilla value is returned.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("CallToPrintStackTrace")
|
||||||
|
public final class CommandHooks
|
||||||
|
{
|
||||||
|
private CommandHooks() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the {@code null} that {@code CommandBase.findCommandCls} returns when no command of
|
||||||
|
* Project Zomboid matches {@code command}: the mods' command class for it, or {@code null}.
|
||||||
|
*/
|
||||||
|
public static @Nullable Class<?> findCommand(@Nullable Class<?> vanilla, String command)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return ModCommands.find(ForgeInstance.FORGE.commands(), command);
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
t.printStackTrace();
|
||||||
|
return vanilla;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the array that {@code CommandBase.getSubClasses} returns: Project Zomboid's
|
||||||
|
* command classes followed by the mods', in registration order. Without mod commands, the
|
||||||
|
* vanilla array itself.
|
||||||
|
*/
|
||||||
|
public static Class<?>[] listCommands(Class<?>[] vanilla)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<Class<?>> mods = ForgeInstance.FORGE.commands();
|
||||||
|
if (mods.isEmpty()) return vanilla;
|
||||||
|
|
||||||
|
Class<?>[] all = Arrays.copyOf(vanilla, vanilla.length + mods.size());
|
||||||
|
for (int i = 0; i < mods.size(); i++) all[vanilla.length + i] = mods.get(i);
|
||||||
|
|
||||||
|
return all;
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
t.printStackTrace();
|
||||||
|
return vanilla;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-4
@@ -75,7 +75,7 @@ public final class ServerHooks
|
|||||||
ForgeInstance.FORGE.started();
|
ForgeInstance.FORGE.started();
|
||||||
System.out.println("[ZomboidForge] Server started (ZomboidForge " + ZomboidForge.VERSION + ").");
|
System.out.println("[ZomboidForge] Server started (ZomboidForge " + ZomboidForge.VERSION + ").");
|
||||||
}
|
}
|
||||||
catch (RuntimeException e) { e.printStackTrace(); }
|
catch (Throwable t) { t.printStackTrace(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,8 +86,8 @@ public final class ServerHooks
|
|||||||
*/
|
*/
|
||||||
public static void onTick()
|
public static void onTick()
|
||||||
{
|
{
|
||||||
try { ForgeInstance.FORGE.tick(); }
|
try { ForgeInstance.FORGE.tick(); }
|
||||||
catch (RuntimeException e) { e.printStackTrace(); }
|
catch (Throwable t) { t.printStackTrace(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,6 +105,6 @@ public final class ServerHooks
|
|||||||
System.out.println("[ZomboidForge] Server stopping.");
|
System.out.println("[ZomboidForge] Server stopping.");
|
||||||
ForgeInstance.FORGE.stopping();
|
ForgeInstance.FORGE.stopping();
|
||||||
}
|
}
|
||||||
catch (RuntimeException e) { e.printStackTrace(); }
|
catch (Throwable t) { t.printStackTrace(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -20,6 +20,6 @@ public final class StorageHooks
|
|||||||
if (running) ForgeInstance.FORGE.backupStarted();
|
if (running) ForgeInstance.FORGE.backupStarted();
|
||||||
else ForgeInstance.FORGE.backupFinished();
|
else ForgeInstance.FORGE.backupFinished();
|
||||||
}
|
}
|
||||||
catch (RuntimeException e) { e.printStackTrace(); }
|
catch (Throwable t) { t.printStackTrace(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-4
@@ -33,10 +33,8 @@ public final class ZombieVehicleHooks
|
|||||||
* and is skipped here.
|
* and is skipped here.
|
||||||
*/
|
*/
|
||||||
public static @Nullable Vector3f getIntersectPoint(
|
public static @Nullable Vector3f getIntersectPoint(
|
||||||
@NotNull BaseVehicle vehicle,
|
BaseVehicle vehicle, Vector3f start,
|
||||||
@NotNull Vector3f start,
|
Vector3f end, @Nullable Vector3f result
|
||||||
@NotNull Vector3f end,
|
|
||||||
@Nullable Vector3f result
|
|
||||||
) {
|
) {
|
||||||
VehicleScript script = vehicle.getScript();
|
VehicleScript script = vehicle.getScript();
|
||||||
Vector3f extents = script.getExtents();
|
Vector3f extents = script.getExtents();
|
||||||
|
|||||||
+127
@@ -0,0 +1,127 @@
|
|||||||
|
package dev.overlord.zomboidforge.compat.b42.commands;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import se.krka.kahlua.j2se.KahluaTableImpl;
|
||||||
|
import se.krka.kahlua.vm.KahluaTable;
|
||||||
|
|
||||||
|
import zombie.iso.IsoDirections;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
/** Runs against the Kahlua classes of the server jar; {@code LuaManager.platform} is not used. */
|
||||||
|
class LuaTablesTest
|
||||||
|
{
|
||||||
|
private static final Supplier<KahluaTable> NEW_TABLE = () -> new KahluaTableImpl(new HashMap<>());
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void convertsTablesToUnmodifiableMaps()
|
||||||
|
{
|
||||||
|
KahluaTable items = LuaTablesTest.NEW_TABLE.get();
|
||||||
|
items.rawset(1.0, "Base.Axe");
|
||||||
|
items.rawset(2.0, "Base.Saw");
|
||||||
|
|
||||||
|
KahluaTable table = LuaTablesTest.NEW_TABLE.get();
|
||||||
|
table.rawset("count", 3.0);
|
||||||
|
table.rawset("gift", true);
|
||||||
|
table.rawset("facing", IsoDirections.N);
|
||||||
|
table.rawset("items", items);
|
||||||
|
|
||||||
|
Map<Object, Object> args = LuaTables.toJava(table);
|
||||||
|
|
||||||
|
assertEquals(Map.of("count", 3.0, "gift", true, "facing", IsoDirections.N, "items", Map.of(1.0, "Base.Axe", 2.0, "Base.Saw")), args);
|
||||||
|
assertThrows(UnsupportedOperationException.class, () -> args.put("x", "y"));
|
||||||
|
assertThrows(UnsupportedOperationException.class, () -> ((Map<?, ?>) args.get("items")).clear());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void convertsMissingArgumentsToAnEmptyMap()
|
||||||
|
{
|
||||||
|
assertEquals(Map.of(), LuaTables.toJava(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void copiesJavaValuesInLuaTypes()
|
||||||
|
{
|
||||||
|
Map<String, Object> args = new LinkedHashMap<>();
|
||||||
|
args.put("count", 3);
|
||||||
|
args.put("price", 2.5F);
|
||||||
|
args.put("items", List.of("Base.Axe", "Base.Saw"));
|
||||||
|
args.put("seller", Map.of("name", "alice", 7, false));
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
Map.of(
|
||||||
|
"count", 3.0,
|
||||||
|
"price", 2.5,
|
||||||
|
"items", Map.of(1.0, "Base.Axe", 2.0, "Base.Saw"),
|
||||||
|
"seller", Map.of("name", "alice", 7.0, false)
|
||||||
|
),
|
||||||
|
LuaTables.copy(args)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void copiesAtOnceSoLaterChangesAreNotSent()
|
||||||
|
{
|
||||||
|
Map<String, Object> args = new HashMap<>(Map.of("count", 1));
|
||||||
|
Map<Object, Object> copy = LuaTables.copy(args);
|
||||||
|
|
||||||
|
args.put("count", 2);
|
||||||
|
|
||||||
|
assertEquals(Map.of("count", 1.0), copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void buildsNestedTablesFromACopy()
|
||||||
|
{
|
||||||
|
KahluaTable table = LuaTables.toLua(LuaTables.copy(Map.of("count", 3, "items", List.of("Base.Axe"))), LuaTablesTest.NEW_TABLE);
|
||||||
|
|
||||||
|
assertEquals(3.0, table.rawget("count"));
|
||||||
|
|
||||||
|
KahluaTable items = (KahluaTable) table.rawget("items");
|
||||||
|
assertEquals("Base.Axe", items.rawget(1.0));
|
||||||
|
assertNull(items.rawget(2.0));
|
||||||
|
assertEquals(1, items.len());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void namesTheFirstValueThatCannotBeSent()
|
||||||
|
{
|
||||||
|
IllegalArgumentException e = assertThrows(
|
||||||
|
IllegalArgumentException.class,
|
||||||
|
() -> LuaTables.copy(Map.of("seller", Map.of("since", new Object())))
|
||||||
|
);
|
||||||
|
|
||||||
|
assertTrue(e.getMessage().startsWith("'args[seller][since]' is a 'java.lang.Object'; values are strings, numbers, booleans,"), e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsNullValuesOtherKeysAndCycles()
|
||||||
|
{
|
||||||
|
Map<Object, Object> withNull = new HashMap<>();
|
||||||
|
withNull.put("name", null);
|
||||||
|
|
||||||
|
Map<Object, Object> withObjectKey = new HashMap<>();
|
||||||
|
withObjectKey.put(true, "yes");
|
||||||
|
|
||||||
|
List<Object> cycle = new ArrayList<>();
|
||||||
|
cycle.add(cycle);
|
||||||
|
|
||||||
|
assertEquals("'args[name]' is null.", assertThrows(IllegalArgumentException.class, () -> LuaTables.copy(withNull)).getMessage());
|
||||||
|
assertEquals(
|
||||||
|
"'args' has the key 'true' ('java.lang.Boolean'); keys are strings or numbers.",
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> LuaTables.copy(withObjectKey)).getMessage()
|
||||||
|
);
|
||||||
|
assertEquals("'args[list][1]' contains itself.", assertThrows(IllegalArgumentException.class, () -> LuaTables.copy(Map.of("list", cycle))).getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
package dev.overlord.zomboidforge.compat.b42.commands;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import zombie.characters.Capability;
|
||||||
|
import zombie.characters.Role;
|
||||||
|
import zombie.commands.CommandBase;
|
||||||
|
import zombie.commands.CommandName;
|
||||||
|
import zombie.commands.DisabledCommand;
|
||||||
|
import zombie.commands.RequiredCapability;
|
||||||
|
import zombie.core.raknet.UdpConnection;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
/** Runs against the classes of the server jar that the module compiles against. */
|
||||||
|
class ModCommandsTest
|
||||||
|
{
|
||||||
|
@CommandName(name = "zfshop")
|
||||||
|
@CommandName(name = "zfbuy")
|
||||||
|
@RequiredCapability(requiredCapability = Capability.LoginOnServer)
|
||||||
|
public static final class ShopCommand extends CommandBase
|
||||||
|
{
|
||||||
|
public ShopCommand(String username, Role role, String command, UdpConnection connection) { super(username, role, command, connection); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String Command() { return "shop"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@CommandName(name = "ZFSHOP")
|
||||||
|
@RequiredCapability(requiredCapability = Capability.LoginOnServer)
|
||||||
|
public static final class OtherShopCommand extends CommandBase
|
||||||
|
{
|
||||||
|
public OtherShopCommand(String username, Role role, String command, UdpConnection connection) { super(username, role, command, connection); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String Command() { return "other shop"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@CommandName(name = "Save")
|
||||||
|
@CommandName(name = "zf-save")
|
||||||
|
@RequiredCapability(requiredCapability = Capability.SaveWorld)
|
||||||
|
public static final class SaveCommand extends CommandBase
|
||||||
|
{
|
||||||
|
public SaveCommand(String username, Role role, String command, UdpConnection connection) { super(username, role, command, connection); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String Command() { return "save"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisabledCommand
|
||||||
|
@CommandName(name = "zfoff")
|
||||||
|
@RequiredCapability(requiredCapability = Capability.LoginOnServer)
|
||||||
|
public static final class DisabledShopCommand extends CommandBase
|
||||||
|
{
|
||||||
|
public DisabledShopCommand(String username, Role role, String command, UdpConnection connection) { super(username, role, command, connection); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String Command() { return "off"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Neither a command nor annotated; its constructor has no parameters. */
|
||||||
|
public static final class NotACommand {}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void acceptsAUsableCommand()
|
||||||
|
{
|
||||||
|
assertDoesNotThrow(() -> ModCommands.check(ModCommandsTest.ShopCommand.class, List.of()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void listsEveryProblemOfAClassThatIsNoCommand()
|
||||||
|
{
|
||||||
|
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> ModCommands.check(ModCommandsTest.NotACommand.class, List.of()));
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"'" + ModCommandsTest.NotACommand.class.getName() + "' cannot be a command: it does not extend 'zombie.commands.CommandBase';"
|
||||||
|
+ " it needs exactly one public constructor '(String, Role, String, UdpConnection)';"
|
||||||
|
+ " it has no @RequiredCapability, and Project Zomboid runs no command without one; it has no @CommandName.",
|
||||||
|
e.getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsNamesOfProjectZomboidIgnoringCaseAndNamesWithOtherCharacters()
|
||||||
|
{
|
||||||
|
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> ModCommands.check(ModCommandsTest.SaveCommand.class, List.of()));
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"'" + ModCommandsTest.SaveCommand.class.getName() + "' cannot be a command:"
|
||||||
|
+ " the name 'Save' is taken by 'zombie.commands.serverCommands.SaveCommand';"
|
||||||
|
+ " the name 'zf-save' contains characters other than letters, digits, and '_'.",
|
||||||
|
e.getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsNamesOfRegisteredCommands()
|
||||||
|
{
|
||||||
|
IllegalArgumentException e = assertThrows(
|
||||||
|
IllegalArgumentException.class,
|
||||||
|
() -> ModCommands.check(ModCommandsTest.OtherShopCommand.class, List.of(ModCommandsTest.ShopCommand.class))
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"'" + ModCommandsTest.OtherShopCommand.class.getName() + "' cannot be a command: the name 'ZFSHOP' is taken by '" + ModCommandsTest.ShopCommand.class.getName() + "'.",
|
||||||
|
e.getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void findsCommandsByTheirFirstWordIgnoringCase()
|
||||||
|
{
|
||||||
|
List<Class<?>> commands = List.of(ModCommandsTest.DisabledShopCommand.class, ModCommandsTest.ShopCommand.class);
|
||||||
|
|
||||||
|
assertEquals(ModCommandsTest.ShopCommand.class, ModCommands.find(commands, "zfshop"));
|
||||||
|
assertEquals(ModCommandsTest.ShopCommand.class, ModCommands.find(commands, "ZFBuy apple 3"));
|
||||||
|
assertNull(ModCommands.find(commands, "zfshopping"));
|
||||||
|
assertNull(ModCommands.find(commands, "zfoff"), "disabled commands are skipped, like Project Zomboid's");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,10 +2,14 @@ package dev.overlord.zomboidforge.core;
|
|||||||
|
|
||||||
import dev.overlord.zomboidforge.api.Event;
|
import dev.overlord.zomboidforge.api.Event;
|
||||||
import dev.overlord.zomboidforge.api.GameVersion;
|
import dev.overlord.zomboidforge.api.GameVersion;
|
||||||
|
import dev.overlord.zomboidforge.api.MainThread;
|
||||||
import dev.overlord.zomboidforge.api.Mod;
|
import dev.overlord.zomboidforge.api.Mod;
|
||||||
import dev.overlord.zomboidforge.api.TickEvent;
|
import dev.overlord.zomboidforge.api.TickEvent;
|
||||||
import dev.overlord.zomboidforge.api.ZomboidForge;
|
import dev.overlord.zomboidforge.api.ZomboidForge;
|
||||||
import dev.overlord.zomboidforge.api.storage.StorageException;
|
import dev.overlord.zomboidforge.api.storage.StorageException;
|
||||||
|
import dev.overlord.zomboidforge.core.commands.ClientCommandSender;
|
||||||
|
import dev.overlord.zomboidforge.core.commands.CommandRegistry;
|
||||||
|
import dev.overlord.zomboidforge.core.commands.ModClientCommands;
|
||||||
import dev.overlord.zomboidforge.core.config.ForgeSettings;
|
import dev.overlord.zomboidforge.core.config.ForgeSettings;
|
||||||
import dev.overlord.zomboidforge.core.mods.GameClasses;
|
import dev.overlord.zomboidforge.core.mods.GameClasses;
|
||||||
import dev.overlord.zomboidforge.core.mods.ModDiscovery;
|
import dev.overlord.zomboidforge.core.mods.ModDiscovery;
|
||||||
@@ -52,6 +56,8 @@ public final class Forge
|
|||||||
|
|
||||||
private final Path directory;
|
private final Path directory;
|
||||||
private final @Nullable ModVersion api;
|
private final @Nullable ModVersion api;
|
||||||
|
private final CommandRegistry commands;
|
||||||
|
private final ClientCommandSender clientCommands;
|
||||||
|
|
||||||
private volatile List<ModLoader.LoadedMod> mods = List.of();
|
private volatile List<ModLoader.LoadedMod> mods = List.of();
|
||||||
private volatile ForgeSettings settings = ForgeSettings.DEFAULTS;
|
private volatile ForgeSettings settings = ForgeSettings.DEFAULTS;
|
||||||
@@ -61,32 +67,44 @@ public final class Forge
|
|||||||
* @param directory the ZomboidForge directory
|
* @param directory the ZomboidForge directory
|
||||||
* @param api the API version mods are checked against, or {@code null} to skip the
|
* @param api the API version mods are checked against, or {@code null} to skip the
|
||||||
* check
|
* check
|
||||||
|
* @param commands checks the command classes that mods register against the running
|
||||||
|
* game version
|
||||||
|
* @param clientCommands sends the mods' server commands to clients in the running game version
|
||||||
*/
|
*/
|
||||||
public Forge(Path directory, @Nullable ModVersion api)
|
public Forge(Path directory, @Nullable ModVersion api, CommandRegistry.Validator commands, ClientCommandSender clientCommands)
|
||||||
{
|
{
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
this.commands = new CommandRegistry(commands, this::commandsOpen);
|
||||||
|
this.clientCommands = clientCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory from {@value #DIRECTORY_PROPERTY} (default {@value #DEFAULT_DIRECTORY}); API
|
* Directory from {@value #DIRECTORY_PROPERTY} (default {@value #DEFAULT_DIRECTORY}); API
|
||||||
* version from {@link ZomboidForge#VERSION}. Builds without a release version ({@code dev},
|
* version from {@link ZomboidForge#VERSION}. Builds without a release version ({@code dev},
|
||||||
* {@code 0.0.0-...}) skip the API check.
|
* {@code 0.0.0-...}) skip the API check.
|
||||||
|
*
|
||||||
|
* @param commands checks the command classes that mods register against the running
|
||||||
|
* game version
|
||||||
|
* @param clientCommands sends the mods' server commands to clients in the running game version
|
||||||
*/
|
*/
|
||||||
public static Forge fromSystemProperties()
|
public static Forge fromSystemProperties(CommandRegistry.Validator commands, ClientCommandSender clientCommands)
|
||||||
{
|
{
|
||||||
Path directory = Path.of(System.getProperty(Forge.DIRECTORY_PROPERTY, Forge.DEFAULT_DIRECTORY));
|
Path directory = Path.of(System.getProperty(Forge.DIRECTORY_PROPERTY, Forge.DEFAULT_DIRECTORY));
|
||||||
ModVersion api = ModVersion.tryParse(ZomboidForge.VERSION)
|
ModVersion api = ModVersion.tryParse(ZomboidForge.VERSION)
|
||||||
.filter(version -> version.major() != 0 || version.minor() != 0 || version.patch() != 0)
|
.filter(version -> version.major() != 0 || version.minor() != 0 || version.patch() != 0)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
return new Forge(directory, api);
|
return new Forge(directory, api, commands, clientCommands);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Lifecycle.Phase phase() { return this.lifecycle.phase(); }
|
public Lifecycle.Phase phase() { return this.lifecycle.phase(); }
|
||||||
|
|
||||||
public List<ModLoader.LoadedMod> mods() { return this.mods; }
|
public List<ModLoader.LoadedMod> mods() { return this.mods; }
|
||||||
|
|
||||||
|
/** The admin command classes that mods registered, in registration order. */
|
||||||
|
public List<Class<?>> commands() { return this.commands.classes(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads {@code forge.toml}, then discovers, checks, and loads every mod in
|
* Reads {@code forge.toml}, then discovers, checks, and loads every mod in
|
||||||
* {@code <directory>/mods}. Called once on the main thread, which becomes the thread of
|
* {@code <directory>/mods}. Called once on the main thread, which becomes the thread of
|
||||||
@@ -154,14 +172,17 @@ public final class Forge
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calls {@link Mod#onServerStarted()} of every mod in load order. Main thread. */
|
/**
|
||||||
|
* Calls {@link Mod#onServerStarted()} of every mod in load order. Main thread. Anything a
|
||||||
|
* mod throws is logged, and the next mod is called.
|
||||||
|
*/
|
||||||
public void started()
|
public void started()
|
||||||
{
|
{
|
||||||
this.lifecycle.started();
|
this.lifecycle.started();
|
||||||
|
|
||||||
for (ModLoader.LoadedMod mod : this.mods) {
|
for (ModLoader.LoadedMod mod : this.mods) {
|
||||||
try { mod.mod().onServerStarted(); }
|
try { mod.mod().onServerStarted(); }
|
||||||
catch (RuntimeException e) { this.logger.log(System.Logger.Level.ERROR, "'" + mod.descriptor().id() + "': onServerStarted() threw.", e); }
|
catch (Throwable t) { this.logger.log(System.Logger.Level.ERROR, "'" + mod.descriptor().id() + "': onServerStarted() threw.", t); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +204,9 @@ public final class Forge
|
|||||||
*/
|
*/
|
||||||
public void post(Event event) { this.events.post(event); }
|
public void post(Event event) { this.events.post(event); }
|
||||||
|
|
||||||
|
/** Whether any mod listens for {@code type}, so a hook can skip creating the event. */
|
||||||
|
public boolean hasListeners(Class<? extends Event> type) { return this.events.hasListeners(type); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pauses storage for a backup of the save folder (see {@link StorageDatabase#backupStarted()}).
|
* Pauses storage for a backup of the save folder (see {@link StorageDatabase#backupStarted()}).
|
||||||
* Called by the patched {@code ZipBackup.makeBackupFile}, on the thread that makes the backup.
|
* Called by the patched {@code ZipBackup.makeBackupFile}, on the thread that makes the backup.
|
||||||
@@ -205,18 +229,24 @@ public final class Forge
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Once: calls {@link Mod#onStopping()} of every mod in reverse load order, then stops the
|
* Once: calls {@link Mod#onStopping()} of every mod in reverse load order, then stops the
|
||||||
* mods' threads, events, and storage (see {@link #stopMods}). Called on the shutdown thread.
|
* mods' threads, events, and storage (see {@link #stopMods}). Called on the shutdown thread,
|
||||||
|
* before the world is saved, so nothing a mod throws leaves this method.
|
||||||
*/
|
*/
|
||||||
public void stopping()
|
public void stopping()
|
||||||
{
|
{
|
||||||
if (!this.lifecycle.stopping()) return;
|
if (!this.lifecycle.stopping()) return;
|
||||||
|
|
||||||
for (ModLoader.LoadedMod mod : this.mods.reversed()) {
|
try
|
||||||
try { mod.mod().onStopping(); }
|
{
|
||||||
catch (RuntimeException e) { this.logger.log(System.Logger.Level.ERROR, "'" + mod.descriptor().id() + "': onStopping() threw.", e); }
|
for (ModLoader.LoadedMod mod : this.mods.reversed()) {
|
||||||
|
try { mod.mod().onStopping(); }
|
||||||
|
catch (Throwable t) { this.logger.log(System.Logger.Level.ERROR, "'" + mod.descriptor().id() + "': onStopping() threw.", t); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
this.stopMods(this.settings.shutdownTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stopMods(this.settings.shutdownTimeout());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -237,6 +267,9 @@ public final class Forge
|
|||||||
catch (StorageException e) { this.logger.log(System.Logger.Level.ERROR, "Closing the storage failed.", e); }
|
catch (StorageException e) { this.logger.log(System.Logger.Level.ERROR, "Closing the storage failed.", e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Mods register commands on the main thread while they load. */
|
||||||
|
private boolean commandsOpen() { return this.queue.isMainThread() && this.lifecycle.phase() == Lifecycle.Phase.BOOTING; }
|
||||||
|
|
||||||
/** The main thread may use storage only before the main loop runs. */
|
/** The main thread may use storage only before the main loop runs. */
|
||||||
private boolean storageForbidden() { return this.queue.isMainThread() && this.lifecycle.phase() == Lifecycle.Phase.RUNNING; }
|
private boolean storageForbidden() { return this.queue.isMainThread() && this.lifecycle.phase() == Lifecycle.Phase.RUNNING; }
|
||||||
|
|
||||||
@@ -245,13 +278,16 @@ public final class Forge
|
|||||||
ModThreads.ModExecutors executors = this.threads.create(id, logger);
|
ModThreads.ModExecutors executors = this.threads.create(id, logger);
|
||||||
|
|
||||||
StorageDatabase storage = Objects.requireNonNull(this.storage, "storage");
|
StorageDatabase storage = Objects.requireNonNull(this.storage, "storage");
|
||||||
|
MainThread main = this.queue.forMod(id, logger);
|
||||||
|
|
||||||
return new ModServices(
|
return new ModServices(
|
||||||
this.events.forMod(id, executors.modThread(), logger),
|
this.events.forMod(id, executors.modThread(), logger),
|
||||||
this.queue.forMod(id, logger),
|
main,
|
||||||
executors.modThread(),
|
executors.modThread(),
|
||||||
executors.async(),
|
executors.async(),
|
||||||
new ModTables(id, storage, logger)
|
new ModTables(id, storage, logger),
|
||||||
|
this.commands.forMod(logger),
|
||||||
|
new ModClientCommands(this.clientCommands, main)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package dev.overlord.zomboidforge.core.commands;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.api.PlayerRef;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/** Sends server commands to clients; implemented by the compat module of the running game version. */
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ClientCommandSender
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Checks {@code args} on the calling thread and returns the action that converts and sends
|
||||||
|
* the command, which runs on the main thread.
|
||||||
|
*
|
||||||
|
* @param player the receiving player, or {@code null} for every connected client
|
||||||
|
* @throws IllegalArgumentException naming a key or value that cannot be sent
|
||||||
|
*/
|
||||||
|
Runnable prepare(@Nullable PlayerRef player, String module, String command, Map<?, ?> args);
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package dev.overlord.zomboidforge.core.commands;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.api.Commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The admin command classes that mods registered, in registration order. What a command class
|
||||||
|
* has to look like depends on the Project Zomboid version, so a {@link Validator} from the compat
|
||||||
|
* module checks every class. Registration happens only while the mods load, on the main thread;
|
||||||
|
* the compat hooks read {@link #classes()} on the main thread afterwards.
|
||||||
|
*/
|
||||||
|
public final class CommandRegistry
|
||||||
|
{
|
||||||
|
/** Checks a command class against the command framework of the running game version. */
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Validator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param registered the classes registered before, by any mod
|
||||||
|
* @throws IllegalArgumentException naming what is wrong with {@code command}
|
||||||
|
*/
|
||||||
|
void check(Class<?> command, List<Class<?>> registered);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Validator validator;
|
||||||
|
private final BooleanSupplier open;
|
||||||
|
|
||||||
|
private volatile List<Class<?>> classes = List.of();
|
||||||
|
|
||||||
|
/** @param open whether registration is allowed now, on the calling thread */
|
||||||
|
public CommandRegistry(Validator validator, BooleanSupplier open)
|
||||||
|
{
|
||||||
|
this.validator = Objects.requireNonNull(validator);
|
||||||
|
this.open = Objects.requireNonNull(open);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Every registered class, in registration order. */
|
||||||
|
public List<Class<?>> classes() { return this.classes; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registration for one mod; registered classes are logged with {@code logger}. Exceptions do
|
||||||
|
* not name the mod: one thrown in the mod's {@code onLoad()} is reported with its id.
|
||||||
|
*/
|
||||||
|
public Commands forMod(System.Logger logger)
|
||||||
|
{
|
||||||
|
return command ->
|
||||||
|
{
|
||||||
|
this.register(command);
|
||||||
|
logger.log(System.Logger.Level.INFO, "Registered the command class '" + command.getName() + "'.");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void register(Class<?> command)
|
||||||
|
{
|
||||||
|
Objects.requireNonNull(command, "command");
|
||||||
|
|
||||||
|
if (!this.open.getAsBoolean())
|
||||||
|
throw new IllegalStateException("Commands can only be registered on the main thread while the mod loads (constructor or onLoad()).");
|
||||||
|
|
||||||
|
if (this.classes.contains(command))
|
||||||
|
throw new IllegalArgumentException("The command class '" + command.getName() + "' is registered already.");
|
||||||
|
|
||||||
|
this.validator.check(command, this.classes);
|
||||||
|
|
||||||
|
List<Class<?>> updated = new ArrayList<>(this.classes);
|
||||||
|
updated.add(command);
|
||||||
|
|
||||||
|
this.classes = List.copyOf(updated);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package dev.overlord.zomboidforge.core.commands;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.api.ClientCommands;
|
||||||
|
import dev.overlord.zomboidforge.api.MainThread;
|
||||||
|
import dev.overlord.zomboidforge.api.PlayerRef;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link ClientCommands} of one mod: checks on the calling thread, sends through the mod's
|
||||||
|
* {@link MainThread}, so a command sent off the main thread is one of the mod's queued tasks.
|
||||||
|
*/
|
||||||
|
public final class ModClientCommands implements ClientCommands
|
||||||
|
{
|
||||||
|
private final ClientCommandSender sender;
|
||||||
|
private final MainThread main;
|
||||||
|
|
||||||
|
public ModClientCommands(ClientCommandSender sender, MainThread main)
|
||||||
|
{
|
||||||
|
this.sender = Objects.requireNonNull(sender);
|
||||||
|
this.main = Objects.requireNonNull(main);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void send(PlayerRef player, String module, String command, Map<?, ?> args)
|
||||||
|
{
|
||||||
|
Objects.requireNonNull(player, "player");
|
||||||
|
|
||||||
|
this.main.execute(this.sender.prepare(player, ModClientCommands.require(module, "module"), ModClientCommands.require(command, "command"), Objects.requireNonNull(args, "args")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendToAll(String module, String command, Map<?, ?> args)
|
||||||
|
{
|
||||||
|
this.main.execute(this.sender.prepare(null, ModClientCommands.require(module, "module"), ModClientCommands.require(command, "command"), Objects.requireNonNull(args, "args")));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String require(String value, String name)
|
||||||
|
{
|
||||||
|
if (Objects.requireNonNull(value, name).isEmpty()) throw new IllegalArgumentException("'" + name + "' is empty.");
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Commands of loaded mods: the registry of admin commands that the compat hooks consult, and
|
||||||
|
* server commands to clients.
|
||||||
|
*
|
||||||
|
* @noinspection UnstableApiUsage, RedundantSuppression
|
||||||
|
*/
|
||||||
|
@NotNullByDefault
|
||||||
|
package dev.overlord.zomboidforge.core.commands;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNullByDefault;
|
||||||
@@ -29,6 +29,9 @@ import java.util.stream.Collectors;
|
|||||||
*
|
*
|
||||||
* Everything else on the parent's class path, such as ZomboidForge's own classes and libraries,
|
* Everything else on the parent's class path, such as ZomboidForge's own classes and libraries,
|
||||||
* is not visible. A mod's own copy of a library that the game also bundles takes precedence.
|
* is not visible. A mod's own copy of a library that the game also bundles takes precedence.
|
||||||
|
*
|
||||||
|
* <p>The lookup order prevents accidental linkage only. It is not a security boundary: mod code
|
||||||
|
* can still reach other classes through reflection or {@link ClassLoader#getSystemClassLoader()}.
|
||||||
*/
|
*/
|
||||||
final class ModClassLoader extends URLClassLoader
|
final class ModClassLoader extends URLClassLoader
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package dev.overlord.zomboidforge.core.mods;
|
package dev.overlord.zomboidforge.core.mods;
|
||||||
|
|
||||||
import dev.overlord.zomboidforge.api.AsyncExecutor;
|
import dev.overlord.zomboidforge.api.AsyncExecutor;
|
||||||
|
import dev.overlord.zomboidforge.api.ClientCommands;
|
||||||
|
import dev.overlord.zomboidforge.api.Commands;
|
||||||
import dev.overlord.zomboidforge.api.Events;
|
import dev.overlord.zomboidforge.api.Events;
|
||||||
import dev.overlord.zomboidforge.api.GameVersion;
|
import dev.overlord.zomboidforge.api.GameVersion;
|
||||||
import dev.overlord.zomboidforge.api.MainThread;
|
import dev.overlord.zomboidforge.api.MainThread;
|
||||||
@@ -36,17 +38,19 @@ public final class ModLoader
|
|||||||
public record LoadedMod(ModDescriptor descriptor, Path directory, ClassLoader classLoader, Mod mod) {}
|
public record LoadedMod(ModDescriptor descriptor, Path directory, ClassLoader classLoader, Mod mod) {}
|
||||||
|
|
||||||
private record Context(
|
private record Context(
|
||||||
String id,
|
String id,
|
||||||
String version,
|
String version,
|
||||||
GameVersion gameVersion,
|
GameVersion gameVersion,
|
||||||
System.Logger logger,
|
System.Logger logger,
|
||||||
Path directory,
|
Path directory,
|
||||||
ModConfig config,
|
ModConfig config,
|
||||||
Events events,
|
Events events,
|
||||||
MainThread main,
|
MainThread main,
|
||||||
ModThread modThread,
|
ModThread modThread,
|
||||||
AsyncExecutor async,
|
AsyncExecutor async,
|
||||||
ModStorage storage
|
ModStorage storage,
|
||||||
|
Commands commands,
|
||||||
|
ClientCommands clientCommands
|
||||||
) implements ModContext {}
|
) implements ModContext {}
|
||||||
|
|
||||||
private ModLoader() {}
|
private ModLoader() {}
|
||||||
@@ -93,7 +97,9 @@ public final class ModLoader
|
|||||||
provided.main(),
|
provided.main(),
|
||||||
provided.modThread(),
|
provided.modThread(),
|
||||||
provided.async(),
|
provided.async(),
|
||||||
provided.storage()
|
provided.storage(),
|
||||||
|
provided.commands(),
|
||||||
|
provided.clientCommands()
|
||||||
);
|
);
|
||||||
|
|
||||||
loaded.add(new LoadedMod(descriptor, candidate.directory(), loader, ModLoader.create(descriptor, loader, context)));
|
loaded.add(new LoadedMod(descriptor, candidate.directory(), loader, ModLoader.create(descriptor, loader, context)));
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
package dev.overlord.zomboidforge.core.mods;
|
package dev.overlord.zomboidforge.core.mods;
|
||||||
|
|
||||||
import dev.overlord.zomboidforge.api.AsyncExecutor;
|
import dev.overlord.zomboidforge.api.AsyncExecutor;
|
||||||
|
import dev.overlord.zomboidforge.api.ClientCommands;
|
||||||
|
import dev.overlord.zomboidforge.api.Commands;
|
||||||
import dev.overlord.zomboidforge.api.Events;
|
import dev.overlord.zomboidforge.api.Events;
|
||||||
import dev.overlord.zomboidforge.api.MainThread;
|
import dev.overlord.zomboidforge.api.MainThread;
|
||||||
import dev.overlord.zomboidforge.api.ModThread;
|
import dev.overlord.zomboidforge.api.ModThread;
|
||||||
import dev.overlord.zomboidforge.api.storage.ModStorage;
|
import dev.overlord.zomboidforge.api.storage.ModStorage;
|
||||||
|
|
||||||
/** The threads, event registration, and storage of one mod, created before its entry point. */
|
/** The threads, event and command registration, storage, and client commands of one mod, created before its entry point. */
|
||||||
public record ModServices(Events events, MainThread main, ModThread modThread, AsyncExecutor async, ModStorage storage)
|
public record ModServices(
|
||||||
{
|
Events events,
|
||||||
|
MainThread main,
|
||||||
|
ModThread modThread,
|
||||||
|
AsyncExecutor async,
|
||||||
|
ModStorage storage,
|
||||||
|
Commands commands,
|
||||||
|
ClientCommands clientCommands
|
||||||
|
) {
|
||||||
/** Creates the services of one mod. */
|
/** Creates the services of one mod. */
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Factory
|
public interface Factory
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public record ModVersion(int major, int minor, int patch, @Nullable String preRelease) implements Comparable<ModVersion>
|
public record ModVersion(int major, int minor, int patch, @Nullable String preRelease) implements Comparable<ModVersion>
|
||||||
{
|
{
|
||||||
private static final Pattern FORMAT = Pattern.compile("(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:-([0-9A-Za-z.-]+))?");
|
// At most 9 digits per number, so every number fits an int.
|
||||||
|
private static final Pattern FORMAT = Pattern.compile("(\\d{1,9})(?:\\.(\\d{1,9}))?(?:\\.(\\d{1,9}))?(?:-([0-9A-Za-z.-]+))?");
|
||||||
|
|
||||||
private static final Comparator<ModVersion> ORDER = Comparator
|
private static final Comparator<ModVersion> ORDER = Comparator
|
||||||
.comparingInt(ModVersion::major)
|
.comparingInt(ModVersion::major)
|
||||||
|
|||||||
@@ -79,25 +79,30 @@ public final class MainThreadQueue
|
|||||||
int index = count == 0 ? 0 : this.next % count;
|
int index = count == 0 ? 0 : this.next % count;
|
||||||
int empty = 0;
|
int empty = 0;
|
||||||
|
|
||||||
while (empty < count && !this.closed)
|
try
|
||||||
{
|
{
|
||||||
ModQueue queue = queues[index];
|
while (empty < count && !this.closed)
|
||||||
index = (index + 1) % count;
|
{
|
||||||
|
ModQueue queue = queues[index];
|
||||||
|
index = (index + 1) % count;
|
||||||
|
|
||||||
Task task = queue.tasks.poll();
|
Task task = queue.tasks.poll();
|
||||||
|
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
empty++;
|
empty++;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
empty = 0;
|
||||||
|
queue.run(task.action());
|
||||||
|
|
||||||
|
if (System.nanoTime() >= deadline) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
empty = 0;
|
|
||||||
queue.run(task.action());
|
|
||||||
|
|
||||||
if (System.nanoTime() >= deadline) break;
|
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
this.next = index;
|
{
|
||||||
|
this.next = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Rejects further tasks and cancels the queued ones (their futures are cancelled). Any thread. */
|
/** Rejects further tasks and cancels the queued ones (their futures are cancelled). Any thread. */
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ final class ModTaskEvent extends jdk.jfr.Event
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs {@code action} as a {@code zomboidforge.ModTask} event. Mod code must not end the
|
* Runs {@code action} as a {@code zomboidforge.ModTask} event. Mod code must not end the
|
||||||
* calling thread's work, so failures are returned instead of thrown: runtime exceptions,
|
* calling thread's work, so every failure is returned instead of thrown, including errors
|
||||||
* missing classes or members ({@link LinkageError}), and stack overflows.
|
* and checked exceptions thrown without being declared.
|
||||||
*
|
*
|
||||||
* @return the failure, or {@code null} when {@code action} returned normally
|
* @return the failure, or {@code null} when {@code action} returned normally
|
||||||
*/
|
*/
|
||||||
@@ -40,9 +40,9 @@ final class ModTaskEvent extends jdk.jfr.Event
|
|||||||
action.run();
|
action.run();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (RuntimeException | LinkageError | StackOverflowError e)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
return e;
|
return t;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,6 +44,13 @@ public final class ModTables implements ModStorage
|
|||||||
/** A stored schema. */
|
/** A stored schema. */
|
||||||
private record Schema(int version, List<Column> columns) {}
|
private record Schema(int version, List<Column> columns) {}
|
||||||
|
|
||||||
|
/** Work on one stored row; may throw {@link SQLException}. */
|
||||||
|
@FunctionalInterface
|
||||||
|
private interface RowAction
|
||||||
|
{
|
||||||
|
void accept(Row row) throws SQLException;
|
||||||
|
}
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final StorageDatabase database;
|
private final StorageDatabase database;
|
||||||
private final System.Logger logger;
|
private final System.Logger logger;
|
||||||
@@ -226,13 +233,12 @@ public final class ModTables implements ModStorage
|
|||||||
throw new StorageException(table + " has schema version " + stored.version() + ", the mod declares " + this.version + " but no migration from " + stored.version() + ".");
|
throw new StorageException(table + " has schema version " + stored.version() + ", the mod declares " + this.version + " but no migration from " + stored.version() + ".");
|
||||||
|
|
||||||
String rebuilt = physical + "__migrating";
|
String rebuilt = physical + "__migrating";
|
||||||
List<Row> rows = ModTables.rows(connection, physical);
|
|
||||||
SqlTable<R> target = new SqlTable<>(ModTables.this.database, codec, rebuilt);
|
SqlTable<R> target = new SqlTable<>(ModTables.this.database, codec, rebuilt);
|
||||||
|
|
||||||
ModTables.execute(connection, "DROP TABLE IF EXISTS " + SqlTable.quoted(rebuilt));
|
ModTables.execute(connection, "DROP TABLE IF EXISTS " + SqlTable.quoted(rebuilt));
|
||||||
ModTables.create(connection, rebuilt, codec.columns());
|
ModTables.create(connection, rebuilt, codec.columns());
|
||||||
|
|
||||||
for (Row row : rows)
|
int migrated = ModTables.forEachRow(connection, physical, row ->
|
||||||
{
|
{
|
||||||
R record;
|
R record;
|
||||||
|
|
||||||
@@ -240,13 +246,13 @@ public final class ModTables implements ModStorage
|
|||||||
catch (RuntimeException e) { throw new StorageException(table + ": the migration from version " + stored.version() + " failed for row '" + row.key() + "': " + e, e); }
|
catch (RuntimeException e) { throw new StorageException(table + ": the migration from version " + stored.version() + " failed for row '" + row.key() + "': " + e, e); }
|
||||||
|
|
||||||
target.set(row.key(), record);
|
target.set(row.key(), record);
|
||||||
}
|
});
|
||||||
|
|
||||||
ModTables.execute(connection, "DROP TABLE " + SqlTable.quoted(physical));
|
ModTables.execute(connection, "DROP TABLE " + SqlTable.quoted(physical));
|
||||||
ModTables.execute(connection, "ALTER TABLE " + SqlTable.quoted(rebuilt) + " RENAME TO " + SqlTable.quoted(physical));
|
ModTables.execute(connection, "ALTER TABLE " + SqlTable.quoted(rebuilt) + " RENAME TO " + SqlTable.quoted(physical));
|
||||||
ModTables.this.saveSchema(connection, this.name, this.version, codec.columns());
|
ModTables.this.saveSchema(connection, this.name, this.version, codec.columns());
|
||||||
|
|
||||||
ModTables.this.logger.log(System.Logger.Level.INFO, table + ": migrated " + rows.size() + " row(s) from schema version " + stored.version() + " to " + this.version + ".");
|
ModTables.this.logger.log(System.Logger.Level.INFO, table + ": migrated " + migrated + " row(s) from schema version " + stored.version() + " to " + this.version + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,10 +282,15 @@ public final class ModTables implements ModStorage
|
|||||||
ModTables.execute(connection, "CREATE TABLE " + SqlTable.quoted(physical) + " (" + SqlTable.quoted(SqlTable.KEY) + " TEXT PRIMARY KEY NOT NULL" + definitions + ")");
|
ModTables.execute(connection, "CREATE TABLE " + SqlTable.quoted(physical) + " (" + SqlTable.quoted(SqlTable.KEY) + " TEXT PRIMARY KEY NOT NULL" + definitions + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Every row of {@code physical} with all its columns, sorted by key. */
|
/**
|
||||||
private static List<Row> rows(Connection connection, String physical) throws SQLException
|
* Calls {@code action} for every row of {@code physical} with all its columns, sorted by key,
|
||||||
|
* reading one row at a time.
|
||||||
|
*
|
||||||
|
* @return the number of rows
|
||||||
|
*/
|
||||||
|
private static int forEachRow(Connection connection, String physical, RowAction action) throws SQLException
|
||||||
{
|
{
|
||||||
List<Row> rows = new ArrayList<>();
|
int count = 0;
|
||||||
|
|
||||||
try (Statement statement = connection.createStatement(); ResultSet result = statement.executeQuery("SELECT * FROM " + SqlTable.quoted(physical) + " ORDER BY " + SqlTable.quoted(SqlTable.KEY)))
|
try (Statement statement = connection.createStatement(); ResultSet result = statement.executeQuery("SELECT * FROM " + SqlTable.quoted(physical) + " ORDER BY " + SqlTable.quoted(SqlTable.KEY)))
|
||||||
{
|
{
|
||||||
@@ -299,11 +310,12 @@ public final class ModTables implements ModStorage
|
|||||||
else values.put(column, value instanceof Integer number ? Long.valueOf(number) : value);
|
else values.put(column, value instanceof Integer number ? Long.valueOf(number) : value);
|
||||||
}
|
}
|
||||||
|
|
||||||
rows.add(new StoredRow(key, values));
|
action.accept(new StoredRow(key, values));
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rows;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> tableNames(Connection connection, String mod) throws SQLException
|
private static List<String> tableNames(Connection connection, String mod) throws SQLException
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ final class RecordCodec<R extends Record>
|
|||||||
if (stored == null && !column.nullable())
|
if (stored == null && !column.nullable())
|
||||||
throw new StorageException("Column '" + column.name() + "' of '" + this.type.getSimpleName() + "' is null in the database.");
|
throw new StorageException("Column '" + column.name() + "' of '" + this.type.getSimpleName() + "' is null in the database.");
|
||||||
|
|
||||||
arguments[i] = stored == null ? null : RecordCodec.value(column.kind(), this.types[i], stored);
|
try { arguments[i] = stored == null ? null : RecordCodec.value(column.kind(), this.types[i], stored); }
|
||||||
|
catch (RuntimeException e) { throw new StorageException("Column '" + column.name() + "' of '" + this.type.getSimpleName() + "' holds '" + stored + "', which is not a valid '" + this.types[i].getSimpleName() + "': " + e, e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
try { return this.type.cast(this.constructor.invokeWithArguments(arguments)); }
|
try { return this.type.cast(this.constructor.invokeWithArguments(arguments)); }
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import java.nio.file.Path;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Savepoint;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
@@ -31,6 +34,9 @@ public final class StorageDatabase implements AutoCloseable
|
|||||||
/** File name, in the world's save folder. */
|
/** File name, in the world's save folder. */
|
||||||
public static final String FILE = "zomboidforge.db";
|
public static final String FILE = "zomboidforge.db";
|
||||||
|
|
||||||
|
/** Longest wait of a backup for the running storage operation. */
|
||||||
|
static final Duration BACKUP_WAIT = Duration.ofSeconds(10);
|
||||||
|
|
||||||
/** Work with the connection that has a result; may throw {@link SQLException}. */
|
/** Work with the connection that has a result; may throw {@link SQLException}. */
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Work<T>
|
public interface Work<T>
|
||||||
@@ -104,8 +110,10 @@ public final class StorageDatabase implements AutoCloseable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs {@code work} in a transaction. Nested calls on the same thread join the outer
|
* Runs {@code work} in a transaction. The outermost call on a thread commits when
|
||||||
* transaction; it commits when the outermost call returns and rolls back when any throws.
|
* {@code work} returns and rolls back when it throws. A nested call runs inside a savepoint
|
||||||
|
* of the outer transaction: when its {@code work} throws, only its own writes are rolled
|
||||||
|
* back, also when the outer work catches the exception.
|
||||||
*/
|
*/
|
||||||
public <T> T transaction(Work<T> work)
|
public <T> T transaction(Work<T> work)
|
||||||
{
|
{
|
||||||
@@ -118,19 +126,23 @@ public final class StorageDatabase implements AutoCloseable
|
|||||||
boolean outermost = this.depth == 0;
|
boolean outermost = this.depth == 0;
|
||||||
|
|
||||||
if (outermost) connection.setAutoCommit(false);
|
if (outermost) connection.setAutoCommit(false);
|
||||||
|
|
||||||
|
Savepoint savepoint = outermost ? null : connection.setSavepoint();
|
||||||
this.depth++;
|
this.depth++;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
T result = work.run(connection);
|
T result = work.run(connection);
|
||||||
if (outermost) connection.commit();
|
|
||||||
|
if (savepoint == null) connection.commit();
|
||||||
|
else connection.releaseSavepoint(savepoint);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
catch (SQLException | RuntimeException | Error e)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
if (outermost) StorageDatabase.rollback(connection, e);
|
StorageDatabase.rollback(connection, savepoint, t);
|
||||||
throw e;
|
throw t;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -149,15 +161,30 @@ public final class StorageDatabase implements AutoCloseable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocks storage for a backup of the save folder: waits for the running operation, writes
|
* Blocks storage for a backup of the save folder: waits up to {@link #BACKUP_WAIT} for the
|
||||||
* the WAL into the database file ({@code PRAGMA wal_checkpoint(TRUNCATE)}), and keeps the
|
* running operation, writes the WAL into the database file
|
||||||
* lock until {@link #backupFinished()} on the same thread. Other threads' storage calls wait.
|
* ({@code PRAGMA wal_checkpoint(TRUNCATE)}), and keeps the lock until
|
||||||
|
* {@link #backupFinished()} on the same thread. Other threads' storage calls wait.
|
||||||
|
*
|
||||||
|
* <p>When the running operation takes longer, for example a transaction that waits for the
|
||||||
|
* thread making the backup, the backup runs without the lock and storage stays usable.
|
||||||
*
|
*
|
||||||
* @return a problem to log, or {@code null}
|
* @return a problem to log, or {@code null}
|
||||||
*/
|
*/
|
||||||
public @Nullable String backupStarted()
|
public @Nullable String backupStarted() { return this.backupStarted(StorageDatabase.BACKUP_WAIT); }
|
||||||
|
|
||||||
|
@Nullable String backupStarted(Duration wait)
|
||||||
{
|
{
|
||||||
this.lock.lock();
|
try
|
||||||
|
{
|
||||||
|
if (!this.lock.tryLock(wait.toMillis(), TimeUnit.MILLISECONDS))
|
||||||
|
return "Storage was busy for " + wait.toSeconds() + " s; the backup runs without pausing storage, so its copy of '" + StorageDatabase.FILE + "' may be incomplete.";
|
||||||
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return "Interrupted while waiting for storage; the backup runs without pausing storage, so its copy of '" + StorageDatabase.FILE + "' may be incomplete.";
|
||||||
|
}
|
||||||
|
|
||||||
Connection connection = this.connection;
|
Connection connection = this.connection;
|
||||||
if (connection == null) return null;
|
if (connection == null) return null;
|
||||||
@@ -241,9 +268,21 @@ public final class StorageDatabase implements AutoCloseable
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void rollback(Connection connection, Throwable cause)
|
/** Rolls back the transaction, or only to {@code savepoint} (and releases it) when one is given. */
|
||||||
|
private static void rollback(Connection connection, @Nullable Savepoint savepoint, Throwable cause)
|
||||||
{
|
{
|
||||||
try { connection.rollback(); }
|
try
|
||||||
catch (SQLException e) { cause.addSuppressed(e); }
|
{
|
||||||
|
if (savepoint == null) {
|
||||||
|
connection.rollback();
|
||||||
|
} else {
|
||||||
|
connection.rollback(savepoint);
|
||||||
|
connection.releaseSavepoint(savepoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
cause.addSuppressed(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,13 +11,16 @@ import org.junit.jupiter.api.BeforeEach;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.io.TempDir;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
|
import testmods.CommandMod;
|
||||||
import testmods.ContextMod;
|
import testmods.ContextMod;
|
||||||
|
import testmods.ErrorMod;
|
||||||
import testmods.Recorder;
|
import testmods.Recorder;
|
||||||
import testmods.ThreadMod;
|
import testmods.ThreadMod;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -26,6 +29,7 @@ import java.util.function.BooleanSupplier;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@@ -44,6 +48,12 @@ class ForgeTest
|
|||||||
private Path gameJar;
|
private Path gameJar;
|
||||||
private Path storageFile;
|
private Path storageFile;
|
||||||
|
|
||||||
|
/** Classes that mods registered as commands, as {@code "<name> after <registered count>"}; every class is accepted. */
|
||||||
|
private final List<String> checkedCommands = new ArrayList<>();
|
||||||
|
|
||||||
|
/** Client commands that mods sent, as {@code "<player or all> <module>.<command> <args>"}. */
|
||||||
|
private final List<String> sentClientCommands = new ArrayList<>();
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() throws IOException
|
void setUp() throws IOException
|
||||||
{
|
{
|
||||||
@@ -55,7 +65,15 @@ class ForgeTest
|
|||||||
Recorder.EVENTS.clear();
|
Recorder.EVENTS.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Forge forge() { return new Forge(this.directory, ModVersion.parse("0.3.0")); }
|
private Forge forge()
|
||||||
|
{
|
||||||
|
return new Forge(
|
||||||
|
this.directory,
|
||||||
|
ModVersion.parse("0.3.0"),
|
||||||
|
(command, registered) -> this.checkedCommands.add(command.getName() + " after " + registered.size()),
|
||||||
|
(player, module, command, args) -> () -> this.sentClientCommands.add((player == null ? "all" : player.username()) + " " + module + "." + command + " " + args)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private Forge load() throws ModLoadException
|
private Forge load() throws ModLoadException
|
||||||
{
|
{
|
||||||
@@ -104,6 +122,38 @@ class ForgeTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void modsRegisterCommandsOnlyWhileTheyLoad() throws Exception
|
||||||
|
{
|
||||||
|
TestMods.folder(this.mods, "commands", TestMods.toml("commands", CommandMod.class.getName(), ""), Map.of(
|
||||||
|
"testmods/CommandMod", TestMods.classFile(CommandMod.class),
|
||||||
|
"testmods/CommandMod$Command", TestMods.classFile(CommandMod.Command.class)
|
||||||
|
));
|
||||||
|
|
||||||
|
Forge forge = this.load();
|
||||||
|
|
||||||
|
assertEquals(List.of("testmods.CommandMod$Command"), forge.commands().stream().map(Class::getName).toList());
|
||||||
|
assertEquals(List.of("testmods.CommandMod$Command after 0"), this.checkedCommands);
|
||||||
|
|
||||||
|
forge.started();
|
||||||
|
|
||||||
|
assertInstanceOf(IllegalStateException.class, ForgeTest.field(forge.mods().getFirst().mod(), "lateRegistration"));
|
||||||
|
assertEquals(1, forge.commands().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void modsSendClientCommandsThroughTheGameSender() throws Exception
|
||||||
|
{
|
||||||
|
TestMods.folder(this.mods, "commands", TestMods.toml("commands", CommandMod.class.getName(), ""), Map.of(
|
||||||
|
"testmods/CommandMod", TestMods.classFile(CommandMod.class),
|
||||||
|
"testmods/CommandMod$Command", TestMods.classFile(CommandMod.Command.class)
|
||||||
|
));
|
||||||
|
|
||||||
|
this.load().started();
|
||||||
|
|
||||||
|
assertEquals(List.of("all Test.started {count=1}"), this.sentClientCommands);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void modsSeeTheirContextAndSettingsInTheConstructor() throws Exception
|
void modsSeeTheirContextAndSettingsInTheConstructor() throws Exception
|
||||||
{
|
{
|
||||||
@@ -197,6 +247,25 @@ class ForgeTest
|
|||||||
assertEquals(Lifecycle.Phase.BOOTING, forge.phase());
|
assertEquals(Lifecycle.Phase.BOOTING, forge.phase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void errorsOfModsInStartedAndStoppingReachNeitherTheGameNorTheOtherMods() throws Exception
|
||||||
|
{
|
||||||
|
TestMods.folder(this.mods, "economy", TestMods.toml("economy", "economy.EconomyMod", ForgeTest.USES_GAME), Map.of(
|
||||||
|
"economy/EconomyMod", TestMods.modClass("economy/EconomyMod", "economy", null, false)
|
||||||
|
));
|
||||||
|
TestMods.folder(this.mods, "errors", TestMods.toml("errors", ErrorMod.class.getName(), "[dependencies]\neconomy = \"1.0\"\n"), Map.of(
|
||||||
|
"testmods/ErrorMod", TestMods.classFile(ErrorMod.class)
|
||||||
|
));
|
||||||
|
|
||||||
|
Forge forge = this.load();
|
||||||
|
|
||||||
|
forge.started();
|
||||||
|
forge.stopping();
|
||||||
|
|
||||||
|
assertEquals(List.of("economy:new", "economy:onLoad", "economy:onServerStarted", "economy:onStopping"), Recorder.EVENTS, "economy is stopped after errors stopped");
|
||||||
|
assertEquals(Lifecycle.Phase.STOPPING, forge.phase());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void failsWhenTheEntryPointIsNoMod() throws IOException
|
void failsWhenTheEntryPointIsNoMod() throws IOException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package dev.overlord.zomboidforge.core.commands;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.api.Commands;
|
||||||
|
import dev.overlord.zomboidforge.core.RecordingLogger;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
class CommandRegistryTest
|
||||||
|
{
|
||||||
|
private final List<String> checked = new ArrayList<>();
|
||||||
|
private final AtomicBoolean open = new AtomicBoolean(true);
|
||||||
|
private final RecordingLogger logger = new RecordingLogger();
|
||||||
|
|
||||||
|
/** Records every check as {@code "<simple name> after <registered count>"} and rejects {@link Integer}. */
|
||||||
|
private final CommandRegistry registry = new CommandRegistry(
|
||||||
|
(command, registered) ->
|
||||||
|
{
|
||||||
|
this.checked.add(command.getSimpleName() + " after " + registered.size());
|
||||||
|
if (command == Integer.class) throw new IllegalArgumentException("'java.lang.Integer' cannot be a command.");
|
||||||
|
},
|
||||||
|
this.open::get
|
||||||
|
);
|
||||||
|
|
||||||
|
private final Commands commands = this.registry.forMod(this.logger);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void registersInOrderAndShowsTheValidatorTheEarlierClasses()
|
||||||
|
{
|
||||||
|
this.commands.register(String.class);
|
||||||
|
this.commands.register(Long.class);
|
||||||
|
|
||||||
|
assertEquals(List.of(String.class, Long.class), this.registry.classes());
|
||||||
|
assertEquals(List.of("String after 0", "Long after 1"), this.checked);
|
||||||
|
assertEquals(
|
||||||
|
List.of("INFO: Registered the command class 'java.lang.String'.", "INFO: Registered the command class 'java.lang.Long'."),
|
||||||
|
this.logger.messages
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectedClassesAreNotRegistered()
|
||||||
|
{
|
||||||
|
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> this.commands.register(Integer.class));
|
||||||
|
|
||||||
|
assertEquals("'java.lang.Integer' cannot be a command.", e.getMessage());
|
||||||
|
assertEquals(List.of(), this.registry.classes());
|
||||||
|
assertEquals(List.of(), this.logger.messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsTheSameClassTwice()
|
||||||
|
{
|
||||||
|
this.commands.register(String.class);
|
||||||
|
|
||||||
|
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> this.commands.register(String.class));
|
||||||
|
|
||||||
|
assertEquals("The command class 'java.lang.String' is registered already.", e.getMessage());
|
||||||
|
assertEquals(List.of(String.class), this.registry.classes());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsRegistrationWhileClosed()
|
||||||
|
{
|
||||||
|
this.open.set(false);
|
||||||
|
|
||||||
|
IllegalStateException e = assertThrows(IllegalStateException.class, () -> this.commands.register(String.class));
|
||||||
|
|
||||||
|
assertEquals("Commands can only be registered on the main thread while the mod loads (constructor or onLoad()).", e.getMessage());
|
||||||
|
assertEquals(List.of(), this.checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
+107
@@ -0,0 +1,107 @@
|
|||||||
|
package dev.overlord.zomboidforge.core.commands;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.api.ClientCommands;
|
||||||
|
import dev.overlord.zomboidforge.api.PlayerRef;
|
||||||
|
import dev.overlord.zomboidforge.core.RecordingLogger;
|
||||||
|
import dev.overlord.zomboidforge.core.runtime.MainThreadQueue;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
/** The test thread is the main thread. */
|
||||||
|
class ModClientCommandsTest
|
||||||
|
{
|
||||||
|
private static final PlayerRef PLAYER = new PlayerRef(3, "alice");
|
||||||
|
|
||||||
|
/** What the sender prepared ({@code "prepare ..."}) and sent ({@code "send ... on <thread>"}). */
|
||||||
|
private final List<String> log = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
|
/** Records both steps; rejects arguments that contain the key {@code "bad"}. */
|
||||||
|
private final ClientCommandSender sender = (player, module, command, args) ->
|
||||||
|
{
|
||||||
|
if (args.containsKey("bad")) throw new IllegalArgumentException("'args[bad]' cannot be sent.");
|
||||||
|
|
||||||
|
String target = player == null ? "all" : player.username();
|
||||||
|
this.log.add("prepare " + target + " " + module + "." + command + " " + args);
|
||||||
|
|
||||||
|
return () -> this.log.add("send " + target + " " + module + "." + command + " on " + Thread.currentThread().getName());
|
||||||
|
};
|
||||||
|
|
||||||
|
private MainThreadQueue queue;
|
||||||
|
private ClientCommands commands;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp()
|
||||||
|
{
|
||||||
|
this.queue = new MainThreadQueue(Duration.ofSeconds(10));
|
||||||
|
this.queue.bindToCurrentThread();
|
||||||
|
|
||||||
|
this.commands = new ModClientCommands(this.sender, this.queue.forMod("shop", new RecordingLogger()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sendsAtOnceOnTheMainThread()
|
||||||
|
{
|
||||||
|
this.commands.send(ModClientCommandsTest.PLAYER, "Shop", "bought", Map.of("item", "Base.Axe"));
|
||||||
|
this.commands.sendToAll("Shop", "opened", Map.of());
|
||||||
|
|
||||||
|
String main = Thread.currentThread().getName();
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
List.of(
|
||||||
|
"prepare alice Shop.bought {item=Base.Axe}", "send alice Shop.bought on " + main,
|
||||||
|
"prepare all Shop.opened {}", "send all Shop.opened on " + main
|
||||||
|
),
|
||||||
|
this.log
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void checksOnTheCallingThreadAndSendsOnTheMainThreadLater() throws InterruptedException
|
||||||
|
{
|
||||||
|
Thread other = Thread.ofPlatform().name("worker").start(() -> this.commands.sendToAll("Shop", "opened", Map.of()));
|
||||||
|
other.join();
|
||||||
|
|
||||||
|
assertEquals(List.of("prepare all Shop.opened {}"), this.log);
|
||||||
|
|
||||||
|
this.queue.drain();
|
||||||
|
|
||||||
|
assertEquals(List.of("prepare all Shop.opened {}", "send all Shop.opened on " + Thread.currentThread().getName()), this.log);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectedArgumentsThrowToTheCallerOnAnyThread() throws InterruptedException
|
||||||
|
{
|
||||||
|
AtomicReference<Throwable> thrown = new AtomicReference<>();
|
||||||
|
|
||||||
|
Thread other = Thread.ofPlatform().start(() ->
|
||||||
|
{
|
||||||
|
try { this.commands.sendToAll("Shop", "opened", Map.of("bad", 1)); }
|
||||||
|
catch (Throwable t) { thrown.set(t); }
|
||||||
|
});
|
||||||
|
other.join();
|
||||||
|
|
||||||
|
assertInstanceOf(IllegalArgumentException.class, thrown.get());
|
||||||
|
|
||||||
|
this.queue.drain();
|
||||||
|
assertEquals(List.of(), this.log);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsEmptyModuleAndCommand()
|
||||||
|
{
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> this.commands.sendToAll("", "opened", Map.of()));
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> this.commands.send(ModClientCommandsTest.PLAYER, "Shop", "", Map.of()));
|
||||||
|
assertEquals(List.of(), this.log);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,15 @@ class ModVersionTest
|
|||||||
assertThrows(IllegalArgumentException.class, () -> ModVersion.parse("v1.0"));
|
assertThrows(IllegalArgumentException.class, () -> ModVersion.parse("v1.0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsNumbersOutsideTheIntRange()
|
||||||
|
{
|
||||||
|
assertEquals(new ModVersion(999999999, 0, 0, null), ModVersion.parse("999999999"));
|
||||||
|
assertTrue(ModVersion.tryParse("99999999999").isEmpty());
|
||||||
|
assertTrue(ModVersion.tryParse("1.99999999999").isEmpty());
|
||||||
|
assertTrue(ModVersion.tryParse("1.0.99999999999").isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void preReleaseSortsBeforeRelease()
|
void preReleaseSortsBeforeRelease()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -152,6 +152,22 @@ class MainThreadQueueTest
|
|||||||
assertEquals(List.of("ERROR: A main-thread task threw. (java.lang.IllegalStateException: executed)"), this.logger.messages);
|
assertEquals(List.of("ERROR: A main-thread task threw. (java.lang.IllegalStateException: executed)"), this.logger.messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void logsErrorsOfTasksAndRunsTheNextTask() throws Exception
|
||||||
|
{
|
||||||
|
MainThread a = this.queue.forMod("a", this.logger);
|
||||||
|
|
||||||
|
MainThreadQueueTest.fromOtherThread(() -> {
|
||||||
|
a.execute(() -> { throw new AssertionError("failed"); });
|
||||||
|
a.execute(() -> this.ran.add("next"));
|
||||||
|
});
|
||||||
|
|
||||||
|
this.queue.drain();
|
||||||
|
|
||||||
|
assertEquals(List.of("next"), this.ran);
|
||||||
|
assertEquals(List.of("ERROR: A main-thread task threw. (java.lang.AssertionError: failed)"), this.logger.messages);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void closeCancelsQueuedTasksAndRejectsNewOnes() throws Exception
|
void closeCancelsQueuedTasksAndRejectsNewOnes() throws Exception
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.junit.jupiter.api.io.TempDir;
|
|||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -34,6 +35,8 @@ class ModTablesTest
|
|||||||
{
|
{
|
||||||
private enum Mode { EASY, HARD }
|
private enum Mode { EASY, HARD }
|
||||||
|
|
||||||
|
private enum RenamedMode { SIMPLE, HARD }
|
||||||
|
|
||||||
private record Everything(String text, long big, int small, double ratio, float factor, boolean flag, byte[] bytes, UUID id, Instant when, Mode mode, @Nullable Long optional) {}
|
private record Everything(String text, long big, int small, double ratio, float factor, boolean flag, byte[] bytes, UUID id, Instant when, Mode mode, @Nullable Long optional) {}
|
||||||
|
|
||||||
private record Balance(long coins) {}
|
private record Balance(long coins) {}
|
||||||
@@ -46,6 +49,10 @@ class ModTablesTest
|
|||||||
|
|
||||||
private record Empty() {}
|
private record Empty() {}
|
||||||
|
|
||||||
|
private record Difficulty(Mode mode) {}
|
||||||
|
|
||||||
|
private record RenamedDifficulty(RenamedMode mode) {}
|
||||||
|
|
||||||
@TempDir
|
@TempDir
|
||||||
Path directory;
|
Path directory;
|
||||||
|
|
||||||
@@ -90,6 +97,18 @@ class ModTablesTest
|
|||||||
assertTrue(Files.isRegularFile(this.file), "the database is created on first use");
|
assertTrue(Files.isRegularFile(this.file), "the database is created on first use");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void reportsUnreadableStoredValuesAsStorageExceptions()
|
||||||
|
{
|
||||||
|
this.storage("shop").table("difficulties", Difficulty.class).set("a", new Difficulty(Mode.EASY));
|
||||||
|
|
||||||
|
Table<RenamedDifficulty> renamed = this.storage("shop").table("difficulties", RenamedDifficulty.class);
|
||||||
|
|
||||||
|
StorageException e = assertThrows(StorageException.class, () -> renamed.get("a"));
|
||||||
|
assertTrue(e.getMessage().startsWith("Column 'mode' of 'RenamedDifficulty' holds 'EASY', which is not a valid 'RenamedMode': "), e.getMessage());
|
||||||
|
assertThrows(StorageException.class, () -> renamed.forEach((key, difficulty) -> {}));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void readsAndWritesRows()
|
void readsAndWritesRows()
|
||||||
{
|
{
|
||||||
@@ -140,6 +159,50 @@ class ModTablesTest
|
|||||||
assertEquals(9, sum);
|
assertEquals(9, sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rollsBackAFailedNestedTransactionThatTheOuterOneCatches()
|
||||||
|
{
|
||||||
|
ModStorage storage = this.storage("shop");
|
||||||
|
Table<Balance> balances = storage.table("balances", Balance.class);
|
||||||
|
|
||||||
|
storage.transaction(() -> {
|
||||||
|
balances.set("a", new Balance(1));
|
||||||
|
|
||||||
|
assertThrows(IllegalStateException.class, () -> storage.transaction(() -> {
|
||||||
|
balances.set("a", new Balance(100));
|
||||||
|
balances.set("b", new Balance(100));
|
||||||
|
throw new IllegalStateException("abort");
|
||||||
|
}));
|
||||||
|
|
||||||
|
balances.set("c", new Balance(3));
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEquals(Optional.of(new Balance(1)), balances.get("a"));
|
||||||
|
assertFalse(balances.contains("b"));
|
||||||
|
assertEquals(Optional.of(new Balance(3)), balances.get("c"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rollsBackForErrorsAndUndeclaredCheckedExceptions()
|
||||||
|
{
|
||||||
|
ModStorage storage = this.storage("shop");
|
||||||
|
Table<Balance> balances = storage.table("balances", Balance.class);
|
||||||
|
|
||||||
|
assertThrows(AssertionError.class, () -> storage.transaction(() -> {
|
||||||
|
balances.set("a", new Balance(1));
|
||||||
|
throw new AssertionError("abort");
|
||||||
|
}));
|
||||||
|
assertThrows(Exception.class, () -> storage.transaction(() -> {
|
||||||
|
balances.set("b", new Balance(1));
|
||||||
|
ModTablesTest.sneakyThrow(new Exception("abort"));
|
||||||
|
}));
|
||||||
|
|
||||||
|
assertEquals(0, balances.count());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private static <E extends Throwable> void sneakyThrow(Throwable t) throws E { throw (E) t; }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void keepsModsApart()
|
void keepsModsApart()
|
||||||
{
|
{
|
||||||
@@ -277,6 +340,38 @@ class ModTablesTest
|
|||||||
assertTrue(balances.contains("b"));
|
assertTrue(balances.contains("b"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void backupsDoNotWaitForeverForStorage() throws Exception
|
||||||
|
{
|
||||||
|
Table<Balance> balances = this.storage("shop").table("balances", Balance.class);
|
||||||
|
balances.set("a", new Balance(1));
|
||||||
|
|
||||||
|
CountDownLatch inside = new CountDownLatch(1);
|
||||||
|
CountDownLatch release = new CountDownLatch(1);
|
||||||
|
Thread holder = Thread.ofPlatform().start(() -> this.storage("shop").transaction(() -> {
|
||||||
|
inside.countDown();
|
||||||
|
ModTablesTest.await(release);
|
||||||
|
}));
|
||||||
|
|
||||||
|
assertTrue(inside.await(5, TimeUnit.SECONDS));
|
||||||
|
|
||||||
|
String problem = this.database.backupStarted(Duration.ofSeconds(1));
|
||||||
|
assertEquals("Storage was busy for 1 s; the backup runs without pausing storage, so its copy of 'zomboidforge.db' may be incomplete.", problem);
|
||||||
|
this.database.backupFinished();
|
||||||
|
|
||||||
|
release.countDown();
|
||||||
|
holder.join();
|
||||||
|
|
||||||
|
balances.set("b", new Balance(2));
|
||||||
|
assertTrue(balances.contains("b"), "storage stays usable after the skipped pause");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void await(CountDownLatch latch)
|
||||||
|
{
|
||||||
|
try { latch.await(); }
|
||||||
|
catch (InterruptedException e) { Thread.currentThread().interrupt(); }
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void rejectsBadNamesTypesAndUseAfterClose()
|
void rejectsBadNamesTypesAndUseAfterClose()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package testmods;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.api.Mod;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry point that tests package into a mod jar. Registers {@link Command} in {@code onLoad()}
|
||||||
|
* and tries again in {@code onServerStarted()}, which is too late; sends a client command to
|
||||||
|
* every client there.
|
||||||
|
*/
|
||||||
|
public final class CommandMod extends Mod
|
||||||
|
{
|
||||||
|
/** Stands in for a command class; the tests' validator accepts any class. */
|
||||||
|
public static final class Command {}
|
||||||
|
|
||||||
|
public volatile @Nullable RuntimeException lateRegistration;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() { this.commands().register(CommandMod.Command.class); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServerStarted()
|
||||||
|
{
|
||||||
|
try { this.commands().register(CommandMod.Command.class); }
|
||||||
|
catch (RuntimeException e) { this.lateRegistration = e; }
|
||||||
|
|
||||||
|
this.clientCommands().sendToAll("Test", "started", Map.of("count", 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package testmods;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.api.Mod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry point that tests package into a mod jar. Its lifecycle methods throw errors, which aren't
|
||||||
|
* {@link RuntimeException}.
|
||||||
|
*/
|
||||||
|
public final class ErrorMod extends Mod
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onServerStarted() { throw new AssertionError("started"); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopping() { throw new NoClassDefFoundError("stopping"); }
|
||||||
|
}
|
||||||
@@ -32,7 +32,8 @@ public abstract class DownloadGame extends DefaultTask
|
|||||||
static final String JAR = "java/projectzomboid.jar";
|
static final String JAR = "java/projectzomboid.jar";
|
||||||
|
|
||||||
private static final String APP_ID = "380870";
|
private static final String APP_ID = "380870";
|
||||||
private static final String IMAGE = "docker.io/steamcmd/steamcmd:latest";
|
// The same image as the Dockerfile's server stage.
|
||||||
|
private static final String IMAGE = "docker.io/steamcmd/steamcmd:debian-13@sha256:b0b49ef3101c304ed6e3fbc3ea930b2940d7c489563a1ebac524ad5bb46d336d";
|
||||||
private static final int MAX_ATTEMPTS = 3;
|
private static final int MAX_ATTEMPTS = 3;
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
|
|||||||
+15
-3
@@ -102,7 +102,7 @@ public abstract class GenerateModDescriptor extends DefaultTask
|
|||||||
if (!dependencies.isEmpty())
|
if (!dependencies.isEmpty())
|
||||||
{
|
{
|
||||||
toml.append("\n[dependencies]\n");
|
toml.append("\n[dependencies]\n");
|
||||||
dependencies.forEach((id, version) -> toml.append(id).append(" = ").append(GenerateModDescriptor.string(version)).append('\n'));
|
dependencies.forEach((id, version) -> toml.append(GenerateModDescriptor.string(id)).append(" = ").append(GenerateModDescriptor.string(version)).append('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return toml.toString();
|
return toml.toString();
|
||||||
@@ -110,6 +110,18 @@ public abstract class GenerateModDescriptor extends DefaultTask
|
|||||||
|
|
||||||
private static String list(List<String> values) { return values.stream().map(GenerateModDescriptor::string).collect(Collectors.joining(", ", "[", "]")); }
|
private static String list(List<String> values) { return values.stream().map(GenerateModDescriptor::string).collect(Collectors.joining(", ", "[", "]")); }
|
||||||
|
|
||||||
/** A TOML basic string. */
|
/** A TOML basic string, also used for keys: backslashes, quotes, and control characters are escaped. */
|
||||||
private static String string(String value) { return "\"" + value.replace("\\", "\\\\").replace("\"", "\\\"") + "\""; }
|
private static String string(String value)
|
||||||
|
{
|
||||||
|
StringBuilder escaped = new StringBuilder("\"");
|
||||||
|
|
||||||
|
for (char c : value.toCharArray())
|
||||||
|
{
|
||||||
|
if (c == '\\' || c == '"') escaped.append('\\').append(c);
|
||||||
|
else if (c < 0x20 || c == 0x7F) escaped.append(String.format("\\u%04X", (int) c));
|
||||||
|
else escaped.append(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return escaped.append('"').toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package dev.overlord.zomboidforge.gradle;
|
|||||||
import org.gradle.api.DefaultTask;
|
import org.gradle.api.DefaultTask;
|
||||||
import org.gradle.api.GradleException;
|
import org.gradle.api.GradleException;
|
||||||
import org.gradle.api.file.DirectoryProperty;
|
import org.gradle.api.file.DirectoryProperty;
|
||||||
|
import org.gradle.api.file.RegularFileProperty;
|
||||||
import org.gradle.api.provider.Property;
|
import org.gradle.api.provider.Property;
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
import org.gradle.api.tasks.Internal;
|
import org.gradle.api.tasks.Internal;
|
||||||
@@ -15,6 +16,13 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.nio.file.attribute.PosixFileAttributeView;
|
||||||
|
import java.nio.file.attribute.PosixFilePermissions;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -37,6 +45,8 @@ public abstract class RunServer extends DefaultTask
|
|||||||
/** Seconds the server gets to save the world after a stop request. */
|
/** Seconds the server gets to save the world after a stop request. */
|
||||||
private static final int STOP_TIMEOUT = 120;
|
private static final int STOP_TIMEOUT = 120;
|
||||||
|
|
||||||
|
private static final SecureRandom RANDOM = new SecureRandom();
|
||||||
|
|
||||||
/** Contains one folder per mod, as in {@code <forge>/mods}. */
|
/** Contains one folder per mod, as in {@code <forge>/mods}. */
|
||||||
@Internal
|
@Internal
|
||||||
public abstract DirectoryProperty getModsDirectory();
|
public abstract DirectoryProperty getModsDirectory();
|
||||||
@@ -50,9 +60,17 @@ public abstract class RunServer extends DefaultTask
|
|||||||
@Input
|
@Input
|
||||||
public abstract Property<String> getDataVolume();
|
public abstract Property<String> getDataVolume();
|
||||||
|
|
||||||
@Input
|
/** Not an input, so it is not stored in the task history. */
|
||||||
|
@Internal
|
||||||
public abstract Property<String> getAdminPassword();
|
public abstract Property<String> getAdminPassword();
|
||||||
|
|
||||||
|
/** Holds the generated admin password of the volume when {@link #getAdminPassword()} is not set. */
|
||||||
|
@Internal
|
||||||
|
public abstract RegularFileProperty getAdminPasswordFile();
|
||||||
|
|
||||||
|
@Input
|
||||||
|
public abstract Property<String> getServerAddress();
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
@Optional
|
@Optional
|
||||||
public abstract Property<String> getContainerEngine();
|
public abstract Property<String> getContainerEngine();
|
||||||
@@ -60,23 +78,28 @@ public abstract class RunServer extends DefaultTask
|
|||||||
@TaskAction
|
@TaskAction
|
||||||
public void run() throws IOException
|
public void run() throws IOException
|
||||||
{
|
{
|
||||||
String engine = Executables.containerEngine(this.getContainerEngine().getOrNull());
|
String engine = Executables.containerEngine(this.getContainerEngine().getOrNull());
|
||||||
String name = this.getContainerName().get();
|
String name = this.getContainerName().get();
|
||||||
|
String address = this.getServerAddress().get();
|
||||||
|
|
||||||
|
// ADMIN_PASSWORD without a value takes the value from the engine's environment, so it is not in the command line.
|
||||||
List<String> command = List.of(
|
List<String> command = List.of(
|
||||||
engine, "run", "--rm",
|
engine, "run", "--rm",
|
||||||
"--name", name,
|
"--name", name,
|
||||||
"--publish", "16261:16261/udp",
|
"--publish", address + ":16261:16261/udp",
|
||||||
"--publish", "16262:16262/udp",
|
"--publish", address + ":16262:16262/udp",
|
||||||
"--env", "ADMIN_PASSWORD=" + this.getAdminPassword().get(),
|
"--env", "ADMIN_PASSWORD",
|
||||||
"--volume", this.getDataVolume().get() + ":/data",
|
"--volume", this.getDataVolume().get() + ":/data",
|
||||||
"--volume", this.getModsDirectory().get().getAsFile().getAbsolutePath() + ":/forge/mods:ro,Z",
|
"--volume", this.getModsDirectory().get().getAsFile().getAbsolutePath() + ":/forge/mods:ro,Z",
|
||||||
this.getImage().get()
|
this.getImage().get()
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getLogger().lifecycle("Starting {} with the mod; connect to localhost:16261. Cancel the build (Ctrl+C) to stop the server.", this.getImage().get());
|
ProcessBuilder builder = new ProcessBuilder(command).redirectErrorStream(true);
|
||||||
|
builder.environment().put("ADMIN_PASSWORD", this.adminPassword());
|
||||||
|
|
||||||
Process process = new ProcessBuilder(command).redirectErrorStream(true).start();
|
this.getLogger().lifecycle("Starting {} with the mod on {}:16261. Cancel the build (Ctrl+C) to stop the server.", this.getImage().get(), address);
|
||||||
|
|
||||||
|
Process process = builder.start();
|
||||||
Thread output = new Thread(() -> RunServer.forward(process), "runServer output");
|
Thread output = new Thread(() -> RunServer.forward(process), "runServer output");
|
||||||
|
|
||||||
output.setDaemon(true);
|
output.setDaemon(true);
|
||||||
@@ -96,6 +119,42 @@ public abstract class RunServer extends DefaultTask
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The configured admin password, else the one in {@link #getAdminPasswordFile()}; a random one
|
||||||
|
* is generated into the file when it does not exist. The server uses the password only when it
|
||||||
|
* creates the admin account on the volume's first start.
|
||||||
|
*/
|
||||||
|
private String adminPassword() throws IOException
|
||||||
|
{
|
||||||
|
String configured = this.getAdminPassword().getOrNull();
|
||||||
|
if (configured != null) return configured;
|
||||||
|
|
||||||
|
Path file = this.getAdminPasswordFile().get().getAsFile().toPath();
|
||||||
|
|
||||||
|
if (Files.exists(file)) return Files.readString(file, StandardCharsets.UTF_8).strip();
|
||||||
|
|
||||||
|
byte[] random = new byte[18];
|
||||||
|
RunServer.RANDOM.nextBytes(random);
|
||||||
|
|
||||||
|
String password = Base64.getUrlEncoder().withoutPadding().encodeToString(random);
|
||||||
|
|
||||||
|
Files.createDirectories(file.getParent());
|
||||||
|
Files.writeString(file, password, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW);
|
||||||
|
RunServer.restrictToOwner(file);
|
||||||
|
|
||||||
|
this.getLogger().lifecycle("Generated the admin password '{}' for '{}', kept in '{}'.", password, this.getDataVolume().get(), file);
|
||||||
|
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Makes {@code file} readable and writable by its owner only, where the file system has POSIX permissions. */
|
||||||
|
private static void restrictToOwner(Path file) throws IOException
|
||||||
|
{
|
||||||
|
if (!Files.getFileStore(file).supportsFileAttributeView(PosixFileAttributeView.class)) return;
|
||||||
|
|
||||||
|
Files.setPosixFilePermissions(file, PosixFilePermissions.fromString("rw-------"));
|
||||||
|
}
|
||||||
|
|
||||||
/** Copies the container's output to the build output, line by line. */
|
/** Copies the container's output to the build output, line by line. */
|
||||||
private static void forward(Process process)
|
private static void forward(Process process)
|
||||||
{
|
{
|
||||||
|
|||||||
+8
-1
@@ -64,9 +64,16 @@ public abstract class ZomboidForgeExtension
|
|||||||
/** Image for {@code runServer}. Default: the ZomboidForge image tagged "latest". */
|
/** Image for {@code runServer}. Default: the ZomboidForge image tagged "latest". */
|
||||||
public abstract Property<String> getServerImage();
|
public abstract Property<String> getServerImage();
|
||||||
|
|
||||||
/** Admin password of the {@code runServer} server. Default: "admin". */
|
/**
|
||||||
|
* Admin password of the {@code runServer} server, used when its volume is created. Default:
|
||||||
|
* a random password, generated once per volume and kept in
|
||||||
|
* {@code <Gradle user home>/zomboidforge/admin-passwords/<volume>}.
|
||||||
|
*/
|
||||||
public abstract Property<String> getAdminPassword();
|
public abstract Property<String> getAdminPassword();
|
||||||
|
|
||||||
|
/** Host address {@code runServer} publishes the game ports on. Default: "127.0.0.1" (this machine only); "0.0.0.0" for every interface. */
|
||||||
|
public abstract Property<String> getServerAddress();
|
||||||
|
|
||||||
/** Volume for the {@code runServer} server's /data (world, config). Default: "zomboidforge-<id>". */
|
/** Volume for the {@code runServer} server's /data (world, config). Default: "zomboidforge-<id>". */
|
||||||
public abstract Property<String> getDataVolume();
|
public abstract Property<String> getDataVolume();
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -55,6 +55,7 @@ public final class ZomboidForgeModPlugin implements Plugin<Project>
|
|||||||
private static final String TOOLS = "dev.overlord.zomboidforge:mod-tools:";
|
private static final String TOOLS = "dev.overlord.zomboidforge:mod-tools:";
|
||||||
private static final String TOOLS_MAIN = "dev.overlord.zomboidforge.tools.ModCheck";
|
private static final String TOOLS_MAIN = "dev.overlord.zomboidforge.tools.ModCheck";
|
||||||
private static final String DEFAULT_IMAGE = "git.security-command.org/overlord/zomboidforge:latest";
|
private static final String DEFAULT_IMAGE = "git.security-command.org/overlord/zomboidforge:latest";
|
||||||
|
private static final String MOD_CONFIG = "config.toml";
|
||||||
private static final int JAVA = 25;
|
private static final int JAVA = 25;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,7 +73,7 @@ public final class ZomboidForgeModPlugin implements Plugin<Project>
|
|||||||
extension.getApi().convention(version);
|
extension.getApi().convention(version);
|
||||||
extension.getSteamBranch().convention("public");
|
extension.getSteamBranch().convention("public");
|
||||||
extension.getServerImage().convention(ZomboidForgeModPlugin.DEFAULT_IMAGE);
|
extension.getServerImage().convention(ZomboidForgeModPlugin.DEFAULT_IMAGE);
|
||||||
extension.getAdminPassword().convention("admin");
|
extension.getServerAddress().convention("127.0.0.1");
|
||||||
extension.getDataVolume().convention(extension.getId().map(id -> "zomboidforge-" + id));
|
extension.getDataVolume().convention(extension.getId().map(id -> "zomboidforge-" + id));
|
||||||
extension.getGameJar().convention(layout.file(project.getProviders().gradleProperty("zomboidforge.gameJar").map(File::new)));
|
extension.getGameJar().convention(layout.file(project.getProviders().gradleProperty("zomboidforge.gameJar").map(File::new)));
|
||||||
|
|
||||||
@@ -220,6 +221,8 @@ public final class ZomboidForgeModPlugin implements Plugin<Project>
|
|||||||
project.getTasks().named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME, task -> task.dependsOn(modFolder, modZip));
|
project.getTasks().named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME, task -> task.dependsOn(modFolder, modZip));
|
||||||
|
|
||||||
// Trying the mod.
|
// Trying the mod.
|
||||||
|
File passwords = new File(project.getGradle().getGradleUserHomeDir(), "zomboidforge/admin-passwords");
|
||||||
|
|
||||||
project.getTasks().register("runServer", RunServer.class, task ->
|
project.getTasks().register("runServer", RunServer.class, task ->
|
||||||
{
|
{
|
||||||
task.setGroup(ZomboidForgeModPlugin.GROUP);
|
task.setGroup(ZomboidForgeModPlugin.GROUP);
|
||||||
@@ -230,14 +233,17 @@ public final class ZomboidForgeModPlugin implements Plugin<Project>
|
|||||||
task.getContainerName().set(id.map(name -> "zomboidforge-" + name));
|
task.getContainerName().set(id.map(name -> "zomboidforge-" + name));
|
||||||
task.getDataVolume().set(extension.getDataVolume());
|
task.getDataVolume().set(extension.getDataVolume());
|
||||||
task.getAdminPassword().set(extension.getAdminPassword());
|
task.getAdminPassword().set(extension.getAdminPassword());
|
||||||
|
task.getAdminPasswordFile().set(layout.file(extension.getDataVolume().map(volume -> new File(passwords, volume))));
|
||||||
|
task.getServerAddress().set(extension.getServerAddress());
|
||||||
task.getContainerEngine().set(extension.getContainerEngine());
|
task.getContainerEngine().set(extension.getContainerEngine());
|
||||||
});
|
});
|
||||||
|
|
||||||
project.getTasks().register("deployMod", Sync.class, task ->
|
project.getTasks().register("deployMod", Sync.class, task ->
|
||||||
{
|
{
|
||||||
task.setGroup(ZomboidForgeModPlugin.GROUP);
|
task.setGroup(ZomboidForgeModPlugin.GROUP);
|
||||||
task.setDescription("Copies the mod folder into zomboidForge.deployDirectory (a server's mods directory).");
|
task.setDescription("Copies the mod folder into zomboidForge.deployDirectory (a server's mods directory); keeps the server's config.toml of the mod.");
|
||||||
task.from(modFolder);
|
task.from(modFolder);
|
||||||
|
task.preserve(filter -> filter.include(ZomboidForgeModPlugin.MOD_CONFIG));
|
||||||
task.into(extension.getDeployDirectory().dir(id).orElse(layout.getBuildDirectory().dir("deploy-not-configured")));
|
task.into(extension.getDeployDirectory().dir(id).orElse(layout.getBuildDirectory().dir("deploy-not-configured")));
|
||||||
task.onlyIf("zomboidForge.deployDirectory is set", element -> extension.getDeployDirectory().isPresent());
|
task.onlyIf("zomboidForge.deployDirectory is set", element -> extension.getDeployDirectory().isPresent());
|
||||||
});
|
});
|
||||||
|
|||||||
+35
-1
@@ -22,6 +22,7 @@ import java.util.jar.JarOutputStream;
|
|||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
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 static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.objectweb.asm.Opcodes.ACC_FINAL;
|
import static org.objectweb.asm.Opcodes.ACC_FINAL;
|
||||||
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
|
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
|
||||||
@@ -140,6 +141,23 @@ class ZomboidForgeModPluginTest
|
|||||||
assertEquals(TaskOutcome.UP_TO_DATE, again.task(":checkMod").getOutcome());
|
assertEquals(TaskOutcome.UP_TO_DATE, again.task(":checkMod").getOutcome());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void deployReplacesTheModButKeepsTheServerSettings() throws IOException
|
||||||
|
{
|
||||||
|
this.modProject(" deployDirectory = layout.projectDirectory.dir(\"server/mods\")", "");
|
||||||
|
|
||||||
|
Path deployed = this.project.resolve("server/mods/shop");
|
||||||
|
this.write("server/mods/shop/config.toml", "limit = 7\n");
|
||||||
|
this.write("server/mods/shop/lib/old.jar", "");
|
||||||
|
|
||||||
|
this.runner("deployMod").build();
|
||||||
|
|
||||||
|
assertTrue(Files.isRegularFile(deployed.resolve("shop.jar")));
|
||||||
|
assertTrue(Files.isRegularFile(deployed.resolve("lib/util.jar")));
|
||||||
|
assertFalse(Files.exists(deployed.resolve("lib/old.jar")), "files the mod no longer has are removed");
|
||||||
|
assertEquals("limit = 7\n", Files.readString(deployed.resolve("config.toml")));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void checksAGameModAgainstTheGameJar() throws IOException
|
void checksAGameModAgainstTheGameJar() throws IOException
|
||||||
{
|
{
|
||||||
@@ -159,7 +177,7 @@ class ZomboidForgeModPluginTest
|
|||||||
String toml = new String(jar.getInputStream(jar.getEntry("META-INF/zomboidforge/mod.toml")).readAllBytes(), StandardCharsets.UTF_8);
|
String toml = new String(jar.getInputStream(jar.getEntry("META-INF/zomboidforge/mod.toml")).readAllBytes(), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
assertTrue(toml.contains("game = [\"42.21\"]"), toml);
|
assertTrue(toml.contains("game = [\"42.21\"]"), toml);
|
||||||
assertTrue(toml.contains("[dependencies]\neconomy = \"2.0\""), toml);
|
assertTrue(toml.contains("[dependencies]\n\"economy\" = \"2.0\""), toml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +207,22 @@ class ZomboidForgeModPluginTest
|
|||||||
assertTrue(result.getOutput().contains("is written by hand; the ZomboidForge plugin generates mod.toml from zomboidForge { }."), result.getOutput());
|
assertTrue(result.getOutput().contains("is written by hand; the ZomboidForge plugin generates mod.toml from zomboidForge { }."), result.getOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void writesAnyTextAsValidToml() throws IOException
|
||||||
|
{
|
||||||
|
this.modProject("""
|
||||||
|
name = "Shop\\tMod \\"one\\""
|
||||||
|
dependsOn("eco.nomy", "2.0")
|
||||||
|
""", "");
|
||||||
|
|
||||||
|
BuildResult result = this.runner("build").buildAndFail();
|
||||||
|
|
||||||
|
assertTrue(result.getOutput().contains("'dependencies' contains 'eco.nomy', which is not a valid mod id."), result.getOutput());
|
||||||
|
|
||||||
|
String toml = Files.readString(this.project.resolve("build/generated/zomboidforge/descriptor/META-INF/zomboidforge/mod.toml"));
|
||||||
|
assertTrue(toml.contains("name = \"Shop\\u0009Mod \\\"one\\\"\""), toml);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void failsWhenTheEntryPointIsMissing() throws IOException
|
void failsWhenTheEntryPointIsMissing() throws IOException
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@ group=dev.overlord.zomboidforge
|
|||||||
|
|
||||||
# Project Zomboid version the build targets. Selects compat/b<major>/, and
|
# Project Zomboid version the build targets. Selects compat/b<major>/, and
|
||||||
# :patcher:patchServerJar fails when the server jar reports another version.
|
# :patcher:patchServerJar fails when the server jar reports another version.
|
||||||
# "42.21" matches every 42.21.x build; "42.21.0" matches exactly.
|
# "42" matches every Build 42 version, "42.21" every 42.21.x build, "42.21.0" exactly.
|
||||||
pz.version=42.21
|
pz.version=42
|
||||||
|
|
||||||
# Vanilla dedicated server jar used for compilation and patching.
|
# Vanilla dedicated server jar used for compilation and patching.
|
||||||
# Default: lib/server/java/projectzomboid.jar (relative to the root project).
|
# Default: lib/server/java/projectzomboid.jar (relative to the root project).
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ asm = "9.10.1"
|
|||||||
junit = "6.1.3"
|
junit = "6.1.3"
|
||||||
jetbrains-annotations = "26.0.2"
|
jetbrains-annotations = "26.0.2"
|
||||||
night-config = "3.9.0"
|
night-config = "3.9.0"
|
||||||
|
shadow = "9.6.1"
|
||||||
sqlite-jdbc = "3.48.0.0" # Same version as the SQLite JDBC driver bundled in Project Zomboid (sqlite-jdbc.properties).
|
sqlite-jdbc = "3.48.0.0" # Same version as the SQLite JDBC driver bundled in Project Zomboid (sqlite-jdbc.properties).
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
@@ -20,3 +21,6 @@ junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher
|
|||||||
|
|
||||||
[bundles]
|
[bundles]
|
||||||
asm = ["asm", "asm-tree", "asm-commons", "asm-util"]
|
asm = ["asm", "asm-tree", "asm-commons", "asm-util"]
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
|
||||||
@@ -0,0 +1,981 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<verification-metadata xmlns="https://schema.gradle.org/dependency-verification" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://schema.gradle.org/dependency-verification https://schema.gradle.org/dependency-verification/dependency-verification-1.4.xsd">
|
||||||
|
<configuration>
|
||||||
|
<verify-metadata>true</verify-metadata>
|
||||||
|
<verify-signatures>false</verify-signatures>
|
||||||
|
<trusted-artifacts>
|
||||||
|
<trust file=".*-javadoc[.]jar" regex="true"/>
|
||||||
|
<trust file=".*-sources[.]jar" regex="true"/>
|
||||||
|
<trust group="gradle" name="gradle" file="gradle-.*-src[.]zip" regex="true"/>
|
||||||
|
</trusted-artifacts>
|
||||||
|
</configuration>
|
||||||
|
<components>
|
||||||
|
<component group="com.electronwill.night-config" name="core" version="3.9.0">
|
||||||
|
<artifact name="core-3.9.0.jar">
|
||||||
|
<sha256 value="cd890520bd3c680cf82e79f16071de9c8f367206a2f841c777d944289f343ebc" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="core-3.9.0.module">
|
||||||
|
<sha256 value="b3110c2f09d492dbb9c28485a678c75c18abc19090e22a70d053661c78caa958" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.electronwill.night-config" name="toml" version="3.9.0">
|
||||||
|
<artifact name="toml-3.9.0.jar">
|
||||||
|
<sha256 value="475e6fa3315619294d5ab74f2eb80f0705129d43e652d3ccd5337c77d0a29a6b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="toml-3.9.0.module">
|
||||||
|
<sha256 value="6b06ac9284f0daa19464263852b04cba4e77e6d1193ccbe0693aee4a89640fe1" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.fasterxml" name="oss-parent" version="55">
|
||||||
|
<artifact name="oss-parent-55.pom">
|
||||||
|
<sha256 value="0f5e18f2b35ebf6d839f7fd549972883f696c210f9ae3230afd2c20ba886c04d" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.fasterxml" name="oss-parent" version="68">
|
||||||
|
<artifact name="oss-parent-68.pom">
|
||||||
|
<sha256 value="25eafd96dae242b6b5a7108f55b2c14015b828daa5abe234289fd6e774a1ce57" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.fasterxml" name="oss-parent" version="69">
|
||||||
|
<artifact name="oss-parent-69.pom">
|
||||||
|
<sha256 value="3856d584aaa1c8e33ce94c67244f71f6f70538a259ffe8e781761b9faaad875f" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.fasterxml.jackson" name="jackson-bom" version="2.19.2">
|
||||||
|
<artifact name="jackson-bom-2.19.2.pom">
|
||||||
|
<sha256 value="22006be70fd018099e99c6c27ac0982320f3a0f3c2ce053c55703579a5eea303" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.fasterxml.jackson" name="jackson-parent" version="2.19.3">
|
||||||
|
<artifact name="jackson-parent-2.19.3.pom">
|
||||||
|
<sha256 value="23d186c8d8cd06015d022c710c715423d660d49e2973b15870b029cc26018682" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.fasterxml.woodstox" name="woodstox-core" version="7.1.1">
|
||||||
|
<artifact name="woodstox-core-7.1.1.jar">
|
||||||
|
<sha256 value="02b9d022e9d47704ff8a7a859a0dbfd3b2882a8311eb7ff1e180f760ccda2712" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="woodstox-core-7.1.1.pom">
|
||||||
|
<sha256 value="afb5cb45d41c1f9e3675909de4fef242bdc1cea4476a0634ae20f4d7a54433ff" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.google.code.gson" name="gson" version="2.11.0">
|
||||||
|
<artifact name="gson-2.11.0.jar">
|
||||||
|
<sha256 value="57928d6e5a6edeb2abd3770a8f95ba44dce45f3b23b7a9dc2b309c581552a78b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="gson-2.11.0.pom">
|
||||||
|
<sha256 value="c0e547bea998888e6e25c5886a90e762272bc88b5275343dd2c05ded6ca2e360" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.google.code.gson" name="gson-parent" version="2.11.0">
|
||||||
|
<artifact name="gson-parent-2.11.0.pom">
|
||||||
|
<sha256 value="8acb1f3b72a6f026916ac0735bad9aab0293d527edb7b365327def13a9367b7a" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.google.errorprone" name="error_prone_annotations" version="2.27.0">
|
||||||
|
<artifact name="error_prone_annotations-2.27.0.jar">
|
||||||
|
<sha256 value="24c923372c58e35d0b9f16a028929bb9aedc77521867c274f2bd0735df5ba1f5" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="error_prone_annotations-2.27.0.pom">
|
||||||
|
<sha256 value="4ca5a35d61235e16549ac346d1e34551cdf0fe27e84aa57e03cbeb255ea4e5da" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.google.errorprone" name="error_prone_parent" version="2.27.0">
|
||||||
|
<artifact name="error_prone_parent-2.27.0.pom">
|
||||||
|
<sha256 value="fa81829d049559df6927f9c9a6fd6bbd09f8b50e6d4736ae72c8300b6c3d7654" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.gradleup.shadow" name="com.gradleup.shadow.gradle.plugin" version="9.6.1">
|
||||||
|
<artifact name="com.gradleup.shadow.gradle.plugin-9.6.1.pom">
|
||||||
|
<sha256 value="3e3e0fa4124c31db0f0a8c7502ca6574abc09dc383a5ac5c582040d53244d112" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="com.gradleup.shadow" name="shadow-gradle-plugin" version="9.6.1">
|
||||||
|
<artifact name="shadow-gradle-plugin-9.6.1.jar">
|
||||||
|
<sha256 value="7053bc4366cf80798f205e37f4f649cde516081e5e653a3c49ea6700b2047b11" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="shadow-gradle-plugin-9.6.1.module">
|
||||||
|
<sha256 value="dabee846ad818d012ceb002d61fac34fb4937f74eeeb4c964519318a2a260d25" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="commons-codec" name="commons-codec" version="1.22.0">
|
||||||
|
<artifact name="commons-codec-1.22.0.jar">
|
||||||
|
<sha256 value="d164fe79f262c32d9b18a0b5b2d317d1c27653d5e98fd2b998c24bf901c72ce4" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="commons-codec-1.22.0.pom">
|
||||||
|
<sha256 value="d9a565d978faa69d2b1195fb1ec27e60f29e7feb09afb85adac78f280068f8fe" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="commons-io" name="commons-io" version="2.22.0">
|
||||||
|
<artifact name="commons-io-2.22.0.jar">
|
||||||
|
<sha256 value="2b9a7b1f726fb86216dbd2c8321eabe0221dbd5b1be81c18e1cb53811b104758" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="commons-io-2.22.0.pom">
|
||||||
|
<sha256 value="6425cec0ea760035efa77277de85f89fa6dbed147ab3dd95b8d2cbc55340accf" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="jakarta.platform" name="jakarta.jakartaee-bom" version="9.1.0">
|
||||||
|
<artifact name="jakarta.jakartaee-bom-9.1.0.pom">
|
||||||
|
<sha256 value="df98e0266219fdbb82562826d79a3a20776a8ba02aa787f0f0765a538654c8a4" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="jakarta.platform" name="jakartaee-api-parent" version="9.1.0">
|
||||||
|
<artifact name="jakartaee-api-parent-9.1.0.pom">
|
||||||
|
<sha256 value="a7702c487026802784b5797b62330a8b8d6592bf0f4737b25c67a5eac82659c0" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache" name="apache" version="35">
|
||||||
|
<artifact name="apache-35.pom">
|
||||||
|
<sha256 value="ea297dcd114136e8b8e8b630230d52a76c2fc69f6c5db25d672b1857000728b8" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache" name="apache" version="37">
|
||||||
|
<artifact name="apache-37.pom">
|
||||||
|
<sha256 value="524ec4787aff73af6b3a9fafa154c7f1881b648299b663fdbfcadda1286f2353" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.ant" name="ant" version="1.10.17">
|
||||||
|
<artifact name="ant-1.10.17.jar">
|
||||||
|
<sha256 value="8be692e02837f41a47a3d21cde6655792142fdf42fe23bcb16d7129cad9b2284" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="ant-1.10.17.pom">
|
||||||
|
<sha256 value="63a6eb88e2e0fcd76967aae7e6f5811b02f3f9c52d96db766b6b4905768fc62b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.ant" name="ant-launcher" version="1.10.17">
|
||||||
|
<artifact name="ant-launcher-1.10.17.jar">
|
||||||
|
<sha256 value="f6e3de06dc0ea396638004f1a003f55fdbd20c3e7ccfb9b7a524f49fd0ae8568" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="ant-launcher-1.10.17.pom">
|
||||||
|
<sha256 value="f400b6a35d13bd9e71eac48359f1d91fbf7d40c86d9c776ec3167f7108795ecd" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.ant" name="ant-parent" version="1.10.17">
|
||||||
|
<artifact name="ant-parent-1.10.17.pom">
|
||||||
|
<sha256 value="9a9ef70732bee11a34a08643aa69463d1c258658401d7279a54f73ad0a15a9e4" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.commons" name="commons-parent" version="98">
|
||||||
|
<artifact name="commons-parent-98.pom">
|
||||||
|
<sha256 value="d40318527f56033e0ff0789971cc38c856aa99a685eea11270814e7f1eda9fba" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy" version="4.0.33">
|
||||||
|
<artifact name="groovy-4.0.33.module">
|
||||||
|
<sha256 value="b51f0a5b8ecfba534d47612a49aa51b279ecdac72e7f790a8ed3130070d80dc5" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-4.0.33.pom">
|
||||||
|
<sha256 value="4a077cc859cb0fabab55f8637e77889fe03b2489692c9d1da253e43715c28cf8" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-ant" version="4.0.33">
|
||||||
|
<artifact name="groovy-ant-4.0.33.module">
|
||||||
|
<sha256 value="c498aa114fb510a7f6841c94f973fb16d4580357c170ab978fd5ae2a8e4fb57a" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-ant-4.0.33.pom">
|
||||||
|
<sha256 value="e64319f32699287e1d39c1f8da358a6a7740c8a8dc5516a7c43d606b0fa16298" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-astbuilder" version="4.0.33">
|
||||||
|
<artifact name="groovy-astbuilder-4.0.33.module">
|
||||||
|
<sha256 value="655c1b59499c7e590dbc3d643a9485f2d512e34145f1735fd477bcb03e3ced73" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-astbuilder-4.0.33.pom">
|
||||||
|
<sha256 value="fe25b6081390bbb9cf32fc9cf5b373fa391cb3854bfdedcde81a238ea88ad68c" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-bom" version="4.0.27">
|
||||||
|
<artifact name="groovy-bom-4.0.27.module">
|
||||||
|
<sha256 value="d6c2254c8347b84cda84caf74914a187c2f377e4284e8d8bb3f901521810aa8b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-bom-4.0.27.pom">
|
||||||
|
<sha256 value="aa44eb52bfdfe61d27b3e450d2b348d88deaa3437ab4d9d49a84095348f9f6fb" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-bom" version="4.0.33">
|
||||||
|
<artifact name="groovy-bom-4.0.33.module">
|
||||||
|
<sha256 value="a87e4410ce69764f53e10ff399ba4ed8875bc59845b766181e9c82e9ddfc5f75" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-bom-4.0.33.pom">
|
||||||
|
<sha256 value="c30cc3b9184251be043e8b98ec9f6f17c39b0925183e91c7856ea82b18d9f5ce" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-datetime" version="4.0.33">
|
||||||
|
<artifact name="groovy-datetime-4.0.33.module">
|
||||||
|
<sha256 value="97199c00ad134459c8c3c5244f16f0d9e3f08d61a8b2a7b1ad66e827f027d10e" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-datetime-4.0.33.pom">
|
||||||
|
<sha256 value="691f2eb07b9a60f69926644902103fb2b4ae6370a4154eb4aac765d073fc9e1d" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-dateutil" version="4.0.33">
|
||||||
|
<artifact name="groovy-dateutil-4.0.33.module">
|
||||||
|
<sha256 value="b7848a9cf1159b796c11097d380a9f1cb3c2c60fdb9feb560dc88c5bb5b441bd" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-dateutil-4.0.33.pom">
|
||||||
|
<sha256 value="c7bab371bf9f8666d6c738bcf268671b45ebc305160d2d170520110527ee106b" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-docgenerator" version="4.0.33">
|
||||||
|
<artifact name="groovy-docgenerator-4.0.33.module">
|
||||||
|
<sha256 value="594227fa51d93092f70be2d17ac90c1358960131a7ccd9e9c589b82bca3b640f" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-docgenerator-4.0.33.pom">
|
||||||
|
<sha256 value="cfd1d47f567d2d8c1047c9fa69e5ac873d25c57088767204c5a7cb888d95104e" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-groovydoc" version="4.0.33">
|
||||||
|
<artifact name="groovy-groovydoc-4.0.33.module">
|
||||||
|
<sha256 value="70cf9d616c4757ebbe206e1db77e4f2225b9e238e9d79634a62ddc2cc45f706c" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-groovydoc-4.0.33.pom">
|
||||||
|
<sha256 value="de5bec405a6a258dc48820cd136bd2d2920142a6bc620921a05271157be62945" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-json" version="4.0.33">
|
||||||
|
<artifact name="groovy-json-4.0.33.module">
|
||||||
|
<sha256 value="591dc453651b086a4301984b64c18679b5f8fb70fc6dd4f2ab25263d4119dfb4" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-json-4.0.33.pom">
|
||||||
|
<sha256 value="d92a8fa210f6fb7777a1f0f123fe96f268a7d25d000666f1884d3520535b2900" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-nio" version="4.0.33">
|
||||||
|
<artifact name="groovy-nio-4.0.33.module">
|
||||||
|
<sha256 value="0a3d28bb3c364d2dd83e78127100facd2de4a7be491f8f64a58f7852be29d716" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-nio-4.0.33.pom">
|
||||||
|
<sha256 value="044bfe5a61dce53a32031c1ee373efac9648c3eb27272a64f2c05e0eed4d1ec5" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-templates" version="4.0.33">
|
||||||
|
<artifact name="groovy-templates-4.0.33.module">
|
||||||
|
<sha256 value="8eae833715e00c5d56aafa0d3bb6dd7efcbb6245cd3e9ea5f6776de4c6e9eef1" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-templates-4.0.33.pom">
|
||||||
|
<sha256 value="5819f6df4c0536bcd76d28aeb044e570e68aff3e2546118c6715a615460e92bf" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.groovy" name="groovy-xml" version="4.0.33">
|
||||||
|
<artifact name="groovy-xml-4.0.33.module">
|
||||||
|
<sha256 value="bd326e05cf9e63da4e509eeb03689889be869605eb4ac5459970adef5ba32202" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="groovy-xml-4.0.33.pom">
|
||||||
|
<sha256 value="01eb2e96423efa4725424036b578ddf95647979438f3a92a017f2ed176ce5abd" origin="Generated by IntelliJ sync"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.logging.log4j" name="log4j" version="2.26.1">
|
||||||
|
<artifact name="log4j-2.26.1.pom">
|
||||||
|
<sha256 value="ea4705725fd94bf5debe2911d4ea7af20898603f68354e64b2461a0f249e445d" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.logging.log4j" name="log4j-api" version="2.26.1">
|
||||||
|
<artifact name="log4j-api-2.26.1.jar">
|
||||||
|
<sha256 value="f1810a4704ccce019d02bba029dc02a4f2ac0c997f647b465e7d409c1927f822" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="log4j-api-2.26.1.module">
|
||||||
|
<sha256 value="5ed93f6fb5334bf7ee52943d1a654bc3a1f3f10765ae2fd4bbd387333be6678a" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.logging.log4j" name="log4j-bom" version="2.26.1">
|
||||||
|
<artifact name="log4j-bom-2.26.1.pom">
|
||||||
|
<sha256 value="4415ad189dd04db54958a43e23b37cc397a1edee9e888214b8bd47fbe819072e" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.logging.log4j" name="log4j-core" version="2.26.1">
|
||||||
|
<artifact name="log4j-core-2.26.1.jar">
|
||||||
|
<sha256 value="2ec8c3bf5a6d7c89be8620116a2fc973f7dda1ad0261ad393c4d4726edfd3dcb" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="log4j-core-2.26.1.module">
|
||||||
|
<sha256 value="03bfd8adbe306ac46001ec9de668f8e5d24f6659f212fc64e62a1b672a5a2f6a" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.maven" name="maven" version="4.0.0-rc-5">
|
||||||
|
<artifact name="maven-4.0.0-rc-5.pom">
|
||||||
|
<sha256 value="8514a1eb3998f1222d24580909c4576d5cf0df53d4069dbbb4ca6d34313802f5" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.maven" name="maven-api" version="4.0.0-rc-5">
|
||||||
|
<artifact name="maven-api-4.0.0-rc-5.pom">
|
||||||
|
<sha256 value="610c044f0159a6e15c579ed0579403270fbf9e00e83edb276926b1cf77f5aca9" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.maven" name="maven-api-annotations" version="4.0.0-rc-5">
|
||||||
|
<artifact name="maven-api-annotations-4.0.0-rc-5.jar">
|
||||||
|
<sha256 value="1f7325c01a0ac5a5206caff09fa388520c6505dab850178f452d2c6aad3d3c83" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="maven-api-annotations-4.0.0-rc-5.pom">
|
||||||
|
<sha256 value="294b175b31db653d186a12c1f9c12abc30ce24d84fd08ed8ee7acd3ffcff7352" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.maven" name="maven-api-xml" version="4.0.0-rc-5">
|
||||||
|
<artifact name="maven-api-xml-4.0.0-rc-5.jar">
|
||||||
|
<sha256 value="358851a87edd0ddd566a437470ea021ba851a0487ec4d14825ff04db03ff5877" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="maven-api-xml-4.0.0-rc-5.pom">
|
||||||
|
<sha256 value="8a9255abee26463f9a730c5aadaef42d5914935980509bd16777f885f2732d1b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.maven" name="maven-impl-modules" version="4.0.0-rc-5">
|
||||||
|
<artifact name="maven-impl-modules-4.0.0-rc-5.pom">
|
||||||
|
<sha256 value="9734a4c3338786c6e6aafe7db4376cad0b9f4edea63d9efcc8e9f26f20625f35" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.maven" name="maven-parent" version="45">
|
||||||
|
<artifact name="maven-parent-45.pom">
|
||||||
|
<sha256 value="94fe869eb9b4ce9fce3995d05ea86b168c85d927f9d17beb814a1960c76d7e6f" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apache.maven" name="maven-xml" version="4.0.0-rc-5">
|
||||||
|
<artifact name="maven-xml-4.0.0-rc-5.jar">
|
||||||
|
<sha256 value="a4b7ad3e3410e0feb6438ebb6231c8e02449cd02fcf6451baed820008a103564" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="maven-xml-4.0.0-rc-5.pom">
|
||||||
|
<sha256 value="a5030a4958eaa43b067ce360c2973190bd78ba49eecce5eaf36f196853efc92f" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.apiguardian" name="apiguardian-api" version="1.1.2">
|
||||||
|
<artifact name="apiguardian-api-1.1.2.jar">
|
||||||
|
<sha256 value="b509448ac506d607319f182537f0b35d71007582ec741832a1f111e5b5b70b38" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="apiguardian-api-1.1.2.module">
|
||||||
|
<sha256 value="e08028131375b357d1d28734e9a4fb4216da84b240641cb3ef7e7c7d628223fc" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.codehaus.plexus" name="plexus" version="25">
|
||||||
|
<artifact name="plexus-25.pom">
|
||||||
|
<sha256 value="faa7947c2020967ad0c92b259ee9fa361d05e90cd036d17c37098bb1edaea3a3" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.codehaus.plexus" name="plexus-utils" version="4.0.3">
|
||||||
|
<artifact name="plexus-utils-4.0.3.jar">
|
||||||
|
<sha256 value="421ff6ed146c53a9d4eaade8f629b52b12af7187101f1bd06c2c64e904019f3c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="plexus-utils-4.0.3.pom">
|
||||||
|
<sha256 value="35736658f3fe1efa395086c91df2592664fafa24c3f2608fdaba1136d17fd360" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.codehaus.plexus" name="plexus-xml" version="4.1.1">
|
||||||
|
<artifact name="plexus-xml-4.1.1.jar">
|
||||||
|
<sha256 value="e09b1fcc46da744a0e4dabe703f287ce133b631ea95c6e1a8a82ebad2b1a2815" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="plexus-xml-4.1.1.pom">
|
||||||
|
<sha256 value="cf88711cc5bf9089334710e727616095407cf04b968375677e0ddaa98aa57e0d" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.codehaus.woodstox" name="stax2-api" version="4.2.2">
|
||||||
|
<artifact name="stax2-api-4.2.2.jar">
|
||||||
|
<sha256 value="a61c48d553efad78bc01fffc4ac528bebbae64cbaec170b2a5e39cf61eb51abe" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="stax2-api-4.2.2.pom">
|
||||||
|
<sha256 value="4e902ec556fc6598b41c2952ec1573edc815037e7330ec4922eab619422686e2" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.eclipse.ee4j" name="project" version="1.0.7">
|
||||||
|
<artifact name="project-1.0.7.pom">
|
||||||
|
<sha256 value="205c039a42cbae3556efbeb04a483eb3a3cf9550bd75bf84260dc8f28218f105" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.gradle.kotlin" name="gradle-kotlin-dsl-plugins" version="6.7.6">
|
||||||
|
<artifact name="gradle-kotlin-dsl-plugins-6.7.6.jar">
|
||||||
|
<sha256 value="25f9dfe83fee8d12408aca94c8b596d2ebdb7331730fad815d5470ccb92aaeb0" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="gradle-kotlin-dsl-plugins-6.7.6.module">
|
||||||
|
<sha256 value="9e6127e1412675f5294b5324ccfde26f12a95c024e230353da2f9fe6318f43f1" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.gradle.kotlin.kotlin-dsl" name="org.gradle.kotlin.kotlin-dsl.gradle.plugin" version="6.7.6">
|
||||||
|
<artifact name="org.gradle.kotlin.kotlin-dsl.gradle.plugin-6.7.6.pom">
|
||||||
|
<sha256 value="a74aa6bd177ed61defa0d57524f0d9429f9553d845a4dc2d7363442090e7e2b2" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jdom" name="jdom2" version="2.0.6.1">
|
||||||
|
<artifact name="jdom2-2.0.6.1.jar">
|
||||||
|
<sha256 value="0b20f45e3a0fd8f0d12cdc5316b06776e902b1365db00118876f9175c60f302c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="jdom2-2.0.6.1.pom">
|
||||||
|
<sha256 value="55795e1018b8ae647b937967cf810a99b08582c2374e7873c128734c8c914bf3" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains" name="annotations" version="13.0">
|
||||||
|
<artifact name="annotations-13.0.jar">
|
||||||
|
<sha256 value="ace2a10dc8e2d5fd34925ecac03e4988b2c0f851650c94b8cef49ba1bd111478" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="annotations-13.0.pom">
|
||||||
|
<sha256 value="965aeb2bedff369819bdde1bf7a0b3b89b8247dd69c88b86375d76163bb8c397" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains" name="annotations" version="26.0.2">
|
||||||
|
<artifact name="annotations-26.0.2.jar">
|
||||||
|
<sha256 value="2037be378980d3ba9333e97955f3b2cde392aa124d04ca73ce2eee6657199297" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="annotations-26.0.2.module">
|
||||||
|
<sha256 value="bef0b8352b2dfd4cb7155ecc2a39227bf16a3e08667babec650c76b1abbfcecb" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="fus-statistics-gradle-plugin" version="2.4.10">
|
||||||
|
<artifact name="fus-statistics-gradle-plugin-2.4.10-gradle813.jar">
|
||||||
|
<sha256 value="d312eb7d69a8d5ac5377c712546665c9b94a63ca8fc9cdd315431f10672e8091" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="fus-statistics-gradle-plugin-2.4.10.module">
|
||||||
|
<sha256 value="8ed5af5c6da4a233cad89f0bedacfccfd3ef0e19396a020bb974e2fedbe23e97" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-assignment" version="2.4.10">
|
||||||
|
<artifact name="kotlin-assignment-2.4.10-gradle813.jar">
|
||||||
|
<sha256 value="350dc125b48e62b2d458ecde12153274c1d5b644bee34a8c4565776ed43ba851" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-assignment-2.4.10.module">
|
||||||
|
<sha256 value="bb0abf587a21039337fd81a8347564f6c5b7b1d44c7b46f15dfa41a349ee36a9" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-assignment-compiler-plugin-embeddable" version="2.4.10">
|
||||||
|
<artifact name="kotlin-assignment-compiler-plugin-embeddable-2.4.10.jar">
|
||||||
|
<sha256 value="f915c845195fc5dedfe893057cfa6cb806a5819f46cfca408abef483817f3afd" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-assignment-compiler-plugin-embeddable-2.4.10.pom">
|
||||||
|
<sha256 value="ca65889d2a6b5f336035c3458f57cbdb73d300958f26a6bf50bff310b5918bef" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-build-statistics" version="2.4.10">
|
||||||
|
<artifact name="kotlin-build-statistics-2.4.10.jar">
|
||||||
|
<sha256 value="ba2748b67fb7b24ee1401eecfee32eb67dd055c85a59a5742188f795477a11cc" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-build-statistics-2.4.10.pom">
|
||||||
|
<sha256 value="01cc32ad3b11274444939d06424cbf43a3e207e877683d1c851196ca19088ac1" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-build-tools-api" version="2.4.0">
|
||||||
|
<artifact name="kotlin-build-tools-api-2.4.0.jar">
|
||||||
|
<sha256 value="66917335497f9ab75a36c34b3d90bad2bc8dc256c34b2413ecd0c9467fcf597d" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-build-tools-api-2.4.0.pom">
|
||||||
|
<sha256 value="9686fa8f16867b2aba2e5c0e4cfc4a0aeecf59fe6de419f89f7bd838fdde8e74" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-build-tools-api" version="2.4.10">
|
||||||
|
<artifact name="kotlin-build-tools-api-2.4.10.jar">
|
||||||
|
<sha256 value="3953d283e7710c990672e403a87df393d9726a9bf3e172194ebb5c33e062fcb0" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-build-tools-api-2.4.10.pom">
|
||||||
|
<sha256 value="78242a9440f92400eaf3df8d2108ad706f669a53125845a7d31d3df7c4de4439" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-build-tools-compat" version="2.4.10">
|
||||||
|
<artifact name="kotlin-build-tools-compat-2.4.10.jar">
|
||||||
|
<sha256 value="cdcc50d8016f4250e7dc61822f28f227ba9a9b7d3f9eb5503c315eb12188d952" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-build-tools-compat-2.4.10.pom">
|
||||||
|
<sha256 value="a081a796f828ae644b59950f072cd00bd64ac74f12b12e830399da8de2e4fa34" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-build-tools-cri-impl" version="2.4.0">
|
||||||
|
<artifact name="kotlin-build-tools-cri-impl-2.4.0.jar">
|
||||||
|
<sha256 value="5168b866945f6ac1ffcb6d4c88cf582497249469c2e4a4eafc0bcd35b5a264a9" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-build-tools-cri-impl-2.4.0.pom">
|
||||||
|
<sha256 value="856d59395489276e93edb4390c99397de83e20d27572c5238c56ed21e43433da" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-build-tools-cri-impl" version="2.4.10">
|
||||||
|
<artifact name="kotlin-build-tools-cri-impl-2.4.10.jar">
|
||||||
|
<sha256 value="781c95a28f053ded2d183b818bdae98db3d6d15ebc0555cecf64800fea003b3b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-build-tools-cri-impl-2.4.10.pom">
|
||||||
|
<sha256 value="ada6ecb7cb544ef2fcee73e252c31f80c8e342c3bdb51bb9999fe57fec041fd2" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-build-tools-impl" version="2.4.0">
|
||||||
|
<artifact name="kotlin-build-tools-impl-2.4.0.jar">
|
||||||
|
<sha256 value="076c0a7f84d303f1e390774410c8678b8b584faa3f642435f93d2e4e81dabe7c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-build-tools-impl-2.4.0.pom">
|
||||||
|
<sha256 value="485ca3d511aa384207db5706e0741dc79ace45d40e0489f9ef29731aafb14f7c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-build-tools-impl" version="2.4.10">
|
||||||
|
<artifact name="kotlin-build-tools-impl-2.4.10.jar">
|
||||||
|
<sha256 value="4a32f63522ef4726afbdee1783f05698499abc7a5ecade3a6cafa3e4074562ee" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-build-tools-impl-2.4.10.pom">
|
||||||
|
<sha256 value="f1b431c37717f0d472cd053dc81d893204cb59280f8035d636f534bc7c5d8db4" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-compiler-embeddable" version="2.4.0">
|
||||||
|
<artifact name="kotlin-compiler-embeddable-2.4.0.jar">
|
||||||
|
<sha256 value="c2b25e8c1c93ec416ba4327f5e31eaec0f0c8847241b9353e294b8db9dce564f" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-compiler-embeddable-2.4.0.pom">
|
||||||
|
<sha256 value="f5d78540108e7bbc9162253ce52c42507ead2e530945213dd2a3b793b590c53c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-compiler-embeddable" version="2.4.10">
|
||||||
|
<artifact name="kotlin-compiler-embeddable-2.4.10.jar">
|
||||||
|
<sha256 value="9309638a2ee03e6bde9ef4b7444055a94b84ab906563675d71ff9aecb64da913" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-compiler-embeddable-2.4.10.pom">
|
||||||
|
<sha256 value="c3adb4f66fbfaa843c019b402d2c7e5f0880d32956bd8dd84022946177251102" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-compiler-runner" version="2.4.0">
|
||||||
|
<artifact name="kotlin-compiler-runner-2.4.0.jar">
|
||||||
|
<sha256 value="ad9608152740e92d94a278b4ff2ca82c4bf5ff8ef219220e3c07aeb554638cee" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-compiler-runner-2.4.0.pom">
|
||||||
|
<sha256 value="5e1ed156cb8d38b61e2ccc546dbd8b2bde778367eb298f8875bd820fbfd0b0f2" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-compiler-runner" version="2.4.10">
|
||||||
|
<artifact name="kotlin-compiler-runner-2.4.10.jar">
|
||||||
|
<sha256 value="9e869d66504572852f421bcb1625c0d564c2b3c8cecbf6cd5fef7e7f33e0013e" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-compiler-runner-2.4.10.pom">
|
||||||
|
<sha256 value="180738762c8941c4e30d7174a92071955bd869587332d785e61391167c82bc5a" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-daemon-client" version="2.4.0">
|
||||||
|
<artifact name="kotlin-daemon-client-2.4.0.jar">
|
||||||
|
<sha256 value="f546f0b3699c4984f320dd03080de05cad61064208ba8f37df0d3f8f4a7fd14a" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-daemon-client-2.4.0.pom">
|
||||||
|
<sha256 value="143793627382d905eda93e152a28c993f6323fc4b748370a45c7badc99914a13" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-daemon-client" version="2.4.10">
|
||||||
|
<artifact name="kotlin-daemon-client-2.4.10.jar">
|
||||||
|
<sha256 value="a3d1a5854fd92766de1ca37ff003a822d3da2039902008384dd1f7375f3d5cf9" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-daemon-client-2.4.10.pom">
|
||||||
|
<sha256 value="f6de9e3a0e89add8e043fa76866d9a2ff10fb87963b1396377bbb00c229fde6e" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-daemon-embeddable" version="2.4.0">
|
||||||
|
<artifact name="kotlin-daemon-embeddable-2.4.0.jar">
|
||||||
|
<sha256 value="383093af5e078435b60043d19bfa83eb6191be0f4d13a28fb1c8a0f3ab24fe66" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-daemon-embeddable-2.4.0.pom">
|
||||||
|
<sha256 value="cb36e780fcb39ee09aab6e398f9bd5ea27f982bb6e19329742a20eb2ebdc2936" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-daemon-embeddable" version="2.4.10">
|
||||||
|
<artifact name="kotlin-daemon-embeddable-2.4.10.jar">
|
||||||
|
<sha256 value="547d969a2eab602fe0bdfd9fcb1b563a5c6d30099d3351394d6427eba8288467" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-daemon-embeddable-2.4.10.pom">
|
||||||
|
<sha256 value="44ed1a490a4b646313fc0bc2683897a1eac4d8c6b57c0825d3e81fa7ca376d35" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-gradle-plugin" version="2.4.10">
|
||||||
|
<artifact name="kotlin-gradle-plugin-2.4.10-gradle813.jar">
|
||||||
|
<sha256 value="13e22c869df3972db9496b47bf2815fbcfb61e0439f96cbd8d6aeb912b481375" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-gradle-plugin-2.4.10.module">
|
||||||
|
<sha256 value="0e7713d84605da0bee038b578f31795882ccd721220a79cc36736ac9af9cb412" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-gradle-plugin-annotations" version="2.4.10">
|
||||||
|
<artifact name="kotlin-gradle-plugin-annotations-2.4.10.jar">
|
||||||
|
<sha256 value="15c3b98f18c874b9ac5be2565f3724b3eaf6c6cf57dc784d73516a22a9e470cf" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-gradle-plugin-annotations-2.4.10.pom">
|
||||||
|
<sha256 value="44fc5a0a711c92df16f00d3575d0f2c4a264f43ab2f588e455b3c6043124fd53" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-gradle-plugin-api" version="2.4.10">
|
||||||
|
<artifact name="kotlin-gradle-plugin-api-2.4.10-gradle813.jar">
|
||||||
|
<sha256 value="74c4e4f7d037e850bab666db12c90a49e065d9495fd2dfdaa7bc39dd963083d6" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-gradle-plugin-api-2.4.10.module">
|
||||||
|
<sha256 value="ade28e1831b222e161e00c120d5c9d56f9d4fe3b0aabed9e54912d71ab6ee8cb" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-gradle-plugin-idea" version="2.4.10">
|
||||||
|
<artifact name="kotlin-gradle-plugin-idea-2.4.10.jar">
|
||||||
|
<sha256 value="086734484c7edf19a620ab1a617d097c40e03bc52602e77840ea5ebd6380e514" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-gradle-plugin-idea-2.4.10.module">
|
||||||
|
<sha256 value="7e883fbfe9d2c9ced4a8fa99217a8dd413bb14a7ea932edbbda35d5e91a5119a" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-gradle-plugin-idea-proto" version="2.4.10">
|
||||||
|
<artifact name="kotlin-gradle-plugin-idea-proto-2.4.10.jar">
|
||||||
|
<sha256 value="355ac566ff74d74d230f7cb6d55e2ed50158b4c28fc186fc8d8268e8fe9868f4" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-gradle-plugin-idea-proto-2.4.10.pom">
|
||||||
|
<sha256 value="074ee0dd408de542a8e4b726daad829dc33a9e56ddb4f43a00eb9b9f67aff17f" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-gradle-plugins-bom" version="2.4.10">
|
||||||
|
<artifact name="kotlin-gradle-plugins-bom-2.4.10.module">
|
||||||
|
<sha256 value="48eb4756284d1d7ea24639d22861f15ff0cb685a15331a6c6a3674ff44baf029" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-gradle-plugins-bom-2.4.10.pom">
|
||||||
|
<sha256 value="733fccda03ae34773e7b5c85d0e278c897df283370059cb39825f7c0381e49b6" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-klib-commonizer-api" version="2.4.10">
|
||||||
|
<artifact name="kotlin-klib-commonizer-api-2.4.10.jar">
|
||||||
|
<sha256 value="971bb968b4af10932bcc18f3395721ee48cc166597b50926731aeeff334086da" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-klib-commonizer-api-2.4.10.pom">
|
||||||
|
<sha256 value="139b3ce8d655807eb68a45798f04329760b2106669ab332d2ac108843d758b29" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-klib-commonizer-embeddable" version="2.4.10">
|
||||||
|
<artifact name="kotlin-klib-commonizer-embeddable-2.4.10.jar">
|
||||||
|
<sha256 value="c5e543412f81a32ff4611a886e18399fa5afa15c77e3ef2fdc0faa397ad8abce" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-klib-commonizer-embeddable-2.4.10.pom">
|
||||||
|
<sha256 value="bebdd5b6115a8d377edd8d00e8c1d4cfcacbf2bc0bdbb7248d43c5c7a19bafab" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-metadata-jvm" version="2.4.10">
|
||||||
|
<artifact name="kotlin-metadata-jvm-2.4.10.jar">
|
||||||
|
<sha256 value="233aaa84ca268e26d6d3a99ce30401e6dc111a7ae10e0a0b4794ce6351d7adc4" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-metadata-jvm-2.4.10.pom">
|
||||||
|
<sha256 value="694915b86862dbd6060c69239690594f1f52df2543bb110a011666242a41060b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-native-utils" version="2.4.10">
|
||||||
|
<artifact name="kotlin-native-utils-2.4.10.jar">
|
||||||
|
<sha256 value="76ec55f967dc8f57481a27b3e7868cc97cb32964d6d285517aef310c3d754a44" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-native-utils-2.4.10.pom">
|
||||||
|
<sha256 value="9b91e38cfc84eaa34183140192c307ddc68f4a4c6035f554c4c22e15f33916c7" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-reflect" version="1.6.10">
|
||||||
|
<artifact name="kotlin-reflect-1.6.10.jar">
|
||||||
|
<sha256 value="3277ac102ae17aad10a55abec75ff5696c8d109790396434b496e75087854203" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-reflect-1.6.10.pom">
|
||||||
|
<sha256 value="57905524274a00ae028aaccc27283f6bc5925a934a046c1cc5d06c8ee4d6d5a9" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-reflect" version="2.4.10">
|
||||||
|
<artifact name="kotlin-reflect-2.4.10.jar">
|
||||||
|
<sha256 value="25a1aef7454d46548ecaaf51021b0e52e38141a62ed75af124da109b7324c4e5" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-reflect-2.4.10.pom">
|
||||||
|
<sha256 value="4258f0212f4bd72e3047f7daace38e0de2ebff3f7e923e836431fd8f5b19189d" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-sam-with-receiver" version="2.4.10">
|
||||||
|
<artifact name="kotlin-sam-with-receiver-2.4.10-gradle813.jar">
|
||||||
|
<sha256 value="a84421755b6d88994ea547921a0a548f62a5fa35062e1a4c8e71644ca08f36b8" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-sam-with-receiver-2.4.10.module">
|
||||||
|
<sha256 value="1b23bbbdf7eb4c34e63482e04f54efc4b437add063ced3507da889b0af9c069f" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-sam-with-receiver-compiler-plugin-embeddable" version="2.4.10">
|
||||||
|
<artifact name="kotlin-sam-with-receiver-compiler-plugin-embeddable-2.4.10.jar">
|
||||||
|
<sha256 value="8f30cb3c9ca1127c0c196abf3eb9eee96415442d471c341327d5fc05ca2ad4c9" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-sam-with-receiver-compiler-plugin-embeddable-2.4.10.pom">
|
||||||
|
<sha256 value="26785f2a3a79b173f50e8bac682001430cb6291074d49fc0af11adb18cbc70ed" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-script-runtime" version="2.4.0">
|
||||||
|
<artifact name="kotlin-script-runtime-2.4.0.jar">
|
||||||
|
<sha256 value="196e8ecbf63daf477e34e67c2f871ee232ae7bf8b377432d876d1bbf9d273de3" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-script-runtime-2.4.0.pom">
|
||||||
|
<sha256 value="ce705c50e7e0afb22298acff0a983cdb6ea0f7fe2d1b473cee42b38405bc357f" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-script-runtime" version="2.4.10">
|
||||||
|
<artifact name="kotlin-script-runtime-2.4.10.jar">
|
||||||
|
<sha256 value="f4a5b30c2fdfbe386b097101b7989dbeea3743c06396136664784e08e15c6899" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-script-runtime-2.4.10.pom">
|
||||||
|
<sha256 value="edcf0e2cd709646c4e5945be0f0a4920a0f3f417f328756746a29d92b23b1593" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-scripting-common" version="2.4.10">
|
||||||
|
<artifact name="kotlin-scripting-common-2.4.10.jar">
|
||||||
|
<sha256 value="d5399982cdbf5994f7f3a731afacfbc5c21b797d97ffd7328b62cea670103076" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-scripting-common-2.4.10.pom">
|
||||||
|
<sha256 value="185636a91c18f09f8af87f87ea1788c2d55f72a6880210a0365a5a6a44d61833" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-scripting-compiler-embeddable" version="2.4.10">
|
||||||
|
<artifact name="kotlin-scripting-compiler-embeddable-2.4.10.jar">
|
||||||
|
<sha256 value="156c68ff816251c9d297c90d77e7e8e513eaad594277cee50a36faeddbe88935" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-scripting-compiler-embeddable-2.4.10.pom">
|
||||||
|
<sha256 value="07d9913a83317c28ca7704be0c109a1429a276236e43be8b98f87dbd4d02afad" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-scripting-compiler-impl-embeddable" version="2.4.10">
|
||||||
|
<artifact name="kotlin-scripting-compiler-impl-embeddable-2.4.10.jar">
|
||||||
|
<sha256 value="1dcfc5495d8c74966fcbbd39240a9c0f8ab36bb4faad2ea5ffc000c5d7785171" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-scripting-compiler-impl-embeddable-2.4.10.pom">
|
||||||
|
<sha256 value="a80b463dc4e3de57555c4e1b6e73658d40ac215b2788f4c193f56c91b3494ca9" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-scripting-jvm" version="2.4.10">
|
||||||
|
<artifact name="kotlin-scripting-jvm-2.4.10.jar">
|
||||||
|
<sha256 value="0b7518219da69b427e0b3f840f13e280db9e61a839c7d3ff094de4630ddbc9f5" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-scripting-jvm-2.4.10.pom">
|
||||||
|
<sha256 value="403a12911dc71b4fa4c2e3dc305cd98e0ef3fea1fabce72d0a656dcf890b3775" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-stdlib" version="2.4.0">
|
||||||
|
<artifact name="kotlin-stdlib-2.4.0.jar">
|
||||||
|
<sha256 value="ccb14ff83fabcb11458b798dbc9824748ccdffeec79c9aba789e6ed1cda86b1c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-stdlib-2.4.0.module">
|
||||||
|
<sha256 value="c24a47dcbd9295d776f443be41d77ac245309601ed053711dee2b0254be02db6" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-stdlib" version="2.4.10">
|
||||||
|
<artifact name="kotlin-stdlib-2.4.10.jar">
|
||||||
|
<sha256 value="4ec0293bc3751423b203f1d8493251c57c42e73eb6377a6b8560d0974ff0a6df" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-stdlib-2.4.10.module">
|
||||||
|
<sha256 value="1c04a98f1200c8705d015df08977211589eecbc87cf1c4c6d28a92682fe8446e" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-tooling-core" version="2.4.10">
|
||||||
|
<artifact name="kotlin-tooling-core-2.4.10.jar">
|
||||||
|
<sha256 value="59ea305372e3a2b7417764dcfecf645066a0d9b1792ab40afd15c1cc8535b58a" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-tooling-core-2.4.10.pom">
|
||||||
|
<sha256 value="590248328a863d8f000ef063ac0ee8b4483f52d3e22fa51ca243ce7f6a78c75c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-util-io" version="2.4.10">
|
||||||
|
<artifact name="kotlin-util-io-2.4.10.jar">
|
||||||
|
<sha256 value="06a9a0f89884c1c1a86baa96260238d927fb027077ba67bb5d2958af6fd776d7" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-util-io-2.4.10.pom">
|
||||||
|
<sha256 value="3c9ca43ebff84366e7ff28742b7475553619c5f0f8acc2d7a979a6f4b437c81a" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-util-klib" version="2.4.10">
|
||||||
|
<artifact name="kotlin-util-klib-2.4.10.jar">
|
||||||
|
<sha256 value="408d3bd16e0f513ac2f4f04a78871701924836081c2cc774aa2b3f739278e430" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-util-klib-2.4.10.pom">
|
||||||
|
<sha256 value="631dbfefce3aefea1de3573d8dc1e54919be9af88c142505d3352127d84abb84" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlin" name="kotlin-util-klib-metadata" version="2.4.10">
|
||||||
|
<artifact name="kotlin-util-klib-metadata-2.4.10.jar">
|
||||||
|
<sha256 value="f9b0cc33542c53d83004ab4aeff6f6515d509d26e14e78f420eeae2a459f4927" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlin-util-klib-metadata-2.4.10.pom">
|
||||||
|
<sha256 value="606f70d8788a23f9b017039107d005248d0887481f0815e6284ba9a6933a7b7b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlinx" name="kotlinx-coroutines-bom" version="1.8.0">
|
||||||
|
<artifact name="kotlinx-coroutines-bom-1.8.0.pom">
|
||||||
|
<sha256 value="1239e9dbe1397cd5971342956b2511bc3ace7b641842e4372a088dcfa8b9ad55" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jetbrains.kotlinx" name="kotlinx-coroutines-core-jvm" version="1.8.0">
|
||||||
|
<artifact name="kotlinx-coroutines-core-jvm-1.8.0.jar">
|
||||||
|
<sha256 value="9860906a1937490bf5f3b06d2f0e10ef451e65b95b269f22daf68a3d1f5065c5" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="kotlinx-coroutines-core-jvm-1.8.0.module">
|
||||||
|
<sha256 value="ff6a22da40040938751db0ae21177e76517dbf126a76796f5426727bf76c1228" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.jspecify" name="jspecify" version="1.0.0">
|
||||||
|
<artifact name="jspecify-1.0.0.jar">
|
||||||
|
<sha256 value="1fad6e6be7557781e4d33729d49ae1cdc8fdda6fe477bb0cc68ce351eafdfbab" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="jspecify-1.0.0.module">
|
||||||
|
<sha256 value="d307ca77a54e18ac1ef1aaed4e5bbe014bd2f49f29e1d2f813e47c278283195b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit" name="junit-bom" version="5.13.1">
|
||||||
|
<artifact name="junit-bom-5.13.1.module">
|
||||||
|
<sha256 value="33c07ab9724790a6e5859ba07d69117ac530439724545a81c4179e3272c75de8" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-bom-5.13.1.pom">
|
||||||
|
<sha256 value="fa68451ea830572ed43ffe51d75b6a05f7a5e665a602a51f49d6be02063a65f3" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit" name="junit-bom" version="5.13.4">
|
||||||
|
<artifact name="junit-bom-5.13.4.module">
|
||||||
|
<sha256 value="e959288fde1b1b050d9bc082fc786789128da5d2853091468fca504104bdf400" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-bom-5.13.4.pom">
|
||||||
|
<sha256 value="d7a08a99b2502f0bb68cd4e1f984f0bf69324aaa208bd0f73366c03fc3548a42" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit" name="junit-bom" version="5.14.1">
|
||||||
|
<artifact name="junit-bom-5.14.1.module">
|
||||||
|
<sha256 value="278acb11ccc9998694224386f96fb4941a22edb42cb446c92e0f1f33014b6b48" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-bom-5.14.1.pom">
|
||||||
|
<sha256 value="01b01dfa366550b40ac5760548a7d728b6109d17c451e83864d1e5e0ce862c94" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit" name="junit-bom" version="5.14.2">
|
||||||
|
<artifact name="junit-bom-5.14.2.module">
|
||||||
|
<sha256 value="5d26f4440392326dd2483cf490143eea1495d5095459a0b9651a7b1b38e24ebf" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-bom-5.14.2.pom">
|
||||||
|
<sha256 value="ed2dcc7855bd460bccc93a1bf0c962e63b566ff7d8f1ded0f1f2593ba8183aaf" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit" name="junit-bom" version="6.1.3">
|
||||||
|
<artifact name="junit-bom-6.1.3.module">
|
||||||
|
<sha256 value="9f5d57dadcfa07f7b38efcfb22b052ece188922a1df76b5a98e44a1df7a7701b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-bom-6.1.3.pom">
|
||||||
|
<sha256 value="a9000043610a3e90c852e779a6b1a8eb724a9f312cf5f7ddd57862b010c65dc8" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit.jupiter" name="junit-jupiter" version="6.1.3">
|
||||||
|
<artifact name="junit-jupiter-6.1.3.jar">
|
||||||
|
<sha256 value="6b0a14075c74221de53047e363860b7d19fce802bebc152df2c35c4089c6c379" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-jupiter-6.1.3.module">
|
||||||
|
<sha256 value="ca7b7dd4508d57a9dc105102aa93fb5bc960b2095601534b9311f951ffb39979" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit.jupiter" name="junit-jupiter-api" version="6.1.3">
|
||||||
|
<artifact name="junit-jupiter-api-6.1.3.jar">
|
||||||
|
<sha256 value="555d6cf20fa1710884dd01b86cc5785397ba73e21ada2d4b784f5f1a14dcafc4" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-jupiter-api-6.1.3.module">
|
||||||
|
<sha256 value="ad9909c1fa88a579b2821a091a196c45a84bcd0f4fc7357990fdc73d3801c8a5" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit.jupiter" name="junit-jupiter-engine" version="6.1.3">
|
||||||
|
<artifact name="junit-jupiter-engine-6.1.3.jar">
|
||||||
|
<sha256 value="414559e78bbfa3bdb2eab009ac3ab1e22369ac31117c270a0bd666da115c5c6c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-jupiter-engine-6.1.3.module">
|
||||||
|
<sha256 value="626a29f286c36d0f6f36409644371e12a3fe2bfcbb881e13f8265ac9de96bb77" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit.jupiter" name="junit-jupiter-params" version="6.1.3">
|
||||||
|
<artifact name="junit-jupiter-params-6.1.3.jar">
|
||||||
|
<sha256 value="05c51cedba2c06a9770707391e006cee825876937dea580b94a265ce145d4939" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-jupiter-params-6.1.3.module">
|
||||||
|
<sha256 value="9ec7795f4aeb92578fb4d43b6a73c324fff216ca971f3910335073882c78a167" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit.platform" name="junit-platform-commons" version="6.1.3">
|
||||||
|
<artifact name="junit-platform-commons-6.1.3.jar">
|
||||||
|
<sha256 value="a4774ae923c109544034aeae7c762cf017fbcdd1342403ba90e0921984b608c3" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-platform-commons-6.1.3.module">
|
||||||
|
<sha256 value="a6f1218616341b599f6aa029a3768c6f956ab1d3216ed7250e4be5d79adfce7d" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit.platform" name="junit-platform-engine" version="6.1.3">
|
||||||
|
<artifact name="junit-platform-engine-6.1.3.jar">
|
||||||
|
<sha256 value="21ad7ad3a35beda16387979317be1833a72a71d812f9a66ee4b9a7bafb56334c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-platform-engine-6.1.3.module">
|
||||||
|
<sha256 value="70f5020adb4c91575025499a804b266e8fc2d027aa6e78febfa372be3a88cef5" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.junit.platform" name="junit-platform-launcher" version="6.1.3">
|
||||||
|
<artifact name="junit-platform-launcher-6.1.3.jar">
|
||||||
|
<sha256 value="1dec64b1fc0b7c47a11302aa5b4d37d8160c041b396e27067709ce775601a7b6" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="junit-platform-launcher-6.1.3.module">
|
||||||
|
<sha256 value="62d2198a3a779c54316bbe839e51623b3a6bd111e672d586dd9a3bbb222569e6" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.mockito" name="mockito-bom" version="4.11.0">
|
||||||
|
<artifact name="mockito-bom-4.11.0.pom">
|
||||||
|
<sha256 value="d8531a746c988f7f68ed5f188cdea945006aea993ec5df9e524e0d27d61491da" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.mockito" name="mockito-bom" version="5.20.0">
|
||||||
|
<artifact name="mockito-bom-5.20.0.pom">
|
||||||
|
<sha256 value="626bc0f79f389d2c41543d16d8d9db0b53ad0848cc37a6e0b4ce771a4fe0bc49" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.opentest4j" name="opentest4j" version="1.3.0">
|
||||||
|
<artifact name="opentest4j-1.3.0.jar">
|
||||||
|
<sha256 value="48e2df636cab6563ced64dcdff8abb2355627cb236ef0bf37598682ddf742f1b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="opentest4j-1.3.0.module">
|
||||||
|
<sha256 value="48bf1d6c8b5dc94f74652bd17900f654deb714350248cf5e8fca27b9090c8e0d" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.ow2" name="ow2" version="1.5.1">
|
||||||
|
<artifact name="ow2-1.5.1.pom">
|
||||||
|
<sha256 value="321ddbb7ee6fe4f53dea6b4cd6db74154d6bfa42391c1f763b361b9f485acf05" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.ow2.asm" name="asm" version="9.10.1">
|
||||||
|
<artifact name="asm-9.10.1.jar">
|
||||||
|
<sha256 value="ed825d10ab1399c8c0cb669e688cf0c8c82629b4c8399b58352b68e92ca10fcb" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="asm-9.10.1.pom">
|
||||||
|
<sha256 value="e1b1c3832ca3ac0a9e563c405f4c760118b5556a4920daee14058886197e094d" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.ow2.asm" name="asm-analysis" version="9.10.1">
|
||||||
|
<artifact name="asm-analysis-9.10.1.jar">
|
||||||
|
<sha256 value="dede75a21306b65974ecd8f87114ff6970f09fb794157a4ca09ab25c888c2bfc" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="asm-analysis-9.10.1.pom">
|
||||||
|
<sha256 value="534fbb85f643c2330691e92652ec40dd497b4f279ef13d829d85858905d33ba3" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.ow2.asm" name="asm-commons" version="9.10.1">
|
||||||
|
<artifact name="asm-commons-9.10.1.jar">
|
||||||
|
<sha256 value="6d0abefb7cbf972ea16edb37ec14835372505063a45f976ab7ea889ed9497895" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="asm-commons-9.10.1.pom">
|
||||||
|
<sha256 value="ceb2c43f3a273db88af8652d89ed6312f3e91a1a1e0ffc6f7823169278cf795c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.ow2.asm" name="asm-tree" version="9.10.1">
|
||||||
|
<artifact name="asm-tree-9.10.1.jar">
|
||||||
|
<sha256 value="3dfb0d5b6a106cd40b5b250e39935fbf2f927f4477546a5369a3ac609cf0506b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="asm-tree-9.10.1.pom">
|
||||||
|
<sha256 value="963eebdea6e2e1ff25c9068b64a238e1585c99f8acd455595ac159a7f52b6c41" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.ow2.asm" name="asm-util" version="9.10.1">
|
||||||
|
<artifact name="asm-util-9.10.1.jar">
|
||||||
|
<sha256 value="1bb99d091fba2597dc6d51193e9bbcf0d8447e7ed96bd8f0198b18152f09655c" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="asm-util-9.10.1.pom">
|
||||||
|
<sha256 value="fcea2bad7868ed18949a2e71c40cf26de1516d16440e63f585c3e05d285c0d2b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.springframework" name="spring-framework-bom" version="5.3.39">
|
||||||
|
<artifact name="spring-framework-bom-5.3.39.module">
|
||||||
|
<sha256 value="f88b40e2a50333b40b42f181eee272b75ec75dd8666cb145bd90b15b97e183e3" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="spring-framework-bom-5.3.39.pom">
|
||||||
|
<sha256 value="f6d481093e75767cba1ac7e1db38f8f692cbe3e38744693371a75aeb21c6148b" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.vafer" name="jdependency" version="2.16">
|
||||||
|
<artifact name="jdependency-2.16.jar">
|
||||||
|
<sha256 value="86981d2f50ab15eebe1a90f843a195f28f0bd1ee52255d76a73ec0b4b7ec79cd" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="jdependency-2.16.pom">
|
||||||
|
<sha256 value="fa35299b0d0c47313d70364a75d20b9ac3a887443c632c7ecf50ba7df8871be5" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
<component group="org.xerial" name="sqlite-jdbc" version="3.48.0.0">
|
||||||
|
<artifact name="sqlite-jdbc-3.48.0.0.jar">
|
||||||
|
<sha256 value="dbe24ab138e9654c918f561299e47cb6a3baf1a946eda97871f6f3abd4eca395" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
<artifact name="sqlite-jdbc-3.48.0.0.pom">
|
||||||
|
<sha256 value="edd6eb33447eeaaf21dac7d4bd879dc9874c868bb023183a140489fd473c0108" origin="Generated by Gradle"/>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
|
</components>
|
||||||
|
</verification-metadata>
|
||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionSha256Sum=bafd5ce9cfaea0fbccfdc8439a1ac42fbd4cd9c89dc9a988228d8a2639a58e6c
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.0-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ public final class ModCheck
|
|||||||
if (descriptor == null) return new Result(null, null, problems);
|
if (descriptor == null) return new Result(null, null, problems);
|
||||||
|
|
||||||
ModCheck.checkDefaultConfig(arguments.jar(), problems);
|
ModCheck.checkDefaultConfig(arguments.jar(), problems);
|
||||||
ModCheck.checkEntrypoint(arguments.jar(), descriptor, problems);
|
ModCheck.checkEntrypoint(arguments, descriptor, problems);
|
||||||
|
|
||||||
List<ModDiscovery.Candidate> candidates = new ArrayList<>();
|
List<ModDiscovery.Candidate> candidates = new ArrayList<>();
|
||||||
|
|
||||||
@@ -283,9 +283,14 @@ public final class ModCheck
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The entry point and its superclasses inside the jar must lead to {@code Mod}. */
|
/**
|
||||||
private static void checkEntrypoint(Path jar, ModDescriptor descriptor, List<String> problems)
|
* The entry point must be in the jar, and its superclasses must lead to {@code Mod}. As in the
|
||||||
|
* server's class loader, superclasses come from the jar, its libraries, and then its
|
||||||
|
* dependencies.
|
||||||
|
*/
|
||||||
|
private static void checkEntrypoint(Arguments arguments, ModDescriptor descriptor, List<String> problems)
|
||||||
{
|
{
|
||||||
|
Path jar = arguments.jar();
|
||||||
String entrypoint = descriptor.entrypoint();
|
String entrypoint = descriptor.entrypoint();
|
||||||
ClassNode type = ModCheck.classNode(jar, entrypoint.replace('.', '/'), problems);
|
ClassNode type = ModCheck.classNode(jar, entrypoint.replace('.', '/'), problems);
|
||||||
|
|
||||||
@@ -300,6 +305,11 @@ public final class ModCheck
|
|||||||
boolean constructor = type.methods.stream().anyMatch(ModCheck::isPublicNoArgConstructor);
|
boolean constructor = type.methods.stream().anyMatch(ModCheck::isPublicNoArgConstructor);
|
||||||
if (!constructor || (type.access & Opcodes.ACC_PUBLIC) == 0) problems.add("The entry point '" + entrypoint + "' needs to be public, with a public constructor without parameters.");
|
if (!constructor || (type.access & Opcodes.ACC_PUBLIC) == 0) problems.add("The entry point '" + entrypoint + "' needs to be public, with a public constructor without parameters.");
|
||||||
|
|
||||||
|
List<Path> visible = new ArrayList<>();
|
||||||
|
visible.add(jar);
|
||||||
|
visible.addAll(arguments.libraries());
|
||||||
|
visible.addAll(arguments.dependencies());
|
||||||
|
|
||||||
ClassNode current = type;
|
ClassNode current = type;
|
||||||
|
|
||||||
for (int depth = 0; depth < 32; depth++)
|
for (int depth = 0; depth < 32; depth++)
|
||||||
@@ -309,7 +319,13 @@ public final class ModCheck
|
|||||||
if (ModCheck.MOD_CLASS.equals(superName)) return;
|
if (ModCheck.MOD_CLASS.equals(superName)) return;
|
||||||
if (superName == null) break;
|
if (superName == null) break;
|
||||||
|
|
||||||
ClassNode parent = ModCheck.classNode(jar, superName, problems);
|
ClassNode parent = ModCheck.classNode(visible, superName, problems);
|
||||||
|
|
||||||
|
if (parent == null && !ModCheck.isJdkClass(superName)) {
|
||||||
|
problems.add("The entry point '" + entrypoint + "' extends '" + superName.replace('/', '.') + "', which is not in '" + jar.getFileName() + "', its libraries, or its dependencies.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (parent == null) break;
|
if (parent == null) break;
|
||||||
|
|
||||||
current = parent;
|
current = parent;
|
||||||
@@ -344,6 +360,21 @@ public final class ModCheck
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether {@code internalName} is a JDK class; none of them leads to {@code Mod}. */
|
||||||
|
private static boolean isJdkClass(String internalName) { return ClassLoader.getPlatformClassLoader().getResource(internalName + ".class") != null; }
|
||||||
|
|
||||||
|
/** The class from the first of {@code jars} that contains it. */
|
||||||
|
private static @Nullable ClassNode classNode(List<Path> jars, String internalName, List<String> problems)
|
||||||
|
{
|
||||||
|
for (Path jar : jars)
|
||||||
|
{
|
||||||
|
ClassNode node = ModCheck.classNode(jar, internalName, problems);
|
||||||
|
if (node != null) return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private static @Nullable ClassNode classNode(Path jar, String internalName, List<String> problems)
|
private static @Nullable ClassNode classNode(Path jar, String internalName, List<String> problems)
|
||||||
{
|
{
|
||||||
byte[] bytes = ModCheck.bytes(jar, internalName + ".class", problems);
|
byte[] bytes = ModCheck.bytes(jar, internalName + ".class", problems);
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package dev.overlord.zomboidforge.tools;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
import org.objectweb.asm.MethodVisitor;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarOutputStream;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||||
|
import static org.objectweb.asm.Opcodes.ALOAD;
|
||||||
|
import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
|
||||||
|
import static org.objectweb.asm.Opcodes.RETURN;
|
||||||
|
import static org.objectweb.asm.Opcodes.V25;
|
||||||
|
|
||||||
|
class ModCheckTest
|
||||||
|
{
|
||||||
|
private static final String MOD = "dev/overlord/zomboidforge/api/Mod";
|
||||||
|
private static final String TOML = """
|
||||||
|
id = "shop"
|
||||||
|
version = "1.0.0"
|
||||||
|
entrypoint = "a.Main"
|
||||||
|
api = "0.3"
|
||||||
|
""";
|
||||||
|
|
||||||
|
@TempDir
|
||||||
|
Path directory;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void findsEntryPointSuperclassesInLibraries() throws IOException
|
||||||
|
{
|
||||||
|
Path mod = this.jar("shop.jar", ModCheckTest.TOML, Map.of("a/Main", ModCheckTest.type("a/Main", "b/Base")));
|
||||||
|
Path library = this.jar("base.jar", null, Map.of("b/Base", ModCheckTest.type("b/Base", ModCheckTest.MOD)));
|
||||||
|
|
||||||
|
ModCheck.Result result = ModCheck.check(new ModCheck.Arguments(mod, null, List.of(library), List.of(), null));
|
||||||
|
|
||||||
|
assertEquals(List.of(), result.problems());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void reportsSuperclassesThatAreNowhere() throws IOException
|
||||||
|
{
|
||||||
|
Path mod = this.jar("shop.jar", ModCheckTest.TOML, Map.of("a/Main", ModCheckTest.type("a/Main", "b/Base")));
|
||||||
|
|
||||||
|
ModCheck.Result result = ModCheck.check(new ModCheck.Arguments(mod, null, List.of(), List.of(), null));
|
||||||
|
|
||||||
|
assertEquals(List.of("The entry point 'a.Main' extends 'b.Base', which is not in 'shop.jar', its libraries, or its dependencies."), result.problems());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void reportsEntryPointsThatDoNotExtendMod() throws IOException
|
||||||
|
{
|
||||||
|
Path mod = this.jar("shop.jar", ModCheckTest.TOML, Map.of("a/Main", ModCheckTest.type("a/Main", "java/lang/Thread")));
|
||||||
|
|
||||||
|
ModCheck.Result result = ModCheck.check(new ModCheck.Arguments(mod, null, List.of(), List.of(), null));
|
||||||
|
|
||||||
|
assertEquals(List.of("The entry point 'a.Main' does not extend 'dev.overlord.zomboidforge.api.Mod'."), result.problems());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A public class extending {@code superName} with a public constructor without parameters. */
|
||||||
|
private static byte[] type(String name, String superName)
|
||||||
|
{
|
||||||
|
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||||
|
writer.visit(V25, ACC_PUBLIC, name, null, superName, null);
|
||||||
|
|
||||||
|
MethodVisitor init = writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
|
||||||
|
init.visitVarInsn(ALOAD, 0);
|
||||||
|
init.visitMethodInsn(INVOKESPECIAL, superName, "<init>", "()V", false);
|
||||||
|
init.visitInsn(RETURN);
|
||||||
|
init.visitMaxs(0, 0);
|
||||||
|
|
||||||
|
writer.visitEnd();
|
||||||
|
return writer.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A jar with {@code mod.toml} (unless {@code null}) and {@code classes} (internal name to bytes). */
|
||||||
|
private Path jar(String name, @Nullable String toml, Map<String, byte[]> classes) throws IOException
|
||||||
|
{
|
||||||
|
Path jar = this.directory.resolve(name);
|
||||||
|
|
||||||
|
try (OutputStream file = Files.newOutputStream(jar); JarOutputStream out = new JarOutputStream(file))
|
||||||
|
{
|
||||||
|
if (toml != null) {
|
||||||
|
out.putNextEntry(new JarEntry("META-INF/zomboidforge/mod.toml"));
|
||||||
|
out.write(toml.getBytes(StandardCharsets.UTF_8));
|
||||||
|
out.closeEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, byte[]> entry : classes.entrySet()) {
|
||||||
|
out.putNextEntry(new JarEntry(entry.getKey() + ".class"));
|
||||||
|
out.write(entry.getValue());
|
||||||
|
out.closeEntry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return jar;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,3 +60,17 @@ tasks.register<JavaExec>("patchServerJar") {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used by ci/release.sh (Dockerfile stage game-version) to name the image before the full build.
|
||||||
|
tasks.register<JavaExec>("printGameVersion") {
|
||||||
|
description = "Prints the game version of the server jar (pz.jar)."
|
||||||
|
group = "help"
|
||||||
|
|
||||||
|
val serverJar = projectZomboid.serverJar
|
||||||
|
|
||||||
|
classpath = sourceSets.main.get().runtimeClasspath
|
||||||
|
mainClass = "dev.overlord.zomboidforge.patcher.GameVersionReader"
|
||||||
|
argumentProviders.add(CommandLineArgumentProvider {
|
||||||
|
listOf(serverJar.get().asFile.absolutePath)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -13,6 +13,8 @@ import org.objectweb.asm.tree.IntInsnNode;
|
|||||||
import org.objectweb.asm.tree.MethodInsnNode;
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -32,6 +34,18 @@ public final class GameVersionReader
|
|||||||
|
|
||||||
private GameVersionReader() {}
|
private GameVersionReader() {}
|
||||||
|
|
||||||
|
/** Usage: {@code GameVersionReader <server.jar>}. Prints the jar's game version, e.g. {@code 42.21.0}. */
|
||||||
|
static void main(String[] args) throws IOException
|
||||||
|
{
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
|
System.err.println("Usage: GameVersionReader <server.jar>");
|
||||||
|
System.exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(JarPatcher.readGameVersion(Path.of(args[0])));
|
||||||
|
}
|
||||||
|
|
||||||
public static GameVersion read(byte[] coreClass)
|
public static GameVersion read(byte[] coreClass)
|
||||||
{
|
{
|
||||||
ClassNode core = new ClassNode();
|
ClassNode core = new ClassNode();
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package dev.overlord.zomboidforge.patcher;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.LocalVariableNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import org.objectweb.asm.tree.VarInsnNode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A value of the patched method that a {@link Hook} receives as an argument. The hook's
|
||||||
|
* parameters are the types of its arguments, in order.
|
||||||
|
*/
|
||||||
|
public sealed interface HookArgument
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The local variable slot that holds the value at the instruction {@code at} of
|
||||||
|
* {@code method}. Fails with an {@link IllegalStateException} when the value does not
|
||||||
|
* exist there.
|
||||||
|
*/
|
||||||
|
Slot resolve(ClassNode node, MethodNode method, AbstractInsnNode at);
|
||||||
|
|
||||||
|
/** A local variable slot and the type of the value in it. */
|
||||||
|
record Slot(int index, Type type)
|
||||||
|
{
|
||||||
|
/** The instruction that pushes the value onto the operand stack. */
|
||||||
|
public VarInsnNode load() { return new VarInsnNode(this.type.getOpcode(Opcodes.ILOAD), this.index); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parameter {@code index} of the patched method, counted from 0 in the order of its
|
||||||
|
* descriptor; {@code this} of an instance method is not counted.
|
||||||
|
*/
|
||||||
|
record Parameter(int index) implements HookArgument
|
||||||
|
{
|
||||||
|
public Parameter
|
||||||
|
{
|
||||||
|
if (index < 0) throw new IllegalArgumentException("Not a parameter index: " + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Slot resolve(ClassNode node, MethodNode method, AbstractInsnNode at)
|
||||||
|
{
|
||||||
|
Type[] types = Type.getArgumentTypes(method.desc);
|
||||||
|
|
||||||
|
if (this.index >= types.length) throw new IllegalStateException("'" + node.name + "." + method.name + method.desc + "' has no parameter " + this.index + ".");
|
||||||
|
|
||||||
|
int slot = (method.access & Opcodes.ACC_STATIC) != 0 ? 0 : 1;
|
||||||
|
for (int i = 0; i < this.index; i++) slot += types[i].getSize();
|
||||||
|
|
||||||
|
return new Slot(slot, types[this.index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() { return "parameter " + this.index; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The local variable {@code name} of the patched method, from its local variable table.
|
||||||
|
* Exactly one variable of that name has to be in scope at the anchor.
|
||||||
|
*/
|
||||||
|
record Local(String name) implements HookArgument
|
||||||
|
{
|
||||||
|
public Local
|
||||||
|
{
|
||||||
|
Objects.requireNonNull(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Slot resolve(ClassNode node, MethodNode method, AbstractInsnNode at)
|
||||||
|
{
|
||||||
|
List<LocalVariableNode> variables = Objects.requireNonNullElse(method.localVariables, List.<LocalVariableNode>of());
|
||||||
|
int position = method.instructions.indexOf(at);
|
||||||
|
|
||||||
|
List<LocalVariableNode> matches = variables.stream()
|
||||||
|
.filter(variable -> variable.name.equals(this.name))
|
||||||
|
.filter(variable -> method.instructions.indexOf(variable.start) <= position && position < method.instructions.indexOf(variable.end))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (matches.size() != 1) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Expected exactly one local variable '" + this.name + "' in scope at the anchor in '"
|
||||||
|
+ node.name + "." + method.name + method.desc + "', found " + matches.size()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalVariableNode variable = matches.getFirst();
|
||||||
|
|
||||||
|
return new Slot(variable.index, Type.getType(variable.desc));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() { return "local '" + this.name + "'"; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import org.objectweb.asm.ClassReader;
|
|||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -161,7 +162,7 @@ public final class JarPatcher
|
|||||||
{
|
{
|
||||||
ZipEntry entry = entries.nextElement();
|
ZipEntry entry = entries.nextElement();
|
||||||
List<ClassPatch> patches = patchesByEntry.get(entry.getName());
|
List<ClassPatch> patches = patchesByEntry.get(entry.getName());
|
||||||
byte[] bytes = jar.getInputStream(entry).readAllBytes();
|
byte[] bytes = JarPatcher.read(jar, entry);
|
||||||
|
|
||||||
if (patches != null) {
|
if (patches != null) {
|
||||||
bytes = transform(jar, bytes, patches);
|
bytes = transform(jar, bytes, patches);
|
||||||
@@ -205,10 +206,7 @@ public final class JarPatcher
|
|||||||
ClassNode node = new ClassNode();
|
ClassNode node = new ClassNode();
|
||||||
new ClassReader(bytes).accept(node, 0);
|
new ClassReader(bytes).accept(node, 0);
|
||||||
|
|
||||||
for (ClassPatch patch : patches) {
|
for (ClassPatch patch : patches) JarPatcher.apply(patch, node);
|
||||||
JarPatcher.verifyAnchor(patch, node);
|
|
||||||
patch.apply(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
HierarchyClassWriter writer = new HierarchyClassWriter(name -> JarPatcher.read(jar, name + ".class"));
|
HierarchyClassWriter writer = new HierarchyClassWriter(name -> JarPatcher.read(jar, name + ".class"));
|
||||||
node.accept(writer);
|
node.accept(writer);
|
||||||
@@ -216,9 +214,14 @@ public final class JarPatcher
|
|||||||
return writer.toByteArray();
|
return writer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void verifyAnchor(ClassPatch patch, ClassNode node)
|
/** Verifies the anchor of {@code patch}, then applies it; failures name the patch. */
|
||||||
|
private static void apply(ClassPatch patch, ClassNode node)
|
||||||
{
|
{
|
||||||
try { patch.anchor().verify(node); }
|
try
|
||||||
|
{
|
||||||
|
patch.anchor().verify(node);
|
||||||
|
patch.apply(node);
|
||||||
|
}
|
||||||
catch (IllegalStateException e) { throw new IllegalStateException("'" + patch.getClass().getSimpleName() + "': " + e.getMessage(), e); }
|
catch (IllegalStateException e) { throw new IllegalStateException("'" + patch.getClass().getSimpleName() + "': " + e.getMessage(), e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +230,12 @@ public final class JarPatcher
|
|||||||
ZipEntry entry = jar.getEntry(entryName);
|
ZipEntry entry = jar.getEntry(entryName);
|
||||||
if (entry == null) return null;
|
if (entry == null) return null;
|
||||||
|
|
||||||
try { return jar.getInputStream(entry).readAllBytes(); }
|
try { return JarPatcher.read(jar, entry); }
|
||||||
catch (IOException e) { throw new UncheckedIOException(e); }
|
catch (IOException e) { throw new UncheckedIOException(e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static byte[] read(ZipFile jar, ZipEntry entry) throws IOException
|
||||||
|
{
|
||||||
|
try (InputStream in = jar.getInputStream(entry)) { return in.readAllBytes(); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+93
@@ -0,0 +1,93 @@
|
|||||||
|
package dev.overlord.zomboidforge.patcher.Patches;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.patcher.Anchor;
|
||||||
|
import dev.overlord.zomboidforge.patcher.ClassPatch;
|
||||||
|
import dev.overlord.zomboidforge.patcher.Hook;
|
||||||
|
import dev.overlord.zomboidforge.patcher.HookArgument;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.InsnList;
|
||||||
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
|
import org.objectweb.asm.tree.JumpInsnNode;
|
||||||
|
import org.objectweb.asm.tree.LabelNode;
|
||||||
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a call in the target class depend on a {@link Hook}: the hook runs directly before the
|
||||||
|
* call and returns {@code true} to skip it.
|
||||||
|
*
|
||||||
|
* <pre>{@code
|
||||||
|
* if (!Hooks.hook(arguments)) Owner.call(...);
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* The receiver and the arguments of the call are evaluated before the hook runs; a skipped call
|
||||||
|
* pops them. The call returns {@code void}, so a skipped call leaves no value missing. The hook
|
||||||
|
* receives the {@link HookArgument}s, which are read from local variable slots.
|
||||||
|
*/
|
||||||
|
public abstract class CancellableHookPatch implements ClassPatch
|
||||||
|
{
|
||||||
|
private final String target;
|
||||||
|
private final Anchor.Call anchor;
|
||||||
|
private final Hook hook;
|
||||||
|
private final List<HookArgument> arguments;
|
||||||
|
|
||||||
|
/** A hook with one parameter per element of {@code arguments}, in order, returning {@code boolean}. */
|
||||||
|
protected CancellableHookPatch(String target, Anchor.Call anchor, Hook hook, List<HookArgument> arguments)
|
||||||
|
{
|
||||||
|
if (!Type.getReturnType(anchor.desc()).equals(Type.VOID_TYPE))
|
||||||
|
throw new IllegalArgumentException("Anchor call '" + anchor.owner() + "." + anchor.name() + anchor.desc() + "' must return 'V'.");
|
||||||
|
|
||||||
|
if (anchor.name().equals("<init>"))
|
||||||
|
throw new IllegalArgumentException("Anchor call '" + anchor.owner() + "." + anchor.name() + anchor.desc() + "' is a constructor, which cannot be skipped.");
|
||||||
|
|
||||||
|
HookCall.checkShape(hook, arguments, Type.BOOLEAN_TYPE);
|
||||||
|
|
||||||
|
this.target = Objects.requireNonNull(target);
|
||||||
|
this.anchor = anchor;
|
||||||
|
this.hook = hook;
|
||||||
|
this.arguments = List.copyOf(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final String target() { return this.target; }
|
||||||
|
@Override
|
||||||
|
public final Anchor.Call anchor() { return this.anchor; }
|
||||||
|
@Override
|
||||||
|
public final Hook hook() { return this.hook; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void apply(ClassNode node)
|
||||||
|
{
|
||||||
|
MethodNode method = this.anchor.in().resolve(node);
|
||||||
|
MethodInsnNode call = this.anchor.resolve(node);
|
||||||
|
InsnList code = HookCall.invoke(this.hook, this.arguments, Type.BOOLEAN_TYPE, node, method, call);
|
||||||
|
LabelNode run = new LabelNode();
|
||||||
|
LabelNode end = new LabelNode();
|
||||||
|
|
||||||
|
code.add(new JumpInsnNode(Opcodes.IFEQ, run));
|
||||||
|
code.add(CancellableHookPatch.discardOperands(call));
|
||||||
|
code.add(new JumpInsnNode(Opcodes.GOTO, end));
|
||||||
|
code.add(run);
|
||||||
|
|
||||||
|
method.instructions.insertBefore(call, code);
|
||||||
|
method.instructions.insert(call, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pops the arguments of {@code call}, last first, then its receiver. */
|
||||||
|
private static InsnList discardOperands(MethodInsnNode call)
|
||||||
|
{
|
||||||
|
InsnList code = new InsnList();
|
||||||
|
Type[] arguments = Type.getArgumentTypes(call.desc);
|
||||||
|
|
||||||
|
for (int i = arguments.length - 1; i >= 0; i--) code.add(new InsnNode(arguments[i].getSize() == 2 ? Opcodes.POP2 : Opcodes.POP));
|
||||||
|
if (call.getOpcode() != Opcodes.INVOKESTATIC) code.add(new InsnNode(Opcodes.POP));
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package dev.overlord.zomboidforge.patcher.Patches;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.patcher.Hook;
|
||||||
|
import dev.overlord.zomboidforge.patcher.HookArgument;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.InsnList;
|
||||||
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The call of a {@link Hook} with its {@link HookArgument}s, shared by the hook patch types. A
|
||||||
|
* hook may also take values that are already on the operand stack where it is called; those
|
||||||
|
* come first in its parameter list, followed by one parameter per argument.
|
||||||
|
*/
|
||||||
|
final class HookCall
|
||||||
|
{
|
||||||
|
private HookCall() {}
|
||||||
|
|
||||||
|
/** {@link #checkShape(Hook, List, List, Type)} without values on the stack. */
|
||||||
|
static void checkShape(Hook hook, List<HookArgument> arguments, Type returnType) { HookCall.checkShape(hook, List.of(), arguments, returnType); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fails unless {@code hook} returns {@code returnType}, takes the types {@code onStack} first,
|
||||||
|
* and then one parameter per argument. The types of those parameters are checked by
|
||||||
|
* {@link #invoke}, once the arguments are resolved.
|
||||||
|
*/
|
||||||
|
static void checkShape(Hook hook, List<Type> onStack, List<HookArgument> arguments, Type returnType)
|
||||||
|
{
|
||||||
|
Type actualReturn = Type.getReturnType(hook.desc());
|
||||||
|
Type[] parameters = Type.getArgumentTypes(hook.desc());
|
||||||
|
|
||||||
|
if (!actualReturn.equals(returnType))
|
||||||
|
throw new IllegalArgumentException("Hook '" + hook + "' must return '" + returnType.getDescriptor() + "'.");
|
||||||
|
|
||||||
|
if (parameters.length != onStack.size() + arguments.size())
|
||||||
|
throw new IllegalArgumentException("Hook '" + hook + "' must take " + (onStack.size() + arguments.size()) + " parameter(s): " + HookCall.describe(onStack, arguments) + ".");
|
||||||
|
|
||||||
|
for (int i = 0; i < onStack.size(); i++)
|
||||||
|
{
|
||||||
|
if (!parameters[i].equals(onStack.get(i)))
|
||||||
|
throw new IllegalArgumentException("Parameter " + i + " of hook '" + hook + "' must be '" + onStack.get(i).getDescriptor() + "'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@link #invoke(Hook, List, List, Type, ClassNode, MethodNode, AbstractInsnNode)} without values on the stack. */
|
||||||
|
static InsnList invoke(Hook hook, List<HookArgument> arguments, Type returnType, ClassNode node, MethodNode method, AbstractInsnNode at)
|
||||||
|
{
|
||||||
|
return HookCall.invoke(hook, List.of(), arguments, returnType, node, method, at);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions that push {@code arguments} and call {@code hook}, for insertion directly
|
||||||
|
* before or after {@code at} in {@code method}, where the values of the types {@code onStack}
|
||||||
|
* are on top of the operand stack. Fails when the hook's descriptor does not match.
|
||||||
|
*/
|
||||||
|
static InsnList invoke(Hook hook, List<Type> onStack, List<HookArgument> arguments, Type returnType, ClassNode node, MethodNode method, AbstractInsnNode at)
|
||||||
|
{
|
||||||
|
InsnList code = new InsnList();
|
||||||
|
List<Type> types = new ArrayList<>(onStack);
|
||||||
|
|
||||||
|
for (HookArgument argument : arguments)
|
||||||
|
{
|
||||||
|
HookArgument.Slot slot = argument.resolve(node, method, at);
|
||||||
|
|
||||||
|
types.add(slot.type());
|
||||||
|
code.add(slot.load());
|
||||||
|
}
|
||||||
|
|
||||||
|
String expected = Type.getMethodDescriptor(returnType, types.toArray(Type[]::new));
|
||||||
|
if (!hook.desc().equals(expected))
|
||||||
|
throw new IllegalStateException("Hook '" + hook + "' must have descriptor '" + expected + "' for " + HookCall.describe(onStack, arguments) + ".");
|
||||||
|
|
||||||
|
code.add(new MethodInsnNode(Opcodes.INVOKESTATIC, hook.owner(), hook.name(), hook.desc(), false));
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** E.g. {@code the arguments [parameter 0]} or {@code the stack value(s) [Ljava/lang/Class;] and the arguments [parameter 0]}. */
|
||||||
|
private static String describe(List<Type> onStack, List<HookArgument> arguments)
|
||||||
|
{
|
||||||
|
String argumentsText = "the arguments " + arguments;
|
||||||
|
if (onStack.isEmpty()) return argumentsText;
|
||||||
|
|
||||||
|
return "the stack value(s) " + onStack.stream().map(Type::getDescriptor).toList() + " and " + argumentsText;
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
-24
@@ -3,34 +3,40 @@ package dev.overlord.zomboidforge.patcher.Patches;
|
|||||||
import dev.overlord.zomboidforge.patcher.Anchor;
|
import dev.overlord.zomboidforge.patcher.Anchor;
|
||||||
import dev.overlord.zomboidforge.patcher.ClassPatch;
|
import dev.overlord.zomboidforge.patcher.ClassPatch;
|
||||||
import dev.overlord.zomboidforge.patcher.Hook;
|
import dev.overlord.zomboidforge.patcher.Hook;
|
||||||
|
import dev.overlord.zomboidforge.patcher.HookArgument;
|
||||||
|
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Type;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.MethodInsnNode;
|
import org.objectweb.asm.tree.MethodInsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a call to a {@link Hook} directly after a call in the target class. The hook takes
|
* Inserts a call to a {@link Hook} directly after a call in the target class. The hook returns
|
||||||
* no arguments and returns nothing, so the operand stack and the stack map frames of the
|
* nothing and receives the {@link HookArgument}s, which are read from local variable slots, so
|
||||||
* patched method stay unchanged.
|
* the operand stack after the inserted code is the same as before it.
|
||||||
*/
|
*/
|
||||||
public abstract class HookInjectionPatch implements ClassPatch
|
public abstract class HookInjectionPatch implements ClassPatch
|
||||||
{
|
{
|
||||||
private static final String HOOK_DESC = "()V";
|
private final String target;
|
||||||
|
private final Anchor.Call anchor;
|
||||||
|
private final Hook hook;
|
||||||
|
private final List<HookArgument> arguments;
|
||||||
|
|
||||||
private final String target;
|
/** A hook without arguments, {@code ()V}. */
|
||||||
private final Anchor.Call anchor;
|
protected HookInjectionPatch(String target, Anchor.Call anchor, Hook hook) { this(target, anchor, hook, List.of()); }
|
||||||
private final Hook hook;
|
|
||||||
|
|
||||||
protected HookInjectionPatch(String target, Anchor.Call anchor, Hook hook)
|
/** A hook with one parameter per element of {@code arguments}, in order, returning {@code void}. */
|
||||||
|
protected HookInjectionPatch(String target, Anchor.Call anchor, Hook hook, List<HookArgument> arguments)
|
||||||
{
|
{
|
||||||
if (!hook.desc().equals(HookInjectionPatch.HOOK_DESC))
|
HookCall.checkShape(hook, arguments, Type.VOID_TYPE);
|
||||||
throw new IllegalArgumentException("Hook '" + hook + "' must have descriptor '" + HookInjectionPatch.HOOK_DESC + "'.");
|
|
||||||
|
|
||||||
this.target = Objects.requireNonNull(target);
|
this.target = Objects.requireNonNull(target);
|
||||||
this.anchor = Objects.requireNonNull(anchor);
|
this.anchor = Objects.requireNonNull(anchor);
|
||||||
this.hook = hook;
|
this.hook = hook;
|
||||||
|
this.arguments = List.copyOf(arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,16 +49,9 @@ public abstract class HookInjectionPatch implements ClassPatch
|
|||||||
@Override
|
@Override
|
||||||
public final void apply(ClassNode node)
|
public final void apply(ClassNode node)
|
||||||
{
|
{
|
||||||
MethodInsnNode call = this.anchor.resolve(node);
|
MethodNode method = this.anchor.in().resolve(node);
|
||||||
|
MethodInsnNode call = this.anchor.resolve(node);
|
||||||
|
|
||||||
this.anchor.in().resolve(node).instructions.insert(
|
method.instructions.insert(call, HookCall.invoke(this.hook, this.arguments, Type.VOID_TYPE, node, method, call));
|
||||||
call, new MethodInsnNode(
|
|
||||||
Opcodes.INVOKESTATIC,
|
|
||||||
this.hook.owner(),
|
|
||||||
this.hook.name(),
|
|
||||||
this.hook.desc(),
|
|
||||||
false
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package dev.overlord.zomboidforge.patcher.Patches;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.patcher.Anchor;
|
||||||
|
import dev.overlord.zomboidforge.patcher.ClassPatch;
|
||||||
|
import dev.overlord.zomboidforge.patcher.Hook;
|
||||||
|
import dev.overlord.zomboidforge.patcher.HookArgument;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
import org.objectweb.asm.util.Printer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Passes the value that one return instruction of a method is about to return to a
|
||||||
|
* {@link Hook}, which returns the value to return instead:
|
||||||
|
*
|
||||||
|
* <pre>{@code
|
||||||
|
* return Hooks.hook(value, arguments);
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* The anchor is a {@link Anchor.Sequence} whose last instruction is that return instruction;
|
||||||
|
* the instructions before it identify which return of the method is meant. The hook's first
|
||||||
|
* parameter and its return type are the method's return type, followed by one parameter per
|
||||||
|
* {@link HookArgument}. Other returns of the method are unchanged.
|
||||||
|
*/
|
||||||
|
public abstract class ReturnHookPatch implements ClassPatch
|
||||||
|
{
|
||||||
|
private final String target;
|
||||||
|
private final Anchor.Sequence anchor;
|
||||||
|
private final Hook hook;
|
||||||
|
private final List<HookArgument> arguments;
|
||||||
|
private final Type returned;
|
||||||
|
|
||||||
|
protected ReturnHookPatch(String target, Anchor.Sequence anchor, Hook hook, List<HookArgument> arguments)
|
||||||
|
{
|
||||||
|
Type returned = Type.getReturnType(anchor.in().desc());
|
||||||
|
|
||||||
|
if (returned.equals(Type.VOID_TYPE))
|
||||||
|
throw new IllegalArgumentException("Method '" + anchor.in().name() + anchor.in().desc() + "' returns no value.");
|
||||||
|
|
||||||
|
HookCall.checkShape(hook, List.of(returned), arguments, returned);
|
||||||
|
|
||||||
|
this.target = Objects.requireNonNull(target);
|
||||||
|
this.anchor = anchor;
|
||||||
|
this.hook = hook;
|
||||||
|
this.arguments = List.copyOf(arguments);
|
||||||
|
this.returned = returned;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final String target() { return this.target; }
|
||||||
|
@Override
|
||||||
|
public final Anchor.Sequence anchor() { return this.anchor; }
|
||||||
|
@Override
|
||||||
|
public final Hook hook() { return this.hook; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void apply(ClassNode node)
|
||||||
|
{
|
||||||
|
MethodNode method = this.anchor.in().resolve(node);
|
||||||
|
AbstractInsnNode instruction = this.anchor.resolve(node).getLast();
|
||||||
|
int returnOpcode = this.returned.getOpcode(Opcodes.IRETURN);
|
||||||
|
|
||||||
|
if (instruction.getOpcode() != returnOpcode)
|
||||||
|
throw new IllegalStateException("The last instruction of the anchor must be '" + Printer.OPCODES[returnOpcode].toLowerCase(Locale.ROOT) + "'.");
|
||||||
|
|
||||||
|
method.instructions.insertBefore(instruction, HookCall.invoke(this.hook, List.of(this.returned), this.arguments, this.returned, node, method, instruction));
|
||||||
|
}
|
||||||
|
}
|
||||||
+196
@@ -0,0 +1,196 @@
|
|||||||
|
package dev.overlord.zomboidforge.patcher;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.patcher.Patches.CancellableHookPatch;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
import org.objectweb.asm.MethodVisitor;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||||
|
import static org.objectweb.asm.Opcodes.ACC_STATIC;
|
||||||
|
import static org.objectweb.asm.Opcodes.ALOAD;
|
||||||
|
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
|
||||||
|
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
|
||||||
|
import static org.objectweb.asm.Opcodes.LLOAD;
|
||||||
|
import static org.objectweb.asm.Opcodes.RETURN;
|
||||||
|
import static org.objectweb.asm.Opcodes.V25;
|
||||||
|
|
||||||
|
class CancellableHookPatchTest
|
||||||
|
{
|
||||||
|
private static final String CALLS = Type.getInternalName(CancellableHookPatchTest.Calls.class);
|
||||||
|
private static final String CALLS_DESC = Type.getDescriptor(CancellableHookPatchTest.Calls.class);
|
||||||
|
|
||||||
|
@TempDir
|
||||||
|
Path dir;
|
||||||
|
|
||||||
|
/** Stands in for the anchor calls and the hooks, and records the calls. */
|
||||||
|
public static final class Calls
|
||||||
|
{
|
||||||
|
public static final List<String> LOG = new ArrayList<>();
|
||||||
|
|
||||||
|
/** What the hooks return. */
|
||||||
|
public static boolean cancel;
|
||||||
|
|
||||||
|
public static void staticCall(long number, String text) { Calls.LOG.add("call " + number + " " + text); }
|
||||||
|
|
||||||
|
public void virtualCall(String text) { Calls.LOG.add("virtual " + text); }
|
||||||
|
|
||||||
|
public static void after() { Calls.LOG.add("after"); }
|
||||||
|
|
||||||
|
public static boolean staticHook(String text, long number)
|
||||||
|
{
|
||||||
|
Calls.LOG.add("hook " + text + " " + number);
|
||||||
|
|
||||||
|
return Calls.cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean virtualHook(String text)
|
||||||
|
{
|
||||||
|
Calls.LOG.add("virtual hook " + text);
|
||||||
|
|
||||||
|
return Calls.cancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Skips {@code Calls.staticCall(number, text)} in {@code runStatic}; the hook gets {@code text} and {@code number}. */
|
||||||
|
private static final class StaticCallPatch extends CancellableHookPatch
|
||||||
|
{
|
||||||
|
StaticCallPatch() {
|
||||||
|
super(
|
||||||
|
"t/Target",
|
||||||
|
new Anchor.Call(new Anchor.Method("runStatic", "(JLjava/lang/String;)V"), CancellableHookPatchTest.CALLS, "staticCall", "(JLjava/lang/String;)V"),
|
||||||
|
new Hook(CancellableHookPatchTest.CALLS, "staticHook", "(Ljava/lang/String;J)Z"),
|
||||||
|
List.of(new HookArgument.Parameter(1), new HookArgument.Parameter(0))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Skips {@code calls.virtualCall(text)} in {@code runVirtual}; the hook gets {@code text}. */
|
||||||
|
private static final class VirtualCallPatch extends CancellableHookPatch
|
||||||
|
{
|
||||||
|
VirtualCallPatch() {
|
||||||
|
super(
|
||||||
|
"t/Target",
|
||||||
|
new Anchor.Call(new Anchor.Method("runVirtual", "(" + CancellableHookPatchTest.CALLS_DESC + "Ljava/lang/String;)V"), CancellableHookPatchTest.CALLS, "virtualCall", "(Ljava/lang/String;)V"),
|
||||||
|
new Hook(CancellableHookPatchTest.CALLS, "virtualHook", "(Ljava/lang/String;)Z"),
|
||||||
|
List.of(new HookArgument.Parameter(1))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code static runStatic(long number, String text)}: {@code Calls.staticCall(number, text); Calls.after();}
|
||||||
|
* and {@code static runVirtual(Calls calls, String text)}: {@code calls.virtualCall(text); Calls.after();}.
|
||||||
|
*/
|
||||||
|
private static byte[] target()
|
||||||
|
{
|
||||||
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
|
||||||
|
cw.visit(V25, ACC_PUBLIC, "t/Target", null, "java/lang/Object", null);
|
||||||
|
|
||||||
|
MethodVisitor runStatic = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "runStatic", "(JLjava/lang/String;)V", null, null);
|
||||||
|
runStatic.visitVarInsn(LLOAD, 0);
|
||||||
|
runStatic.visitVarInsn(ALOAD, 2);
|
||||||
|
runStatic.visitMethodInsn(INVOKESTATIC, CancellableHookPatchTest.CALLS, "staticCall", "(JLjava/lang/String;)V", false);
|
||||||
|
runStatic.visitMethodInsn(INVOKESTATIC, CancellableHookPatchTest.CALLS, "after", "()V", false);
|
||||||
|
runStatic.visitInsn(RETURN);
|
||||||
|
runStatic.visitMaxs(0, 0);
|
||||||
|
|
||||||
|
MethodVisitor runVirtual = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "runVirtual", "(" + CancellableHookPatchTest.CALLS_DESC + "Ljava/lang/String;)V", null, null);
|
||||||
|
runVirtual.visitVarInsn(ALOAD, 0);
|
||||||
|
runVirtual.visitVarInsn(ALOAD, 1);
|
||||||
|
runVirtual.visitMethodInsn(INVOKEVIRTUAL, CancellableHookPatchTest.CALLS, "virtualCall", "(Ljava/lang/String;)V", false);
|
||||||
|
runVirtual.visitMethodInsn(INVOKESTATIC, CancellableHookPatchTest.CALLS, "after", "()V", false);
|
||||||
|
runVirtual.visitInsn(RETURN);
|
||||||
|
runVirtual.visitMaxs(0, 0);
|
||||||
|
|
||||||
|
cw.visitEnd();
|
||||||
|
return cw.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Patches {@link #target()} with both patches and runs {@code runStatic(7, "a")} and {@code runVirtual(new Calls(), "b")}. */
|
||||||
|
private List<String> runPatched(boolean cancel) throws Exception
|
||||||
|
{
|
||||||
|
Path in = this.dir.resolve("in.jar");
|
||||||
|
Path out = this.dir.resolve("patched.jar");
|
||||||
|
|
||||||
|
try (ZipOutputStream zip = new ZipOutputStream(Files.newOutputStream(in)))
|
||||||
|
{
|
||||||
|
zip.putNextEntry(new ZipEntry("t/Target.class"));
|
||||||
|
zip.write(CancellableHookPatchTest.target());
|
||||||
|
zip.closeEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(1, new JarPatcher(List.of(new StaticCallPatch(), new VirtualCallPatch())).patch(in, out));
|
||||||
|
|
||||||
|
CancellableHookPatchTest.Calls.cancel = cancel;
|
||||||
|
|
||||||
|
try (URLClassLoader loader = new URLClassLoader(new URL[]{out.toUri().toURL()}, CancellableHookPatchTest.class.getClassLoader()))
|
||||||
|
{
|
||||||
|
Class<?> target = loader.loadClass("t.Target");
|
||||||
|
|
||||||
|
target.getMethod("runStatic", long.class, String.class).invoke(null, 7L, "a");
|
||||||
|
target.getMethod("runVirtual", CancellableHookPatchTest.Calls.class, String.class).invoke(null, new CancellableHookPatchTest.Calls(), "b");
|
||||||
|
}
|
||||||
|
|
||||||
|
return CancellableHookPatchTest.Calls.LOG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void clearLog() { CancellableHookPatchTest.Calls.LOG.clear(); }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void runsTheCallWhenTheHookReturnsFalse() throws Exception
|
||||||
|
{
|
||||||
|
assertEquals(
|
||||||
|
List.of("hook a 7", "call 7 a", "after", "virtual hook b", "virtual b", "after"),
|
||||||
|
this.runPatched(false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void skipsTheCallWhenTheHookReturnsTrue() throws Exception
|
||||||
|
{
|
||||||
|
assertEquals(
|
||||||
|
List.of("hook a 7", "after", "virtual hook b", "after"),
|
||||||
|
this.runPatched(true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsAnchorCallThatReturnsAValue()
|
||||||
|
{
|
||||||
|
Anchor.Call anchor = new Anchor.Call(new Anchor.Method("run", "()V"), "t/Dep", "value", "()I");
|
||||||
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> new CancellableHookPatch("t/Target", anchor, new Hook("t/Hooks", "hook", "()Z"), List.of()) {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsConstructorAnchor()
|
||||||
|
{
|
||||||
|
Anchor.Call anchor = new Anchor.Call(new Anchor.Method("run", "()V"), "t/Dep", "<init>", "()V");
|
||||||
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> new CancellableHookPatch("t/Target", anchor, new Hook("t/Hooks", "hook", "()Z"), List.of()) {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsHookThatDoesNotReturnBoolean()
|
||||||
|
{
|
||||||
|
Anchor.Call anchor = new Anchor.Call(new Anchor.Method("run", "()V"), "t/Dep", "call", "()V");
|
||||||
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> new CancellableHookPatch("t/Target", anchor, new Hook("t/Hooks", "hook", "()V"), List.of()) {});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
package dev.overlord.zomboidforge.patcher;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
|
import org.objectweb.asm.tree.LabelNode;
|
||||||
|
import org.objectweb.asm.tree.LocalVariableNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||||
|
import static org.objectweb.asm.Opcodes.ACC_STATIC;
|
||||||
|
import static org.objectweb.asm.Opcodes.ALOAD;
|
||||||
|
import static org.objectweb.asm.Opcodes.ASM9;
|
||||||
|
import static org.objectweb.asm.Opcodes.LLOAD;
|
||||||
|
import static org.objectweb.asm.Opcodes.NOP;
|
||||||
|
import static org.objectweb.asm.Opcodes.RETURN;
|
||||||
|
|
||||||
|
class HookArgumentTest
|
||||||
|
{
|
||||||
|
private static final String STRING = "Ljava/lang/String;";
|
||||||
|
|
||||||
|
private static ClassNode target()
|
||||||
|
{
|
||||||
|
ClassNode node = new ClassNode();
|
||||||
|
node.name = "t/Target";
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void parameterSlotsSkipThisAndCountWideTypesTwice()
|
||||||
|
{
|
||||||
|
MethodNode staticMethod = new MethodNode(ASM9, ACC_PUBLIC | ACC_STATIC, "run", "(JLjava/lang/String;)V", null, null);
|
||||||
|
MethodNode instanceMethod = new MethodNode(ASM9, ACC_PUBLIC, "run", "(JLjava/lang/String;)V", null, null);
|
||||||
|
ClassNode node = HookArgumentTest.target();
|
||||||
|
|
||||||
|
assertEquals(new HookArgument.Slot(0, Type.LONG_TYPE), new HookArgument.Parameter(0).resolve(node, staticMethod, new InsnNode(RETURN)));
|
||||||
|
assertEquals(new HookArgument.Slot(2, Type.getType(HookArgumentTest.STRING)), new HookArgument.Parameter(1).resolve(node, staticMethod, new InsnNode(RETURN)));
|
||||||
|
assertEquals(new HookArgument.Slot(3, Type.getType(HookArgumentTest.STRING)), new HookArgument.Parameter(1).resolve(node, instanceMethod, new InsnNode(RETURN)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void slotLoadsWithTheOpcodeOfItsType()
|
||||||
|
{
|
||||||
|
assertEquals(LLOAD, new HookArgument.Slot(0, Type.LONG_TYPE).load().getOpcode());
|
||||||
|
assertEquals(ALOAD, new HookArgument.Slot(2, Type.getType(HookArgumentTest.STRING)).load().getOpcode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void reportsMissingParameter()
|
||||||
|
{
|
||||||
|
MethodNode method = new MethodNode(ASM9, ACC_STATIC, "run", "(I)V", null, null);
|
||||||
|
|
||||||
|
IllegalStateException e = assertThrows(
|
||||||
|
IllegalStateException.class,
|
||||||
|
() -> new HookArgument.Parameter(1).resolve(HookArgumentTest.target(), method, new InsnNode(RETURN))
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals("'t/Target.run(I)V' has no parameter 1.", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsNegativeParameterIndex()
|
||||||
|
{
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> new HookArgument.Parameter(-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@code run()}: {@code nop} (before), label, {@code nop} (inside), label, {@code return}; {@code name} is in scope only inside. */
|
||||||
|
@Test
|
||||||
|
void localResolvesOnlyWhereItIsInScope()
|
||||||
|
{
|
||||||
|
MethodNode method = new MethodNode(ASM9, ACC_STATIC, "run", "()V", null, null);
|
||||||
|
InsnNode before = new InsnNode(NOP);
|
||||||
|
InsnNode inside = new InsnNode(NOP);
|
||||||
|
LabelNode start = new LabelNode();
|
||||||
|
LabelNode end = new LabelNode();
|
||||||
|
|
||||||
|
method.instructions.add(before);
|
||||||
|
method.instructions.add(start);
|
||||||
|
method.instructions.add(inside);
|
||||||
|
method.instructions.add(end);
|
||||||
|
method.instructions.add(new InsnNode(RETURN));
|
||||||
|
method.localVariables.add(new LocalVariableNode("name", HookArgumentTest.STRING, null, start, end, 4));
|
||||||
|
|
||||||
|
HookArgument.Local name = new HookArgument.Local("name");
|
||||||
|
|
||||||
|
assertEquals(new HookArgument.Slot(4, Type.getType(HookArgumentTest.STRING)), name.resolve(HookArgumentTest.target(), method, inside));
|
||||||
|
|
||||||
|
IllegalStateException e = assertThrows(IllegalStateException.class, () -> name.resolve(HookArgumentTest.target(), method, before));
|
||||||
|
assertEquals("Expected exactly one local variable 'name' in scope at the anchor in 't/Target.run()V', found 0", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void localRejectsTwoVariablesOfTheSameNameInScope()
|
||||||
|
{
|
||||||
|
MethodNode method = new MethodNode(ASM9, ACC_STATIC, "run", "()V", null, null);
|
||||||
|
InsnNode inside = new InsnNode(NOP);
|
||||||
|
LabelNode start = new LabelNode();
|
||||||
|
LabelNode end = new LabelNode();
|
||||||
|
|
||||||
|
method.instructions.add(start);
|
||||||
|
method.instructions.add(inside);
|
||||||
|
method.instructions.add(end);
|
||||||
|
method.localVariables.add(new LocalVariableNode("name", HookArgumentTest.STRING, null, start, end, 0));
|
||||||
|
method.localVariables.add(new LocalVariableNode("name", "I", null, start, end, 1));
|
||||||
|
|
||||||
|
IllegalStateException e = assertThrows(
|
||||||
|
IllegalStateException.class,
|
||||||
|
() -> new HookArgument.Local("name").resolve(HookArgumentTest.target(), method, inside)
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals("Expected exactly one local variable 'name' in scope at the anchor in 't/Target.run()V', found 2", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,15 +2,19 @@ package dev.overlord.zomboidforge.patcher;
|
|||||||
|
|
||||||
import dev.overlord.zomboidforge.patcher.Patches.HookInjectionPatch;
|
import dev.overlord.zomboidforge.patcher.Patches.HookInjectionPatch;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.io.TempDir;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
import org.objectweb.asm.Label;
|
||||||
import org.objectweb.asm.MethodVisitor;
|
import org.objectweb.asm.MethodVisitor;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
@@ -20,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||||
import static org.objectweb.asm.Opcodes.ACC_STATIC;
|
import static org.objectweb.asm.Opcodes.ACC_STATIC;
|
||||||
|
import static org.objectweb.asm.Opcodes.ASTORE;
|
||||||
import static org.objectweb.asm.Opcodes.DUP;
|
import static org.objectweb.asm.Opcodes.DUP;
|
||||||
import static org.objectweb.asm.Opcodes.GETSTATIC;
|
import static org.objectweb.asm.Opcodes.GETSTATIC;
|
||||||
import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
|
import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
|
||||||
@@ -171,4 +176,105 @@ class HookInjectionPatchTest
|
|||||||
"t/Target", HookInjectionPatchTest.ANCHOR, new Hook("t/Hooks", "hook", "(I)V")
|
"t/Target", HookInjectionPatchTest.ANCHOR, new Hook("t/Hooks", "hook", "(I)V")
|
||||||
) {});
|
) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsHookThatReturnsAValue()
|
||||||
|
{
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> new HookInjectionPatch(
|
||||||
|
"t/Target", HookInjectionPatchTest.ANCHOR, new Hook("t/Hooks", "hook", "()Z")
|
||||||
|
) {});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hooks with arguments
|
||||||
|
|
||||||
|
private static final String CALLS = Type.getInternalName(HookInjectionPatchTest.Calls.class);
|
||||||
|
|
||||||
|
private static final Anchor.Call ARGUMENTS_ANCHOR = new Anchor.Call(
|
||||||
|
new Anchor.Method("run", "(JLjava/lang/String;)V"), HookInjectionPatchTest.CALLS, "anchor", "()V"
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final List<HookArgument> ARGUMENTS = List.of(
|
||||||
|
new HookArgument.Parameter(1),
|
||||||
|
new HookArgument.Parameter(0),
|
||||||
|
new HookArgument.Local("word")
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Stands in for the anchor call and the hook of {@link ArgumentPatch} and records the calls. */
|
||||||
|
public static final class Calls
|
||||||
|
{
|
||||||
|
public static final List<String> LOG = new ArrayList<>();
|
||||||
|
|
||||||
|
private Calls() {}
|
||||||
|
|
||||||
|
public static void anchor() { Calls.LOG.add("anchor"); }
|
||||||
|
|
||||||
|
public static void hook(String text, long number, String word) { Calls.LOG.add("hook " + text + " " + number + " " + word); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class ArgumentPatch extends HookInjectionPatch
|
||||||
|
{
|
||||||
|
ArgumentPatch(String hookDesc) {
|
||||||
|
super("t/Target", HookInjectionPatchTest.ARGUMENTS_ANCHOR, new Hook(HookInjectionPatchTest.CALLS, "hook", hookDesc), HookInjectionPatchTest.ARGUMENTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@code static run(long number, String text)}: {@code String word = "local"; Calls.anchor();}. */
|
||||||
|
private static byte[] argumentsTarget()
|
||||||
|
{
|
||||||
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
|
||||||
|
cw.visit(V25, ACC_PUBLIC, "t/Target", null, "java/lang/Object", null);
|
||||||
|
|
||||||
|
Label start = new Label();
|
||||||
|
Label end = new Label();
|
||||||
|
|
||||||
|
MethodVisitor run = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "run", "(JLjava/lang/String;)V", null, null);
|
||||||
|
run.visitLdcInsn("local");
|
||||||
|
run.visitVarInsn(ASTORE, 3);
|
||||||
|
run.visitLabel(start);
|
||||||
|
run.visitMethodInsn(INVOKESTATIC, HookInjectionPatchTest.CALLS, "anchor", "()V", false);
|
||||||
|
run.visitInsn(RETURN);
|
||||||
|
run.visitLabel(end);
|
||||||
|
run.visitLocalVariable("word", "Ljava/lang/String;", null, start, end, 3);
|
||||||
|
run.visitMaxs(0, 0);
|
||||||
|
|
||||||
|
cw.visitEnd();
|
||||||
|
return cw.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void clearLog() { HookInjectionPatchTest.Calls.LOG.clear(); }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void passesParametersAndLocalsToHook() throws Exception
|
||||||
|
{
|
||||||
|
Path in = this.jar(Map.of("t/Target.class", HookInjectionPatchTest.argumentsTarget()));
|
||||||
|
Path out = this.dir.resolve("patched.jar");
|
||||||
|
|
||||||
|
new JarPatcher(List.of(new ArgumentPatch("(Ljava/lang/String;JLjava/lang/String;)V"))).patch(in, out);
|
||||||
|
|
||||||
|
try (URLClassLoader loader = new URLClassLoader(new URL[]{out.toUri().toURL()}, HookInjectionPatchTest.class.getClassLoader()))
|
||||||
|
{
|
||||||
|
loader.loadClass("t.Target").getMethod("run", long.class, String.class).invoke(null, 7L, "text");
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(List.of("anchor", "hook text 7 local"), HookInjectionPatchTest.Calls.LOG);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void reportsHookWhoseParametersDoNotMatchTheArguments() throws Exception
|
||||||
|
{
|
||||||
|
Path in = this.jar(Map.of("t/Target.class", HookInjectionPatchTest.argumentsTarget()));
|
||||||
|
ArgumentPatch patch = new ArgumentPatch("(Ljava/lang/String;ILjava/lang/String;)V");
|
||||||
|
|
||||||
|
IllegalStateException e = assertThrows(
|
||||||
|
IllegalStateException.class,
|
||||||
|
() -> new JarPatcher(List.of(patch)).patch(in, this.dir.resolve("out.jar"))
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"'ArgumentPatch': Hook '" + patch.hook() + "' must have descriptor '(Ljava/lang/String;JLjava/lang/String;)V'"
|
||||||
|
+ " for the arguments [parameter 1, parameter 0, local 'word'].",
|
||||||
|
e.getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
package dev.overlord.zomboidforge.patcher;
|
||||||
|
|
||||||
|
import dev.overlord.zomboidforge.patcher.Patches.ReturnHookPatch;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
import org.objectweb.asm.Label;
|
||||||
|
import org.objectweb.asm.MethodVisitor;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||||
|
import static org.objectweb.asm.Opcodes.ACC_STATIC;
|
||||||
|
import static org.objectweb.asm.Opcodes.ACONST_NULL;
|
||||||
|
import static org.objectweb.asm.Opcodes.ALOAD;
|
||||||
|
import static org.objectweb.asm.Opcodes.ARETURN;
|
||||||
|
import static org.objectweb.asm.Opcodes.IFEQ;
|
||||||
|
import static org.objectweb.asm.Opcodes.ILOAD;
|
||||||
|
import static org.objectweb.asm.Opcodes.LRETURN;
|
||||||
|
import static org.objectweb.asm.Opcodes.V25;
|
||||||
|
|
||||||
|
class ReturnHookPatchTest
|
||||||
|
{
|
||||||
|
private static final String CALLS = Type.getInternalName(ReturnHookPatchTest.Calls.class);
|
||||||
|
|
||||||
|
private static final Anchor.Method PICK = new Anchor.Method("pick", "(Ljava/lang/String;Z)Ljava/lang/String;");
|
||||||
|
private static final Anchor.Method WIDE = new Anchor.Method("wide", "()J");
|
||||||
|
|
||||||
|
@TempDir
|
||||||
|
Path dir;
|
||||||
|
|
||||||
|
/** The hooks. */
|
||||||
|
public static final class Calls
|
||||||
|
{
|
||||||
|
private Calls() {}
|
||||||
|
|
||||||
|
public static String replaceNull(@Nullable String value, String input) { return "hook " + value + " " + input; }
|
||||||
|
|
||||||
|
public static long doubled(long value) { return value * 2; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Replaces the {@code null} that {@code pick} returns; the hook gets {@code input}. */
|
||||||
|
private static final class NullPatch extends ReturnHookPatch
|
||||||
|
{
|
||||||
|
NullPatch() {
|
||||||
|
super(
|
||||||
|
"t/Target",
|
||||||
|
new Anchor.Sequence(ReturnHookPatchTest.PICK, new Anchor.Instruction.Opcode(ACONST_NULL), new Anchor.Instruction.Opcode(ARETURN)),
|
||||||
|
new Hook(ReturnHookPatchTest.CALLS, "replaceNull", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
|
||||||
|
List.of(new HookArgument.Parameter(0))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Doubles the {@code long} that {@code wide} returns. */
|
||||||
|
private static final class WidePatch extends ReturnHookPatch
|
||||||
|
{
|
||||||
|
WidePatch() {
|
||||||
|
super(
|
||||||
|
"t/Target",
|
||||||
|
new Anchor.Sequence(ReturnHookPatchTest.WIDE, new Anchor.Instruction.Constant(5L), new Anchor.Instruction.Opcode(LRETURN)),
|
||||||
|
new Hook(ReturnHookPatchTest.CALLS, "doubled", "(J)J"),
|
||||||
|
List.of()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Anchored on {@code aconst_null} alone, not on a return instruction. */
|
||||||
|
private static final class NoReturnPatch extends ReturnHookPatch
|
||||||
|
{
|
||||||
|
NoReturnPatch() {
|
||||||
|
super(
|
||||||
|
"t/Target",
|
||||||
|
new Anchor.Sequence(ReturnHookPatchTest.PICK, new Anchor.Instruction.Opcode(ACONST_NULL)),
|
||||||
|
new Hook(ReturnHookPatchTest.CALLS, "replaceNull", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
|
||||||
|
List.of(new HookArgument.Parameter(0))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code static pick(String input, boolean keep)}: {@code return keep ? input : null;} and
|
||||||
|
* {@code static wide()}: {@code return 5L;}.
|
||||||
|
*/
|
||||||
|
private Path target() throws Exception
|
||||||
|
{
|
||||||
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
|
||||||
|
cw.visit(V25, ACC_PUBLIC, "t/Target", null, "java/lang/Object", null);
|
||||||
|
|
||||||
|
Label returnNull = new Label();
|
||||||
|
|
||||||
|
MethodVisitor pick = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "pick", ReturnHookPatchTest.PICK.desc(), null, null);
|
||||||
|
pick.visitVarInsn(ILOAD, 1);
|
||||||
|
pick.visitJumpInsn(IFEQ, returnNull);
|
||||||
|
pick.visitVarInsn(ALOAD, 0);
|
||||||
|
pick.visitInsn(ARETURN);
|
||||||
|
pick.visitLabel(returnNull);
|
||||||
|
pick.visitInsn(ACONST_NULL);
|
||||||
|
pick.visitInsn(ARETURN);
|
||||||
|
pick.visitMaxs(0, 0);
|
||||||
|
|
||||||
|
MethodVisitor wide = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "wide", ReturnHookPatchTest.WIDE.desc(), null, null);
|
||||||
|
wide.visitLdcInsn(5L);
|
||||||
|
wide.visitInsn(LRETURN);
|
||||||
|
wide.visitMaxs(0, 0);
|
||||||
|
|
||||||
|
cw.visitEnd();
|
||||||
|
|
||||||
|
Path jar = this.dir.resolve("in.jar");
|
||||||
|
|
||||||
|
try (ZipOutputStream zip = new ZipOutputStream(Files.newOutputStream(jar)))
|
||||||
|
{
|
||||||
|
zip.putNextEntry(new ZipEntry("t/Target.class"));
|
||||||
|
zip.write(cw.toByteArray());
|
||||||
|
zip.closeEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
return jar;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void replacesTheAnchoredReturnValueOnly() throws Exception
|
||||||
|
{
|
||||||
|
Path out = this.dir.resolve("patched.jar");
|
||||||
|
|
||||||
|
new JarPatcher(List.of(new NullPatch(), new WidePatch())).patch(this.target(), out);
|
||||||
|
|
||||||
|
try (URLClassLoader loader = new URLClassLoader(new URL[]{out.toUri().toURL()}, ReturnHookPatchTest.class.getClassLoader()))
|
||||||
|
{
|
||||||
|
Class<?> target = loader.loadClass("t.Target");
|
||||||
|
|
||||||
|
assertEquals("kept", target.getMethod("pick", String.class, boolean.class).invoke(null, "kept", true));
|
||||||
|
assertEquals("hook null input", target.getMethod("pick", String.class, boolean.class).invoke(null, "input", false));
|
||||||
|
assertEquals(10L, target.getMethod("wide").invoke(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void reportsAnchorThatDoesNotEndInAReturn() throws Exception
|
||||||
|
{
|
||||||
|
Path in = this.target();
|
||||||
|
|
||||||
|
IllegalStateException e = assertThrows(
|
||||||
|
IllegalStateException.class,
|
||||||
|
() -> new JarPatcher(List.of(new NoReturnPatch())).patch(in, this.dir.resolve("out.jar"))
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals("'NoReturnPatch': The last instruction of the anchor must be 'areturn'.", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsMethodWithoutReturnValue()
|
||||||
|
{
|
||||||
|
Anchor.Sequence anchor = new Anchor.Sequence(new Anchor.Method("run", "()V"), new Anchor.Instruction.Opcode(ARETURN));
|
||||||
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> new ReturnHookPatch("t/Target", anchor, new Hook("t/Hooks", "hook", "()V"), List.of()) {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsHookWhoseFirstParameterIsNotTheReturnType()
|
||||||
|
{
|
||||||
|
Anchor.Sequence anchor = new Anchor.Sequence(ReturnHookPatchTest.WIDE, new Anchor.Instruction.Opcode(LRETURN));
|
||||||
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> new ReturnHookPatch("t/Target", anchor, new Hook("t/Hooks", "hook", "(I)J"), List.of()) {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsHookThatReturnsAnotherType()
|
||||||
|
{
|
||||||
|
Anchor.Sequence anchor = new Anchor.Sequence(ReturnHookPatchTest.WIDE, new Anchor.Instruction.Opcode(LRETURN));
|
||||||
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> new ReturnHookPatch("t/Target", anchor, new Hook("t/Hooks", "hook", "(J)I"), List.of()) {});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user