nyam00nyam

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

yaml
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

code
Paper Server → LavaDisBot.jar → Runtime Manager → Node.js Runtime → Aurora Bot (Node/TS) → Discord API

Config (config.yml)

code
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-blocking
  • isRunning(), 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:

code
[LavaDisBot] Initializing...
[LavaDisBot] Loading Aurora Bot runtime...
[LavaDisBot] Starting Discord bot...
[LavaDisBot] Aurora Bot is starting...
[LavaDisBot] Discord bot is online.
On disable:
code
[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

  1. Scaffold Paper plugin project (Maven/Gradle), plugin.yml, base command skeleton.
  2. Implement ProcessManager wrapping ProcessBuilder for the Node process, async via Bukkit's scheduler/executor, with piped stdout/stderr readers on separate threads.
  3. Implement config loader/validator (env var handling, secret redaction in any log output).
  4. Implement crash detection + backoff restart logic.
  5. Implement /lavadis command tree + permissions + tab completion.
  6. 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).
  7. Wire shutdown hook for clean process termination.
  8. Test: start/stop/restart cycles, forced crash, config reload, permission checks, log capture under load — confirm no main-thread blocking (watch TPS).
Kodari AI
KodariSep 15 at 7:13 am 3
LavaDisBot
LavaDisBot is a Paper plugin that supervises the lifecycle of an external Discord bot (Aurora Bot) running on Node.js. It manages process start, stop, restart, and crash detection with exponential backoff, captures stdout/stderr into a bounded ring buffer with optional console forwarding, and exposes admin commands for status, logs, and resource monitoring. The plugin reads bot metadata via a JSON heartbeat file for command counts and DB/Redis states, redacts secrets from all logs, and ensures clean process termination on server shutdown without blocking the main thread.
  1. Scaffold the Paper plugin and configuration.

  2. Implement the asynchronous Node/Aurora process manager, logging, restart backoff, metadata, and resource monitoring.

  3. Add lifecycle wiring plus the /lavadis command tree, permissions, status, info, logs, reload, and tab completion.

Built LavaDisBot as a Paper plugin project with:

  • Asynchronous BotProcessManager using a real Node.js child process.

  • Bundled/system Node runtime support.

  • Safe environment variable injection with secret redaction.

  • Non-blocking start, stop, restart, shutdown, output capture, and crash monitoring.

  • Bounded log buffer with file persistence and optional console forwarding.

  • Restart backoff sequence: 5s, 10s, 20s, 30s, 60s, with configurable limits.

  • Resource monitoring for uptime, PID, memory, CPU, and Node version.

  • Aurora metadata support for command count, version, Discord, PostgreSQL, Redis, and heartbeat status.

  • /lavadis start|stop|restart|status|logs|info|reload.

  • Per-command permissions plus lavadis.admin.

  • Shutdown hook and forced process termination protection.

  • Paper plugin configuration and Gradle build files.

After installing the plugin, place the existing Aurora Bot in:

Plain Text
plugins/LavaDisBot/bot/

Then provide the configured Node runtime at:

Plain Text
plugins/LavaDisBot/runtime/node

and fill in the environment values in config.yml.

nyam00nyam

What is version paper

Kodari AI
KodariSep 15 at 7:13 am 1

The project targets Paper 1.20.6:

Plain Text
paper-api:1.20.6-R0.1-SNAPSHOT

It also requires Java 17.

nyam00nyam

[07:23:15] [lavadis-lifecycle/ERROR]: [LavaDisBot] Aurora Bot failed to start: Bot entrypoint does not exist: dist/index.js [07:23:15] [lavadis-lifecycle/WARN]: [LavaDisBot] Scheduling Aurora Bot restart after 10000 ms (startup failure).

Kodari AI
KodariSep 15 at 7:24 am 1

The plugin is working, but Aurora Bot has not been built or its compiled entrypoint is different.

LavaDisBot currently expects:

Plain Text
plugins/LavaDisBot/bot/dist/index.js

Build Aurora Bot first:

Shell
cd plugins/LavaDisBot/bot
npm install
npm run build

Verify the file exists:

Shell
ls -l dist/index.js

Then start it:

Plain Text
/lavadis reload
/lavadis start

