Online editor + auto deployment/releases (#264)

* web editor

* editor command help

* editor sync cmd

* removed same user restriction

* removed player executed restriction

* no server identifier sent to server

* editor url updated

* config harsher verification + send world names to editor api

* no more session controls

* addons editor commands

* moved rtp to /betterrtp-core to create a better env for maven compiling

* bettersync lib

* Own core and addon editor schemas with BetterSync validation

* Simplify editor metadata and publish core and addon schemas on release

* Release core and addons together using their Maven versions

* Exclude unavailable ProtocolLib executor snapshot from Addons build

* betterrtp compiling
This commit is contained in:
RonanCraft authored and GitHub committed 2026-11-12 14:17:03 -05:00
1 parent 4697f06163
commit c8c5a04a59
224 files changed
+2041 -388

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
<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>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>
<dependency><groupId>org.spigotmc</groupId><artifactId>spigot-api</artifactId><version>1.8.8-R0.1-SNAPSHOT</version><exclusions><exclusion><groupId>net.md-5</groupId><artifactId>bungeecord-chat</artifactId></exclusion></exclusions></dependency>
<dependency><groupId>net.md-5</groupId><artifactId>bungeecord-chat</artifactId><version>1.16-R0.4</version></dependency>
<dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.13.2</version><scope>test</scope></dependency>
</dependencies>
<build>
<sourceDirectory>../../BetterRTP-Core/src/main/java</sourceDirectory>
<plugins>
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.14.0</version><configuration><includes><include>**/web/editor/*.java</include></includes></configuration></plugin>
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>3.5.3</version></plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,105 @@
import org.junit.Test;
import static org.junit.Assert.*;
import java.nio.file.*;
import java.nio.charset.StandardCharsets;
public class EditorConfigTest {
private final String original = "Language-File: en.yml\nSettings:\n MaxAttempts: 32\n PreloadRadius: 5\nDefault:\n MinRadius: 10\n MaxRadius: 1000\n Shape: square\n Biomes: []\n";
private void rejected(String edited) throws Exception {
try { SchemaConfig.validate(original, edited); fail("Expected rejection"); }
catch (java.io.IOException expected) { }
}
private String addons() throws Exception {
return new String(Files.readAllBytes(Paths.get("../../BetterRTPAddons/src/main/resources/config.yml")), StandardCharsets.UTF_8);
}
@Test public void acceptsAddonDefaultsAndCollectionEdits() throws Exception {
String before = addons();
SchemaConfig.validate(before, before);
String after = before.replace("600: ", "300: ").replace("world_nether:", "survival:").replace("Lines: 3", "Lines: 4");
SchemaConfig.validate(before, after);
Path dir = Files.createTempDirectory("addons-editor");
Path file = dir.resolve("config.yml");
Files.write(file, before.getBytes(StandardCharsets.UTF_8));
Path backup = SchemaConfig.apply(file, before.getBytes(StandardCharsets.UTF_8), after, () -> {});
assertEquals(before, new String(Files.readAllBytes(backup), StandardCharsets.UTF_8));
assertTrue(SchemaConfig.equivalent(after, new String(Files.readAllBytes(file), StandardCharsets.UTF_8)));
}
@Test public void rejectsInvalidAddonSettingsAndUnsafeYaml() throws Exception {
String before = addons();
for (String after : new String[] {
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) { }
}
}
@Test public void acceptsValidChange() throws Exception { SchemaConfig.validate(original, original.replace("1000", "2000")); }
@Test public void rejectsWrongTypeAndRange() throws Exception {
rejected(original.replace("1000", "false"));
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");
rejected(original + "Tag: !!java/object foo\n");
rejected(original + "Object:\n ==: org.bukkit.inventory.ItemStack\n");
}
@Test public void validatesBundledConfig() throws Exception {
String bundled = new String(Files.readAllBytes(Paths.get("../../BetterRTP-Core/src/main/resources/config.yml")), StandardCharsets.UTF_8);
SchemaConfig.validate(bundled, bundled.replace("MaxRadius: 1000\n", "MaxRadius: 2000\n"));
}
@Test public void allowsStaleWritesAndKeepsNewFileAfterReloadFailure() throws Exception {
Path dir = Files.createTempDirectory("betterrtp-editor-apply"); Path file = dir.resolve("config.yml");
byte[] snapshot = original.getBytes(StandardCharsets.UTF_8);
try {
Files.write(file, snapshot);
String edited = original.replace("1000", "2000");
Path backup = SchemaConfig.apply(file, snapshot, edited, () -> {});
assertArrayEquals(snapshot, Files.readAllBytes(backup));
assertTrue(SchemaConfig.equivalent(edited, new String(Files.readAllBytes(file), StandardCharsets.UTF_8)));
// The original snapshot is now stale; applying it is intentionally allowed.
SchemaConfig.apply(file, snapshot, original, () -> {});
assertArrayEquals(snapshot, Files.readAllBytes(file));
byte[] current = Files.readAllBytes(file);
final int[] reloads = { 0 };
try {
SchemaConfig.apply(file, current, edited, () -> { reloads[0]++; throw new java.io.IOException("Simulated reload failure"); });
fail("Reload should fail");
} catch (java.io.IOException expected) { }
assertEquals(1, reloads[0]);
assertArrayEquals(edited.getBytes(StandardCharsets.UTF_8), Files.readAllBytes(file));
byte[] unchanged = Files.readAllBytes(file);
try { SchemaConfig.apply(file, snapshot, "broken: [", () -> fail("Must not reload")); fail("Must reject invalid config"); }
catch (Exception expected) { }
assertArrayEquals(unchanged, Files.readAllBytes(file));
} finally {
try (java.util.stream.Stream<Path> files = Files.walk(dir)) {
files.sorted(java.util.Comparator.reverseOrder()).forEach(p -> { try { Files.delete(p); } catch (java.io.IOException e) { throw new RuntimeException(e); } });
}
}
}
@Test public void validatesCollectionFixtures() throws Exception {
Path root = Paths.get("src/test/resources/collections");
String baseline = new String(Files.readAllBytes(root.resolve("baseline.yml")), StandardCharsets.UTF_8);
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 (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);
}
}
}
@Test public void replacesAtomicallyAndBoundsReads() throws Exception {
Path dir = Files.createTempDirectory("betterrtp-editor-test"); Path file = dir.resolve("config.yml");
try {
Files.write(file, original.getBytes(StandardCharsets.UTF_8));
byte[] replacement = original.replace("1000", "2000").getBytes(StandardCharsets.UTF_8);
SchemaConfig.replace(file, replacement); assertArrayEquals(replacement, SchemaConfig.read(file));
Files.write(file, new byte[SchemaConfig.MAX_BYTES + 1]);
try { SchemaConfig.read(file); fail("Oversized read"); } catch (java.io.IOException expected) { }
} finally { Files.deleteIfExists(file); Files.deleteIfExists(dir); }
}
}
@@ -0,0 +1,19 @@
import com.ronanplugins.bettersync.editor.EditorSchema;
import com.ronanplugins.bettersync.editor.EditorFiles;
import java.nio.file.*;
import java.nio.charset.StandardCharsets;
/** Tests the actual plugin-owned resource, not BetterSync's legacy profile. */
final class SchemaConfig {
static final int MAX_BYTES = EditorFiles.MAX_BYTES;
private static EditorSchema schema(String text) throws Exception {
return new EditorSchema(new String(Files.readAllBytes(Paths.get(text.contains("Flashback:") ? "../../BetterRTPAddons/src/main/resources/META-INF/editor-schema.json" : "../../BetterRTP-Core/src/main/resources/META-INF/editor-schema.json")), StandardCharsets.UTF_8));
}
static void validate(String before, String after) throws Exception { schema(before).validate(before, after); }
static boolean equivalent(String before, String after) throws Exception { return schema(before).equivalent(before, after); }
static Path apply(Path file, byte[] before, String after, EditorFiles.Reload reload) throws Exception {
return EditorFiles.apply(schema(new String(before, StandardCharsets.UTF_8)), file, before, after, reload);
}
static byte[] read(Path file) throws Exception { return EditorFiles.read(file); }
static void replace(Path file, byte[] bytes) throws Exception { EditorFiles.replace(file, bytes); }
}
@@ -0,0 +1,25 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,25 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: [false]
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,26 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
- lobby: nether
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,23 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip: false
@@ -0,0 +1,25 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MinRadius: 3000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,25 @@
Language-File: other.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,25 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Cooldown: -1
@@ -0,0 +1,25 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
Injected: true
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,25 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: false
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,25 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: END
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,24 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,25 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: false
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,28 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
- resource:
Shape: circle
MaxRadius: 5000
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,25 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: []
DisabledWorlds: [prison]
Overrides: []
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0
@@ -0,0 +1,29 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- hub: survival
- resource: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
MaxRadius: 2000
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- staff:
- survival:
Priority: 2
Biomes: [forest]
Cooldown: 30
- member: []
@@ -0,0 +1,24 @@
Language-File: en.yml
Settings:
MaxAttempts: 32
Default:
MinRadius: 10
MaxRadius: 1000
MinY: 0
MaxY: 320
Biomes: []
BlacklistedBlocks: [water]
DisabledWorlds: [prison]
Overrides:
- lobby: world
WorldType:
- world: NORMAL
CustomWorlds:
- world:
Future: unchanged
PermissionGroup:
Enabled: true
Groups:
- vip:
- world:
Priority: 0