kai007579

Create a Minecraft Paper 1.21.8 plugin that implements a command whitelist system. The plugin should allow server owners to define a list of allowed commands in a config.yml file, and if a player tries to use a command that is not included in the whitelist, the command should be blocked automatically and the player should receive a customizable action bar message defined in the config. The config should include options to add or remove whitelisted commands and customize the action bar message text, with support for Minecraft color codes. The plugin should work for all players except those with a specific bypass permission (e.g., commandwhitelist.bypass) so staff can still use any command. It should be lightweight, compatible with Paper 1.21.8, and properly register events like PlayerCommandPreprocessEvent to intercept commands before execution

Kodari AI
KodariMar 9 at 7:38 pm 10,809 (v2)

I’ll create a command whitelist plugin for Paper 1.21 with action bar notifications and configurable command lists.

CommandWhitelist
A lightweight command whitelist plugin for Paper that blocks unauthorized commands and displays action bar notifications. Features configurable command lists, bypass permissions for staff, and support for legacy color codes in messages. Intercepts commands using PlayerCommandPreprocessEvent before execution.

Plan

  • Core system with ConfigManager for whitelist and message storage

  • CommandListener to intercept PlayerCommandPreprocessEvent

  • Action bar notifications using Adventure API with legacy color code support

  • Bypass permission system with reload command for admins

Plugin created successfully! The CommandWhitelist system includes:

Features:

  • Command interception using PlayerCommandPreprocessEvent at HIGHEST priority

  • Configurable whitelist in config.yml (case-insensitive matching)

  • Action bar notifications with legacy color code support (&c, &a, &l, etc.)

  • Bypass permission (commandwhitelist.bypass) for staff

  • Reload command (/commandwhitelist reload or /cwl reload)

  • Adventure API integration for Paper 1.21 compatibility

Usage:

  1. Add/remove commands in whitelisted-commands list (without leading slash)

  2. Customize blocked-message with Minecraft color codes

  3. Grant commandwhitelist.bypass to staff who need unrestricted access

  4. Use /cwl reload to apply config changes without restart

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
8 213
src/main/java/com/example/commandwhitelist/CommandWhitelist.java
package com.example.commandwhitelist;

import com.example.commandwhitelist.command.ReloadCommand;
import com.example.commandwhitelist.listener.CommandListener;
import com.example.commandwhitelist.manager.ConfigManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class CommandWhitelist extends JavaPlugin {
    private ConfigManager configManager;
    
    @Override
    public void onEnable() {
        this.saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        
        this.getServer().getPluginManager().registerEvents(new CommandListener(this), this);
        
        this.getCommand("commandwhitelist").setExecutor(new ReloadCommand(this));
        
        this.getLogger().info("CommandWhitelist has been enabled!");
    }
    
    @Override
    public void onDisable() {
        this.getLogger().info("CommandWhitelist has been disabled!");
    }
}