mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-09-21 17:04:00 +00:00
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:
co-authored by
Claude Fable 5
parent
bea8d46c82
commit
8a15745cf8
@@ -27,7 +27,7 @@ local types = {} --- @class (partial) Commands.types
|
||||
types.role =
|
||||
add("role", function(input)
|
||||
local names = {}
|
||||
for index, role in ipairs(Roles.get_roles()) do
|
||||
for index, role in ipairs(Roles.get_ordered_roles()) do
|
||||
names[index] = role.name
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ local format_player_name = Commands.format_player_name_locale
|
||||
local format_text = Commands.format_rich_text_color_locale
|
||||
|
||||
local Roles = require("modules/exp_roles")
|
||||
local get_roles = Roles.get_roles
|
||||
local get_ordered_roles = Roles.get_ordered_roles
|
||||
local get_player_roles = Roles.get_player_roles
|
||||
|
||||
--- Assigns a role to a player
|
||||
@@ -40,11 +40,11 @@ Commands.new("get-roles", { "exp-commands_roles.description-get" })
|
||||
:add_aliases{ "roles" }
|
||||
:register(function(player, other_player)
|
||||
--- @cast other_player LuaPlayer?
|
||||
local roles = get_roles()
|
||||
local roles = get_ordered_roles()
|
||||
local roles_formatted = { "" } --- @type LocalisedString
|
||||
local response = { "exp-commands_roles.list-roles", roles_formatted } --[[@as LocalisedString]]
|
||||
if other_player then
|
||||
roles = get_player_roles(other_player)
|
||||
roles = Roles.sort_roles(get_player_roles(other_player))
|
||||
response[1] = "exp-commands_roles.list-player"
|
||||
response[3] = format_player_name(other_player)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user