nawajahmad3535-afk

GodWhitelist

Plugin Information

  • Plugin Name: GodWhitelist
  • Minecraft Version: Paper/Spigot 1.21+
  • Developer Credit: SkyKing01

---

Plugin Purpose

GodWhitelist is a Discord-integrated whitelist plugin that automatically manages server access through a Discord channel. Players can whitelist themselves by sending their Minecraft username in a configured Discord channel.

No INVENTORY GUI. Lightweight and simple.

---

Discord Integration

Auto Whitelist System

The plugin connects to a Discord bot and monitors a configured channel.

When a player sends a message in the configured channel:

Example:

Steve

The plugin will:

  1. Check if the username is valid.
  2. Automatically add the player to the Minecraft whitelist.
  3. Save the whitelist date.
  4. Send a confirmation message in Discord.
  5. Log the action in console.

Example Discord Response:

Steve has been added to the whitelist.

---

Auto Unwhitelist System

The plugin tracks the last join date of every whitelisted player.

If a player does not join the server for 10 days:

  • Automatically remove them from the whitelist.
  • Send a Discord notification.
  • Log the action in console.

Example:

Steve was removed from the whitelist due to 10 days of inactivity.

---

Commands

Admin Commands

/gw reload

Reload all configuration files.

Permission:

godwhitelist.reload

/gw on

Enable whitelist protection.

Permission:

godwhitelist.admin

/gw off

Disable whitelist protection.

Permission:

godwhitelist.admin

/gw whitelist <player>

Manually whitelist a player.

Permission:

godwhitelist.admin

/gw unwhitelist <player>

Manually remove a player from the whitelist.

Permission:

godwhitelist.admin

---

Config.yml

whitelist-enabled: true

auto-unwhitelist-days: 10

discord: enabled: true

bot-token: ""

whitelist-channel-id: ""

messages: whitelist-success: "&aYou have been whitelisted." auto-remove: "&cRemoved due to inactivity."

---

Data Storage

Store:

  • UUID
  • Username
  • Whitelist Date
  • Last Join Date

Use YAML by default.

---

Startup

When the server starts:

  • Connect to Discord bot.
  • Load all whitelist data.
  • Start inactivity checker.
  • Log successful connection.

Console:

[GodWhitelist] Connected to Discord. [GodWhitelist] Inactivity checker started.

---

Performance Requirements

  • Fully asynchronous Discord API.
  • No lag on main thread.
  • Automatic data saving.
  • Support hundreds of players.

---

Goal

Create a lightweight whitelist plugin where players whitelist themselves through Discord and inactive players are automatically removed after 10 days without joining the server.

Kodari AI
KodariJun 6 at 2:56 pm 1

I’ll create the GodWhitelist plugin with Discord integration and auto-unwhitelist system.

GodWhitelist
A Discord-integrated whitelist plugin for Paper 1.21+. Players whitelist themselves by sending their Minecraft username in a configured Discord channel. Features automatic UUID resolution via Mojang API, auto-removal of inactive players after 10 days, YAML data storage, asynchronous Discord operations, and full admin command support. Lightweight with no GUI dependencies.

New project. Creating everything from scratch.

GodWhitelist
A Discord-integrated whitelist plugin for Paper 1.21+. Players whitelist themselves by sending their Minecraft username in a configured Discord channel. Features automatic UUID resolution via Mojang API, auto-removal of inactive players after 10 days, YAML data storage, asynchronous Discord operations via JDA, and admin commands for manual management.
A Discord-integrated whitelist plugin for Paper 1.21+. Players whitelist themselves by sending their Minecraft username in a configured Discord channel. Features automatic UUID resolution via Mojang API, auto-removal of inactive players after 10 days, YAML data storage, fully asynchronous Discord operations via JDA, and admin commands for manual whitelist management.
nawajahmad3535-afk

The compilation failed with this error:

code
Compilation failed with 1 error(s):

ERROR in src/main/java/com/godwhitelist/listeners/JoinListener.java at line 36: class, interface, enum, or record expected
</create<project_name>GodWhitelist</project_name>
^


=== COMPILATION ERROR ANALYSIS ===

SYNTAX ERRORS:
  - Line 36: class, interface, enum, or record expected
ACTION: Check for missing semicolons or brackets

FILES TO INVESTIGATE:
  - src/main/java/com/godwhitelist/listeners/JoinListener.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariJun 6 at 2:57 pm 1
nawajahmad3535-afk

The compilation failed with this error:

code
Compilation failed with 1 error(s):

ERROR in src/main/java/com/godwhitelist/listeners/JoinListener.java at line 36: class, interface, enum, or record expected
</create<project_name>GodWhitelist</project_name>
^


=== COMPILATION ERROR ANALYSIS ===

SYNTAX ERRORS:
  - Line 36: class, interface, enum, or record expected
ACTION: Check for missing semicolons or brackets

FILES TO INVESTIGATE:
  - src/main/java/com/godwhitelist/listeners/JoinListener.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariJun 6 at 2:58 pm 1

The file has a stray XML tag on line 36 that breaks compilation.

Fixed the stray tag. Let me verify the other files are clean too

Clean. Let me also check GWCommand.java for the same issue and verify with a compile

No stray tags anywhere. The plugin should compile clean now.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
11 616
src/main/java/com/godwhitelist/GodWhitelist.java
package com.godwhitelist;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.UUID;

public class GodWhitelist extends JavaPlugin {

    private DataManager dataManager;
    private WhitelistManager whitelistManager;
    private DiscordBot discordBot;
    private InactivityChecker inactivityChecker;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        reloadConfig();

        this.dataManager = new DataManager(this);
        this.dataManager.loadData();

