-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.js
52 lines (41 loc) · 1.38 KB
/
logger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// LiteLoader-AIDS automatic generated
/// <reference path="c:\Users\LenovoG580\Documents\ll/dts/HelperLib-master/src/index.d.ts"/>
const config = require('./config.js');
const prefixDB = require('./prefixes.js');
const fs = require('fs');
const logs = config.get('logs')['chat'];
const commands = config.get('logs')['commands'];
const path = './plugins/chatmanager/logs/';
let chat_file;
let command_file;
mc.listen('onServerStarted', () => {
if (logs) {
File.mkdir(path);
const chat_path = `${path}chat-latest.txt`;
const command_path = `${path}command-latest.txt`;
chat_file = fs.createWriteStream(chat_path);
command_file = fs.createWriteStream(command_path);
chat_file.write('Server started!\n');
command_file.write('Server started!\n');
log('Log files created succefully!');
}
});
mc.listen('onChat', (pl, msg) => {
if (logs) {
let prefix = prefixDB.get(pl.realName);
let text;
if (prefix == '' || prefix == ' ' || prefix == undefined) {
text = `${pl.realName} > ${msg}\n`;
} else {
text = `[${prefix}]${pl.realName} > ${msg}\n`
}
chat_file.write(text);
}
});
mc.listen('onPlayerCmd', (pl, cmd) => {
if (commands) {
const text = `${pl.realName} > /${cmd}\n`;
command_file.write(text);
}
});
module.exports = null;