Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ jobs:
with:
persist-credentials: false

- name: Install shared plugin dependencies
uses: TF-Minecraft/TLibs/.github/actions/setup-plugins@8ef41de589f121c98ff892b10696e7c1feb4ca74
with:
mode: pinned

- name: Set up JDK 21
uses: actions/setup-java@v6
with:
Expand Down Expand Up @@ -51,6 +56,11 @@ jobs:
PLUGIN_VERSION: ${{ steps.dev.outputs.version }}
run: mvn -B --no-transfer-progress -f integration-tests/pom.xml "-Dcompanionpets.version=$PLUGIN_VERSION" clean package

- name: Compile isolated ownership fixture
env:
PLUGIN_VERSION: ${{ steps.dev.outputs.version }}
run: mvn -B --no-transfer-progress -f integration-tests/ownership/pom.xml "-Dcompanionpets.version=$PLUGIN_VERSION" clean package

- name: Verify runtime JAR
env:
ARTIFACT_PATH: ${{ steps.dev.outputs.jar }}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
}
[[ "${TAG^^}" != *SNAPSHOT* ]] || exit 1

- name: Install shared plugin dependencies
uses: TF-Minecraft/TLibs/.github/actions/setup-plugins@8ef41de589f121c98ff892b10696e7c1feb4ca74
with:
mode: pinned

- name: Set version from tag and build
id: maven
env:
Expand All @@ -64,7 +69,8 @@ jobs:
run: |
python3 .github/scripts/plugin-artifact.py \
--jar "$ARTIFACT_PATH" --version "${TAG#v}" \
--stage "$RUNNER_TEMP/plugin-release"
--stage "$RUNNER_TEMP/plugin-release" \
--dependencies .build/plugin-dependencies.json

- uses: actions/upload-artifact@v7
with:
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ CompanionPets gives players a companion that lives beyond a single entity. Each
pet hatches from an egg with its own name, sex, personality, and favourite toy,
and keeps its needs, bond, and learned tricks between summons. Vanilla wolves,
cats, and foxes need no model plugin; ModelEngine, MythicMobs, MMOItems, and
ItemsAdder are optional.
ItemsAdder are optional. TLibs 2.6.0 and a ready character identity provider
(supplied by RPCharacters) are required for pet ownership actions. Pets and Pet
Houses belong to their character; account-wide capacity limits remain shared.

## Features

Expand All @@ -24,7 +26,7 @@ ItemsAdder are optional.
- **Configurable species** — per-type bodies, eggs, interaction items, learnable
tricks, optional behaviours, and custom tricks, with optional ModelEngine models
and animations. Resting pets look around with bounded head movement.
- **Staff tools** — browse, locate, and create pets for any player, give eggs,
- **Staff tools** — browse, locate, and create pets for a living character, give eggs,
and audit every staff intervention.
- **Pet recovery** — keep pets and their learning across restarts, including pets
left outside their Pet House.
Expand All @@ -41,7 +43,7 @@ Technical documentation is maintained in [TF-Minecraft/Docs](https://github.com/

## Tests

With Java 21 and Maven installed, run:
With Java 21 and the pinned plugin dependencies installed, run:

```sh
mvn clean verify
Expand Down
23 changes: 23 additions & 0 deletions integration-tests/ownership/LegacyApiCheck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import java.net.URLClassLoader;
import java.nio.file.Path;

/** Run with current Paper API dependencies on the parent classpath; load actual old TLibs separately. */
public final class LegacyApiCheck {
public static void main(String[] args) throws Exception {
try (var loader = new URLClassLoader(new java.net.URL[]{Path.of(args[0]).toUri().toURL(),Path.of(args[1]).toUri().toURL()},LegacyApiCheck.class.getClassLoader()) {
@Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
if (name.startsWith("net.tfminecraft.companionpets.") || name.startsWith("net.tfminecraft.tlibs.")) {
Class<?> type=findLoadedClass(name);if(type==null)type=findClass(name);if(resolve)resolveClass(type);return type;
}
return super.loadClass(name,resolve);
}
}) {
Class<?> identity=loader.loadClass("net.tfminecraft.companionpets.ownership.CharacterAccess");
if(!Boolean.FALSE.equals(identity.getMethod("available").invoke(null)))throw new AssertionError("Old TLibs incorrectly accepts character ownership migration");
if(!Boolean.FALSE.equals(identity.getMethod("heirReady").invoke(null)))throw new AssertionError("Old provider readiness must fail closed");
Class<?> estates=loader.loadClass("net.tfminecraft.companionpets.estate.EstateProbe");
if(!Boolean.FALSE.equals(estates.getMethod("available").invoke(null)))throw new AssertionError("Old TLibs incorrectly accepts estate API");
System.out.println("{\"passed\":true,\"checks\":3,\"legacyJar\":\""+args[1]+"\"}");
}
}
}
20 changes: 20 additions & 0 deletions integration-tests/ownership/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Loopback ownership fixture

Build after the parent plugin's verified install:

```sh
tfmc-mvn -o -B -f integration-tests/ownership/pom.xml clean package
```

Use a fresh isolated Paper 1.21.10 directory, TLibs 2.6.0 and CompanionPets, loopback IP `127.0.0.1`, port `25583`, offline mode and a disposable world. This probe refuses other addresses/ports. Connect the synthetic offline account `S6PetProbe`; no real character files are required. The fixture registers a fake identity provider, creates its own pet/store and verifies actual native following under A, switches the same connected account to B, checks outgoing prompts/training, native-selector exclusion, swimming safety and body reattachment. It writes `plugins/CompanionPetsOwnershipProbe/result.json`, logs each check and shuts the isolated server down. Never install it on Main or Dev.

With `native-combat: true`, the probe sets real native owner combat memories and verifies both owner-assist goals select A's target and reject same-account B; native self-defense remains registered. The probe also starts an actual training navigation goal under A and verifies it cannot remain active under B. `OWNERSHIP_PROOF PASS` and `result.json.passed=true` are both required; a successful Maven compilation alone is not runtime evidence.

`LegacyApiCheck.java` loads CompanionPets classes and an actual older TLibs JAR in an isolated classloader, with the normal Paper API dependencies on the parent classpath:

```sh
javac -cp "$PAPER_API_CLASSPATH" -d /tmp/cp-legacy-check integration-tests/ownership/LegacyApiCheck.java
java -cp "/tmp/cp-legacy-check:$PAPER_API_CLASSPATH" LegacyApiCheck target/classes /path/to/tlibs-2.3.0.jar
```

All three character/estate capability checks must report false without linkage failure. Use test dependencies as the API classpath; do not include an old TLibs JAR on the parent classpath.
49 changes: 49 additions & 0 deletions integration-tests/ownership/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.tfminecraft</groupId>
<artifactId>companionpets-ownership-probe</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<companionpets.version>main-SNAPSHOT</companionpets.version>
</properties>
<dependencies>
<dependency>
<groupId>net.tfminecraft</groupId>
<artifactId>companionpets</artifactId>
<version>${companionpets.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.plugins</groupId>
<artifactId>tlibs</artifactId>
<version>2.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
</plugin>
</plugins>
</build>
</project>
Loading
Loading