megatron69-glitch

This plugin is a Minecraft SMP Discord whitelist management system that connects your Purpur server with Discord. It allows trusted staff members to manage player access directly from Discord without needing access to the Minecraft console. When a user sends a Minecraft username in a configured Discord channel, the plugin checks that the username is valid and safely runs the Minecraft whitelist command to add that player. Staff can also use commands like !remove PlayerName in Discord to remove a player from the Minecraft whitelist. The plugin is designed to be lightweight, secure, and only allow whitelist-related actions, preventing users from executing other server commands. It makes managing SMP players faster by controlling whitelist access directly through Discord.

Kodari AI
KodariJun 22 at 11:12 pm 7

I’ll create a Discord whitelist management plugin for your Minecraft SMP server.

DiscordWhitelistBridge
A secure Discord-to-Minecraft whitelist management system for SMP servers. Allows trusted staff to add/remove players from the server whitelist directly through Discord without console access. Features username validation, role-based permissions, configurable messages, and safe command execution limited to whitelist operations only. Staff send Minecraft usernames in a designated Discord channel to whitelist players, or use !remove to revoke access.

DiscordWhitelistBridge is ready! Setup instructions:

  1. Get a Discord bot token:

    • Create a new application → Bot → Reset Token

    • Enable “Message Content Intent” under Privileged Gateway Intents

    • Copy the token to config.yml

  2. Get your channel ID:

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

    • Right-click your whitelist channel → Copy ID

    • Paste into config.yml

  3. Optional staff role:

    • Right-click your staff role → Copy ID

    • Paste into staff-role-id (leave empty to allow anyone)

  4. Invite the bot:

    • In Developer Portal → OAuth2 → URL Generator

    • Select scopes: bot

    • Select permissions: Send Messages, Read Message History

    • Copy and open the generated URL

Usage:

  • Notch → Adds Notch to whitelist

  • !remove Notch → Removes Notch from whitelist

  • !check Notch → Checks if Notch is whitelisted

megatron69-glitch

Reload command without restarting server

Kodari AI
KodariJun 22 at 11:17 pm 10

Reload command added! Use /dwbreload (or /dwbr or /whitelistreload) in-game to reload the configuration without restarting the server.

Permission: discordwhitelist.reload (default: op)

The reload updates channel ID, staff role, messages, and logging settings without reconnecting the Discord bot.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
9 392
src/main/java/com/whitelistbridge/DiscordWhitelistBridge.java
package com.whitelistbridge;

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.requests.GatewayIntent;
import org.bukkit.plugin.java.JavaPlugin;

public class DiscordWhitelistBridge extends JavaPlugin {

    private JDA jda;
    private WhitelistManager whitelistManager;
    private DiscordListener discordListener;
    private String channelId;
    private String staffRoleId;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        if (!initializeBot()) {
            return;
        }

        getCommand("dwbreload").setExecutor(new ReloadCommand(this));
        getLogger().info("DiscordWhitelistBridge enabled!");
    }

    @Override
    public void onDisable() {
        if (jda != null) {
            jda.shutdown();
            getLogger().info("Discord bot disconnected.");
        }
    }

    public boolean reload() {
        reloadConfig();
        
        if (jda != null) {
            jda.removeEventListener(discordListener);
        }
        
        this.channelId = getConfig().getString("discord.channel-id", "");
        this.staffRoleId = getConfig().getString("discord.staff-role-id", "");
        
        if (channelId.equals("YOUR_CHANNEL_ID_HERE") || channelId.isEmpty()) {
            getLogger().warning("Discord channel ID not configured!");
            return false;
        }
        
        this.discordListener = new DiscordListener(this);
        if (jda != null) {
            jda.addEventListener(discordListener);
        }
        
        return true;
    }

    private boolean initializeBot() {
        String token = getConfig().getString("discord.token", "");
        this.channelId = getConfig().getString("discord.channel-id", "");
        this.staffRoleId = getConfig().getString("discord.staff-role-id", "");

        if (token.equals("YOUR_BOT_TOKEN_HERE") || token.isEmpty()) {
            getLogger().severe("Discord bot token not configured! Please set it in config.yml");
            getServer().getPluginManager().disablePlugin(this);
            return false;
        }

        if (channelId.equals("YOUR_CHANNEL_ID_HERE") || channelId.isEmpty()) {
            getLogger().severe("Discord channel ID not configured! Please set it in config.yml");
            getServer().getPluginManager().disablePlugin(this);
            return false;
        }

        this.whitelistManager = new WhitelistManager(this);
        this.discordListener = new DiscordListener(this);

        try {
            this.jda = JDABuilder.createDefault(token)
                    .enableIntents(GatewayIntent.GUILD_MESSAGES, GatewayIntent.MESSAGE_CONTENT)
                    .addEventListeners(discordListener)
                    .build();

            getLogger().info("Discord bot connecting...");
            return true;
        } catch (Exception e) {
            getLogger().severe("Failed to start Discord bot: " + e.getMessage());
            getServer().getPluginManager().disablePlugin(this);
            return false;
        }
    }

    public JDA getJDA() {
        return jda;
    }

    public WhitelistManager getWhitelistManager() {
        return whitelistManager;
    }

    public String getChannelId() {
        return channelId;
    }

    public String getStaffRoleId() {
        return staffRoleId;
    }

    public String getMessage(String key) {
        return getConfig().getString("messages." + key, "Message not found: " + key);
    }

    public boolean isLoggingEnabled(String type) {
        return getConfig().getBoolean("logging.log-" + type, true);
    }
}