If Aurora’s build produces another file, update plugins/LavaDisBot/config.yml. For example:

YAML
bot:
  entrypoint: "dist/main.js"

The path is relative to:

Plain Text
plugins/LavaDisBot/bot/

Do not configure src/index.ts unless Aurora explicitly uses a Node TypeScript loader. The supervisor launches Node directly and expects a runnable JavaScript entrypoint.

The 10000 ms message is the automatic restart backoff after the second startup failure. It will stop retrying after the configured maximum restart attempts.

nyam00nyam

Make full working and put this

Kodari AI
KodariSep 15 at 7:26 am 1
  1. Make the Aurora entrypoint configurable and validate it against the installed bot directory.

  2. Improve startup diagnostics and automatic entrypoint discovery for common compiled layouts.

  3. Update the default configuration so the plugin can be installed and started without code changes.

[Generation stopped]

nyam00nyam

Make me working and

Kodari AI
KodariSep 15 at 7:26 am 1

The generation was stopped before any content could be produced.

nyam00nyam

environment:

NODE_ENV: "production" DISCORD_TOKEN: "<redacted>" CLIENT_ID: "1548897193937731705" GUILD_ID: "1544532772474064928" DATABASE_URL: "" REDIS_URL: ""

Kodari AI
KodariSep 15 at 7:26 am 1

That Discord token is now exposed publicly. Revoke it immediately:

  1. Open the Discord Developer Portal.

  2. Select the Aurora Bot application.

  3. Go to Bot → Reset Token.

  4. Copy the newly generated token.

  5. Do not paste it into chat or commit it to Git.

Use this in plugins/LavaDisBot/config.yml with the new token:

YAML
environment:
  NODE_ENV: "production"
  DISCORD_TOKEN: "PASTE_NEW_TOKEN_HERE"
  CLIENT_ID: "1548897193937731705"
  GUILD_ID: "1544532772474064928"
  DATABASE_URL: ""
  REDIS_URL: ""

Also configure the remaining required services if Aurora Bot uses them:

YAML
  DATABASE_URL: "postgresql://user:password@host:5432/database"
  REDIS_URL: "redis://:password@host:6379"

Keep the file restricted:

Shell
chmod 600 plugins/LavaDisBot/config.yml

Then run:

Plain Text
/lavadis reload
/lavadis start

Never share the replacement token.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
10 1,130
src/main/java/com/lavadisbot/LavaDisBotPlugin.java
package com.lavadisbot;

import com.lavadisbot.command.LavaDisCommand;
import com.lavadisbot.config.BotConfig;
import com.lavadisbot.runtime.BotProcessManager;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Objects;

public final class LavaDisBotPlugin extends JavaPlugin {
    private BotConfig botConfig;
    private BotProcessManager processManager;

    @Override
    public void onEnable() {
        getLogger().info("Initializing...");
        saveDefaultConfig();
        botConfig = BotConfig.from(getConfig());
        getLogger().info("Loading Aurora Bot runtime...");
        processManager = new BotProcessManager(this, botConfig);

        PluginCommand command = Objects.requireNonNull(getCommand("lavadis"), "lavadis command is missing from plugin.yml");
        LavaDisCommand executor = new LavaDisCommand(this, processManager);
        command.setExecutor(executor);
        command.setTabCompleter(executor);

        getLogger().info("Starting Discord bot...");
        processManager.startBot().exceptionally(error -> {
            getLogger().warning("Aurora Bot did not start: " + (error.getMessage() == null ? error.getClass().getSimpleName() : error.getMessage()));
            return null;
        });
    }

    @Override
    public void onDisable() {
        if (processManager == null) {
            getLogger().info("LavaDisBot disabled.");
            return;
        }
        getLogger().info("Stopping Aurora Bot...");
        processManager.shutdown().whenComplete((ignored, error) -> {
            getLogger().info("Aurora Bot stopped.");
            getLogger().info("LavaDisBot disabled.");
        });
    }

    public BotConfig getBotConfig() {
        return botConfig;
    }

    public BotProcessManager getProcessManager() {
        return processManager;
    }

    public void reloadBotConfiguration() {
        reloadConfig();
        botConfig = BotConfig.from(getConfig());
        processManager.applyConfig(botConfig);
    }
}