_raiyan_0
📎 1 file 2,746 chars
📄
pasted-code-1787263876478.txt
txt 40 lines
▶
Task: Build a fully customizable, high-performance, asynchronous Paper plugin (compatible with Minecraft 1.20+ / 1.21+) named "DiscordBridgeLogger" that forwards server logs, console commands, player commands, and player chat directly to Discord via Webhooks or a Discord Bot.

### Core Requirements & Features:

1. **Fully Configurable (config.yml):**
   - Toggle switches for:
     - `forward-console-logs` (true/false) + Log level filter (INFO, WARN, ERROR, etc.)
     - `forward-console-commands` (true/false)
     - `forward-player-commands` (true/false) + Ignored commands list (e.g., /login, /register)
     - `forward-player-chat` (true/false)
   - Discord Integration Settings:
     - `webhook-url` (String)
     - Embed colors, author headers, footers, and custom message formats using placeholders like `%player%`, `%message%`, `%command%`, `%level%`.
   - Advanced filters:
     - Regex blacklist/whitelist for logs and commands to prevent spam or sensitive leaks (e.g., passwords).

2. **Console Logs & Console Command Interception:**
   - Attach a custom `Log4j2` Appender or intercept standard server logging safely to capture console output and console-executed commands without lagging the main thread.
   - Filter out plugin's own outbound HTTP requests or recursive logging loops.

3. **Player Activity Interception:**
   - **Player Chat:** Capture all chat events asynchronously (`AsyncChatEvent` for modern Paper API or legacy
`AsyncPlayerChatEvent`).
   - **Player Commands:** Capture all commands executed by players using `PlayerCommandPreprocessEvent`. Check against the ignored/blacklisted command list.

4. **Async Discord Dispatcher:**
   - All HTTP requests to Discord Webhooks must run asynchronously (`Bukkit.getScheduler().runTaskAsynchronously`) using a lightweight HTTP client (like `OkHttp` or `HttpURLConnection` wrapped in an executor) to ensure zero TPS drop or server hitching.
   - Implement basic rate-limit handling (HTTP 429 retry-after header parsing or simple queueing).

5. **Project Structure & Build System:**
   - Use **Gradle** (Kotlin DSL or Groovy) with ShadowJar plugin to bundle dependencies cleanly (e.g., Gson / OkHttp if needed).
   - Provide clean, modular Java classes:
     - `DiscordBridgePlugin.java` (Main class, config loader, event listeners setup)
     - `LogAppender.java` (Log4j2 hook for console logs)
     - `EventListener.java` (Player chat & command events)
     - `DiscordWebhookClient.java` (Async HTTP sender with embed formatting)

### Deliverables:
- Complete file tree and source code (`build.gradle`, `plugin.yml`, `config.yml`, and all Java source files).
- Instructions on how to build with `./gradlew build` and configure it.
Kodari AI
KodariAug 20 at 10:13 pm 10
DiscordBridgeLogger
Asynchronous Paper plugin forwarding server logs, console commands, player commands, and chat to Discord via webhooks. Features configurable log level filtering, regex blacklist/whitelist for sensitive data protection, ignored command lists, custom embed formatting with placeholders, and rate-limit handling. Uses Log4j2 appender for console interception and async HTTP dispatcher with OkHttp for zero TPS impact. Includes Gradle build with ShadowJar for dependency bundling.
  1. Create the Gradle Paper plugin project with no external runtime libraries.

  2. Add immutable configuration/filter handling and Discord webhook/bot async dispatching.

  3. Hook Log4j2 console output plus server, player-command, and async-chat events.

  4. Provide default configuration and build/configuration instructions.

Created the complete DiscordBridgeLogger Paper plugin project.

  • Gradle Java 17 build targeting Paper 1.20+/1.21+

  • Async queued Discord webhook or bot-channel delivery with 429 retry handling

  • Log4j2 appender for filtered console logs with recursion prevention

  • Console commands, player commands, and modern AsyncChatEvent forwarding

  • Configurable toggles, formatting placeholders, embeds, ignored commands, and regex filters

  • Default config.yml, plugin.yml, and build/configuration instructions in README.md

