All Mods Resource Packs Data Packs Shaders Modpacks Plugins
Player Roles

Player Roles

by NucleoidMC • Downloads: 0 • Followers: 0
Description
Gallery
Changelog
Versions

Player Roles for Fabric

This is a simple implementation allowing for custom permissions to be assigned to players via Discord-like "roles". Roles and their permissions are defined within a JSON file, which can be easily modified and reloaded at runtime for rapid iteration.

The roles.json file is located in the config directory (<root>/config/roles.json). An example configuration may look like:

{
  "admin": {
    "level": 100,
    "overrides": {
      "name_decoration": {
        "style": ["red", "bold"],
        "suffix": {"text": "*"}
      },
      "permission_level": 4,
      "command_feedback": true,
      "commands": {
        ".*": "allow"
      }
    }
  },
  "spectator": {
    "level": 10,
    "overrides": {
      "commands": {
        "gamemode (spectator|adventure)": "allow"
      }
    }
  },
  "mute": {
    "level": 1,
    "overrides": {
      "mute": true
    }
  },
  "everyone": {
    "overrides": {
      "commands": {
        "help": "allow",
        ".*": "deny"
      }
    }
  }
}

But what's going on here? This JSON file is declaring three roles: admin, spectator and everyone.

everyone is the default role: every player will have this role, and it cannot be removed. The other roles that are specified function as overrides on top of the everyone role.

Overrides

Within each role declaration, we list a set of overrides. Overrides are the generic system that this mod uses to change game behavior based on roles. Currently, the supported override types are commands, name_decoration, chat_type, mute, command_feedback, permission_level and entity_selectors.

It is important to consider how overrides are applied when multiple roles target the same things. Conflicts like this are resolved by always choosing the role with the highest level. So, in the case of the example: although everyone declares every command except help to be disallowed, because admin and spectator have higher levels, they will override this behaviour.

Commands

The commands override is used to manipulate the commands that a player is able to use. Each override entry specifies a regular expression pattern to match, and then a strategy for how to respond when the mod encounters that pattern.

For example, the pattern .* matches every possible command, while gamemode (spectator|adventure) would match the gamemode command only with spectator and adventure mode. The strategies that can then be used alongside these patterns are allow and deny: allow will make sure that the player is allowed to use this command, while deny will prevent the player from using this command.

For example:

"commands": {
  "gamemode (spectator|adventure)": "allow"
}

The commands override can additionally make use of the hidden rule result, which will allow the command to be used, while hiding it from command suggestions.

Name Decoration

The name_decoration override modifies how the names of players with a role are displayed. This can be used to override name colors as well as prepend or append text. This has lower priority than scoreboard team colors.

Name decoration might be declared like:

"name_decoration": {
  "prefix": {"text": "[Prefix] ", "color": "green"},
  "suffix": {"text": "-Suffix"},
  "style": ["#ff0000", "bold", "underline"],
  "contexts": ["chat", "tab_list"]
}

Three fields can be optionally declared:

  • style: accepts a list of text formatting types or hex colors
  • prefix: accepts a text component that is prepended before the name
  • suffix: accepts a text component that is appended after the name
  • contexts: accepts a set of possible contexts defining where this decoration should be applied
    • Accepts: chat and tab_list
    • Default: applies to all possible contexts

Chat Types

The chat_type override allows the chat message decorations to be replaced for all players with a role. This integrates with the Vanilla minecraft:chat_type registry, which can be altered with a datapack.

The chat_type override declares simply the chat_type that should be used:

"chat_type": "minecraft:say_command"

This example will replace all messages for players with a given role to apply the say_command style.

It is important to note that Vanilla chat type registry is loaded from the datapack on server start, and cannot be hot-reloaded like the player roles config.

Declaring custom chat types

Custom chat types can be declared with a custom datapack in data/<namespace>/chat_type/<name>.

For example, we might declare a data/mydatapack/chat_type/admin.json:

{
  "chat": {
    "decoration": {
      "parameters": ["sender", "content"],
      "style": {},
      "translation_key": "%s: %s <- an admin said this!"
    }
  },
  "narration": {
    "decoration": {
      "parameters": ["sender", "content"],
      "style": {},
      "translation_key": "chat.type.text.narrate"
    },
    "priority": "chat"
  }
}

