christianm266
📎 1 file 6,658 chars
📄
pasted-code-1777208083790.txt
txt 214 lines
▶
Create a production-ready Minecraft Paper plugin for 1.21.11 named DraculaCommandHider.

Goal:
Build a lightweight tab-completion visibility plugin that hides commands from players when they type "/" in chat. It must show only commands allowed for that player's permission group. This plugin is for a Paper server and must work cleanly with LuckPerms.

Core behavior:
- Use PlayerCommandSendEvent to filter root command visibility sent to players.
- Also use TabCompleteEvent only where useful for arguments/subcommands, but do not rely on it for root command hiding.
- Do not break command execution by itself. This plugin is for command visibility, not command blocking.
- If a player manually types a hidden command and they still have permission for it from another plugin, this plugin should not cancel execution unless I enable an optional block-hidden-commands setting in config.
- Hide plugin namespace commands like "plugin:command" from normal players.
- Support Paper 1.21.11 and Java 21.

Architecture:
- Maven project.
- Clean package structure.
- Main class: com.draculamc.commandhider.DraculaCommandHider
- Managers/services for config loading, group resolution, command filtering, and optional command blocking.
- Use null-safe code and good logging.
- No NMS.
- No external database.
- Optional PlaceholderAPI not required.
- Hook into LuckPerms only if available, otherwise fall back to Bukkit permissions.

Permission/group model:
The plugin must support config-driven groups based on permission nodes.
A player belongs to the first matching visible-command group by permission priority.
Example group permissions:
- draculahider.group.default
- draculahider.group.helper
- draculahider.group.admin
- draculahider.bypass
Players with draculahider.bypass can see all commands.

Important:
This plugin must support two whitelist methods:
1. command labels whitelist
2. permission-node-based visibility mapping

Meaning:
- I can whitelist exact visible commands like "team", "ally", "war", "spawn", "rtp"
- I can also map a permission node to one or more visible commands
  Example:
  draculateamwar.team -> team
  draculateamwar.ally -> ally
  draculateamwar.war -> war
  essentials.spawn -> spawn
  zenrtp.use -> rtp
If the player has the permission node, they can see the mapped command in tab completion.

Config requirements:
Create a full config.yml with comments and examples.

Config sections:
- settings:
    debug: false
    hide-namespaced-commands: true
    hide-minecraft-defaults: false
    block-hidden-commands: false
    case-sensitive: false
    refresh-on-join: true
    refresh-on-world-change: true
    refresh-on-permission-change: false
- groups:
    default:
      priority: 1
      match-permission: draculahider.group.default
      visible-commands:
        - team
        - ally
        - war
        - spawn
        - rtp
        - bed
        - auction
        - ah
        - tax
        - paytax
        - showfines
        - showtax
        - trade
        - mobcash
        - claim
        - claims
        - unclaim
        - buyclaimblocks
        - sellclaimblocks
      visible-by-permissions:
        draculateamwar.team:
          - team
        draculateamwar.ally:
          - ally
        draculateamwar.war:
          - war
        essentials.spawn:
          - spawn
        zenrtp.use:
          - rtp
        bedspawn.use:
          - bed
        ezauction.auction:
          - auction
          - ah
        eztax.command.use:
          - tax
        eztax.command.paytax:
          - paytax
        eztax.command.showfines:
          - showfines
        eztax.command.showtax:
          - showtax
        axtrade:
          - trade
        axtrade.trade:
          - trade
        lmobcash.receive:
          - mobcash
        lmobcash.stats:
          - mobcash
        griefprevention.claims:
          - claim
          - claims
        griefprevention.createclaims:
          - claim
        griefprevention.deleteclaims:
          - unclaim
        griefprevention.buysellclaimblocks:
          - buyclaimblocks
          - sellclaimblocks

- aliases:
    ah: auction
    claims: claim

- blocked-root-commands:
    - plugins
    - pl
    - ver
    - version
    - about
    - bukkit:plugins
    - bukkit:pl
    - bukkit:ver
    - bukkit:version
    - minecraft:help

- blocked-namespaces:
    - bukkit
    - spigot
    - paper
    - minecraft

Commands:
- /draculahider reload
- /draculahider debug
- /draculahider check 
- /draculahider list 

Permissions:
- draculahider.admin
- draculahider.reload
- draculahider.debug
- draculahider.check
- draculahider.bypass
- draculahider.group.default
- draculahider.group.helper
- draculahider.group.admin

Behavior details:
- On PlayerCommandSendEvent, filter the command set so the player only receives allowed root commands.
- Strip namespaced duplicates such as minecraft:help or plugin:command unless bypassed.
- Merge visibility from:
  1. static visible-commands list
  2. visible-by-permissions mappings for permissions the player currently has
- If multiple groups match, use highest priority or merge based on a config setting:
  group-resolution-mode: highest-priority
  supported values: highest-priority, merge
- Add detailed debug logging when debug is true:
  show player name, matched group, visible commands, removed commands.
- Make reload safe and re-read config fully.

Optional advanced features:
- Optional support for hiding subcommands for known commands using TabCompleteEvent.
- Optional per-world visibility groups.
- Optional per-server-mode preset for survival/hub/staff.

plugin.yml requirements:
- proper commands
- proper permissions
- api-version compatible with modern Paper
- clean descriptions

