mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-11-28 00:34:36 +00:00
editor sync cmd
This commit is contained in:
1 parent
9f0801fda4
commit
c2a45e8b7b
9 files changed
+137
-86
No files matched your search
+28
-32
@@ -1,45 +1,41 @@
|
||||
# Free command editor
|
||||
|
||||
`/rtp editor` opens a temporary web session for the existing `config.yml`. It does not register the server, require a premium plan, or require Discord. `/rtp editor cancel` stops the active session. Permission: `betterrtp.editor` (default: op), including permission to write config and reload BetterRTP. Existing `/rtp edit` is unchanged.
|
||||
`/rtp editor` creates a private, 24-hour web session for `config.yml`. It requires a player with `betterrtp.editor` (default: op), but no Discord login or premium. `/rtp editor cancel` revokes the current session and all its saved tokens; only its creator may cancel it. One session is active per running server. Existing `/rtp edit` is unchanged.
|
||||
|
||||
## Setup
|
||||
## Setup and use
|
||||
|
||||
1. Deploy the companion BetterRTP-Webapp with PostgreSQL. Apply its committed Drizzle migrations, set `EDITOR_ENABLED=true`, and set `APP_ORIGIN=https://minecentral.net`.
|
||||
2. Build/install this plugin. The editor website is fixed to `https://minecentral.net`; there is no website setting or `editor.yml` resource. Any old editor.yml file is ignored.
|
||||
3. Run `/rtp editor`. Open the private chat link, edit the YAML, and choose **Save and apply to server**. Download is also available. A player who started the session must remain online with permission when applying; console-created sessions use console authority.
|
||||
4. The UI first shows pending. It shows applied only after the plugin has validated, backed up, written, reloaded, verified the loaded/persisted settings, and acknowledged the result.
|
||||
1. Deploy the companion website with PostgreSQL and apply its migrations using `pnpm db:deploy`. Protocol 2 requires migration `0002_editor_command_sync`. Set `APP_ORIGIN` to the deployed website origin. The editor API is available by default.
|
||||
2. Install the matching plugin build and restart Minecraft. Normal builds target `https://minecentral.net`; staging builds target the test website below. There is no website setting or `editor.yml` resource.
|
||||
3. As a player, run `/rtp editor` and open the private link. The website displays the target label and `config.yml` as read-only context.
|
||||
4. Edit and click **Save and get sync command**. This stores an immutable version; nothing is applied to Minecraft yet.
|
||||
5. Run `/betterrtp editorsync <token>` as the same player on the same server. The plugin downloads that version over HTTPS, checks permission again, validates it, backs up the current file, atomically replaces it, and reloads BetterRTP.
|
||||
|
||||
No inbound ports on the Minecraft server are needed. The plugin calls the website over HTTPS every three seconds while a session is active. Outbound HTTPS must be permitted. Certificate checks remain enabled, and redirects are refused.
|
||||
There are no inbound Minecraft connections and no automatic polling. Allow outbound HTTPS. TLS certificate validation remains enabled and redirects are refused. Never publish editor links or command tokens; Minecraft command logging plugins may capture sync commands.
|
||||
|
||||
## Limits and failure handling
|
||||
## Expiry, versions, and errors
|
||||
|
||||
- One active editor per running server; fifteen-minute expiry and one submitted save. Start a fresh session for further edits. Cancelling cannot undo a write already in progress.
|
||||
- Only `config.yml`, at most 128 KiB. Economy, database, language and other files are not exposed. Changing `Language-File` is blocked.
|
||||
- Existing setting names and structured world/group entries must remain. Values and scalar lists may change. Numeric ranges and setting types are checked, with conservative limits for preload radius and attempts. YAML tags, anchors and aliases are rejected. The conservative parser also rejects literal equals signs and encoded character escapes to prevent Bukkit object-deserialization markers; edit such unusual configs locally. This is structural validation plus selected semantic checks, not a version-complete schema for every integration.
|
||||
- A file changed since the session snapshot is rejected. Do not edit the file externally during apply: external processes do not participate in the plugin's lock/checks.
|
||||
- Backups are written to `plugins/BetterRTP/editor-backups/` before replacement. Maintain/rotate these backups as appropriate for your server.
|
||||
- Atomic replacement is required. Reload exceptions or a detected reload mismatch restore the original file and attempt another reload. If that reload also fails, restart the server; plugins/integrations may have partially changed in-memory state.
|
||||
- Network failure retries until expiry. After a local apply result, only the acknowledgement is retried, never the write. A crash/restart cancels the in-memory session; it never resumes applying queued edits. If an acknowledgement is lost or the plugin crashes after writing, the website can show pending until expiry: inspect the live config and server messages before starting over.
|
||||
- Anyone with the browser link can submit its one edit until it expires. Permission is checked at creation and again before applying. Do not share links, paste them into public chat, or run them through third-party link tools. Browser tokens are in URL fragments; plugin tokens never reach the browser.
|
||||
- Editor sessions expire 24 hours after creation without activity extending them. Each save has an independent 15-minute, single-use sync token. Saving again does not invalidate previous tokens, and syncing does not close the editor session.
|
||||
- Expiring an editor stops new saves; existing save tokens retain their own deadlines. To replace the current session before its final tokens expire, its creator must use `/rtp editor cancel` first. Cancelling revokes all remaining tokens.
|
||||
- Session expiry preserves the browser text for download. The personal config library and Discord login are not implemented yet.
|
||||
- Tokens are consumed atomically when downloaded. If a response is lost, local validation fails, or the player disconnects before application, save again for a fresh token. The plugin does not retry writes. Minecraft reports the apply outcome; the website does not report generated commands as applied.
|
||||
- The creator must still be online and hold `betterrtp.editor` at apply time. Restarting/disabling the plugin discards its in-memory session, so old tokens cannot be applied by that plugin instance after restart.
|
||||
- Invalid content is rejected before any file change. Validation preserves the existing setting structure and types, checks selected numeric ranges, blocks Language-File changes and unsafe Bukkit YAML constructs, and limits config size to 128 KiB. This is conservative validation, not a complete schema for every integration.
|
||||
- Intervening edits to the Minecraft config do not block syncing: applying a saved version can overwrite those edits. A backup of the current file is created in `plugins/BetterRTP/editor-backups/`; rotate backups as appropriate.
|
||||
- If writing succeeds but reload fails, the new file stays in place and a reload error is reported. There is no automatic rollback. Check Minecraft's console and reload after resolving the failure.
|
||||
- The website trusts the plugin-supplied target label for display only. The private plugin-session capability and player UUID bind redemption to the original session; browser target fields cannot redirect a write.
|
||||
|
||||
The website is trusted with the submitted config; this protocol is not end-to-end encrypted against the hosting operator. Restrict DB access and avoid putting secrets in the main config. The one-time session grants no persistent premium server access.
|
||||
|
||||
## Validation
|
||||
|
||||
Run `mvn -f tests/editor/pom.xml test` for the isolated config validator/file-write suite. It uses the actual Spigot YAML implementation without requiring all of the plugin's protection integrations. Run `mvn package` for the full plugin. Before production use, test the complete flow on a staging Minecraft server, including permissions, disconnect, reload failure and Folia scheduling if applicable.
|
||||
Protocol 1 automatic-apply clients are intentionally incompatible with protocol 2. The website migration closes existing protocol 1 sessions. Update website/database and plugin together for testing.
|
||||
|
||||
## Production and staging builds
|
||||
|
||||
The normal `mvn clean package` build embeds `https://minecentral.net` and produces
|
||||
`target/BetterRTP-3.6.13.jar`. Use `mvn clean package -Pstaging` to embed
|
||||
`https://n2nm1thopoojau1ggnalixvr.minecentral.net` and produce
|
||||
`target/BetterRTP-3.6.13-staging.jar` for the test Minecraft server.
|
||||
Run `mvn clean package` for `target/BetterRTP-3.6.13.jar`, targeting `https://minecentral.net`.
|
||||
Run `mvn clean package -Pstaging` for `target/BetterRTP-3.6.13-staging.jar`, targeting
|
||||
`https://n2nm1thopoojau1ggnalixvr.minecentral.net`.
|
||||
|
||||
The address is filtered into internal JAR metadata at build time. It is not read
|
||||
from `editor.yml`, a server-side file, or an environment variable. Upload only one
|
||||
BetterRTP JAR to a server's plugins directory. The staging website should use its
|
||||
own origin as `APP_ORIGIN` and have the editor enabled and migrations applied.
|
||||
The address is internal JAR build metadata, not a server configuration or environment setting. Upload only one BetterRTP JAR to the plugins directory. Use the staging website origin as its `APP_ORIGIN` and apply the database migration there.
|
||||
|
||||
This profile changes only the destination website. The implementation described
|
||||
above still uses the original polling protocol; the agreed `editorsync` command,
|
||||
24-hour sessions, and independent 15-minute save tokens remain implementation work.
|
||||
## Validation
|
||||
|
||||
Run `mvn -f tests/editor/pom.xml test` for configuration validation/file-write tests and `mvn package -Pstaging` for the full staging plugin. The web repository's `pnpm test` exercises version isolation, atomic single-use redemption, creator/server binding, independent expiry, cancellation, validation, and limits against embedded PostgreSQL.
|
||||
|
||||
Before production use, test the complete flow on the staging Minecraft server, including wrong-player denial, permission loss, disconnect, expiry, repeated saves, intervening local changes, reload errors, restart, and Folia scheduling if applicable. Local automated checks do not substitute for this staging run.
|
||||
Reference in new issue
Block a user