element plugin make sure compatible for different plugin
📎
1 file
11,213 chars
đź“„
pasted-code-1794918132949.txt
txt
177 lines
â–¶
pasted-code-1794918132949.txt
txt
177 lines
ELEMENTAL PLUGIN: OPERATOR TESTING COMMANDS (Complete Specification)
1. Overview and Core Guarantee
Three administrative commands for testing the elemental progression system, plus one helper command:
/element max
/element reset
/element restore
/element backups (lists available backups)
Every operation must be transactional, UUID-protected, reward-neutral, and auditable. A failed operation leaves the original progression unchanged.
Each command operates on a single target player’s data only. It must never modify other players’ data, the player’s assigned element, or global server state.
2. Permissions and Access Control
Required: elemental.admin or server operator status.
The permission check runs before argument parsing and before any data is loaded.
Denied users see You do not have permission to use this command. and no data is read or modified.
Commands are hidden from tab-completion for players without permission.
Console is allowed. Command blocks are blocked by default (allow-command-blocks: false).
A global toggle admin-commands.enabled can disable all of these commands in production.
3. Command Syntax and Arguments
Command Description
/element max Maximize progression for the player’s current element
/element reset [--confirm] Reset progression for the player’s current element
/element restore [--confirm] Restore progression from a backup
/element backups List the player’s backups
accepts an online name, an offline name (resolved via server cache), or a UUID. Resolve to a UUID once at the start, then use only the UUID.
Tab-complete online players first, then known offline players. Tab-complete from the target’s own backups only.
Invalid or missing arguments show: Usage: /element ...
Unknown player or no saved data: No saved elemental data found for .
4. /element max
Purpose: Bring the target to full progression in their currently assigned element.
Preconditions: The target has an assigned element. If not: Error: has no assigned element. No changes made. Abort with zero writes.
Actions (one atomic operation):
Complete all 5 quests for the assigned element.
Unlock all abilities and upgrades.
Set elemental XP and level to their configured maximums (read from config, never hardcoded).
Unlock all applicable Earth X-ray abilities.
Leave the assigned element unchanged.
Rules:
Idempotent: running it twice produces the same end state, with no duplicate unlocks or rewards.
Quests are marked complete through a silent state-setting path that bypasses the normal quest-completion reward pipeline.
Max requires no confirmation.
5. /element reset
Purpose: Return the target’s current element progression to a clean starting state.
Preconditions: The target has an assigned element (same error and zero writes if not).
Confirmation (when require-confirm-for-reset: true): Running without the flag responds:
Warning: This will reset 's progression. A backup will be created. Use /element reset --confirm to continue.
No data is modified, no backup is made, and the attempt is logged as CONFIRMATION_REQUIRED until --confirm is supplied.
Actions (one atomic operation, after a verified backup):
Reset quest progress and completion flags.
Reset elemental XP and level to starting values.
Remove all unlocked abilities and upgrades.
Reset all ability cooldowns and the flight allowance.
Reset applicable X-ray unlocks.
Re-grant only the starting passive ability of the currently assigned element.
Keep the assigned element unchanged.
6. /element restore
Permission: elemental.admin or operator.
Flow:
Validate permission, UUID, and that the backup belongs to the target UUID (reject backups from any other UUID).
Validate the backup: schema version, checksum, and structure.
Show a confirmation (when require-confirm-for-restore: true):
Warning: This will restore 's Elemental progression from backup . A new backup of the current state will be created. Use /element restore --confirm to continue.
On --confirm: create and verify a PRE_RESTORE backup of the current state, then apply the restore.
Rules:
Restore only the target’s Elemental progression.
Never change the assigned element or element ownership. If the backup’s element differs from the current element, abort with a clear message.
Restore silently: no quest rewards, level-up rewards, or special Tridents.
If the PRE_RESTORE backup fails, cancel the restore.
7. Automatic Backups
Before every reset (and restore), create and verify a backup.
Contents: quests and completion flags, XP and level, unlocked abilities and upgrades, cooldowns, flight allowance, X-ray unlocks, assigned element (reference only), schema version, creating admin, and reason (PRE_RESET or PRE_RESTORE).
Storage: plugins/Elemental/backups//-.json, keyed by UUID and timestamp.
Never overwrite previous backups. On a filename collision, append a counter.
Write to a temp file, then atomically rename. Verify that the file exists, is readable, and matches its checksum.
If backup creation or verification fails, cancel the operation, make zero changes, and log FAILED:backup.
Optional retention (max-per-player): delete the oldest only beyond the limit, never during the operation that created the newest backup.
8. UUID and Ownership Protection
UUID is the permanent player identity. Never use a player’s name as the primary database key.
Before any write, verify that:
The progression record’s owner-uuid equals the target UUID.
The record’s element equals the target’s currently assigned element.
If the element was transferred to another player, never modify the new owner’s data. Abort with Ownership mismatch for . No changes made. and log it.
The persistence layer rejects any write where writeUuid != targetUuid.
Only modify the target’s own saved progression for their currently assigned element.
9. Safe Ability Cleanup (Reset)
Cancel only tasks, effects, and states registered by the Elemental plugin (track them in a per-player registry).
Do not remove potion effects, attribute modifiers, or boss bars owned by other plugins. Identify Elemental’s by namespaced keys or UUIDs. Do not interfere with unrelated plugin abilities.
Flight: end Elemental flight and land the player safely. Suppress fall damage from the forced landing through a short, self-expiring grace flag that affects no other damage.
Remove Elemental boss bars, particles, cooldown timers, scheduled tasks, and temporary ability states.
Do not remove, refund, or re-issue items the player already holds.
10. Transaction Model and Data Integrity
For max, reset, and restore:
Resolve the UUID and validate permission, ownership, and preconditions.
Acquire a per-player lock so concurrent commands or saves on the same UUID are serialized.
Load the current state into a working copy.
Create and verify the backup (reset and restore).
Build the new state in memory and validate it.
Swap and save atomically (temp file plus rename, or a database transaction).
Apply live effects on the main thread.
Log the result.
On any failure: roll back to the original state, report the error, and log FAILED:.
Online players: modify live in-memory data, update HUD and scoreboard immediately, then save.
Offline players: load by UUID, modify, and save. If the data is missing, corrupt, or locked, abort with an error and no partial writes.
Threading: mutate live data on the main (or data-owner) thread. Load and save offline data asynchronously, then apply results on the main thread.
11. Reward Neutrality
No command may give items, currency, XP bonuses, or special Tridents, nor create duplicates of any of them.
Max must not trigger the Trident unlock reward. Reset and restore must not remove or re-issue Tridents the player already owns.
If other systems need events (quest complete, level-up, ability unlock), fire them with source = ADMIN_COMMAND, and all reward listeners must skip rewards for that source.
12. Logging and Auditing
Log every execution, including failures, permission denials, and unconfirmed attempts, to the server log and optionally admin-audit.log:
[ELEMENT-ADMIN] | admin= () | action= | target= () | element= | backup= | online= | result=
Optionally log a before/after summary (level, XP, quest count, ability count) and notify online admins with elemental.admin.notify.
13. Feedback Messages
Max success: Maxed progression for .
Reset success: Reset progression for . Backup saved as . Starting passive restored.
Restore success: Restored 's progression from backup .
Optional message to the affected online player (notify-target-player).
Distinct, clear errors for: no permission, no element, player not found, data unavailable, confirmation required, backup failed, backup not found, backup belongs to another UUID, ownership mismatch, element mismatch.
14. Configuration
yaml
admin-commands:
enabled: true
allow-command-blocks: false
require-confirm-for-reset: true
require-confirm-for-restore: true
notify-target-player: true
audit-log-file: admin-audit.log
backups:
directory: backups
max-per-player: 20
verify-checksum: true
15. Acceptance Criteria
A normal player runs any command: denied, no data change, logged.
max on a player with no element: error, no changes.
max twice: same state, no duplicate unlocks or rewards.
After max: 5/5 quests, max level and XP, all abilities, X-ray if applicable, element unchanged.
reset clears quests, XP, level, abilities, cooldowns, flight allowance, and X-ray; only the starting passive remains; element unchanged.
reset without --confirm changes nothing and creates no backup.
reset creates a backup containing all listed fields before changing data.
If backup creation fails, the reset is cancelled and data is unchanged.
Two resets create two separate backups, with no overwrite.
reset mid-flight ends flight safely with no fall damage, and normal fall damage works afterward.
reset does not remove other plugins’ potion effects, attributes, or boss bars.
restore returns the exact saved progression; element unchanged; no rewards or Tridents.
restore creates a PRE_RESTORE backup first; if that fails, the restore is cancelled.
Restoring a backup that belongs to a different UUID is rejected.
If the element was transferred, the command aborts and the new owner’s data is untouched.
All commands work on offline players with valid data and fail cleanly if data is missing.
Other players’ data is byte-for-byte unchanged after any command.
No special Tridents or reward items are created by any command.
Every execution (success or failure) produces an audit log entry.
A crash or exception mid-command leaves no half-applied state.
Concurrent admin commands on the same player are serialized, with no corrupted data.
KodariTue at 12:23 pm 1
ElementalAdminTools
A comprehensive administrative command suite for managing elemental progression in Minecraft. Provides four transactional commands: max, reset, restore, and backups. Features UUID-based ownership protection, atomic operations with rollback, automatic verified backups before destructive actions, confirmation flags, reward-neutral execution, per-player locking for concurrency safety, offline player support, and detailed audit logging. Includes safe ability cleanup that respects other plugins' effects, configurable settings for confirmations and backup retention, and comprehensive error handling with distinct feedback messages for every failure scenario.
Which elemental plugin should these commands manage, and how does it store player progression? Please share its name and, if available, its API documentation or a sample player data file.
The specification doesn’t define the underlying progression system, so I can’t safely implement ownership checks, backups, or live cleanup for another plugin without those details.
Kodari can make mistakes. Review important code before using.
Files
No files in this session
Code