Skip to content

Commit

Permalink
Fix server sign
Browse files Browse the repository at this point in the history
Fix server sign if description is string and no well formed array,
  • Loading branch information
bumbummen99 committed May 18, 2021
1 parent 63d4d15 commit a1d5541
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions inc/extras.php
Expand Up @@ -178,27 +178,30 @@ function skycraft_query_server() {
try
{
$query = new MinecraftPing( get_theme_mod('skycraft_serversign_address'), get_theme_mod('skycraft_serversign_port'), 2 );
$data = $query->Query();

set_transient( $cacheKey, [
'status' => $status,
'result' => $data,
], '', 15 * 60 );

if( $query )
{
$query->Close();
}
}
}
catch( MinecraftPingException $e )
{
$status = false;
}
finally
{
if ($status) {
$data = $query->Query();

set_transient( $cacheKey, [
'status' => $status,
'result' => $data,
], '', 15 * 60 );

if( $query )
{
$query->Close();
}
}
if( $query )
{
$query->Close();
}
}
}
}
}
Expand Down Expand Up @@ -245,10 +248,15 @@ function skycraft_serversign() {
echo '<p class="mb-1">';
//if (get_theme_mod('skycraft_serversign_favicon_enabled')) echo '<img src="' . $data['favicon'] . '" />&nbsp;';
if (get_theme_mod('skycraft_serversign_description_enabled')) {
if (isset($data['description']['extra']) && count($data['description']['extra'])) foreach ($data['description']['extra'] as $element) {
echo '<font color="' . $element['color'] . '">' . $element['text'] . '</font>';
if (is_array($data['description'])) {
if (isset($data['description']['extra']) && count($data['description']['extra'])) foreach ($data['description']['extra'] as $element) {
echo '<font color="' . $element['color'] . '">' . $element['text'] . '</font>';
}
echo $data['description']['text'];
} else if (is_string($data['description'])) {
echo $data['description'];
}
echo $data['description']['text'];

}
echo '</p>' . PHP_EOL;
if (get_theme_mod('skycraft_serversign_players_enabled')) echo '<p class="mb-0">' . __('Spieler', 'skycraft') . ': ' . $data['players']['online'] . '/' . $data['players']['max'] . '</span>' . PHP_EOL;
Expand All @@ -274,4 +282,4 @@ function str_limit($value, $limit = 100, $end = '...')

return rtrim(substr($value, 0, $limit)) . $end;
}
}
}

0 comments on commit a1d5541

Please sign in to comment.