Which can be then referenced in an override like:

"chat_type": "mydatapack:admin"

Permission Level

The permission_level override sets the vanilla permission level for assigned players. This is useful for interacting with other mods, as well as with vanilla features that aren't supported by this mod.

Permission level is declared like:

"permission_level": 4

Mute

The mute override functions very simply by preventing assigned players from typing in chat.

Mute is declared like:

"mute": true

Command Feedback

By default, all operators receive global feedback when another player runs a command. The command_feedback override allows specific roles to receive this same kind of feedback.

Command feedback is declared like:

"command_feedback": true

Entity Selectors

Normally, only command sources with a permission level of two or higher can use entity selectors. The entity_selectors override allows specific roles to use entity selectors.

Entity selectors can be allowed like:

"entity_selectors": true

Other configuration

Roles can additionally be applied to command blocks or function executors through the configuration file. For example:

{
  "commands": {
    "apply": {
      "command_block": true,
      "function": true
    },
    "overrides": {
    }
  }
}

It may also be useful for a role to inherit the overrides from another role. This can be done with the includes declaration by referencing other roles with a lower level. For example:

{
  "foo": {
    "includes": ["bar"],
    "overrides": {
      "commands": {
        ".*": "allow"
      }
    }
  },
  "bar": {
    "overrides": {
      "name_decoration": {
        "style": "red"
      }
    }
  }
}

With this configuration, the foo role will inherit the red name_decoration.

Applying roles in-game

Once you've made modifications to the roles.json file, you can reload it by using the /role reload.

All role management goes through this role command via various subcommands. For example:

  • role assign Gegy admin: assigns the admin role to Gegy
  • role remove Gegy admin: removes the admin role from Gegy
  • role list Gegy: lists all the roles that have been applied to Gegy
  • role reload: reloads the roles.json configuration file

All Versions

+ Add Version
Name Game version Platforms Published Downloads Actions
26.3
Fabric
1mo ago 1
26.2
Fabric
4mo ago 1
26.1.x
Fabric
5mo ago 1
26.1.x
Fabric
7mo ago 1
1.21.x
Fabric
10mo ago 1
1.21.x
Fabric
10mo ago 1
1.21.x
Fabric
last yr. 1
1.21.x
Fabric
last yr. 1
1.21.6
Fabric
last yr. 1
1.21.5
Fabric
last yr. 1
1.21.5
Fabric
last yr. 1
1.21.x
Fabric
last yr. 1
1.21.1
Fabric
last yr. 1
1.21
Fabric
last yr. 1
1.20.6
Fabric
last yr. 1
1.20.4
Fabric
last yr. 1
1.20.4
Fabric
last yr. 1
1.20.2
Fabric
last yr. 1
1.20.x
Fabric
last yr. 1
1.20
Fabric
last yr. 1
1.19.4
Fabric
last yr. 1
1.19.3
Fabric
last yr. 1
1.19.3-rc1
Fabric
last yr. 1
1.19.1
Fabric
last yr. 1
1.19
Fabric
last yr. 1
1.18.1
Fabric
last yr. 1
1.18.x
Fabric
last yr. 1
1.18
Fabric
last yr. 1
1.17.1
Fabric
last yr. 1
1.17
Fabric
last yr. 1
1.17
Fabric
last yr. 1
1.17
Fabric
last yr. 1
1.16.x
Fabric
last yr. 1
1.16.4
Fabric
last yr. 1
1.16.4
Fabric
last yr. 1
1.16.4
Fabric
last yr. 1
[1.9.0-pre.1] v1.9.0-pre.1 by NucleoidMC on Mar 31, 2026
Download
## What's Changed

## New Contributors

[1.7.0+1.21.10] v1.7.0+1.21.10 by NucleoidMC on Oct 10, 2025
Download
## What's Changed
  • Updated to Minecraft 1.21.10


[1.6.14+1.21.5] v1.6.14+1.21.5 by NucleoidMC on Apr 29, 2025
Download
## What's Changed


[1.6.13+1.21.1] v1.6.13+1.21.1 by NucleoidMC on Oct 28, 2024
Download
## What's Changed

## New Contributors

