Build a Bukkit/Paper Minecraft server plugin implementing admin chat. Add a command /ac that takes the rest of the message as text and sends it only to online admins, never regular players. Define admins as players with the permission adminchat.use (and allow console use sensibly if appropriate). Register the command, permission defaults, and plugin metadata in the project's standard files. Ensure sensible behavior for missing message (show usage) and no recipients. Keep the implementation focused and compatible with the project’s configured server/API version. Do not add tests.

Kodari AI
KodariNov 14 at 5:29 pm 1
AdminChatRelay
AdminChatRelay is a Bukkit/Paper plugin providing a private admin chat channel. The /ac command captures the rest of the message and broadcasts it exclusively to online players with the adminchat.use permission, keeping conversations hidden from regular players. The plugin registers the command, defines the permission with default OP status, and supports console usage. It displays usage help when no message is provided and gracefully handles cases with no eligible recipients. The implementation is lightweight, focused, and compatible with modern Paper server versions.
  1. Add the Gradle/Paper project setup for Java 21.

  2. Implement /ac with permission-filtered delivery and sensible console/no-recipient handling.

  3. Register the command, permission default, and plugin metadata in plugin.yml.

Implemented /ac <message> with adminchat.use-only delivery, defaulting to operators. Console can send messages; missing text shows usage, and the sender is notified if there are no online admin recipients. Added the Paper 1.21.4 / Java 21 project setup.

Walter Bean

update it to the newest

Kodari AI
KodariNov 14 at 5:39 pm 1

Updated the Paper API target to the newest published version, 26.3 pre-release, and updated the Java toolchain to 25 and plugin.yml’s API version to 26.3.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 97
src/main/java/com/kodari/adminchat/AdminChatPlugin.java
package com.kodari.adminchat;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class AdminChatPlugin extends JavaPlugin implements CommandExecutor {
    private static final String PERMISSION = "adminchat.use";

    @Override
    public void onEnable() {
        Objects.requireNonNull(getCommand("ac"), "Command 'ac' is missing from plugin.yml")
                .setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender instanceof Player && !sender.hasPermission(PERMISSION)) {
            sender.sendMessage(ChatColor.RED + "You do not have permission to use admin chat.");
            return true;
        }

        if (args.length == 0) {
            sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <message>");
            return true;
        }

        List<Player> recipients = new ArrayList<>();
        for (Player player : getServer().getOnlinePlayers()) {
            if (player.hasPermission(PERMISSION)) {
                recipients.add(player);
            }
        }

        if (recipients.isEmpty()) {
            sender.sendMessage(ChatColor.RED + "There are no online admins to receive your message.");
            return true;
        }

        String message = String.join(" ", args);
        String senderName = sender instanceof Player ? sender.getName() : "Console";
        String formatted = ChatColor.DARK_GRAY + "[" + ChatColor.RED + "AdminChat" + ChatColor.DARK_GRAY + "] "
                + ChatColor.RED + senderName + ChatColor.GRAY + ": " + ChatColor.WHITE + message;

        for (Player recipient : recipients) {
            recipient.sendMessage(formatted);
        }
        if (!(sender instanceof Player)) {
            sender.sendMessage(formatted);
        }
        return true;
    }
}