forked from debkbanerji/minecraft-bedrock-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
82 lines (74 loc) · 2.41 KB
/
utils.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const os = require('os');
const CONFIG_FILE_PATH = './config.json'
const cjson = require(CONFIG_FILE_PATH);
const UNZIPPED_SERVER_FOLDER_NAME = `bedrock-server-${cjson['minecraft-server-version']}`;
const UNZIPPED_SERVER_FOLDER_PATH = `./${UNZIPPED_SERVER_FOLDER_NAME}`;
const ZIPPED_SERVER_PATH = `${UNZIPPED_SERVER_FOLDER_PATH}.zip`;
const SERVER_EXECUTABLE_PATH = `${UNZIPPED_SERVER_FOLDER_PATH}/bedrock_server`;
const WINDOWS_SERVER_LINK = `https://minecraft.azureedge.net/bin-win/${UNZIPPED_SERVER_FOLDER_NAME}.zip`;
const LINUX_SERVER_LINK = `https://minecraft.azureedge.net/bin-linux/${UNZIPPED_SERVER_FOLDER_NAME}.zip`;
const BACKUP_FOLDER_NAME = 'backups'
const BACKUP_FOLDER_PATH = `./${BACKUP_FOLDER_NAME}`;
const SERVER_WORLDS_FOLDER_NAME = 'worlds';
const SERVER_WORLDS_FOLDER_PATH = `${UNZIPPED_SERVER_FOLDER_PATH}/${SERVER_WORLDS_FOLDER_NAME}`;
const SERVER_PROPERTIES_FILE_NAME = 'server.properties';
const SERVER_PROPERTIES_FILE_PATH = `${UNZIPPED_SERVER_FOLDER_PATH}/${SERVER_PROPERTIES_FILE_NAME}`;
const SERVER_PROPERTIES_FIELDS = [
'server-name',
'gamemode',
'difficulty',
'allow-cheats',
'max-players',
'online-mode',
'white-list',
'server-port',
'server-portv6',
'view-distance',
'tick-distance',
'player-idle-timeout',
'max-threads',
'level-name',
'default-player-permission-level',
'texturepack-required',
'content-log-file-enabled',
'compression-threshold',
'server-authoritative-movement',
'player-movement-score-threshold',
'player-movement-distance-threshold',
'player-movement-duration-threshold-in-ms',
'correct-player-movement',
'level-seed'
]
const SEC_IN_MIN = 60;
const MS_IN_SEC = 1000;
const MS_IN_MIN = MS_IN_SEC * SEC_IN_MIN;
const platform = os.platform();
const BACKUP_TYPES = Object.freeze({
'SCHEDULED': 'SCHEDULED',
'MANUAL': 'MANUAL',
'ON_STOP': 'ON_STOP',
'ON_FORCED_STOP':'ON_FORCED_STOP'
});
const BACKUP_TYPE_REGEX_FRAGMENT = `(${Object.keys(BACKUP_TYPES).join('|')})`;
module.exports = {
CONFIG_FILE_PATH,
UNZIPPED_SERVER_FOLDER_NAME,
UNZIPPED_SERVER_FOLDER_PATH,
ZIPPED_SERVER_PATH,
SERVER_EXECUTABLE_PATH,
WINDOWS_SERVER_LINK,
LINUX_SERVER_LINK,
BACKUP_FOLDER_NAME,
BACKUP_FOLDER_PATH,
BACKUP_TYPES,
BACKUP_TYPE_REGEX_FRAGMENT,
SERVER_WORLDS_FOLDER_NAME,
SERVER_WORLDS_FOLDER_PATH,
SERVER_PROPERTIES_FILE_NAME,
SERVER_PROPERTIES_FILE_PATH,
SERVER_PROPERTIES_FIELDS,
SEC_IN_MIN,
MS_IN_SEC,
MS_IN_MIN,
platform
}