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/#/ --> <!-- Upload patches to https://repo.ronanplugins.com/#/ -->
<properties> <properties>
<bettersync.version>1.1.0</bettersync.version> <bettersync.version>2.0.0</bettersync.version>
<maven.compiler.release>8</maven.compiler.release> <maven.compiler.release>8</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<editor.website>https://www.minecentral.net</editor.website> <editor.website>https://www.minecentral.net</editor.website>
@@ -1,84 +1,222 @@
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$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", "title": "BetterRTP editor configuration",
"type": "object", "type": "object",
"required": [
"Settings",
"Default"
],
"properties": { "properties": {
"Settings": { "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": { "Default": {
"type": "object", "type": "object",
"properties": { "properties": {
"Biomes": { "Biomes": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "string", "type": "string"
"pattern": "\\S"
} }
}
},
"x-ranges": [
{
"min": "MinRadius",
"max": "MaxRadius",
"strict": true
}, },
{ "UseWorldBorder": {
"min": "MinY", "type": "boolean"
"max": "MaxY", },
"strict": false "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": { "Language-File": {
"type": "string", "type": "string",
"x-immutable": true,
"description": "Change the language file locally." "description": "Change the language file locally."
}, },
"BlacklistedBlocks": { "BlacklistedBlocks": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "string", "type": "string"
"pattern": "\\S"
} }
}, },
"DisabledWorlds": { "DisabledWorlds": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "string", "type": "string"
"pattern": "\\S"
} }
}, },
"Overrides": { "Overrides": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "object", "type": "object",
"minProperties": 1,
"additionalProperties": { "additionalProperties": {
"type": "string", "type": "string"
"x-entryName": true
} }
}, },
"x-named": true,
"x-editor": { "x-editor": {
"collection": "overrides" "collection": "overrides"
} }
}, },
"WorldType": { "WorldType": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "object", "type": "object",
"minProperties": 1,
"additionalProperties": { "additionalProperties": {
"type": "string", "type": "string",
"enum": [ "enum": [
@@ -88,17 +226,14 @@
"x-caseInsensitive": true "x-caseInsensitive": true
} }
}, },
"x-named": true,
"x-editor": { "x-editor": {
"collection": "types" "collection": "types"
} }
}, },
"CustomWorlds": { "CustomWorlds": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "object", "type": "object",
"minProperties": 1,
"additionalProperties": { "additionalProperties": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -140,7 +275,6 @@
}, },
"Cooldown": { "Cooldown": {
"type": "integer", "type": "integer",
"minimum": 0,
"default": 0 "default": 0
}, },
"RTPOnDeath": { "RTPOnDeath": {
@@ -149,30 +283,15 @@
}, },
"Biomes": { "Biomes": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "string", "type": "string"
"pattern": "\\S"
} }
} }
}, },
"x-editableProperties": true, "x-editableProperties": true,
"x-inherit": "Default", "x-inherit": "Default"
"x-ranges": [
{
"min": "MinRadius",
"max": "MaxRadius",
"strict": true
},
{
"min": "MinY",
"max": "MaxY",
"strict": false
}
]
} }
}, },
"x-named": true,
"x-editor": { "x-editor": {
"collection": "worlds" "collection": "worlds"
} }
@@ -182,16 +301,12 @@
"properties": { "properties": {
"Groups": { "Groups": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "object", "type": "object",
"minProperties": 1,
"additionalProperties": { "additionalProperties": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "object", "type": "object",
"minProperties": 1,
"additionalProperties": { "additionalProperties": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -233,7 +348,6 @@
}, },
"Cooldown": { "Cooldown": {
"type": "integer", "type": "integer",
"minimum": 0,
"default": 0 "default": 0
}, },
"RTPOnDeath": { "RTPOnDeath": {
@@ -242,10 +356,8 @@
}, },
"Biomes": { "Biomes": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "string", "type": "string"
"pattern": "\\S"
} }
}, },
"Priority": { "Priority": {
@@ -254,31 +366,20 @@
} }
}, },
"x-editableProperties": true, "x-editableProperties": true,
"x-inherit": "Default", "x-inherit": "Default"
"x-ranges": [
{
"min": "MinRadius",
"max": "MaxRadius",
"strict": true
},
{
"min": "MinY",
"max": "MaxY",
"strict": false
}
]
} }
}, },
"x-named": true,
"x-editor": { "x-editor": {
"collection": "worlds" "collection": "worlds"
} }
} }
}, },
"x-named": true,
"x-editor": { "x-editor": {
"collection": "groups" "collection": "groups"
} }
},
"Enabled": {
"type": "boolean"
} }
} }
} }
@@ -286,58 +387,11 @@
"x-bettersync": { "x-bettersync": {
"format": 1, "format": 1,
"plugin": "betterrtp", "plugin": "betterrtp",
"schemaVersion": "1", "schemaVersion": "2",
"displayName": "BetterRTP" "displayName": "BetterRTP"
}, },
"x-rules": [ "required": [
{ "Settings",
"path": ".*Radius$", "Default"
"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
}
] ]
} }
+1 -1
View File
@@ -11,7 +11,7 @@
<properties> <properties>
<editor.website>https://www.minecentral.net</editor.website> <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.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -1,18 +1,8 @@
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$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", "title": "BetterRTP Addons editor configuration",
"type": "object", "type": "object",
"required": [
"Flashback",
"Logger",
"Portals",
"ExtraEffects",
"MagicStick",
"Commands",
"Parties",
"RTPMenu"
],
"properties": { "properties": {
"Flashback": { "Flashback": {
"type": "object", "type": "object",
@@ -21,28 +11,24 @@
"type": "object", "type": "object",
"properties": { "properties": {
"Delay": { "Delay": {
"minimum": 0 "type": "number"
}, },
"Warnings": { "Warnings": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "object", "type": "object",
"minProperties": 1,
"additionalProperties": { "additionalProperties": {
"type": "string" "type": "string"
},
"propertyNames": {
"pattern": "^[0-9]+$",
"x-maxNumericName": 2147483647
} }
}, },
"x-named": true,
"x-editor": { "x-editor": {
"collection": "warnings" "collection": "warnings"
} }
} }
} }
},
"Enabled": {
"type": "boolean"
} }
} }
}, },
@@ -50,16 +36,48 @@
"type": "object", "type": "object",
"properties": { "properties": {
"Format": { "Format": {
"type": "string", "type": "string"
"x-serverCheck": "date" },
"Enabled": {
"type": "boolean"
},
"LogToConsole": {
"type": "boolean"
} }
} }
}, },
"Portals": { "Portals": {
"type": "object" "type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"IgnoreDelay": {
"type": "boolean"
},
"IgnoreCooldown": {
"type": "boolean"
}
}
}, },
"ExtraEffects": { "ExtraEffects": {
"type": "object" "type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"YOffset": {
"type": "object",
"properties": {
"Enabled": {
"type": "boolean"
},
"Offset": {
"type": "number"
}
}
}
}
}, },
"MagicStick": { "MagicStick": {
"type": "object", "type": "object",
@@ -68,9 +86,10 @@
"type": "object", "type": "object",
"properties": { "properties": {
"Amount": { "Amount": {
"type": "integer", "type": "integer"
"minimum": 1, },
"maximum": 64 "Enabled": {
"type": "boolean"
} }
} }
}, },
@@ -78,36 +97,89 @@
"type": "object", "type": "object",
"properties": { "properties": {
"Material": { "Material": {
"type": "string", "type": "string"
"x-serverCheck": "material" },
"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": { "Parties": {
"type": "object" "type": "object",
"properties": {
"Enabled": {
"type": "boolean"
}
}
}, },
"RTPMenu": { "RTPMenu": {
"type": "object", "type": "object",
"properties": { "properties": {
"Lines": { "Lines": {
"type": "integer", "type": "integer"
"minimum": 1,
"maximum": 6
}, },
"AutoRefresh": { "AutoRefresh": {
"minimum": 0 "type": "number"
}, },
"WorldList": { "WorldList": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "object", "type": "object",
"minProperties": 1,
"additionalProperties": { "additionalProperties": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -117,101 +189,57 @@
}, },
"Item": { "Item": {
"type": "string", "type": "string",
"default": "MAP", "default": "MAP"
"x-serverCheck": "material"
}, },
"Slot": { "Slot": {
"type": "integer", "type": "integer",
"minimum": 0, "default": 0
"default": 0,
"x-lessThan": {
"path": "RTPMenu.Lines",
"multiply": 9
}
}, },
"Lore": { "Lore": {
"type": "array", "type": "array",
"maxItems": 1000,
"items": { "items": {
"type": "string" "type": "string"
}, },
"default": [] "default": []
} }
}, },
"x-editableProperties": true, "x-editableProperties": true
"x-defaultChecks": {
"Slot": 0
}
} }
}, },
"x-named": true,
"x-editor": { "x-editor": {
"collection": "menu" "collection": "menu"
} }
},
"Enabled": {
"type": "boolean"
},
"Title": {
"type": "string"
},
"AutoCenter": {
"type": "boolean"
} }
} }
}, },
"Language-File": { "Language-File": {
"type": "string", "type": "string",
"x-immutable": true,
"description": "Change the language file locally." "description": "Change the language file locally."
} }
}, },
"x-bettersync": { "x-bettersync": {
"format": 1, "format": 1,
"plugin": "betterrtp-addons", "plugin": "betterrtp-addons",
"schemaVersion": "1", "schemaVersion": "2",
"displayName": "BetterRTP Addons" "displayName": "BetterRTP Addons"
}, },
"x-rules": [ "required": [
{ "Flashback",
"path": ".*Radius$", "Logger",
"schema": { "Portals",
"minimum": 0, "ExtraEffects",
"maximum": 30000000 "MagicStick",
} "Commands",
}, "Parties",
{ "RTPMenu"
"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
}
] ]
} }
+19 -14
View File
@@ -56,8 +56,8 @@ The wiki is available [here](../../wiki)!
## Shared editor library ## Shared editor library
The web editor uses [BetterSync](https://github.com/RonanPlugins/BetterSync), The web editor uses [BetterSync](https://github.com/RonanPlugins/BetterSync),
downloaded by Maven from JitPack as `com.github.RonanPlugins:BetterSync:1.1.0`. downloaded by Maven from JitPack as `com.github.RonanPlugins:BetterSync:2.0.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 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 POMs together when upgrading. Shade bundles and relocates the library into the
plugin JAR; server owners do not install a separate BetterSync plugin. plugin JAR; server owners do not install a separate BetterSync plugin.
@@ -67,17 +67,22 @@ maintained in BetterSync.
### Editor schema ownership ### Editor schema ownership
Each plugin module owns `src/main/resources/META-INF/editor-schema.json`. Edit rules here, Each plugin module owns `src/main/resources/META-INF/editor-schema.json` and packages
not in the website or BetterSync's deprecated legacy profiles. `EditorSchema.load` reads it in its JAR. It describes field types, lists, defaults and form collection hints.
this resource from the plugin JAR; the client sends its independent `schemaVersion` and BetterSync checks basic types and required sections; it does not enforce business
checks the version returned by the website before applying changes. 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 When a stable GitHub release is published, `.github/workflows/publish-editor-schema.yml`
asset URL and SHA-256 to the website's `editor-schemas.lock.json`. Keep old versions in the attaches the schema from that exact release tag to this repository's release. BetterRTP
lock for older servers. A changed rule requires a new schema version; plugin bug fixes publishes both Core and Addons schemas. The workflow uses the built-in GitHub token;
that do not affect configuration can retain the version. Schema publication does not no cross-repository publishing secret is needed. Release tags must include the workflow
publish the rest of a private plugin repository. 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 Website builds discover this repository's latest stable release and download its schema.
the new plugin JARs. Schema resources are bundled automatically by Maven; no sibling No plugin checkout or local Maven install is needed. The website uses a build-only token
plugin/library checkout is needed to compile this project. 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"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>me.SuperRonanCraft</groupId><artifactId>betterrtp-editor-tests</artifactId><version>1.0</version> <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> <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> <dependencies>
<dependency><groupId>com.github.RonanPlugins</groupId><artifactId>BetterSync</artifactId><version>${bettersync.version}</version></dependency> <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 { @Test public void rejectsInvalidAddonSettingsAndUnsafeYaml() throws Exception {
String before = addons(); String before = addons();
for (String after : new String[] { for (String after : new String[] {
before.replace("Lines: 3", "Lines: 7"), before.replace("Slot: 3", "Slot: 27"), before.replace("Lines: 3", "Lines: wrong"), before + "Bad: &anchor value\n",
before.replace("AutoRefresh: 0", "AutoRefresh: -1"), before.replace("600:", "bad:"),
before.replace("en.yml", "other.yml"), before + "Bad: &anchor value\n",
before + "Bad: !!java/object something\n", before + "Bad:\n ==: org.bukkit.inventory.ItemStack\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"); } try { SchemaConfig.validate(before, after); fail("Expected addon validation failure"); }
catch (java.io.IOException expected) { } 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 acceptsValidChange() throws Exception { SchemaConfig.validate(original, original.replace("1000", "2000")); }
@Test public void rejectsWrongTypeAndRange() throws Exception { @Test public void rejectsWrongTypeAndRange() throws Exception {
rejected(original.replace("1000", "false")); rejected(original.replace("1000", "false"));
rejected(original.replace("1000", "5")); SchemaConfig.validate(original, original.replace("1000", "5"));
rejected(original.replace("square", "triangle")); SchemaConfig.validate(original, original + "Injected: true\n");
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", ""));
} }
@Test public void rejectsAliasesAndTags() throws Exception { @Test public void rejectsAliasesAndTags() throws Exception {
rejected(original + "Alias: &x value\n"); rejected(original + "Alias: &x value\n");
@@ -94,7 +84,7 @@ public class EditorConfigTest {
try (java.util.stream.Stream<Path> files = Files.list(root)) { try (java.util.stream.Stream<Path> files = Files.list(root)) {
for (Path file : (Iterable<Path>) files::iterator) { for (Path file : (Iterable<Path>) files::iterator) {
String value = new String(Files.readAllBytes(file), StandardCharsets.UTF_8); 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); } try { SchemaConfig.validate(baseline, value); fail("Expected rejection: " + file); }
catch (java.io.IOException expected) { } catch (java.io.IOException expected) { }
} else SchemaConfig.validate(baseline, value); } else SchemaConfig.validate(baseline, value);