Simplify editor metadata and publish core and addon schemas on release

This commit is contained in:
Ronan committed 2026-11-11 21:49:08 +01:00
1 parent 1d4389188f
commit c7a1a4e069
8 files changed
+379 -265

No files matched your search

@@ -0,0 +1,37 @@
name: Publish editor schema
on:
release:
types: [published]
permissions:
contents: write
jobs:
publish:
if: '!github.event.release.prerelease'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Prepare plugin-owned schemas
env:
SCHEMA_PATHS: BetterRTP-Core/src/main/resources/META-INF/editor-schema.json BetterRTPAddons/src/main/resources/META-INF/editor-schema.json
run: |
node --input-type=module <<'JS'
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
mkdirSync('editor-schemas');
for (const path of process.env.SCHEMA_PATHS.split(' ')) {
const bytes = readFileSync(path), meta = JSON.parse(bytes)['x-bettersync'];
if (meta?.format !== 1 || !/^[a-z0-9-]+$/.test(meta.plugin) || !/^[A-Za-z0-9._-]+$/.test(meta.schemaVersion)) throw new Error('Invalid schema identity');
writeFileSync(`editor-schemas/${meta.plugin}-${meta.schemaVersion}.schema.json`, bytes);
}
JS
- name: Attach schemas to this plugin release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: gh release upload "$RELEASE_TAG" editor-schemas/*.schema.json
+1 -1
View File
@@ -12,7 +12,7 @@
<!-- Upload patches to https://repo.ronanplugins.com/#/ -->
<properties>
<bettersync.version>1.1.0</bettersync.version>
<bettersync.version>2.0.0</bettersync.version>
<maven.compiler.release>8</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<editor.website>https://www.minecentral.net</editor.website>
@@ -1,84 +1,222 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schemas.ronanplugins.com/betterrtp/1",
"$id": "https://schemas.ronanplugins.com/betterrtp/2",
"title": "BetterRTP editor configuration",
"type": "object",
"required": [
"Settings",
"Default"
],
"properties": {
"Settings": {
"type": "object"
"type": "object",
"properties": {
"Respect": {
"type": "object",
"properties": {
"MinePlots": {
"type": "boolean"
},
"WorldGuard": {
"type": "boolean"
},
"GriefPrevention": {
"type": "boolean"
},
"Towny": {
"type": "boolean"
},
"RedProtect": {
"type": "boolean"
},
"FactionsUUID": {
"type": "boolean"
},
"Lands": {
"type": "boolean"
},
"Residence": {
"type": "boolean"
},
"KingdomsX": {
"type": "boolean"
},
"hClaims": {
"type": "boolean"
},
"GriefDefender": {
"type": "boolean"
},
"UltimateClaims": {
"type": "boolean"
},
"Pueblos": {
"type": "boolean"
},
"SaberFactions": {
"type": "boolean"
},
"HuskClaims": {
"type": "boolean"
},
"HuskTowns": {
"type": "boolean"
},
"FactionsBridge": {
"type": "boolean"
},
"CrashClaim": {
"type": "boolean"
}
}
},
"Debugger": {
"type": "boolean"
},
"PreloadRadius": {
"type": "number"
},
"MaxAttempts": {
"type": "number"
},
"RtpOnFirstJoin": {
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"World": {
"type": "string"
},
"SetAsRespawn": {
"type": "boolean"
}
}
},
"Cooldown": {
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"LockAfter": {
"type": "number"
},
"Time": {
"type": "number"
},
"PerWorld": {
"type": "boolean"
}
}
},
"Delay": {
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"Time": {
"type": "number"
},
"CancelOnMove": {
"type": "boolean"
}
}
},
"Queue": {
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
}
}
},
"DisableUpdater": {
"type": "boolean"
},
"Logger": {
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"LogToConsole": {
"type": "boolean"
},
"Format": {
"type": "string"
}
}
}
}
},
"Default": {
"type": "object",
"properties": {
"Biomes": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "string",
"pattern": "\\S"
"type": "string"
}
}
},
"x-ranges": [
{
"min": "MinRadius",
"max": "MaxRadius",
"strict": true
},
{
"min": "MinY",
"max": "MaxY",
"strict": false
"UseWorldBorder": {
"type": "boolean"
},
"MaxRadius": {
"type": "number"
},
"MinRadius": {
"type": "number"
},
"CenterX": {
"type": "number"
},
"CenterZ": {
"type": "number"
},
"Shape": {
"type": "string"
},
"MaxY": {
"type": "number"
},
"MinY": {
"type": "number"
},
"RTPOnDeath": {
"type": "boolean"
}
]
}
},
"Language-File": {
"type": "string",
"x-immutable": true,
"description": "Change the language file locally."
},
"BlacklistedBlocks": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "string",
"pattern": "\\S"
"type": "string"
}
},
"DisabledWorlds": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "string",
"pattern": "\\S"
"type": "string"
}
},
"Overrides": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "object",
"minProperties": 1,
"additionalProperties": {
"type": "string",
"x-entryName": true
"type": "string"
}
},
"x-named": true,
"x-editor": {
"collection": "overrides"
}
},
"WorldType": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "object",
"minProperties": 1,
"additionalProperties": {
"type": "string",
"enum": [
@@ -88,17 +226,14 @@
"x-caseInsensitive": true
}
},
"x-named": true,
"x-editor": {
"collection": "types"
}
},
"CustomWorlds": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "object",
"minProperties": 1,
"additionalProperties": {
"type": "object",
"properties": {
@@ -140,7 +275,6 @@
},
"Cooldown": {
"type": "integer",
"minimum": 0,
"default": 0
},
"RTPOnDeath": {
@@ -149,30 +283,15 @@
},
"Biomes": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "string",
"pattern": "\\S"
"type": "string"
}
}
},
"x-editableProperties": true,
"x-inherit": "Default",
"x-ranges": [
{
"min": "MinRadius",
"max": "MaxRadius",
"strict": true
},
{
"min": "MinY",
"max": "MaxY",
"strict": false
}
]
"x-inherit": "Default"
}
},
"x-named": true,
"x-editor": {
"collection": "worlds"
}
@@ -182,16 +301,12 @@
"properties": {
"Groups": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "object",
"minProperties": 1,
"additionalProperties": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "object",
"minProperties": 1,
"additionalProperties": {
"type": "object",
"properties": {
@@ -233,7 +348,6 @@
},
"Cooldown": {
"type": "integer",
"minimum": 0,
"default": 0
},
"RTPOnDeath": {
@@ -242,10 +356,8 @@
},
"Biomes": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "string",
"pattern": "\\S"
"type": "string"
}
},
"Priority": {
@@ -254,31 +366,20 @@
}
},
"x-editableProperties": true,
"x-inherit": "Default",
"x-ranges": [
{
"min": "MinRadius",
"max": "MaxRadius",
"strict": true
},
{
"min": "MinY",
"max": "MaxY",
"strict": false
}
]
"x-inherit": "Default"
}
},
"x-named": true,
"x-editor": {
"collection": "worlds"
}
}
},
"x-named": true,
"x-editor": {
"collection": "groups"
}
},
"Enabled": {
"type": "boolean"
}
}
}
@@ -286,58 +387,11 @@
"x-bettersync": {
"format": 1,
"plugin": "betterrtp",
"schemaVersion": "1",
"schemaVersion": "2",
"displayName": "BetterRTP"
},
"x-rules": [
{
"path": ".*Radius$",
"schema": {
"minimum": 0,
"maximum": 30000000
}
},
{
"path": ".*\\.(Time|LockAfter)$",
"schema": {
"minimum": 0
}
},
{
"path": ".*\\.PreloadRadius$",
"schema": {
"minimum": 0,
"maximum": 16
}
},
{
"path": ".*\\.MaxAttempts$",
"schema": {
"minimum": 1,
"maximum": 10000
}
},
{
"path": ".*\\.Shape$",
"schema": {
"enum": [
"square",
"circle"
],
"x-caseInsensitive": true
}
}
],
"x-objectRanges": [
{
"min": "MinRadius",
"max": "MaxRadius",
"strict": true
},
{
"min": "MinY",
"max": "MaxY",
"strict": false
}
"required": [
"Settings",
"Default"
]
}
+1 -1
View File
@@ -11,7 +11,7 @@
<properties>
<editor.website>https://www.minecentral.net</editor.website>
<bettersync.version>1.1.0</bettersync.version>
<bettersync.version>2.0.0</bettersync.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -1,18 +1,8 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schemas.ronanplugins.com/betterrtp-addons/1",
"$id": "https://schemas.ronanplugins.com/betterrtp-addons/2",
"title": "BetterRTP Addons editor configuration",
"type": "object",
"required": [
"Flashback",
"Logger",
"Portals",
"ExtraEffects",
"MagicStick",
"Commands",
"Parties",
"RTPMenu"
],
"properties": {
"Flashback": {
"type": "object",
@@ -21,28 +11,24 @@
"type": "object",
"properties": {
"Delay": {
"minimum": 0
"type": "number"
},
"Warnings": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "object",
"minProperties": 1,
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"pattern": "^[0-9]+$",
"x-maxNumericName": 2147483647
}
},
"x-named": true,
"x-editor": {
"collection": "warnings"
}
}
}
},
"Enabled": {
"type": "boolean"
}
}
},
@@ -50,16 +36,48 @@
"type": "object",
"properties": {
"Format": {
"type": "string",
"x-serverCheck": "date"
"type": "string"
},
"Enabled": {
"type": "boolean"
},
"LogToConsole": {
"type": "boolean"
}
}
},
"Portals": {
"type": "object"
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"IgnoreDelay": {
"type": "boolean"
},
"IgnoreCooldown": {
"type": "boolean"
}
}
},
"ExtraEffects": {
"type": "object"
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"YOffset": {
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"Offset": {
"type": "number"
}
}
}
}
},
"MagicStick": {
"type": "object",
@@ -68,9 +86,10 @@
"type": "object",
"properties": {
"Amount": {
"type": "integer",
"minimum": 1,
"maximum": 64
"type": "integer"
},
"Enabled": {
"type": "boolean"
}
}
},
@@ -78,36 +97,89 @@
"type": "object",
"properties": {
"Material": {
"type": "string",
"x-serverCheck": "material"
"type": "string"
},
"Name": {
"type": "string"
},
"Lore": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"Enabled": {
"type": "boolean"
},
"Take": {
"type": "boolean"
}
}
},
"Commands": {
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"Events": {
"type": "object",
"properties": {
"Teleport": {
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"Commands": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"Cancelled": {
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"Commands": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
},
"Commands": {
"type": "object"
},
"Parties": {
"type": "object"
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
}
}
},
"RTPMenu": {
"type": "object",
"properties": {
"Lines": {
"type": "integer",
"minimum": 1,
"maximum": 6
"type": "integer"
},
"AutoRefresh": {
"minimum": 0
"type": "number"
},
"WorldList": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "object",
"minProperties": 1,
"additionalProperties": {
"type": "object",
"properties": {
@@ -117,101 +189,57 @@
},
"Item": {
"type": "string",
"default": "MAP",
"x-serverCheck": "material"
"default": "MAP"
},
"Slot": {
"type": "integer",
"minimum": 0,
"default": 0,
"x-lessThan": {
"path": "RTPMenu.Lines",
"multiply": 9
}
"default": 0
},
"Lore": {
"type": "array",
"maxItems": 1000,
"items": {
"type": "string"
},
"default": []
}
},
"x-editableProperties": true,
"x-defaultChecks": {
"Slot": 0
}
"x-editableProperties": true
}
},
"x-named": true,
"x-editor": {
"collection": "menu"
}
},
"Enabled": {
"type": "boolean"
},
"Title": {
"type": "string"
},
"AutoCenter": {
"type": "boolean"
}
}
},
"Language-File": {
"type": "string",
"x-immutable": true,
"description": "Change the language file locally."
}
},
"x-bettersync": {
"format": 1,
"plugin": "betterrtp-addons",
"schemaVersion": "1",
"schemaVersion": "2",
"displayName": "BetterRTP Addons"
},
"x-rules": [
{
"path": ".*Radius$",
"schema": {
"minimum": 0,
"maximum": 30000000
}
},
{
"path": ".*\\.(Time|LockAfter)$",
"schema": {
"minimum": 0
}
},
{
"path": ".*\\.PreloadRadius$",
"schema": {
"minimum": 0,
"maximum": 16
}
},
{
"path": ".*\\.MaxAttempts$",
"schema": {
"minimum": 1,
"maximum": 10000
}
},
{
"path": ".*\\.Shape$",
"schema": {
"enum": [
"square",
"circle"
],
"x-caseInsensitive": true
}
}
],
"x-objectRanges": [
{
"min": "MinRadius",
"max": "MaxRadius",
"strict": true
},
{
"min": "MinY",
"max": "MaxY",
"strict": false
}
"required": [
"Flashback",
"Logger",
"Portals",
"ExtraEffects",
"MagicStick",
"Commands",
"Parties",
"RTPMenu"
]
}
+19 -14
View File
@@ -56,8 +56,8 @@ The wiki is available [here](../../wiki)!
## Shared editor library
The web editor uses [BetterSync](https://github.com/RonanPlugins/BetterSync),
downloaded by Maven from JitPack as `com.github.RonanPlugins:BetterSync:1.1.0`.
No local BetterSync project or manual Maven install is required. Release `1.1.0` is published on JitPack. Update `bettersync.version` in the plugin and editor-test
downloaded by Maven from JitPack as `com.github.RonanPlugins:BetterSync:2.0.0`.
No local BetterSync project or manual Maven install is required. Release `2.0.0` is published on JitPack. Update `bettersync.version` in the plugin and editor-test
POMs together when upgrading. Shade bundles and relocates the library into the
plugin JAR; server owners do not install a separate BetterSync plugin.
@@ -67,17 +67,22 @@ maintained in BetterSync.
### Editor schema ownership
Each plugin module owns `src/main/resources/META-INF/editor-schema.json`. Edit rules here,
not in the website or BetterSync's deprecated legacy profiles. `EditorSchema.load` reads
this resource from the plugin JAR; the client sends its independent `schemaVersion` and
checks the version returned by the website before applying changes.
Each plugin module owns `src/main/resources/META-INF/editor-schema.json` and packages
it in its JAR. It describes field types, lists, defaults and form collection hints.
BetterSync checks basic types and required sections; it does not enforce business
rules such as ranges, material names or relationships between fields.
Publish the same schema bytes as a public BetterSync GitHub release asset, then add the
asset URL and SHA-256 to the website's `editor-schemas.lock.json`. Keep old versions in the
lock for older servers. A changed rule requires a new schema version; plugin bug fixes
that do not affect configuration can retain the version. Schema publication does not
publish the rest of a private plugin repository.
When a stable GitHub release is published, `.github/workflows/publish-editor-schema.yml`
attaches the schema from that exact release tag to this repository's release. BetterRTP
publishes both Core and Addons schemas. The workflow uses the built-in GitHub token;
no cross-repository publishing secret is needed. Release tags must include the workflow
and the schema resource. Do not replace a published schema; increment `schemaVersion`
when changing field metadata.
Deploy the matching website and its schema-version database migrations before installing
the new plugin JARs. Schema resources are bundled automatically by Maven; no sibling
plugin/library checkout is needed to compile this project.
Website builds discover this repository's latest stable release and download its schema.
No plugin checkout or local Maven install is needed. The website uses a build-only token
with Contents read access for private repositories. It must be rebuilt after the schema
publication workflow succeeds. An unsupported plugin schema version is rejected until
the corresponding website build is deployed.
Use the website's schema-version database migrations before deploying these clients.
+1 -1
View File
@@ -1,7 +1,7 @@
<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>me.SuperRonanCraft</groupId><artifactId>betterrtp-editor-tests</artifactId><version>1.0</version>
<properties><bettersync.version>1.1.0</bettersync.version><maven.compiler.release>8</maven.compiler.release><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties>
<properties><bettersync.version>2.0.0</bettersync.version><maven.compiler.release>8</maven.compiler.release><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties>
<repositories><repository><id>spigot</id><url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url></repository><repository><id>jitpack.io</id><url>https://jitpack.io</url></repository></repositories>
<dependencies>
<dependency><groupId>com.github.RonanPlugins</groupId><artifactId>BetterSync</artifactId><version>${bettersync.version}</version></dependency>
@@ -27,27 +27,17 @@ public class EditorConfigTest {
@Test public void rejectsInvalidAddonSettingsAndUnsafeYaml() throws Exception {
String before = addons();
for (String after : new String[] {
before.replace("Lines: 3", "Lines: 7"), before.replace("Slot: 3", "Slot: 27"),
before.replace("AutoRefresh: 0", "AutoRefresh: -1"), before.replace("600:", "bad:"),
before.replace("en.yml", "other.yml"), before + "Bad: &anchor value\n",
before.replace("Lines: 3", "Lines: wrong"), before + "Bad: &anchor value\n",
before + "Bad: !!java/object something\n", before + "Bad:\n ==: org.bukkit.inventory.ItemStack\n" }) {
try { SchemaConfig.validate(before, after); fail("Expected addon validation failure"); }
catch (java.io.IOException expected) { }
}
try { SchemaConfig.validate(original, before); fail("Expected cross-plugin failure"); }
catch (java.io.IOException expected) { }
}
@Test public void acceptsValidChange() throws Exception { SchemaConfig.validate(original, original.replace("1000", "2000")); }
@Test public void rejectsWrongTypeAndRange() throws Exception {
rejected(original.replace("1000", "false"));
rejected(original.replace("1000", "5"));
rejected(original.replace("square", "triangle"));
rejected(original.replace("PreloadRadius: 5", "PreloadRadius: 5000"));
}
@Test public void rejectsSchemaAndLanguageChanges() throws Exception {
rejected(original + "Injected: true\n");
rejected(original.replace("en.yml", "../secrets.yml"));
rejected(original.replace(" Shape: square\n", ""));
SchemaConfig.validate(original, original.replace("1000", "5"));
SchemaConfig.validate(original, original + "Injected: true\n");
}
@Test public void rejectsAliasesAndTags() throws Exception {
rejected(original + "Alias: &x value\n");
@@ -94,7 +84,7 @@ public class EditorConfigTest {
try (java.util.stream.Stream<Path> files = Files.list(root)) {
for (Path file : (Iterable<Path>) files::iterator) {
String value = new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
if (file.getFileName().toString().startsWith("invalid-")) {
if (java.util.Arrays.asList("invalid-world-setting.yml", "invalid-biome.yml", "invalid-group-shape.yml", "invalid-target.yml").contains(file.getFileName().toString())) {
try { SchemaConfig.validate(baseline, value); fail("Expected rejection: " + file); }
catch (java.io.IOException expected) { }
} else SchemaConfig.validate(baseline, value);