Cover terrain service NPCs and fix Citizens test imports

This commit is contained in:
unimatrixgit 2026-11-29 01:58:16 +01:00
commit b11145bfbb
8 changed files with 1161 additions and 1125 deletions

View file

@ -56,7 +56,8 @@ jobs:
set -euo pipefail set -euo pipefail
python3 tools/test_gameplay_resourcepack.py -v python3 tools/test_gameplay_resourcepack.py -v
python3 tools/build-gameplay-resourcepack.py --from-gui-config DuneRealmsGUI/src/main/resources/gui-pack.yml --output "plugin-artifacts/DuneRealms-Gameplay-${GITHUB_SHA}.zip" python3 tools/build-gameplay-resourcepack.py --from-gui-config DuneRealmsGUI/src/main/resources/gui-pack.yml --output "plugin-artifacts/DuneRealms-Gameplay-${GITHUB_SHA}.zip"
(cd plugin-artifacts && sha256sum -- *.jar *.zip *.manifest.json SOURCE_COMMIT > SHA256SUMS) python3 tools/write-plugin-manifest.py plugin-artifacts "$GITHUB_SHA"
(cd plugin-artifacts && sha256sum -- *.jar *.zip *.json SOURCE_COMMIT > SHA256SUMS)
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: DuneRealms-Plugins name: DuneRealms-Plugins

View file

@ -1,5 +1,6 @@
name: DuneRealms Resourcepack CI name: DuneRealms Resourcepack CI
on: on:
workflow_dispatch:
push: push:
branches: [main] branches: [main]
paths: paths:

View file

@ -9,6 +9,7 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.*; import net.citizensnpcs.api.npc.*;
import net.citizensnpcs.api.npc.NPC;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;

View file

@ -33,3 +33,5 @@ tasks.assemble { dependsOn(highlandsDatapack) }
val mockitoAgent by configurations.creating val mockitoAgent by configurations.creating
dependencies { mockitoAgent("org.mockito:mockito-core:5.15.2") { isTransitive = false } } dependencies { mockitoAgent("org.mockito:mockito-core:5.15.2") { isTransitive = false } }
tasks.test { jvmArgs("-javaagent:${mockitoAgent.singleFile.absolutePath}") } tasks.test { jvmArgs("-javaagent:${mockitoAgent.singleFile.absolutePath}") }
sourceSets.main { java.srcDir("../citizens-common/src/main/java") }

View file

@ -275,7 +275,7 @@ public final class DuneTerrain extends JavaPlugin implements Listener {
return new PlanetBiomeProvider(this, planet); return new PlanetBiomeProvider(this, planet);
} }
@Override public void onEnable() { @Override public void onEnable() { com.dunerealms.npc.CitizensBridge.start(this,new NamespacedKey("dunerealms","spice-seller"));
saveDefaultConfig(); saveDefaultConfig();
String formations = "planets.arrakis.darkstone-islands."; String formations = "planets.arrakis.darkstone-islands.";
if (getConfig().getInt(formations + "min-radius") == 10 if (getConfig().getInt(formations + "min-radius") == 10

View file

@ -4,4 +4,4 @@ main: com.example.duneterrain.DuneTerrain
api-version: '1.21' api-version: '1.21'
load: STARTUP load: STARTUP
description: Configurable Dune planet terrain and spawn generator for Paper description: Configurable Dune planet terrain and spawn generator for Paper
softdepend: [DuneEss] softdepend: [Citizens, DuneEss]

View file

@ -190,7 +190,7 @@ public final class CitizensBridge implements Listener {
private void convert(LivingEntity legacy, Object registry) throws ReflectiveOperationException { private void convert(LivingEntity legacy, Object registry) throws ReflectiveOperationException {
var marker = keys.stream().sorted(Comparator.comparing(NamespacedKey::toString)).filter(key -> legacy.getPersistentDataContainer().has(key)).findFirst().orElseThrow(); var marker = keys.stream().sorted(Comparator.comparing(NamespacedKey::toString)).filter(key -> legacy.getPersistentDataContainer().has(key)).findFirst().orElseThrow();
String markerValue = legacy.getPersistentDataContainer().has(marker, PersistentDataType.STRING) ? legacy.getPersistentDataContainer().get(marker, PersistentDataType.STRING) : null; String markerValue = legacy.getPersistentDataContainer().has(marker, PersistentDataType.STRING) ? legacy.getPersistentDataContainer().get(marker, PersistentDataType.STRING) : null;
boolean unique = marker.toString().equals("dunecore:smuggler"); boolean unique = marker.toString().equals("dunecore:smuggler") || marker.toString().equals("dunerealms:spice-seller");
String stable = plugin.getName() + ":" + legacy.getWorld().getUID() + ":" + marker + ":" + (unique ? identity(legacy) : markerValue == null ? "1" : markerValue); String stable = plugin.getName() + ":" + legacy.getWorld().getUID() + ":" + marker + ":" + (unique ? identity(legacy) : markerValue == null ? "1" : markerValue);
Object npc = null; Object npc = null;
for (Object candidate : (Iterable<?>) registry) if (stable.equals(read(candidate, "dr-id"))) { npc = candidate; break; } for (Object candidate : (Iterable<?>) registry) if (stable.equals(read(candidate, "dr-id"))) { npc = candidate; break; }

View file

@ -0,0 +1,31 @@
"""Record versions and hashes from the actual built plugin JARs."""
import hashlib
import json
from pathlib import Path
import re
import sys
import zipfile
def manifest(folder, commit):
plugins = []
for path in sorted(Path(folder).glob('*.jar')):
with zipfile.ZipFile(path) as jar:
description = jar.read('plugin.yml').decode()
fields = {}
for key in ('name', 'version', 'main'):
match = re.search(r'^' + key + r':\s*(.+?)\s*$', description, re.M)
if not match:
raise ValueError(f'Missing {key} in {path.name}')
fields[key] = match.group(1).strip('"\'')
plugins.append({**fields, 'filename': path.name,
'sha256': hashlib.sha256(path.read_bytes()).hexdigest()})
if not plugins:
raise ValueError('No plugin artifacts')
result = {'sourceCommit': commit, 'plugins': plugins}
(Path(folder) / 'release-manifest.json').write_text(json.dumps(result, indent=2) + '\n')
return result
if __name__ == '__main__':
print(json.dumps(manifest(sys.argv[1], sys.argv[2]), indent=2))