_raiyan_0

eita aro perfect aro best aro functional aro option add koro joto best kora jay jeno amra discordSRV ke beat ke kore premium sell kore korbo 0_0 tai ekhon best as possible you can do. sathe ekta best embed hisabe kora jeno jay abar arekta option add koro to web dash thakbe amra panel ba custom ekta port dibo oita port diye ekta dashboard hoibo amra caile oi plugin er dashboard diyeu kaj korte parbo dashboard ar config file sync hobe. sathe database add kora jabe othaba sqllite mane advanced sokol features sob kichu kora jabe ekhon sob koro ja ja kora dorkar eitay ekhon

dashboard ta clean minimal dark minecraft theme er moddhe korbe

Kodari AI
KodariAug 20 at 10:27 pm 24
  1. Strengthen the configuration, delivery pipeline, and persistence foundation for premium-grade reliability.

  2. Add richer Discord event embeds, routing, filtering, queueing, and operational controls.

  3. Add a synchronized, port-configurable web dashboard with a minimal dark Minecraft design.

  4. Add SQLite support and optional external SQL storage for dashboard/plugin data.

  5. Extend defaults and documentation for all new production settings.

  • Immutable delivery settings now cover bounded queues, retries, timeouts, mention suppression, richer embed metadata, and endpoint modes.

  • The dispatcher will retain its single asynchronous drain while adding safe queue saturation behavior, response-aware retries, and Discord payload limits.

  • Existing format/filter behavior remains compatible with the current configuration keys.

  1. Discord activity capture: add join/quit/death/advancement events plus a reload command and safe runtime configuration refresh.

  • Add lifecycle activity forwarding controlled by independent toggles, retaining existing chat and command safeguards.

  • Make listeners and the Log4j2 hook accept configuration reloads without re-registering or restarting the plugin.

  • Expose /discordbridgelogger reload with a dedicated permission.- Lifecycle delivery has dedicated event toggles and embed routes so busy servers can opt in only to the activity they need.

  • Reloading replaces immutable settings atomically across the event listener, Log4j2 appender, and Discord dispatcher.

  • The command is permission-gated and requires no server restart.

  1. Dashboard and persistence: add a local, token-protected HTTP dashboard plus an asynchronous SQLite-backed activity store; external SQL needs a connection-pool dependency and a separate deployment configuration, so the local SQLite mode is delivered as the secure default.

  • Local SQLite persistence stores every accepted outbound activity on a single background writer, with bounded in-memory dashboard history and automatic retention cleanup.

  • The dashboard is disabled by default, binds to loopback by default, and refuses to start without an API token; its authenticated controls write back to config.yml and reload live.

  • The UI is dependency-free, responsive, and themed as a dark Minecraft operations panel.

  1. Configuration and release readiness: add the remaining production defaults, optional MySQL mode, dashboard access guidance, and correct the persistence dependency surface.

  • Add database-mode configuration for SQLite or MySQL-compatible SQL through the same asynchronous Hikari writer.

  • Remove an unavailable unused metrics import and ensure configured database credentials never appear in the dashboard API or page.

  • Complete default activity, embed, dashboard, delivery, and retention settings.

  1. Final hardening: verify the generated dashboard source and persistence linkage, then remove any deployment-time fragility from the database initialization path.

  • Correct MySQL table creation so the optional SQL backend works as configured rather than relying on SQLite DDL.

  • Keep SQLite’s compact local schema and cleanup behavior unchanged.1. Premium-grade Discord pipeline added: bounded async queue, retry/rate-limit handling, safe mention suppression, richer embed options, avatar/thumbnail support, timestamps, and payload limits.

  1. More activity events added: joins, quits, deaths, and advancements—each independently configurable with custom formats and embed styling.

  2. Live reload support added:

    • /discordbridgelogger reload

    • Permission: discordbridgelogger.admin

    • Reloads Discord delivery, event filters, Log4j2 forwarding, and dashboard settings.

  3. Dark Minecraft dashboard added:

    • Minimal responsive design

    • Token-protected API

    • Shows queue, storage status, recent activity

    • Lets administrators toggle core forwarding settings

    • Writes changes directly to the same config.yml and reloads them live

    • Disabled and loopback-bound by default for safety

  4. Persistent activity storage added:

    • Async SQLite by default (activity.db)

    • Automatic retention cleanup

    • Optional MySQL-compatible storage through HikariCP

    • Dashboard never exposes Discord tokens, webhook URLs, database credentials, or filter rules.

  5. Updated config.yml, build.gradle, manifest.kod, and README.md with all production settings and deployment guidance.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
