Build Prompt: LavaDisBot.jar
Role
You are building a Minecraft Paper plugin named LavaDisBot.jar. Its sole purpose is to host and manage the runtime lifecycle of an already-existing Discord bot called Aurora Bot (TypeScript/Node.js, Discord.js, Prisma, Redis, PostgreSQL). You are NOT building a Discord bot, a DiscordSRV-style chat bridge, or an AutoMod plugin. You are building a process supervisor.
Hard Constraints (do not violate)
- Do NOT recreate, simplify, rewrite, or port any of Aurora Bot's existing commands/systems (moderation, AutoMod, warnings, kick/ban/timeout, purge, utility, help, server/user info, security, welcome/events, DB layer, command framework, event handlers, permissions, embeds).
- Do NOT convert TypeScript/Discord.js commands into Java.
- Do NOT execute TypeScript inside the JVM directly — launch it via a real Node.js process (bundled or system Node).
- Do NOT implement chat sync, AutoMod, or "fake" commands.
- Do NOT expose arbitrary shell execution to players (no
/lavadis exec, no OS command passthrough). - Do NOT print or log secrets (Discord token, DB password, Redis password, API keys) to Minecraft console.
- Do NOT block the Paper main thread with process start/stop/log I/O — everything async, with Bukkit API calls marshalled back to the main thread only when required.
- Do NOT leave orphaned Node.js processes after the Minecraft server stops.
- Do NOT auto-download files from untrusted/arbitrary URLs.
Architecture
runtime:
type: "bundled" # or "system"
node-path: "runtime/node"
bot:
auto-restart: true
max-restarts: 5
restart-delay: 5000 # ms, with exponential backoff: 5s,10s,20s,30s,60s
environment:
NODE_ENV: "production"
DISCORD_TOKEN: ""
CLIENT_ID: ""
GUILD_ID: ""
DATABASE_URL: ""
REDIS_URL: ""
logging:
enabled: true
max-lines: 500
forward-to-console: true
resources:
memory:
enabled: true
max-mb: 1024
cpu:
enabled: false
Plugin responsibilities: start, stop, restart, monitor, capture logs, detect crashes, auto-restart with backoff, manage env vars, manage config, report resource usage/status, expose admin commands.
Directory Layout
Paper Server → LavaDisBot.jar → Runtime Manager → Node.js Runtime → Aurora Bot (Node/TS) → Discord API
Config (config.yml)
plugins/LavaDisBot/
├── config.yml
├── bot/ # existing Aurora Bot app, unmodified
├── runtime/ # bundled Node.js runtime
├── logs/
├── data/
└── cache/
Process Manager API (Java side)
Implement a BotProcessManager with:
startBot(), stopBot(), restartBot() — async, non-blockingisRunning(), getPid(), getUptime(), getExitCode()- Crash detection (unexpected exit, startup failure, invalid env, Node failure, Discord login failure)
- Restart backoff sequence with a configurable max-attempts cap to prevent crash loops
- Log capture (stdout/stderr) into a bounded ring buffer, mirrored to
logs/ and optionally forwarded to Minecraft console
Minecraft Commands
/lavadis <start|stop|restart|status|logs|info|reload>
Permissions: lavadis.admin, lavadis.start, lavadis.stop, lavadis.restart, lavadis.status, lavadis.logs, lavadis.reload
restart restarts only the Node/Discord process, never the Minecraft server.status shows: online/offline, PID, uptime, Node version, memory, CPU%, restart count, Discord connection state.info shows: bot version, runtime, actual loaded command count read from bot metadata (never fabricated), status, DB/Redis connection state.logs shows recent buffered lines, respecting max-lines.
Lifecycle Logging
On enable:
[LavaDisBot] Initializing...
[LavaDisBot] Loading Aurora Bot runtime...
[LavaDisBot] Starting Discord bot...
[LavaDisBot] Aurora Bot is starting...
[LavaDisBot] Discord bot is online.
On disable:
[LavaDisBot] Stopping Aurora Bot...
[LavaDisBot] Aurora Bot stopped.
[LavaDisBot] LavaDisBot disabled.
Ensure disable hook forcibly terminates the child process (with a grace period, then SIGKILL equivalent) so nothing survives the JVM.
Deliverable
A production-ready LavaDisBot.jar installable to plugins/, after which the operator drops the existing Aurora Bot source into plugins/LavaDisBot/bot/ and fills in config.yml. Aurora Bot's own Prisma/Postgres/Redis stack is untouched — LavaDisBot only supplies environment variables and process control.
Suggested Build Order
- Scaffold Paper plugin project (Maven/Gradle),
plugin.yml, base command skeleton. - Implement
ProcessManager wrapping ProcessBuilder for the Node process, async via Bukkit's scheduler/executor, with piped stdout/stderr readers on separate threads. - Implement config loader/validator (env var handling, secret redaction in any log output).
- Implement crash detection + backoff restart logic.
- Implement
/lavadis command tree + permissions + tab completion. - Implement status/info readers (process stats via
ProcessHandle, Node version probe, bot metadata read from a small status file/IPC the Aurora Bot writes — e.g., a JSON heartbeat file with command count and DB/Redis state). - Wire shutdown hook for clean process termination.
- Test: start/stop/restart cycles, forced crash, config reload, permission checks, log capture under load — confirm no main-thread blocking (watch TPS).