-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
82 lines (82 loc) · 5.48 KB
/
index.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
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InfoTagMain = void 0;
const path = require("path");
const fs = require("fs");
const addon_1 = require("./src/addon");
const launcher_1 = require("bdsx/launcher");
const message_1 = require("./src/utils/message");
const event_1 = require("bdsx/event");
let config = {
tag: "&c{health}/{max_health} &8|&r {colorping}ms",
tick: 500,
};
const configPath = path.join(__dirname, "config.json");
try {
config = require(configPath);
}
catch (err) { }
var InfoTagMain;
(function (InfoTagMain) {
function setTag(value) {
config.tag = value;
}
InfoTagMain.setTag = setTag;
function setTick(tick) {
if (tick < 0)
config.tick = 0;
config.tick = tick;
}
InfoTagMain.setTick = setTick;
function getTag() {
return config.tag;
}
InfoTagMain.getTag = getTag;
function getTick() {
if (config.tick < 0)
return 0;
return config.tick;
}
InfoTagMain.getTick = getTick;
function getPlayerTag(player) {
let results = getTag();
for (let [i, addon] of addon_1.InfoTagAddon.getAddons(player).entries()) {
results = results.replace(new RegExp(addon[0], "g"), `${addon[1]}`);
}
return results;
}
InfoTagMain.getPlayerTag = getPlayerTag;
function updatePlayerTag(player) {
player.setScoreTag(getPlayerTag(player));
}
InfoTagMain.updatePlayerTag = updatePlayerTag;
function updatePlayersTag() {
for (const player of launcher_1.bedrockServer.serverInstance.getPlayers()) {
if (!player.isPlayer())
return;
updatePlayerTag(player);
}
}
InfoTagMain.updatePlayersTag = updatePlayersTag;
function save(message = false) {
fs.writeFile(configPath, JSON.stringify(config, null, 2), "utf8", (err) => {
if (message) {
if (err) {
message_1.send.error(`config.json ${err}`);
throw err;
}
else
message_1.send.success(`config.json Saved!`);
}
});
}
InfoTagMain.save = save;
})(InfoTagMain = exports.InfoTagMain || (exports.InfoTagMain = {}));
event_1.events.serverOpen.on(() => {
require("./src");
message_1.send.success("Started!");
});
event_1.events.serverClose.on(() => {
InfoTagMain.save(true);
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw2QkFBNkI7QUFDN0IseUJBQXlCO0FBRXpCLHVDQUEyQztBQUMzQyw0Q0FBOEM7QUFDOUMsaURBQTJDO0FBQzNDLHNDQUFvQztBQUVwQyxJQUFJLE1BQU0sR0FHTjtJQUNBLEdBQUcsRUFBRSw2Q0FBNkM7SUFDbEQsSUFBSSxFQUFFLEdBQUc7Q0FDWixDQUFDO0FBRUYsTUFBTSxVQUFVLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUUsYUFBYSxDQUFDLENBQUM7QUFFdkQsSUFBSTtJQUNBLE1BQU0sR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLENBQUM7Q0FDaEM7QUFBQyxPQUFNLEdBQUcsRUFBRSxHQUFFO0FBRWYsSUFBaUIsV0FBVyxDQW9EM0I7QUFwREQsV0FBaUIsV0FBVztJQUV4QixTQUFnQixNQUFNLENBQUMsS0FBYTtRQUNoQyxNQUFNLENBQUMsR0FBRyxHQUFDLEtBQUssQ0FBQztJQUNyQixDQUFDO0lBRmUsa0JBQU0sU0FFckIsQ0FBQTtJQUVELFNBQWdCLE9BQU8sQ0FBQyxJQUFZO1FBQ2hDLElBQUksSUFBSSxHQUFHLENBQUM7WUFBRSxNQUFNLENBQUMsSUFBSSxHQUFDLENBQUMsQ0FBQztRQUM1QixNQUFNLENBQUMsSUFBSSxHQUFDLElBQUksQ0FBQztJQUNyQixDQUFDO0lBSGUsbUJBQU8s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