Browse Source

show real connections in players count

main
ghost 11 months ago
parent
commit
becb46d1bc
  1. 6
      src/Controller/MainController.php
  2. 5
      src/Controller/ServerController.php
  3. 2
      templates/default/main/index.html.twig
  4. 13
      templates/default/server/index.html.twig

6
src/Controller/MainController.php

@ -102,7 +102,9 @@ class MainController extends AbstractController
'online' => $server->getOnline(), 'online' => $server->getOnline(),
'info' => $info, 'info' => $info,
'status' => $status, 'status' => $status,
'sort' => empty($info['Players']) ? 0 : (int) $info['Players'] 'connections' => is_null($info['Players']) || $info['Players'] < 0 || is_null($info['Bots']) || $info['Bots'] < 0
? 0
: (int) $info['Players'] - (int) $info['Bots']
]; ];
} }
@ -110,7 +112,7 @@ class MainController extends AbstractController
array_multisort( array_multisort(
array_column( array_column(
$servers, $servers,
'sort' 'connections'
), ),
SORT_DESC, SORT_DESC,
$servers $servers

5
src/Controller/ServerController.php

@ -175,7 +175,10 @@ class ServerController extends AbstractController
'session' => $session, 'session' => $session,
'online' => $online, 'online' => $online,
'players' => $players, 'players' => $players,
'status' => $status 'status' => $status,
'connections' => is_null($info['Players']) || $info['Players'] < 0 || is_null($info['Bots']) || $info['Bots'] < 0
? 0
: (int) $info['Players'] - (int) $info['Bots']
] ]
] ]
); );

2
templates/default/main/index.html.twig

@ -35,7 +35,7 @@
<td class="text-align-left">{{ server.info.Map }}</td> <td class="text-align-left">{{ server.info.Map }}</td>
<td class="text-align-left">{{ server.added | format_date }}</td> <td class="text-align-left">{{ server.added | format_date }}</td>
<td class="text-align-left">{{ server.online | format_date }}</td> <td class="text-align-left">{{ server.online | format_date }}</td>
<td class="text-align-center">{{ server.info.Players }}</td> <td class="text-align-center">{{ server.connections }}{#{{ server.info.Players }}#}</td>
<td class="text-align-center">{{ server.info.MaxPlayers }}</td> <td class="text-align-center">{{ server.info.MaxPlayers }}</td>
<td class="text-align-center">{{ server.info.Bots }}</td> <td class="text-align-center">{{ server.info.Bots }}</td>
<td class="text-align-center"> <td class="text-align-center">

13
templates/default/server/index.html.twig

@ -70,8 +70,17 @@
<table> <table>
{% for key, value in server.info %} {% for key, value in server.info %}
<tr> <tr>
<td class="text-align-left">{{ key }}</td> <td class="text-align-left">
<td class="text-align-left">{{ value }}</td> {{ key }}
</td>
<td class="text-align-left">
{# let's show real connections for players {{ value }} #}
{% if key == 'Players' %}
{{ server.connections }}
{% else %}
{{ value }}
{% endif %}
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

Loading…
Cancel
Save