Fix player tracking.

Previously, on servers without or with non-standard join messages, you would have to run /status any time someone in a channel joined or left. Chat channels will now also search players that are visible to the client.
This commit is contained in:
luk3yx 2018-08-31 11:21:44 +12:00
parent 53fbd7e6d9
commit 6b58d8ddc2
1 changed files with 15 additions and 3 deletions

View File

@ -76,7 +76,17 @@ chat_channels.get_channel_users = function(c)
return false
end
elseif prefix == '@' then
if not connected_players[name] then return {} end
if not connected_players[name] then
local empty = true
local visible_players = minetest.get_player_names()
for _, player in ipairs(visible_players) do
if player == name then
empty = false
break
end
end
if empty then return {} end
end
return {name}
else
show_main_channel = true
@ -152,9 +162,11 @@ minetest.register_on_sending_chat_messages(function(msg)
then
local players = chat_channels.get_channel_users(msg)
if players and msg ~= '@' and msg:sub(1, 2) ~= '@/' then
local empty = true
local empty = true
local visible_players = minetest.get_player_names()
for p = 1, #players do
if connected_players[players[p]] then
if connected_players[players[p]]
or visible_players[players[p]] then
empty = false
break
end