Implement a complete new Paper Minecraft plugin in this empty project for Discord account linking. Add player commands /link and /discord. /link generates a secure, unique, one-time code for that Minecraft player and tells them to go to the configured Discord channel and type !link <code>. On valid use, consume/delete the code immediately, associate the Discord user with the Minecraft UUID/player, assign the configured Discord role, and optionally add a configured LuckPerms group. /discord must only show the configured Discord invite URL and do nothing else.

Keep the Discord bot integration inside this plugin using a suitable Java Discord library (JDA is appropriate; declare it through this project's normal external-library manifest mechanism). Make all settings configurable in config.yml: bot token, Discord guild/server ID, link-command channel ID, role ID, invite URL, code length/expiry, and optional LuckPerms group (blank disables). Do not hardcode secrets or print the bot token. Include sensible defaults/placeholders and clear setup instructions in README, including inviting the bot with role-management permissions, placing its role above the target role, enabling Discord Message Content intent, and configuring LuckPerms. Use IDs, not names, for Discord guild/channel/role. Validate config and fail gracefully with a clear console error when required bot settings are missing or bot connection fails; do not prevent the rest of the plugin from loading where possible.

Implement safe thread handling: Discord callbacks must schedule Bukkit/Paper state changes and LuckPerms console command dispatch on the server thread. Persist pending codes and linked accounts to plugin data (or otherwise ensure codes are single-use across reload/restart), expire codes, and prevent duplicate linking/abuse. Avoid command injection in the optional LuckPerms group/player arguments; validate configured group and use the stored player name safely. Ensure the bot only accepts !link <code> in the configured channel and guild, checks exact format, handles unknown/expired/already-used codes with a useful Discord reply, and does not grant roles or groups unless linking succeeds. Add useful permission handling if appropriate without blocking ordinary players from /link or /discord. Implement plugin metadata, command registration, cleanup/shutdown of the Discord client, and documentation. Do not ask questions; treat the request as this complete spec.

Kodari AI
KodariOct 8 at 12:33 pm 4
DiscordLinker
A Paper Minecraft plugin integrating Discord account linking via JDA. Players use /link to generate a secure one-time code, then type !link &lt;code&gt; in a configured Discord channel to associate their Minecraft account with Discord. Successfully linked players receive a configured Discord role and optionally a LuckPerms group. /discord displays the server invite URL. Features configurable bot token, guild/channel/role IDs, code expiry, persistent storage of pending codes and linked accounts, thread-safe Bukkit scheduling, validation of required settings with graceful failure, and comprehensive README setup instructions.

I’ll build the plugin as one unit: config and settings, persistent single-use codes, the JDA listener with server-thread redemption, the two commands, and the README.

I’ve built the DiscordLink plugin: /link and /discord, a JDA bot declared through manifest.kod, single-use codes persisted in data.yml, and a README with setup steps.

Notes on the design:

  • Thread handling: the bot’s message callback hands redemption to the server thread. LuckPerms commands are dispatched from the console on that thread, and role assignment goes through JDA’s async queue.

  • Role failure after linking: if the role assignment fails after the link is saved, the player stays linked. The bot tells them an admin must fix it. Rolling back the link would be safer for abuse but was not in the spec, so I left it out.

  • Build config: I did not create build.gradle, since this platform manages it.

  • Not compiled: I could not compile or run this here, so the JDA API calls are written from memory of JDA 5 and should be checked by the first build.

Nex Zen

Also add a !unlink and /unlink command in game and discord

Kodari AI
KodariOct 8 at 4:45 pm 1
  1. Add persistent unlink operations by Minecraft UUID or Discord user ID.

  2. Implement /unlink and exact !unlink handling, removing the role and optional LuckPerms group only after a link is found.

  3. Register permissions and document both commands and their behavior.

Added /unlink for Minecraft players and exact !unlink in the configured Discord channel. Either command removes the saved account link and attempts to remove the Discord role and optional LuckPerms group; Discord users can unlink only their own account. Registered the in-game permission and documented the commands and role-removal behavior in the README.

Nex Zen

also paper 1.21.11 sorry.

Kodari AI
KodariOct 8 at 5:52 pm 1
  • Set the plugin metadata minimum API to 1.21.

  • Update the documented server requirement to Paper 1.21.11.

Updated the plugin metadata to api-version: '1.21' and changed the README requirement to Paper 1.21.11. Paper’s plugin API version uses the 1.21 minor version, not the patch number.

Nex Zen

Also add a messages.yml that allows me to edit every message (discord and Minecraft) messages with placeholders use SQLite to store data also when linking just make it say "@discorduser linked to {Minecraftuser} successfully" and allow placeholderapi and custom in game commands to run when the user gets successfully verified so if I have a economy server I can make it so when they verified I can do eco give {player} 1000 (gives the player a 1000 dollars) also add some placeholders like {player} gets replaced with the players name or {discorduser} replaced with the players discord user etc

Kodari AI
KodariOct 8 at 6:11 pm 5
  1. Move all Minecraft and Discord text into messages.yml, including supported message placeholders.

  2. Replace file-backed linking data with SQLite while preserving pending-code expiry and single-use behavior.

  3. Add PlaceholderAPI support and configurable post-verification commands, then document setup and placeholders.

  1. All Minecraft and Discord replies now come from messages.yml, with configurable placeholders; the README documents it.

  2. Next: move pending codes and linked-account persistence from YAML to SQLite.

Implemented the requested updates:

  • Added messages.yml for Minecraft and Discord replies, with {player}, {code}, {seconds}, {invite}, {discorduser}, {discordmention}, {discordname}, and {discordid} replacements.

  • Switched persistence to SQLite in plugins/DiscordLink/links.db, including pending and expired/used codes. Existing data.yml records are imported on first startup.

  • Added optional PlaceholderAPI expansion for in-game messages and verification commands.

  • Added link.verification-commands, which runs configured console commands on the server thread after a link succeeds. For example: eco give {player} 1000.

  • Updated plugin metadata and README setup instructions; declared SQLite JDBC in manifest.kod.

I did not run a build here.

Kodari can make mistakes. Review important code before using.
Files
src
manifest.kod
README.md
Code
18 1,633
src/main/java/com/kodari/discordlink/DiscordLinkPlugin.java
package com.kodari.discordlink;

import com.kodari.discordlink.command.DiscordCommand;
import com.kodari.discordlink.command.LinkCommand;
import com.kodari.discordlink.command.UnlinkCommand;
import com.kodari.discordlink.config.LinkSettings;
import com.kodari.discordlink.data.LinkStorage;
import com.kodari.discordlink.discord.DiscordBotManager;
import com.kodari.discordlink.command.VerificationCommandRunner;
import com.kodari.discordlink.integration.PlaceholderApiSupport;
import com.kodari.discordlink.link.LinkManager;
import com.kodari.discordlink.luckperms.LuckPermsGroupGranter;
import com.kodari.discordlink.message.PluginMessages;
import lombok.Getter;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;

public final class DiscordLinkPlugin extends JavaPlugin {

    private static final long PURGE_INTERVAL_TICKS = 20L * 60L * 5L;

    @Getter private LinkSettings linkSettings;
    @Getter private PlaceholderApiSupport placeholderApiSupport;
    @Getter private PluginMessages pluginMessages;
    @Getter private LinkStorage linkStorage;
    @Getter private LinkManager linkManager;
    @Getter private LuckPermsGroupGranter luckPermsGroupGranter;
    @Getter private DiscordBotManager discordBotManager;
    @Getter private VerificationCommandRunner verificationCommandRunner;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        linkSettings = LinkSettings.load(getConfig(), getLogger());
        placeholderApiSupport = new PlaceholderApiSupport(this);
        pluginMessages = new PluginMessages(this, placeholderApiSupport);

        linkStorage = new LinkStorage(new File(getDataFolder(), "links.db"),
                new File(getDataFolder(), "data.yml"), getLogger());
        try {
            linkStorage.load();
        } catch (IllegalStateException exception) {
            getLogger().severe("DiscordLink could not initialize its SQLite database: " + exception.getMessage());
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        linkManager = new LinkManager(linkSettings, linkStorage);
        verificationCommandRunner = new VerificationCommandRunner(this, linkSettings.getVerificationCommands());
        luckPermsGroupGranter = new LuckPermsGroupGranter(this, linkSettings.getLuckPermsGroup());
        discordBotManager = new DiscordBotManager(this, linkSettings);

        registerCommand("link", new LinkCommand(this));
        registerCommand("discord", new DiscordCommand(this));
        registerCommand("unlink", new UnlinkCommand(this));

        getServer().getScheduler().runTaskTimer(this, linkManager::purgeExpired, PURGE_INTERVAL_TICKS, PURGE_INTERVAL_TICKS);

        discordBotManager.start();
        getLogger().info("DiscordLink enabled.");
    }

    @Override
    public void onDisable() {
        if (discordBotManager != null) {
            discordBotManager.shutdown();
        }
        if (linkStorage != null) {
            linkStorage.close();
        }
    }

    private void registerCommand(String name, CommandExecutor executor) {
        PluginCommand command = getCommand(name);
        if (command == null) {
            getLogger().severe("Command /" + name + " is missing from plugin.yml.");
            return;
        }
        command.setExecutor(executor);
    }
}