mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Sort clients in minetest.get_server_status
and privs in minetest.privs_to_string
(#15023)
This commit is contained in:
parent
6cc0452503
commit
b2f6a65bc9
3 changed files with 5 additions and 6 deletions
|
@ -702,6 +702,7 @@ function core.privs_to_string(privs, delim)
|
||||||
list[#list + 1] = priv
|
list[#list + 1] = priv
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
table.sort(list)
|
||||||
return table.concat(list, delim)
|
return table.concat(list, delim)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -221,6 +221,7 @@ core.register_chatcommand("haspriv", {
|
||||||
return true, S("No online player has the \"@1\" privilege.",
|
return true, S("No online player has the \"@1\" privilege.",
|
||||||
param)
|
param)
|
||||||
else
|
else
|
||||||
|
table.sort(players_with_priv)
|
||||||
return true, S("Players online with the \"@1\" privilege: @2",
|
return true, S("Players online with the \"@1\" privilege: @2",
|
||||||
param,
|
param,
|
||||||
table.concat(players_with_priv, ", "))
|
table.concat(players_with_priv, ", "))
|
||||||
|
|
|
@ -3181,14 +3181,11 @@ std::string Server::getStatusString()
|
||||||
bool first = true;
|
bool first = true;
|
||||||
os << " | clients: ";
|
os << " | clients: ";
|
||||||
if (m_env) {
|
if (m_env) {
|
||||||
std::vector<session_t> clients = m_clients.getClientIDs();
|
std::vector<std::string> player_names = m_clients.getPlayerNames();
|
||||||
for (session_t client_id : clients) {
|
|
||||||
RemotePlayer *player = m_env->getPlayer(client_id);
|
|
||||||
|
|
||||||
// Get name of player
|
std::sort(player_names.begin(), player_names.end());
|
||||||
const std::string name = player ? player->getName() : "<unknown>";
|
|
||||||
|
|
||||||
// Add name to information string
|
for (const std::string& name : player_names) {
|
||||||
if (!first)
|
if (!first)
|
||||||
os << ", ";
|
os << ", ";
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue