|
41 | 41 |
|
42 | 42 | if core.settings:get_bool("profiler.load") then
|
43 | 43 | -- Run after register_chatcommand and its register_on_chat_message
|
44 |
| - -- Before any chattcommands that should be profiled |
| 44 | + -- Before any chatcommands that should be profiled |
45 | 45 | profiler.init_chatcommand()
|
46 | 46 | end
|
47 | 47 |
|
@@ -103,6 +103,31 @@ core.register_chatcommand("privs", {
|
103 | 103 | end,
|
104 | 104 | })
|
105 | 105 |
|
| 106 | +core.register_chatcommand("hasprivs", { |
| 107 | + params = "<privilege>", |
| 108 | + description = "Return list of all online players with privilege.", |
| 109 | + privs = {basic_privs = true}, |
| 110 | + func = function(caller, param) |
| 111 | + param = param:trim() |
| 112 | + if param == "" then |
| 113 | + return false, "Invalid parameters (see /help hasprivs)" |
| 114 | + end |
| 115 | + if not core.registered_privileges[param] then |
| 116 | + return false, "Unknown privilege!" |
| 117 | + end |
| 118 | + local privs = core.string_to_privs(param) |
| 119 | + local players_with_privs = {} |
| 120 | + for _, player in pairs(core.get_connected_players()) do |
| 121 | + local player_name = player:get_player_name() |
| 122 | + if core.check_player_privs(player_name, privs) then |
| 123 | + table.insert(players_with_privs, player_name) |
| 124 | + end |
| 125 | + end |
| 126 | + return true, "Players online with the \"" .. param .. "\" priv: " .. |
| 127 | + table.concat(players_with_privs, ", ") |
| 128 | + end |
| 129 | +}) |
| 130 | + |
106 | 131 | local function handle_grant_command(caller, grantname, grantprivstr)
|
107 | 132 | local caller_privs = core.get_player_privs(caller)
|
108 | 133 | if not (caller_privs.privs or caller_privs.basic_privs) then
|
|
0 commit comments