Address review on the roles plugin

- Use the core role permissions rather than defining new ones. Assignments are
  only sent between the controller and an instance, so they are no longer
  addressed to control and need no permission at all.
- Split the datastore reconciliation into ensureRoleMeta, sweepRoleMeta and
  applyAutoAssign, all run on init as well as when roles change. Properties left
  behind by a role deleted while the plugin was not running are now swept up,
  where before they would be inherited by the next role given that id.
- Use a switch in onControllerConfigFieldChanged, matching instance.ts.
- Resolve pending assignments on initialise. A pending role is either confirmed,
  and so now held by synced_players, or it never landed; either way it stops
  being held locally. Roles assigned with assign_player_local are untouched.
- Drop the emit_updates juggling in reject_assignment, sync is already false.
- Send each permission name once and reference it by index, see the benchmark in
  the pull request. Single role updates stay in the plain form.
- Lay the role properties out in columns, name the apply button for the section
  it belongs to, and give every field a tooltip.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
bbassie
2026-08-05 08:04:36 +00:00
co-authored by Claude Opus 5
parent fcfa174794
commit dcba1eef1c
6 changed files with 212 additions and 140 deletions
+3 -30
View File
@@ -7,36 +7,9 @@ declare module "@clusterio/lib" {
}
}
lib.definePermission({
name: "exp_roles.role.list",
title: "List In Game Roles",
description: "List the in game properties of all roles.",
grantByDefault: true,
});
lib.definePermission({
name: "exp_roles.role.subscribe",
title: "Subscribe to In Game Role Updates",
description: "Receive updates when the in game properties of a role change.",
grantByDefault: true,
});
lib.definePermission({
name: "exp_roles.role.update",
title: "Update In Game Roles",
description: "Modify the in game properties of a role, such as its order and colour.",
});
lib.definePermission({
name: "exp_roles.assignment.list",
title: "List Role Assignments",
description: "List the roles held by each player in game.",
grantByDefault: true,
});
lib.definePermission({
name: "exp_roles.assignment.subscribe",
title: "Subscribe to Role Assignment Updates",
description: "Receive updates when the roles held by a player change.",
grantByDefault: true,
});
// The in game properties of a role are part of the role, so they are covered by
// the core role permissions rather than permissions of their own. Assignments
// are only ever sent between the controller and an instance, so they need none.
export const plugin: lib.PluginDeclaration = {
name: "exp_roles",