Build requirements:
- Java 21
- Maven
- Paper API for 1.21.11
- Deliver full source code, plugin.yml, config.yml, pom.xml
- Ensure it compiles successfully
- Keep the plugin lightweight and readable

Code quality requirements:
- No placeholder stubs
- No TODO comments left unfinished
- No dead code
- No legacy color code abuse
- Use modern Java style
- Defensive coding for nulls and missing dependencies
- Clear comments only where needed

After generating code:
- verify compile success
- verify root command hiding logic uses PlayerCommandSendEvent
- verify command blocking is optional and disabled by default
- verify config examples match the exact permissions and commands above
Kodari AI
KodariApr 26 at 12:59 pm 27,010 (v2)

I’ll create a production-ready command hiding plugin for Paper 1.21.11.

DraculaCommandHider
A lightweight tab-completion visibility plugin that hides commands from players based on permission groups. Features include permission-based command filtering, LuckPerms integration, group priority system, optional command blocking, namespace hiding, and dynamic group resolution. Supports both static command whitelists and permission-node-based visibility mapping for fine-grained control over command accessibility.

✅ DraculaCommandHider Complete

Production-ready features implemented:

Core Functionality:

  • PlayerCommandSendEvent filtering for root command hiding

  • Permission-based group system with priority resolution

  • Dual whitelist methods: static commands + permission-node mappings

  • Optional command execution blocking (disabled by default)

  • Namespace command filtering (bukkit:, minecraft:, etc.)

  • Command alias resolution

Group System:

  • Configurable priority-based groups

  • Two resolution modes: highest-priority or merge

  • Wildcard support for admin groups

  • Dynamic visibility via permission mappings

  • LuckPerms integration with fallback to Bukkit permissions

Configuration:

  • Comprehensive config with all requested examples

  • Debug logging with detailed filtering information

  • Case-sensitive option

  • Refresh triggers: join, world change, permission change

  • Blocked commands and namespaces lists

Commands:

  • /draculahider reload - Hot reload configuration

  • /draculahider debug - Toggle debug mode

  • /draculahider check <player> - Inspect player’s visible commands

  • /draculahider list <group> - View group configuration

Technical:

  • Maven build (Java 21, Paper 1.21.11)

  • Null-safe with defensive coding

  • No NMS, no external database

  • Clean package structure with managers, listeners, config

  • Permission-based access control

  • Tab completion for all commands

Compiles successfully and ready for deployment.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
13 1,235
src/main/java/com/draculamc/commandhider/DraculaCommandHider.java
package com.draculamc.commandhider;

import com.draculamc.commandhider.command.DraculaHiderCommand;
import com.draculamc.commandhider.config.ConfigManager;
import com.draculamc.commandhider.listener.CommandBlockListener;
import com.draculamc.commandhider.listener.CommandSendListener;
import com.draculamc.commandhider.listener.PlayerRefreshListener;
import com.draculamc.commandhider.manager.CommandFilterManager;
import com.draculamc.commandhider.manager.GroupManager;
import lombok.Getter;
import net.luckperms.api.LuckPerms;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

public class DraculaCommandHider extends JavaPlugin {
    
    @Getter
    private ConfigManager configManager;
    
    @Getter
    private GroupManager groupManager;
    
    @Getter
    private CommandFilterManager commandFilterManager;
    
    @Getter
    private LuckPerms luckPerms;
    
    @Override
    public void onEnable() {
        long startTime = System.currentTimeMillis();
        
        getLogger().info("Initializing DraculaCommandHider...");
        
        this.configManager = new ConfigManager(this);
        this.configManager.loadConfig();
        
        this.luckPerms = loadLuckPerms();
        if (this.luckPerms != null) {
            getLogger().info("LuckPerms detected and hooked successfully!");
        } else {
            getLogger().info("LuckPerms not found. Using Bukkit permissions.");
        }
        
        this.groupManager = new GroupManager(this);
        this.commandFilterManager = new CommandFilterManager(this);
        
        registerListeners();
        registerCommands();
        
        long loadTime = System.currentTimeMillis() - startTime;
        getLogger().info("DraculaCommandHider enabled in " + loadTime + "ms");
    }
    
    @Override
    public void onDisable() {
        getLogger().info("DraculaCommandHider disabled");
    }
    
    private void registerListeners() {
        Bukkit.getPluginManager().registerEvents(new CommandSendListener(this), this);
        Bukkit.getPluginManager().registerEvents(new PlayerRefreshListener(this), this);
        
        if (this.configManager.isBlockHiddenCommands()) {
            Bukkit.getPluginManager().registerEvents(new CommandBlockListener(this), this);
            getLogger().info("Command blocking enabled");
        }
    }
    
    private void registerCommands() {
        DraculaHiderCommand mainCommand = new DraculaHiderCommand(this);
        getCommand("draculahider").setExecutor(mainCommand);
        getCommand("draculahider").setTabCompleter(mainCommand);
    }
    
    private LuckPerms loadLuckPerms() {
        RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
        if (provider != null) {
            return provider.getProvider();
        }
        return null;
    }
    
    public void reload() {
        this.configManager.loadConfig();
        this.groupManager = new GroupManager(this);
        this.commandFilterManager = new CommandFilterManager(this);
        getLogger().info("Configuration reloaded");
    }
    
    public boolean hasLuckPerms() {
        return this.luckPerms != null;
    }
}