feat: afficher statut OP des joueurs (lire ops.txt)
This commit is contained in:
@@ -46,6 +46,21 @@ router.get('/', isAuthenticated, async (req, res) => {
|
||||
console.warn('usercache.json non trouvé:', usercacheFile);
|
||||
}
|
||||
|
||||
// Récupérer les OP depuis ops.txt
|
||||
let ops = [];
|
||||
const opsFile = path.join(SERVER_DIR, 'ops.txt');
|
||||
if (await fs.pathExists(opsFile)) {
|
||||
try {
|
||||
const opsContent = await fs.readFile(opsFile, 'utf8');
|
||||
ops = opsContent
|
||||
.split('\n')
|
||||
.map(line => line.trim())
|
||||
.filter(line => line.length > 0);
|
||||
} catch (e) {
|
||||
console.error('Erreur lecture ops.txt:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// Récupérer les stats de dernière connexion
|
||||
const statsDir = path.join(SERVER_DIR, 'world', 'stats');
|
||||
let statsByUuid = {};
|
||||
@@ -71,9 +86,11 @@ router.get('/', isAuthenticated, async (req, res) => {
|
||||
|
||||
const players = playerFiles.map(file => {
|
||||
const uuid = file.replace('.dat', '');
|
||||
const playerName = usercache[uuid] || 'Inconnu';
|
||||
return {
|
||||
uuid,
|
||||
name: usercache[uuid] || 'Inconnu',
|
||||
name: playerName,
|
||||
isOp: ops.includes(playerName),
|
||||
lastPlayed: new Date() // TODO: Extraire du fichier .dat si possible
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user