This repository has been archived by the owner on Jul 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLXLETAutoUpdate.js
54 lines (50 loc) · 1.85 KB
/
LXLETAutoUpdate.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
//LiteXLoader Dev Helper
/// <reference path="c:\Users\Lition\.vscode\extensions\moxicat.lxldevhelper-0.1.8/Library/JS/Api.js" />
function update(){
let find = false;
lxl.listPlugins().forEach(p=>{
if(p == "LXLEssential.js"){
lxl.import("lxless:getUpdate")();
find = true;
}
});
if(!find)
getUpdate("0");
}
setInterval(update, 60*1000*10);
function getNewFile(show=false) {
network.httpGet('https://liteldev-lxl.coding.net/p/lxlessential/d/LXLEssential/git/raw/main/LXLEssential.js?download=false', (c, d) => {
if (c == 200) {
if (file.exists(dir_path + ".noupdate") == false) {
file.writeTo(update_dir+`LXLEssential(${version}).js`,file.readFrom('./plugins/LXLEssential.js'));
file.writeTo('./plugins/LXLEssential.js', d);
mc.runcmd("lxl load ./plugins/LXLEssential.js");
}else{
log('您关闭了自动更新,更新检测退出');
}
}if(show)
log('自动更新失败,code:'+c);
});
}
function getUpdate(v,show = false) {
network.httpGet('https://liteldev-lxl.coding.net/p/lxlessential/d/LXLEssential/git/raw/main/api.json?download=false', (c, d) => {
if (c == 200) {
var dt = JSON.parse(d);
//lxl.import("lxless:setUpdate")(dt.latest,dt.msg);
if (dt.latest != v) {
if(dt.necessary){
log(`获取到新版本:${dt.latest},自动更新中...`);
getNewFile(show);
}else{
log("未检测到新版本");
}
} else {
if (show)
log("当前即为最新版本。");
}
}else{
if(show)
log('更新检测失败,code:'+c);
}
});
}