feat: afficher statut OP des joueurs (lire ops.txt)
This commit is contained in:
@@ -891,12 +891,13 @@ function getPlayersHTML() {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<th>OP</th>
|
||||
<th>UUID</th>
|
||||
<th>Dernière Connexion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="playersTable">
|
||||
<tr><td colspan="3" style="text-align: center;">Chargement...</td></tr>
|
||||
<tr><td colspan="4" style="text-align: center;">Chargement...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -924,12 +925,13 @@ async function loadPlayersData() {
|
||||
table.innerHTML = data.players.map(p => `
|
||||
<tr>
|
||||
<td>${p.name}</td>
|
||||
<td style="text-align: center;">${p.isOp ? '✅ OP' : '❌'}</td>
|
||||
<td><code style="font-size: 11px;">${p.uuid}</code></td>
|
||||
<td>${new Date(p.lastPlayed).toLocaleString()}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} else {
|
||||
table.innerHTML = '<tr><td colspan="3" style="text-align: center;">Aucun joueur</td></tr>';
|
||||
table.innerHTML = '<tr><td colspan="4" style="text-align: center;">Aucun joueur</td></tr>';
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Erreur joueurs:', e);
|
||||
@@ -1018,15 +1020,46 @@ window.loadOnlinePlayers = async function() {
|
||||
`;
|
||||
|
||||
if (onlineCount > 0 && playerNames.length > 0) {
|
||||
listDiv.innerHTML = `
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 15px;">
|
||||
${playerNames.map(name => `
|
||||
<div style="padding: 12px; background: white; border: 2px solid #4CAF50; border-radius: 8px; text-align: center;">
|
||||
<span style="font-weight: bold; color: #333;">🎮 ${name}</span>
|
||||
</div>
|
||||
`).join('')}
|
||||
</div>
|
||||
`;
|
||||
// Charger les infos des joueurs pour voir qui est OP
|
||||
try {
|
||||
const playersResponse = await fetch(`${API_URL}/players`, {
|
||||
credentials: 'include'
|
||||
});
|
||||
let playersData = await playersResponse.json();
|
||||
let playersByName = {};
|
||||
if (playersData.players) {
|
||||
playersByName = playersData.players.reduce((acc, p) => {
|
||||
acc[p.name] = p;
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
listDiv.innerHTML = `
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 15px;">
|
||||
${playerNames.map(name => {
|
||||
const playerInfo = playersByName[name];
|
||||
const isOp = playerInfo && playerInfo.isOp;
|
||||
return `
|
||||
<div style="padding: 12px; background: white; border: 2px solid ${isOp ? '#FFD700' : '#4CAF50'}; border-radius: 8px; text-align: center;">
|
||||
<span style="font-weight: bold; color: #333;">🎮 ${name}</span>
|
||||
${isOp ? '<div style="margin-top: 5px; font-size: 12px; color: #FFD700; font-weight: bold;">👑 OP</div>' : ''}
|
||||
</div>
|
||||
`;
|
||||
}).join('')}
|
||||
</div>
|
||||
`;
|
||||
} catch (e) {
|
||||
console.error('Erreur chargement infos joueurs:', e);
|
||||
listDiv.innerHTML = `
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 15px;">
|
||||
${playerNames.map(name => `
|
||||
<div style="padding: 12px; background: white; border: 2px solid #4CAF50; border-radius: 8px; text-align: center;">
|
||||
<span style="font-weight: bold; color: #333;">🎮 ${name}</span>
|
||||
</div>
|
||||
`).join('')}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
} else {
|
||||
listDiv.innerHTML = '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user