miraidev
📎 1 file 2,764 chars
📄
pasted-code-1769502346178.txt
txt 127 lines
▶

### 🎯 PROMPT: Minecraft Discord Account Linking Plugin (1.21.10+)

> Create a **Minecraft Paper plugin for version 1.21.10+** that allows players to **link their Minecraft account with their Discord account** using a temporary verification code system.

#### 🔹 Core Requirements

* Plugin name: `DiscordLink`
* Minecraft server: **PaperMC 1.21.10+**
* Java version: **Java 21**
* Discord integration using **JDA (Java Discord API)**

---

#### 🔹 Minecraft Side

1. Implement a command:

   ```
   /link
   ```
2. When a player runs `/link`:

   * Generate a **random 6-character alphanumeric code** (example: `A9F3K2`)
   * Store the code in memory linked to:

     * Player UUID
     * Expiration time (5 minutes)
   * Send the player a message:

     ```
     Your link code is: 
     Use this code in Discord with: /link 
     ```
3. Each code:

   * Expires after 5 minutes
   * Can only be used once
   * One active code per player at a time

---

#### 🔹 Discord Side

1. Create a Discord bot using **JDA**
2. Register a **slash command**:

   ```
   /link 
   ```
3. When a user runs `/link ` in Discord:

   * Validate that the code exists
   * Check that it is not expired
   * Check that it has not already been used
4. If valid:

   * Link **Minecraft UUID ↔ Discord User ID**
   * Save the link persistently (YAML or SQLite)
   * Respond in Discord:

     ```
     ✅ Successfully linked with Minecraft account 
     ```
5. If invalid or expired:

   * Respond with an error message explaining why

---

#### 🔹 Data Storage

* Temporary link codes stored in memory:

```java
Map
```

* Persistent links stored in `links.yml`:

```yml
links:
  minecraft-uuid: discord-user-id
```

---

#### 🔹 Additional Rules

* One Discord account can only be linked to one Minecraft account
* One Minecraft account can only be linked to one Discord account
* Add `/unlink` command (optional but preferred)
* Send success message to the player in Minecraft when linking is complete

---

#### 🔹 Plugin Structure

* Main plugin class
* Command handler for `/link`
* LinkCodeManager (generate / validate / expire codes)
* DiscordBotManager (JDA setup & slash commands)
* DataManager (load/save linked accounts)

---

#### 🔹 Output Expectations

* Full **working plugin source code**
* `plugin.yml`
* Clear comments explaining logic
* Instructions on how to:

  * Add Discord bot token
  * Invite the bot to a server
  * Run the plugin

---

💡 **Important**

* Do NOT use deprecated Bukkit APIs
* Follow Paper best practices
* Code should be clean, readable, and production-ready


Kodari AI
KodariJan 27 at 8:27 am 9,048 (v2)

I’ll create a comprehensive Discord account linking plugin for Paper 1.21.10+ with JDA integration.

DiscordLink
A robust Discord-Minecraft account linking system using temporary verification codes. Players generate a 6-character alphanumeric code in-game with /link, then verify it in Discord using a slash command. Features automatic code expiration (5 minutes), one-to-one account binding, persistent data storage, and comprehensive validation. Includes both link and unlink functionality with real-time notifications across both platforms.

Plan

  • Setup Gradle build with Paper API, JDA, and Lombok dependencies

  • Create config.yml for Discord bot configuration

  • Implement LinkData model and managers (LinkCodeManager, DataManager, DiscordBotManager)

  • Create Minecraft commands (/link, /unlink)

  • Setup JDA bot with Discord slash commands

  • Implement bidirectional linking with validation


✅ Plugin Complete!

What was created:

  • Full Discord-Minecraft linking system with JDA 5.2.1

  • Secure 6-character alphanumeric code generation

  • Automatic expiration handling (5 minutes)

  • Bidirectional validation (prevents double-linking)

  • Persistent YAML storage with in-memory caching

  • Both /link and /unlink commands on both platforms

  • Comprehensive error handling and user feedback

Next steps:

  1. Build the project with Java 21

  2. Follow README.md to set up Discord bot

  3. Configure config.yml with your bot token and guild ID

  4. Start your Paper server

The bot will auto-register slash commands when it connects. Codes expire automatically and are cleaned up every 60 seconds.

miraidev

Plugin not running ( 1.21.11 ) the plugin name show red when using /plugin that mean plugin not working, also discord bot didn't online when server online

Kodari AI
KodariJan 28 at 2:26 pm 5,692 (v2)

I can see the issue. The plugin is trying to use JDA (Discord library) but it’s not being properly loaded. The manifest.kod syntax is incorrect for JDA.

Issues identified:

  • manifest.kod has wrong syntax for JDA dependency

  • JDA needs to be shaded/relocated properly

  • Plugin.yml api-version should be 1.21 not ‘1.21’

Fix:

The manifest.kod should just reference jda (lowercase) as the library name. The Kodiak system will handle loading the JDA library and all its dependencies automatically. After rebuilding with these changes, the plugin should load correctly and the Discord bot should come online.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
README.md
Code
13 688
src/main/java/com/discordlink/DiscordLinkPlugin.java
package com.discordlink;

import com.discordlink.command.LinkCommand;
import com.discordlink.command.UnlinkCommand;
import com.discordlink.manager.DataManager;
import com.discordlink.manager.DiscordBotManager;
import com.discordlink.manager.LinkCodeManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class DiscordLinkPlugin extends JavaPlugin {
    private LinkCodeManager linkCodeManager;
    private DataManager dataManager;
    private DiscordBotManager discordBotManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.linkCodeManager = new LinkCodeManager(this);
        this.dataManager = new DataManager(this);
        this.dataManager.load();
        
        String botToken = getConfig().getString("discord.bot-token");
        if (botToken == null || botToken.equals("YOUR_BOT_TOKEN_HERE")) {
            getLogger().severe("Discord bot token not configured! Please set it in config.yml");
            getLogger().severe("Plugin will continue loading but Discord features will not work");
        } else {
            this.discordBotManager = new DiscordBotManager(this, botToken);
        }
        
        getCommand("link").setExecutor(new LinkCommand(this));
        getCommand("unlink").setExecutor(new UnlinkCommand(this));
        
        getLogger().info("DiscordLink has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (this.discordBotManager != null) {
            this.discordBotManager.shutdown();
        }
        
        if (this.dataManager != null) {
            this.dataManager.save();
        }
        
        getLogger().info("DiscordLink has been disabled!");
    }
}