[1.6.11+1.21] v1.6.11+1.21 by NucleoidMC on Jun 19, 2024
Download
[1.6.9+1.20.4] v1.6.9+1.20.4 by NucleoidMC on Jun 08, 2024
Download
## What's Changed

## New Contributors

[v1.6.8+1.20.4] v1.6.8+1.20.4 by NucleoidMC on Dec 16, 2023
Download
## What's Changed
  • Updated to 1.20.4 by @jaskarth


[v1.6.7+1.20.2] v1.6.7+1.20.2 by NucleoidMC on Oct 24, 2023
Download
## What's Changed


[v1.6.6+1.20] v1.6.6+1.20 by NucleoidMC on Jul 01, 2023
Download
## What's Changed
  • Name decorations are now applied in the tab list
  • A new contexts list field is now included in the name_decoration override, which can be used to control where name decorations are applied
  • Accepted values are chat and tab_list
  • Fix POM dependencies by @kb-1000 in https://github.com/NucleoidMC/player-roles/pull/73
  • Fix #56: improve compatibility with some mods such as EssentialAddons by avoiding Mixin conflict
  • Fix #71: increase maximum command chain length to support all of Vanilla commands

## New Contributors

[v1.6.4+1.19.4] v1.6.4+1.19.4 by NucleoidMC on Mar 15, 2023
Download
## What's Changed
  • Update to Minecraft 1.19.4


## What's Changed


[1.6.2] player-roles-1.6.2 by NucleoidMC on Dec 03, 2022
Download
  • Update to Minecraft 1.19.3-rc1
[1.6.1] player-roles-1.6.1 by NucleoidMC on Jul 27, 2022
Download
  • Update to Minecraft 1.19.1
[1.6.0] player-roles-1.6.0 by NucleoidMC on Jun 07, 2022
Download
  • Update to 1.19 (thanks @Foxite!)
  • Replace chat_format override with chat_type that references the Vanilla chat type registry
  • Replace name_style override with name_decoration that can support applying prefixes & suffixes to names

These are **breaking** changes to these overrides that are required to update to support 1.19's new chat features. Details on how to use these overrides can be found in the [README](https://github.com/NucleoidMC/player-roles/blob/1.19/README.md).

[1.5.2] player-roles-1.5.2 by NucleoidMC on Feb 10, 2022
Download
  • Fix role autocompletion giving only higher roles (#50, thanks @EnnuiL!)
  • Fix chat_format override not applying for other players (#51)
  • Fix incompatibility with Drogtor causing crashes (#52)
[1.5.1] player-roles-1.5.1 by NucleoidMC on Jan 16, 2022
Download
  • Propagate errors from override definitions that failed to parse: previously these would silently fail (incorrectly), causing confusion
  • Fix permission_keys override type not working until /role reload was run (#45)
  • Fix /role reload not sending up-to-date permissions to players, causing command suggestions to be incorrect until the next /role reload or relog
[1.5.0] player-roles-1.5.0 by NucleoidMC on Dec 10, 2021
Download
Huge thank you to all contributors for this update!

## What's Changed
  • Add the entity selectors override by @haykam821
  • Implement a VirtualServerCommandSource for specifying a custom set of roles by @ashhhleyyy
  • Update to 1.18 by @fluse1367

[1.4.3] player-roles-1.4.3 by NucleoidMC on Aug 04, 2021
Download
  • Fix incorrect permission level checking for the /role command (#41)
[1.4.2] player-roles-1.4.2 by NucleoidMC on Jun 19, 2021
Download
  • Fix chat format override not applying due to an improperly upgraded mixin
  • Fix published API jar not containing fabric.mod.json and consequently not being remapped as a dependency
[1.4.1] player-roles-1.4.1 by NucleoidMC on Jun 11, 2021
Download
  • Fix a critical issue where the game would throw an error when players attempted to respawn (#32)
[1.4.0] player-roles-1.4.0 by NucleoidMC on Jun 10, 2021
Download
  • Update to 1.17!
  • Fix wrong order of inheritance for overrides (#29)
  • Fix command blocks and functions having the everyone role applied (#28)
  • Separate out a simple includable API for interacting with Player Roles
Player Roles Icon
Download Player Roles
Select game version
Select platform