tcoad

Create a Minecraft Paper plugin for my server called CustomRoles.

I want a fully customizable role system with these commands:

/role create <role>

Creates a new role.

/role add <player> <role>

Assigns an existing role to a player.

/role remove <player> <role>

Removes a role from a player.

/role config

Opens/configures the role settings.

Change the role's color.

Toggle bold text on/off.

Configure which Minecraft commands each role is allowed to use.

Add or remove commands from a role's permission list.

Role display:

The player's role must appear before their Minecraft username in the TAB list.

The role must also appear before their username above the player's head/name tag.

Example: Admin Steve Use the configured role color and bold setting.

Permissions:

Each role has its own configurable command permissions.

Example: a Mod role could be allowed to use /kick, /mute, and /ban.

A player without permission for a command must not be able to use it.

The permissions must be editable through /role config.

Other requirements:

Support multiple roles.

Save all roles, players, colors, formatting, and command permissions to files so they persist after server restarts.

Include tab completion for all /role commands.

Only players with the appropriate role-management permission can create, edit, or assign roles.

Support Minecraft 1.21.11 and Paper.

Include plugin.yml and all required source files.

Kodari AI
KodariAug 18 at 4:12 pm 2
CustomRoles
CustomRoles is a Minecraft Paper plugin that introduces a fully customizable role system. It allows server administrators to create roles, assign them to players, and configure each role's display name color, bold formatting, and permitted commands. Players with roles see their role prefix before their username in the TAB list and above their head. The plugin includes commands like /role create, /role add, /role remove, and /role config, with tab completion and permission-based access. All roles, player assignments, and settings persist across server restarts via YAML files, supporting multiple roles and editable command permissions.

Created CustomRoles as a Paper 1.21.11 plugin.

  • Added /role create, /role add, /role remove, /role config, and /role list.

  • Added tab completion for roles, players, colors, formatting, and command settings.

  • Added GUI-based role configuration with color cycling and bold toggling.

  • Added command-based permission editing:

    • /role config <role> command add <command>

    • /role config <role> command remove <command>

  • Added multi-role support with persistent assignments.

  • Added colored and bold role prefixes in TAB and above player name tags.

  • Added command access enforcement through role permissions.

  • Added customroles.manage management permission.

  • Added persistent roles.yml and players.yml storage.

  • Added Gradle build files, plugin.yml, and config.yml.

tcoad

make it so u can see it next to the players name

Kodari AI
KodariAug 18 at 4:17 pm 1
  1. Move the role label from before the username to after it in both the TAB list and overhead name tag, preserving the configured color and bold formatting.

Updated the role display so it appears next to the player’s name:

  • TAB list: Steve Admin

  • Above the player: Steve Admin

The configured role color and bold formatting are preserved.

tcoad

compile it

Kodari AI
KodariAug 18 at 4:18 pm 1

I can’t run the compilation directly in this environment because Gradle/Maven/Javac aren’t installed. The project is set up for automatic verifier compilation.

Locally, run:

Shell
./gradlew build

The compiled plugin will be at:

Plain Text
build/libs/CustomRoles-1.0.0.jar
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle.kts
manifest.kod
settings.gradle.kts
Code
14 985
src/main/java/com/kodari/customroles/CustomRolesPlugin.java
package com.kodari.customroles;

import com.kodari.customroles.command.RoleCommand;
import com.kodari.customroles.display.RoleDisplayManager;
import com.kodari.customroles.listener.CommandPermissionListener;
import com.kodari.customroles.manager.PlayerRoleManager;
import com.kodari.customroles.manager.RoleManager;
import com.kodari.customroles.storage.RoleStorage;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class CustomRolesPlugin extends JavaPlugin implements Listener {
    private RoleStorage storage;
    private RoleManager roleManager;
    private PlayerRoleManager playerRoleManager;
    private RoleDisplayManager displayManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        storage = new RoleStorage(getDataFolder());
        roleManager = new RoleManager();
        roleManager.load(storage.loadRoles());
        playerRoleManager = new PlayerRoleManager(roleManager);
        playerRoleManager.load(storage.loadPlayers());
        displayManager = new RoleDisplayManager(playerRoleManager);

        RoleCommand roleCommand = new RoleCommand(this, roleManager, playerRoleManager, displayManager);
        PluginCommand command = getCommand("role");
        if (command == null) {
            getLogger().severe("The role command is missing from plugin.yml.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        command.setExecutor(roleCommand);
        command.setTabCompleter(roleCommand);

        getServer().getPluginManager().registerEvents(roleCommand, this);
        getServer().getPluginManager().registerEvents(
                new CommandPermissionListener(playerRoleManager), this);
        getServer().getPluginManager().registerEvents(this, this);
        displayManager.updateAll();
    }

    @Override
    public void onDisable() {
        if (storage != null) {
            saveData();
        }
        if (displayManager != null) {
            displayManager.clear();
        }
    }

    public void saveData() {
        storage.saveRoles(roleManager.getRoles());
        storage.savePlayers(playerRoleManager.getStoredRoles());
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        Bukkit.getScheduler().runTask(this, () -> displayManager.update(event.getPlayer()));
    }

    @EventHandler
    public void onQuit(PlayerQuitEvent event) {
        displayManager.remove(event.getPlayer());
    }
}