Address review on the role lookups

- player_has_any_permission and player_has_all_permission, matching the
  account checks the web ui has.
- Roles are no longer sorted on the way out of every lookup. get_ordered_roles
  and the public sort_roles cover the two guis and the command which present
  roles in order, and the highest role is found with a single scan.
- get_held_role_ids returns the list and the set it already built, rather than
  a second function rebuilding the set from the list.
- get_player_names collects into a set before listing, so a player holding the
  role in both the synced and the local list is counted once.
- The role metatable is registered directly under the plugin name, dropping
  the storage import.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
bbassie
2026-08-20 22:02:51 +00:00
co-authored by Claude Fable 5
parent bea8d46c82
commit 8a15745cf8
6 changed files with 96 additions and 49 deletions
+1 -1
View File
@@ -203,7 +203,7 @@ function Elements.player_table.calculate_row_data()
-- Flatten the roles into a single ordered list
local count = 0
local row_data = {}
for _, role in ipairs(Roles.get_roles()) do
for _, role in ipairs(Roles.get_ordered_roles()) do
local role_name = role.name
if players[role_name] then
for _, player in pairs(players[role_name]) do
+1 -1
View File
@@ -214,7 +214,7 @@ define_tab(
container.add{ type = "flow" }.style.height = 4
local role_names = {}
for i, role in ipairs(Roles.get_player_roles(player)) do
for i, role in ipairs(Roles.sort_roles(Roles.get_player_roles(player))) do
role_names[i] = role.name
end