README.md
settings.gradle
Code
13 1,429
src/main/java/com/kodari/discordbridgelogger/DiscordBridgePlugin.java
package com.kodari.discordbridgelogger;

import com.kodari.discordbridgelogger.config.ConfigManager;
import com.kodari.discordbridgelogger.dashboard.DashboardServer;
import com.kodari.discordbridgelogger.discord.DiscordWebhookClient;
import com.kodari.discordbridgelogger.listener.EventListener;
import com.kodari.discordbridgelogger.logging.LogAppender;
import com.kodari.discordbridgelogger.storage.ActivityStore;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Map;

public final class DiscordBridgePlugin extends JavaPlugin {
    private ConfigManager configManager;
    private DiscordWebhookClient discordClient;
    private LogAppender logAppender;
    private EventListener eventListener;
    private ActivityStore activityStore;
    private DashboardServer dashboardServer;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        configManager = new ConfigManager(getConfig());
        activityStore = new ActivityStore(this, configManager.getStorageSettings());
        discordClient = new DiscordWebhookClient(this, configManager, activityStore);

        eventListener = new EventListener(configManager, discordClient);
        getServer().getPluginManager().registerEvents(eventListener, this);

        logAppender = new LogAppender(configManager, discordClient);
        logAppender.attach();

        dashboardServer = new DashboardServer(this, activityStore, configManager);
        dashboardServer.start();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!command.getName().equalsIgnoreCase("discordbridgelogger")) {
            return false;
        }
        if (!sender.hasPermission("discordbridgelogger.admin")) {
            sender.sendMessage("§cYou do not have permission to use this command.");
            return true;
        }
        if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
            reloadRuntimeConfiguration();
            sender.sendMessage("§aDiscordBridgeLogger configuration reloaded.");
            return true;
        }
        sender.sendMessage("§eUsage: /" + label + " reload");
        return true;
    }

    @Override
    public void onDisable() {
        if (dashboardServer != null) {
            dashboardServer.stop();
        }
        if (logAppender != null) {
            logAppender.detach();
        }
        if (discordClient != null) {
            discordClient.shutdown();
        }
        if (activityStore != null) {
            activityStore.close();
        }
    }

    public DiscordWebhookClient getDiscordClient() {
        return discordClient;
    }

    public ConfigManager getConfigManager() {
        return configManager;
    }

    public void updateDashboardSettings(Map<String, String> settings) {
        getServer().getScheduler().runTask(this, () -> {
            getConfig().set("forward-console-logs", Boolean.parseBoolean(settings.getOrDefault("forward-console-logs", "false")));
            getConfig().set("forward-console-commands", Boolean.parseBoolean(settings.getOrDefault("forward-console-commands", "false")));
            getConfig().set("forward-player-commands", Boolean.parseBoolean(settings.getOrDefault("forward-player-commands", "false")));
            getConfig().set("forward-player-chat", Boolean.parseBoolean(settings.getOrDefault("forward-player-chat", "false")));
            saveConfig();
            reloadRuntimeConfiguration();
        });
    }

    private void reloadRuntimeConfiguration() {
        reloadConfig();
        configManager = new ConfigManager(getConfig());
        discordClient.updateConfig(configManager);
        eventListener.updateConfig(configManager);
        logAppender.updateConfig(configManager);
        dashboardServer.restart(configManager);
    }
}