krish.xx

I want to create a Minecraft plugin (preferably for Spigot/Paper) that connects my Minecraft server with Discord.

Requirements:

  1. The plugin should allow a Discord bot command (for example: !playerinfo <playername>) that retrieves and displays detailed information about a player from the Minecraft server.
  1. The information shown in Discord should include:
  • Player Name
  • UUID
  • Current XP Level
  • Exact Coordinates (X, Y, Z)
  • World Name
  • Health
  • Hunger Level
  • Online/Offline Status
  • Player Rank (from LuckPerms or similar permission plugin)
  • Playtime
  • Ping
  1. The plugin should send the data to a Discord channel using an embedded message format for better readability.
  1. The system should work in real time when the command is used.
  1. It should support multiple players and show accurate data for both online and offline players if possible.
  1. The plugin should integrate with:
  • Discord API / Discord Bot
  • LuckPerms for player ranks
  1. The plugin should include configuration options such as:
  • Discord bot token
  • Command prefix
  • Channel ID
  • Permission settings
  1. It should be optimized so it does not affect server performance.

Please provide the full plugin code, setup instructions, and dependencies required.

Kodari AI
KodariMar 11 at 2:54 pm 15,887 (v2)

I’ll create a comprehensive Discord-Minecraft bridge plugin with real-time player information queries.

DiscordBridge
A powerful Discord-Minecraft integration plugin that enables Discord bot commands to query detailed player information in real-time. Features include player stats display (coordinates, health, hunger, XP, playtime), LuckPerms rank integration, embedded Discord messages, online/offline player support, SQLite data persistence, performance-optimized caching, and comprehensive configuration options. Designed for seamless cross-platform communication.

Let me create the complete Discord bridge plugin with all required features.

Perfect! I’ve created a complete Discord-Minecraft bridge plugin. Here’s what was implemented:

🎯 Features Implemented

✅ Discord Bot Integration - JDA-based bot with message command handling ✅ Player Information Command - !playerinfo <player> with rich embeds ✅ Real-time Data - Online player stats fetched live ✅ Offline Support - Last known data for offline players ✅ LuckPerms Integration - Displays player ranks ✅ Playtime Tracking - SQLite database for persistent storage ✅ Performance Optimized - Async operations, caching system ✅ Configurable - Extensive config.yml options ✅ Thread-Safe - Proper async/sync coordination

📦 Setup Instructions

1. Dependencies Required

  • Spigot/Paper 1.16+ server

  • LuckPerms plugin (for rank display)

2. Bot Setup

  1. Create a new application

  2. Go to “Bot” section → Create bot

  3. Enable “Message Content Intent” under Privileged Gateway Intents

  4. Copy the bot token

  5. Invite bot using: https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=2048&scope=bot

    • Replace YOUR_CLIENT_ID with your application ID

    • Permissions: Send Messages (2048)

3. Plugin Installation

  1. Place the compiled JAR in your plugins/ folder

  2. Start the server (generates config)

  3. Stop the server

  4. Edit plugins/DiscordBridge/config.yml:

    YAML
    discord:
      token: "YOUR_BOT_TOKEN_HERE"  # Paste your bot token
      channel-id: "123456789"       # Right-click channel → Copy ID
      command-prefix: "!"
    
  5. Start the server

4. Get Channel ID

  • Enable Developer Mode in Discord (User Settings → Advanced)

  • Right-click the channel → Copy ID

  • Paste into config.yml

🎮 Usage

In your configured Discord channel:

  • !playerinfo Notch - View player information

  • !pinfo Steve - Short alias

In-game admin commands:

  • /discordbridge - View plugin info

  • /discordbridge reload - Reload config and restart bot

📊 Information Displayed

For Online Players:

  • ✅ Real-time coordinates

  • ✅ Current health & hunger

  • ✅ Live XP level

  • ✅ Ping

  • ✅ Current world

  • ✅ Total playtime

  • ✅ Rank from LuckPerms

For Offline Players:

  • ✅ Last known location

  • ✅ Last known stats

  • ✅ Total playtime

  • ✅ Time since last seen

  • ✅ Rank (always current)

⚙️ Configuration Options

YAML
discord:
  embed-color: "#5865F2"  # Customize embed color
  
settings:
  require-permission: false  # Require Discord role to use commands
  allowed-role-id: ""        # Discord role ID if permission required
  debug: false               # Enable debug logging

🔒 Permissions

  • discordbridge.admin - Access to /discordbridge commands (default: OP)

🗄️ Database

  • Uses SQLite (auto-created in plugin folder)

  • Tracks playtime, last location, and player stats

  • Auto-saves on player quit and plugin disable

All files created and ready to compile!

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
13 982
src/main/java/com/discordbridge/plugin/DiscordBridge.java
package com.discordbridge.plugin;

import com.discordbridge.plugin.cache.PlayerDataCache;
import com.discordbridge.plugin.config.ConfigManager;
import com.discordbridge.plugin.data.DataManager;
import com.discordbridge.plugin.discord.DiscordBot;
import com.discordbridge.plugin.listeners.PlayerDataListener;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class DiscordBridge extends JavaPlugin {
    
    private ConfigManager configManager;
    private DataManager dataManager;
    private PlayerDataCache playerDataCache;
    private DiscordBot discordBot;
    
    @Override
    public void onEnable() {
        this.configManager = new ConfigManager(this);
        this.configManager.loadConfig();
        
        this.playerDataCache = new PlayerDataCache();
        
        this.dataManager = new DataManager(this);
        this.dataManager.initialize();
        
        Bukkit.getPluginManager().registerEvents(new PlayerDataListener(this), this);
        
        this.discordBot = new DiscordBot(this);
        this.discordBot.start();
        
        getLogger().info("DiscordBridge has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (this.discordBot != null) {
            this.discordBot.shutdown();
        }
        
        if (this.dataManager != null) {
            this.dataManager.saveAllOnlinePlayers();
            this.dataManager.close();
        }
        
        getLogger().info("DiscordBridge has been disabled!");
    }
    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!command.getName().equalsIgnoreCase("discordbridge")) {
            return false;
        }
        
        if (!sender.hasPermission("discordbridge.admin")) {
            sender.sendMessage("§cYou don't have permission to use this command.");
            return true;
        }
        
        if (args.length == 0) {
            sender.sendMessage("§aDiscordBridge v" + getDescription().getVersion());
            sender.sendMessage("§7Use /discordbridge reload to reload the configuration");
            return true;
        }
        
        if (args[0].equalsIgnoreCase("reload")) {
            this.configManager.loadConfig();
            
            if (this.discordBot != null) {
                this.discordBot.shutdown();
            }
            
            this.discordBot = new DiscordBot(this);
            this.discordBot.start();
            
            sender.sendMessage("§aConfiguration reloaded and Discord bot restarted!");
            return true;
        }
        
        sender.sendMessage("§cUsage: /discordbridge [reload]");
        return true;
    }
}