Custom Permission & Overrides - Flemmli97/Flan GitHub Wiki

This page is both for datapack and mod devs that want to add more integration with flan.

Starting with version 1.10.0 all permissions are moved to a datapack system.

You can view all builtin permissions provided by flan under BuiltinPermission

If you are a mod developer it is recommended to use datagen instead of writing json manually. Flan has DataProviders you can use. Simply extend ClaimPermissionProvider or ClaimPermissionProvider for that

Custom Permissions

To create a custom permission simply create a datapack with a permission .json located under /data/<namespace>/claim_permissions.
For some examples refer to https://github.com/Flemmli97/Flan/tree/HEAD/common/src/generated/resources/data/flan/claim_permissions.
The id of the permission then will be <namespace>/file_name

You can generate one here

Permissions have following format:

{
  "default_value": <true | false>, // Default value this permission should have
  "global": <true | false>, // Whether this permission is global or not. Global permissions are actions without a player or that should not be changeable through player groups (e.g. Wither block breaking permission)
  "gui_item": {
    "id": <item>, // The item used in the gui
  },
  "order": <int>, // An ordering for the gui. Permissions are sorted in ascending order there
  "required_mod": <mod> // Optional. Only useful if you ship your thing in some larger context where the mod MIGHT not be present
}

Simply creating a permission is not enough though as that permission will just sit there doing nothing.

Mod devs can call

ClaimHandler#canInteract(ServerPlayer player, BlockPos pos, ResourceLocation permission)

in their code when they want to check if a player can do some action at the given position. permission should use the id of the created permission.

For datapack devs one way to utilize the newly created permission is to add an interaction override file to your datapack.

Interaction Override

Common interactions can be assigned new permission based on the value they are using.
This is done by defining an .json under data/<namespace>/claim_interactions_override.

You can generate one here

The file has following format:

{
  "type": <type>, // Type of interaction
  "values": [
    {
      "entry": <value>, // The value this represents
      "permission": <permission> // The newly assigned permission to the value
    },
    ...
  ]
}

Following interactions can be affected

  • Left clicking a block: flan:block_left_click
  • Right clicking a block: flan:block_interact
  • Right clicking with an item: flan:item_use
  • Attacking an entity: flan:entity_attack
  • Right clicking an entity: flan:entity_interact
⚠️ **GitHub.com Fallback** ⚠️