suman731220

Act as an Expert Senior Minecraft Java Plugin Developer (Paper API 1.21.x). I need you to create a completely custom, lightweight, and highly optimized Chat Color plugin.

The plugin must be compiled for Java 21 and Paper 1.21.x with ZERO compilation errors and NO deprecated methods. It must cause absolutely ZERO lag and no server crashes.

CORE FEATURES & LOGIC:

  1. Modern Chat Event: - Use Paper's modern AsyncChatEvent (do NOT use the deprecated AsyncPlayerChatEvent).

- Only change the color of the chat MESSAGE itself, keeping the player's name and prefix formatting intact.

  1. Data Storage (Zero Lag):

- Do NOT use external files (like data.yml) to save player colors, as it causes I/O lag. - Use Minecraft's native PersistentDataContainer (PDC) to save the player's selected chat color directly to their UUID. This ensures data is never lost and loads instantly.

  1. Default State:

- If a player has not selected any color (or is new), their chat must remain the default server color.

  1. Colors, Commands, and Permissions:

- The plugin must support exactly these colors: red, dark-red, gold, yellow, lime, green, aqua, cyan, light-blue, blue, purple, pink, white, gray, dark-gray, black. - Command structure: /chatcolor <color> (e.g., /chatcolor red, /chatcolor light-blue). - Every single color MUST have its own strict permission. Format: chatcolor.use.<color> (e.g., chatcolor.use.red, chatcolor.use.dark-gray). - If a player doesn't have the permission for that specific color, deny them with an error message.

  1. Reset/Remove Color:

- Command: /chatcolor reset or /chatcolor off. - Permission: chatcolor.use.reset - This will remove their PDC data and revert their chat color back to default.

  1. Configuration File (config.yml):

- Provide a config.yml where I can change the plugin's prefix. - Example format: ``yaml prefix: "<gray>[<gold>ChatColor<gray>] " messages: color_changed: "<green>Your chat color has been changed to <color_name>!" color_reset: "<yellow>Your chat color has been reset to default." no_permission: "<red>You do not have permission to use this color!" invalid_color: "<red>Invalid color! Use /chatcolor list." ` - Use MiniMessage formatting (e.g., <red>, <green>) for all messages as it is the standard for Paper 1.21.x.

PROJECT STRUCTURE:

Please provide the complete project code including:

  • Main.java
  • ChatListener.java (Handling AsyncChatEvent)
  • ChatColorCommand.java (Handling /chatcolor, applying PDC, and checking permissions)
  • plugin.yml` (Registering the command and declaring permissions)

Make sure the code is extremely clean, handles Component formatting safely, and is fully ready to be compiled.

I need this all colours red dark-red gold yellow lime green aqua cyan light-blue blue purple pink white gray dark-gray black

Kodari AI
KodariMar 11 at 1:36 pm 16,105 (v2)

I’ll create a lightweight Paper 1.21.x chat color plugin with PersistentDataContainer storage and MiniMessage formatting.

ChatColor
A lightweight Paper 1.21.x chat color plugin using PersistentDataContainer for zero-lag color management. Features 16 customizable colors with individual permissions, MiniMessage formatting support, and native Minecraft data storage. Players can personalize their chat messages while maintaining server performance and data persistence without external files.

Now I’ll create the complete plugin structure:

Plugin created successfully! Here’s what I’ve built:

Key Features:

  • AsyncChatEvent - Uses Paper’s modern chat event (no deprecation)

  • PersistentDataContainer - Stores color data directly on player UUID (zero file I/O lag)

  • 16 Colors - All requested colors with individual permissions (chatcolor.use.<color>)

  • MiniMessage - Full Paper 1.21.x Adventure API support

  • Tab Completion - Auto-completes colors, reset, and list

  • Color Preview - /chatcolor list shows colors you can use

Commands:

  • /chatcolor <color> - Set your chat color

  • /chatcolor reset - Remove chat color

  • /chatcolor list - View all colors with permission status

Color Mappings:

  • Standard colors use NamedTextColor

  • Lime = #00FF00 (bright green)

  • Cyan = #00FFFF (bright aqua)

  • Pink = #FFB6C1 (light pink)

The plugin is optimized for zero lag, compiles on Java 21, and stores data permanently in Minecraft’s native PDC system.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
7 369
src/main/java/com/example/chatcolor/ChatColor.java
package com.example.chatcolor;

import com.example.chatcolor.command.ChatColorCommand;
import com.example.chatcolor.listener.ChatListener;
import lombok.Getter;
import org.bukkit.NamespacedKey;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class ChatColor extends JavaPlugin {
    private NamespacedKey chatColorKey;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.chatColorKey = new NamespacedKey(this, "chat_color");
        
        getCommand("chatcolor").setExecutor(new ChatColorCommand(this));
        
        getServer().getPluginManager().registerEvents(new ChatListener(this), this);
        
        getLogger().info("ChatColor plugin enabled successfully!");
    }

    @Override
    public void onDisable() {
        getLogger().info("ChatColor plugin disabled!");
    }
}