$json = json_decode(file_get_contents($jsonFile), true);
    } else {
        die("No data file.");
    }
    //Load suspect score for player, if any
    $dataFile = "{$playerDataDir}/{$playerId}";
    if (is_file($dataFile)) {
        $pstats = unserialize(file_get_contents($dataFile));
        if (array_key_exists('custom.suspect', $pstats)) {
            $suspect = $pstats['custom.suspect']['score'];
        }
    }
} else {
    die("Unknown player.");
}
$inactive = isPlayerInactive($playerId);
//Count stats
$blockStats = [];
$otherStats = [];
foreach ($json as $key => $value) {
    if (strpos($key, 'stat.craftItem.') === 0) {
        $id = substr($key, 15);
        $blockStats[$id]['craft'] = $value;
    } else {
        if (strpos($key, 'stat.useItem.') === 0) {
            $id = substr($key, 13);
            $blockStats[$id]['use'] = $value;
        } else {
            if (strpos($key, 'stat.mineBlock.') === 0) {
                $id = substr($key, 15);
                $blockStats[$id]['mine'] = $value;
Esempio n. 2
0
function createPlayerWidget($uuid, $size, $inject = '')
{
    if ($uuid !== FALSE) {
        return '<span class="player ' . (isPlayerInactive($uuid) ? 'inactive' : '') . '">' . '<img src="' . getPlayerSkin($uuid) . '" ' . 'onload="skinLoaded(this);" onerror="skinError(this, ' . getDefaultSkinGender($uuid) . ');"/><span><canvas width="' . $size . '" height="' . $size . '"/></span>' . "<a href='?player={$uuid}'>" . getPlayerName($uuid) . '</a>' . $inject . '</span>';
    } else {
        return '<div class="player-nobody"><div>Nobody</div></div>';
    }
}