        this.whitelistManager = new WhitelistManager(this);
        Bukkit.getPluginManager().registerEvents(this.whitelistManager, this);

        this.discordBot = new DiscordBot(this);

        if (getConfig().getBoolean("discord.enabled")) {
            String token = getConfig().getString("discord.bot-token", "");
            if (!token.isEmpty()) {
                this.discordBot.connect(token);
            }
        }

        this.inactivityChecker = new InactivityChecker(this);
        this.inactivityChecker.start();

        Bukkit.setWhitelist(getConfig().getBoolean("whitelist-enabled", true));

        getLogger().info("GodWhitelist v" + getDescription().getVersion() + " enabled.");
    }

    @Override
    public void onDisable() {
        if (this.discordBot != null) {
            this.discordBot.disconnect();
        }
        if (this.dataManager != null) {
            this.dataManager.saveData();
        }
        if (this.inactivityChecker != null) {
            this.inactivityChecker.stop();
        }
        getLogger().info("GodWhitelist disabled.");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 0) {
            sender.sendMessage("§6§lGodWhitelist §7v" + getDescription().getVersion());
            sender.sendMessage("§7/gw reload §f- Reload config");
            sender.sendMessage("§7/gw on §f- Enable whitelist");
            sender.sendMessage("§7/gw off §f- Disable whitelist");
            sender.sendMessage("§7/gw whitelist <player> §f- Add player to whitelist");
            sender.sendMessage("§7/gw unwhitelist <player> §f- Remove player from whitelist");
            return true;
        }

        switch (args[0].toLowerCase()) {
            case "reload":
                if (!sender.hasPermission("godwhitelist.reload")) {
                    sender.sendMessage("§cYou don't have permission.");
                    return true;
                }
                reloadConfig();
                this.dataManager.loadData();
                boolean discordEnabled = getConfig().getBoolean("discord.enabled");
                String token = getConfig().getString("discord.bot-token", "");
                if (discordEnabled && !token.isEmpty()) {
                    this.discordBot.disconnect();
                    this.discordBot.connect(token);
                }
                sender.sendMessage("§aGodWhitelist config reloaded.");
                break;

            case "on":
                if (!sender.hasPermission("godwhitelist.admin")) {
                    sender.sendMessage("§cYou don't have permission.");
                    return true;
                }
                Bukkit.setWhitelist(true);
                getConfig().set("whitelist-enabled", true);
                saveConfig();
                sender.sendMessage("§aWhitelist enabled.");
                getLogger().info("Whitelist enabled by " + sender.getName());
                break;

            case "off":
                if (!sender.hasPermission("godwhitelist.admin")) {
                    sender.sendMessage("§cYou don't have permission.");
                    return true;
                }
                Bukkit.setWhitelist(false);
                getConfig().set("whitelist-enabled", false);
                saveConfig();
                sender.sendMessage("§cWhitelist disabled.");
                getLogger().info("Whitelist disabled by " + sender.getName());
                break;

            case "whitelist":
                if (!sender.hasPermission("godwhitelist.admin")) {
                    sender.sendMessage("§cYou don't have permission.");
                    return true;
                }
                if (args.length < 2) {
                    sender.sendMessage("§cUsage: /gw whitelist <player>");
                    return true;
                }
                String addName = args[1];
                whitelistManager.resolveUUID(addName).thenAccept(optUuid -> {
                    if (optUuid.isEmpty()) {
                        sender.sendMessage("§cCould not resolve UUID for " + addName);
                        return;
                    }
                    UUID uuid = optUuid.get();
                    if (dataManager.isWhitelisted(uuid)) {
                        sender.sendMessage("§e" + addName + " is already whitelisted.");
                        return;
                    }
                    Bukkit.getScheduler().runTask(this, () -> {
                        whitelistManager.addToBukkitWhitelist(uuid, addName);
                        dataManager.addPlayer(uuid, addName);
                        dataManager.saveData();
                        sender.sendMessage("§a" + addName + " has been whitelisted.");
                        getLogger().info(addName + " whitelisted by " + sender.getName());
                    });
                });
                break;

            case "unwhitelist":
                if (!sender.hasPermission("godwhitelist.admin")) {
                    sender.sendMessage("§cYou don't have permission.");
                    return true;
                }
                if (args.length < 2) {
                    sender.sendMessage("§cUsage: /gw unwhitelist <player>");
                    return true;
                }
                String removeName = args[1];
                whitelistManager.resolveUUID(removeName).thenAccept(optUuid -> {
                    if (optUuid.isEmpty()) {
                        sender.sendMessage("§cCould not resolve UUID for " + removeName);
                        return;
                    }
                    UUID uuid = optUuid.get();
                    if (!dataManager.isWhitelisted(uuid)) {
                        sender.sendMessage("§e" + removeName + " is not in the whitelist.");
                        return;
                    }
                    Bukkit.getScheduler().runTask(this, () -> {
                        whitelistManager.removeFromBukkitWhitelist(uuid);
                        dataManager.removePlayer(uuid);
                        dataManager.saveData();
                        sender.sendMessage("§a" + removeName + " has been removed from the whitelist.");
                        getLogger().info(removeName + " unwhitelisted by " + sender.getName());
                    });
                });
                break;

            default:
                sender.sendMessage("§cUnknown subcommand. Use /gw for help.");
        }

        return true;
    }

    public DataManager getDataManager() {
        return dataManager;
    }

    public WhitelistManager getWhitelistManager() {
        return whitelistManager;
    }

    public DiscordBot getDiscordBot() {
        return discordBot;
    }

    public InactivityChecker getInactivityChecker() {
        return inactivityChecker;
    }
}