VoiceIsHere

Create a Minecraft plugin that integrates a Discord bot allowing server administrators and staff to execute Minecraft commands directly from Discord. The plugin should include a config.yml section where the server owner can enter their Discord bot token, and once the Minecraft server starts, the bot automatically logs in and becomes active. The bot should listen for messages with a specific prefix (for example .command) and convert them into Minecraft console commands, meaning if a user types .kill PlayerName in Discord, the plugin executes /kill PlayerName on the server. The system must support executing any command available on the server, but access is controlled through a permission bridge between Discord roles and LuckPerms ranks. In the configuration, admins should be able to map Discord role IDs to LuckPerms groups, defining which commands each rank is allowed to use. For example, a Trainee Discord role could be linked to a trainee LuckPerms group that only has permission to run /mute and /kick, while higher ranks can use more powerful commands like /ban. If a Trainee tries to run .ban PlayerName, the bot should deny the command, but .kick PlayerName would execute successfully. The plugin should include configurable command prefixes, role-to-rank mappings, allowed command lists, and clear feedback messages in Discord when commands are executed or denied.

Kodari AI
KodariMar 8 at 8:41 pm 12,271 (v2)

I’ll create a comprehensive Discord bot integration plugin that bridges Discord commands to Minecraft with LuckPerms role-based permissions.

DiscordCommandBridge
A powerful Discord integration plugin that enables server staff to execute Minecraft commands directly from Discord. Features automatic bot login on server start, configurable command prefixes, and a sophisticated permission bridge that maps Discord roles to LuckPerms groups. Each role can be assigned specific allowed commands, providing granular access control. Includes real-time command feedback, wildcard permission support, and comprehensive error handling for seamless Discord-to-Minecraft command execution.

Now I’ll create the complete plugin structure with all necessary files.

Perfect! I’ve created a complete Discord Command Bridge plugin with the following features:

Core Features:

  • ✅ Automatic Discord bot login on server start

  • ✅ Configurable command prefix (default: .)

  • ✅ Discord role to LuckPerms group mapping

  • ✅ Per-role allowed command lists

  • ✅ Wildcard (*) support for full access

  • ✅ Real-time command execution feedback in Discord

  • ✅ Permission denial messages

  • ✅ Channel restriction (optional)

  • ✅ Command logging

  • ✅ Debug mode

  • ✅ /discordbridge reload command

How It Works:

  1. Configure your Discord bot token in config.yml

  2. Map Discord role IDs to LuckPerms groups with specific allowed commands

  3. Users type .command args in Discord

  4. Bot validates permissions and executes on Minecraft server

  5. Clear feedback messages show success/denial

Example Usage:

  • Trainee role with .kick and .mute commands only

  • Moderator role with additional .ban and .tempban access

  • Admin role with * wildcard for all commands

The plugin includes comprehensive error handling, debug logging, and graceful degradation if the bot fails to connect.

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

import com.discordbridge.handler.DiscordCommandHandler;
import com.discordbridge.manager.ConfigManager;
import com.discordbridge.manager.DiscordBotManager;
import com.discordbridge.manager.PermissionManager;
import lombok.Getter;
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 PermissionManager permissionManager;
    private DiscordBotManager discordBotManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.permissionManager = new PermissionManager(this);
        this.discordBotManager = new DiscordBotManager(this);
        
        if (!discordBotManager.connect()) {
            getLogger().severe("Failed to connect Discord bot! Check your configuration.");
            getLogger().severe("Plugin will remain enabled but Discord features will not work.");
        }
        
        getLogger().info("DiscordCommandBridge has been enabled!");
    }

    @Override
    public void onDisable() {
        if (discordBotManager != null) {
            discordBotManager.disconnect();
        }
        
        getLogger().info("DiscordCommandBridge has been disabled!");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("discordbridge")) {
            if (!sender.hasPermission("discordbridge.admin")) {
                sender.sendMessage("§cYou don't have permission to use this command!");
                return true;
            }
            
            if (args.length == 0) {
                sender.sendMessage("§6DiscordCommandBridge v" + getDescription().getVersion());
                sender.sendMessage("§7/discordbridge reload - Reload configuration");
                return true;
            }
            
            if (args[0].equalsIgnoreCase("reload")) {
                reloadConfig();
                configManager.reload();
                permissionManager.reload();
                
                discordBotManager.disconnect();
                if (discordBotManager.connect()) {
                    sender.sendMessage("§aConfiguration reloaded and bot reconnected!");
                } else {
                    sender.sendMessage("§cConfiguration reloaded but bot failed to connect!");
                }
                return true;
            }
        }
        
        return false;
    }
}