Skip to content
This repository was archived by the owner on Nov 26, 2022. It is now read-only.

Commit 041c87b

Browse files
committed
Update 4.1.2 Beta
1 parent fd21a73 commit 041c87b

File tree

8 files changed

+113
-97
lines changed

8 files changed

+113
-97
lines changed

QuickBackupX-BDXCore/mod.cpp

+40-66
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,21 @@ namespace QuickBackupX
5555
\__\_\\____|_|\___|_|\_\____/ \__,_|\___|_|\_\\____| .__/_/\_\
5656
|_|
5757
)" << endl;
58-
58+
if (!filesystem::exists("./QuickBackupX/"))
59+
{
60+
if (filesystem::create_directory(filesystem::path("./QuickBackupX/")))
61+
{
62+
PR(u8"创建QuickBackupX文件夹成功!");
63+
L_INFO("创建QuickBackupX文件夹成功!");
64+
}
65+
else
66+
{
67+
PRERR(u8"创建QuickBackupX文件夹失败!");
68+
PRERR(u8"进程即将退出");
69+
Sleep(3000);
70+
throw 100;
71+
}
72+
}
5973
log->Open();
6074
log->Start();
6175
cfg->getConfig();
@@ -92,40 +106,6 @@ Copyright (C)2020-2021 JasonZYT
92106
2.9 破解、二次创作本插件所造成的一切后果由破解者、二次创作者承担。
93107
)";
94108
eula.close();
95-
if (!filesystem::exists("./QuickBackupX/"))
96-
{
97-
if (filesystem::create_directory(filesystem::path("./QuickBackupX/")))
98-
{
99-
PR(u8"创建QuickBackupX文件夹成功!");
100-
L_INFO("创建QuickBackupX文件夹成功!");
101-
}
102-
else
103-
{
104-
PRERR(u8"创建QuickBackupX文件夹失败!");
105-
PRERR(u8"进程即将退出");
106-
Sleep(3000);
107-
throw 100;
108-
}
109-
}
110-
if (!filesystem::exists(CONFIGFILE))
111-
{
112-
Json::Value root;
113-
Json::Reader reader;
114-
Json::StyledWriter sw;
115-
reader.parse(cfgexample, root);
116-
ofstream cfgf;
117-
cfgf.open(CONFIGFILE, ios::app | ios::out);
118-
if (!cfgf.is_open())
119-
{
120-
PRERR(u8"无法创建文件: " << CONFIGFILE << u8" 请尝试手动创建");
121-
L_ERROR(string("无法创建文件: ") + CONFIGFILE);
122-
Sleep(3000);
123-
throw 102;
124-
return;
125-
}
126-
cfgf << sw.write(root);
127-
cfgf.close();
128-
}
129109
if (!filesystem::exists(BACKUPRECFILE))
130110
{
131111
PR(u8"未找到备份记录Json: " << BACKUPRECFILE);
@@ -225,7 +205,7 @@ Copyright (C)2020-2021 JasonZYT
225205
if (paramsize == 2) rv.type = QBCMDT::Make;
226206
else
227207
{
228-
If_Console{ PRERR(u8"意外的 " << params[2] << " 出现在 " << cmd); }
208+
If_Console{ PRERR(u8"意外的 " << params[2] << u8" 出现在 " << cmd); }
229209
If_Player{ sendText(exer.pname,string("§c意外的 ") + params[2] + " 出现在 " + cmd); }
230210
L_ERROR(string("- 意外的 ") + params[2] + " 出现在 " + cmd);
231211
rv.type = QBCMDT::ERRPAR2;
@@ -236,7 +216,7 @@ Copyright (C)2020-2021 JasonZYT
236216
if (paramsize == 2) rv.type = QBCMDT::List;
237217
else if (paramsize > 3)
238218
{
239-
If_Console{ PRERR(u8"意外的 " << params[4] << " 出现在 " << cmd); }
219+
If_Console{ PRERR(u8"意外的 " << params[4] << u8" 出现在 " << cmd); }
240220
If_Player{ sendText(exer.pname,string("§c意外的 ") + params[4] + " 出现在 " + cmd); }
241221
L_ERROR(string("- 意外的 ") + params[4] + " 出现在 " + cmd);
242222
rv.type = QBCMDT::ERRPAR3;
@@ -269,7 +249,7 @@ Copyright (C)2020-2021 JasonZYT
269249
}
270250
else
271251
{
272-
If_Console{ PRERR(u8"意外的 " << params[4] << " 出现在 " << cmd); }
252+
If_Console{ PRERR(u8"意外的 " << params[4] << u8" 出现在 " << cmd); }
273253
If_Player{ sendText(exer.pname,string("§c意外的 ") + params[4] + " 出现在 " + cmd); }
274254
L_ERROR(string("- 意外的 ") + params[4] + " 出现在 " + cmd);
275255
rv.type = QBCMDT::ERRPAR3;
@@ -280,7 +260,7 @@ Copyright (C)2020-2021 JasonZYT
280260
if (paramsize == 2) rv.type = QBCMDT::Reload;
281261
else
282262
{
283-
If_Console{ PRERR(u8"意外的 " << params[2] << " 出现在 " << cmd); }
263+
If_Console{ PRERR(u8"意外的 " << params[2] << u8" 出现在 " << cmd); }
284264
If_Player{ sendText(exer.pname,string("§c意外的 ") + params[2] + " 出现在 " + cmd); }
285265
L_ERROR(string("- 意外的 ") + params[2] + " 出现在 " + cmd);
286266
rv.type = QBCMDT::ERRPAR2;
@@ -291,7 +271,7 @@ Copyright (C)2020-2021 JasonZYT
291271
if (paramsize == 2) rv.type = QBCMDT::Help;
292272
else
293273
{
294-
If_Console{ PRERR(u8"意外的 " << params[2] << " 出现在 " << cmd); }
274+
If_Console{ PRERR(u8"意外的 " << params[2] << u8" 出现在 " << cmd); }
295275
If_Player{ sendText(exer.pname,string("§c意外的 ") + params[2] + " 出现在 " + cmd); }
296276
L_ERROR(string("- 意外的 ") + params[2] + " 出现在 " + cmd);
297277
rv.type = QBCMDT::ERRPAR2;
@@ -362,7 +342,7 @@ Copyright (C)2020-2021 JasonZYT
362342
}
363343
else
364344
{
365-
If_Console{ PRERR(u8"意外的 " << params[6] << " 出现在 " << cmd); }
345+
If_Console{ PRERR(u8"意外的 " << params[6] << u8" 出现在 " << cmd); }
366346
If_Player{ sendText(exer.pname,string("§c意外的 ") + params[6] + " 出现在 " + cmd); }
367347
L_ERROR(string("- 意外的 ") + params[6] + " 出现在 " + cmd);
368348
rv.type = QBCMDT::ERRPAR6;
@@ -405,31 +385,30 @@ Copyright (C)2020-2021 JasonZYT
405385
{
406386
int page;
407387
if (qcmd.params.size() == 2) page = 1;
408-
else
409-
{
410-
if (qcmd.ParamType(2) == QBCMDParam::_int)
411-
{
412-
PRERR(u8"参数 [page: int](页码) 不合法,请重试!");
413-
L_ERROR("- 参数 [page: int](页码) 不合法!");
414-
L_ERROR("- 执行失败!");
415-
return false;
416-
}
417-
page = atoi(qcmd.params[2].c_str());
418-
}
388+
else page = atoi(qcmd.params[2].c_str());
419389
int pag = 1;
420390
if (page > 0) pag = page;
421391
// List Main
422392
vector<Backup*> baklist = rec->blist;
423-
double v1 = (baklist.size() / static_cast<double>(30));
424-
int page_quan = ceil(v1);
393+
if (cfg->lops <= 0)
394+
{
395+
for (int iter = 0; iter <= baklist.size() - 1 ; iter++)
396+
{
397+
cout << u8"- 备份[" << iter + 1 << "] " << baklist[iter]->time << " " << SizeToString(baklist[iter]->size) << endl;
398+
}
399+
return false;
400+
}
401+
int lpages = cfg->lops;
402+
double v1 = (baklist.size() / static_cast<double>(lpages));
403+
int page_quan = v1 + 0.99999999;
425404
if (pag > page_quan) pag = page_quan;
426405
if (page_quan == 0)
427406
{
428407
PRWARN(u8"无备份!!! 输入 \"qb make\" 创建一个备份");
429408
return false;
430409
}
431-
int startline = 30 * (pag - 1);
432-
int endline = 30 * pag - 1;
410+
int startline = lpages * (pag - 1);
411+
int endline = lpages * pag - 1;
433412
cout << u8"========================= 备份列表 第 " << pag << "/" << page_quan << u8" 页 共 " << baklist.size() << u8" 个备份 =========================" << endl;
434413
for (int iter = startline; iter <= endline && iter <= baklist.size() - 1; iter++)
435414
{
@@ -443,15 +422,13 @@ Copyright (C)2020-2021 JasonZYT
443422
{
444423
PRWARN(u8"您正在执行删除全部备份!");
445424
}
446-
regex reg("^([0-9]+)$");
447-
if (!regex_match(qcmd.params[2], reg))
425+
int onum = atoi(qcmd.params[2].c_str());
426+
if (onum >= rec->blist.size())
448427
{
449-
PRERR(u8"参数 [onum: int](备份序号) 不合法,请重试!");
450-
L_ERROR("- 参数 [onum: int](备份序号) 不合法!");
428+
PRERR(u8"找不到备份[" << onum << "]!发送\"qb list\"查看当前的备份");
451429
L_ERROR("- 执行失败!");
452430
return false;
453431
}
454-
int onum = atoi(qcmd.params[2].c_str());
455432
Backup::Executor exer;
456433
exer.type = Console_Type;
457434
rec->blist[(onum - 1)]->Delete(exer);
@@ -469,12 +446,9 @@ Copyright (C)2020-2021 JasonZYT
469446
L_INFO("配置重载失败!");
470447
}
471448
}
472-
else
449+
else if (qcmd.type == QBCMDT::Back)
473450
{
474-
PRERR(u8"参数不合法!");
475-
L_ERROR("- 参数不合法!");
476-
L_ERROR("- 执行失败!");
477-
return false;
451+
478452
}
479453
return false;
480454
}

QuickBackupX/backup.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ namespace QuickBackupX
9696
return false;
9797
}
9898
PR(u8"创建备份...");
99+
runcmd("save hold");
99100
sendText("all", string("§b[QuickBackupX] 开始创建备份: ") + this->time);
100101
ULARGE_INTEGER bavfree;
101102
ULARGE_INTEGER btotal;
@@ -276,7 +277,6 @@ namespace QuickBackupX
276277
L_ERROR(string("解压失败: ([") + to_string(res) + "]" + ZipRetCheck(res) + ")");
277278
PR(u8"解压失败~ ([" << res << "]" << ZipRetCheck(res) << ")");
278279
}
279-
280280
}
281281

282282
bool Backup::CheckBackupPermission()
@@ -343,7 +343,7 @@ namespace QuickBackupX
343343
ZRESULT Backup::Create()
344344
{
345345
int i;
346-
string bpath = getCustomTime(cfg->bop.c_str());
346+
string bpath = to_UTF8(getCustomTime(cfg->bop.c_str()));
347347
this->CopyLevelToTempDir();
348348
this->IterTempDir();
349349
size_t flsize = this->flist.size();

QuickBackupX/config.cpp

+19-21
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,11 @@ namespace QuickBackupX
7474
}
7575
string Config::getBackupDir()
7676
{
77+
string dir;
7778
size_t pos = this->bop.find_last_of("/");
7879
if (pos == string::npos) pos = this->bop.find_last_of("\\");
79-
if (pos == string::npos)
80-
{
81-
PRERR(u8"BackupOutputPath值有误!其中无\"/\"\"\\\"");
82-
L_ERROR("BackupOutputPath值有误!其中无\"/\"\"\\\"");
83-
Sleep(3000);
84-
throw 109;
85-
}
86-
string dir = this->bop.substr(0, pos + 1);
80+
if (pos == string::npos) dir = "./";
81+
else dir = this->bop.substr(0, pos + 1);
8782
return filesystem::canonical(filesystem::path(dir)).string();
8883
}
8984
string Config::getBackupDisk()
@@ -188,20 +183,17 @@ namespace QuickBackupX
188183
example[0]["Name"] = "Steve";
189184
example[1]["Name"] = "Alex";
190185
example[1]["Xuid"] = "1145141919810";
191-
if (!root.isMember("Debug") || !root["Debug"] .isBool()) root["Debug"] = true;
192-
if (!root.isMember("Allow_CB") || !root["Debug"] .isBool()) root["Allow_CB"] = false;
186+
if (!root.isMember("Debug") || !root["Debug"] .isBool() ) root["Debug"] = true;
187+
if (!root.isMember("Allow_CB") || !root["Debug"] .isBool() ) root["Allow_CB"] = false;
193188
if (!root.isMember("BackupOutputPath") || !root["BackupOutputPath"].isString()) root["BackupOutputPath"] = "./backup/%Y-%m-%d-%H-%M.zip";
194-
if (!root.isMember("EULA") || !root["EULA"] .isBool()) root["EULA"] = false;
195-
if (!root.isMember("Admin_Player") || !root["Admin_Player"] .isArray()) root["Admin_Player"] = example;
196-
if (!root.isMember("Backup_Player") || !root["Backup_Player"] .isArray()) root["Backup_Player"] = example;
197-
if (!root.isMember("Back_Player") || !root["Back_Player"] .isArray()) root["Back_Player"] = example;
189+
if (!root.isMember("EULA") || !root["EULA"] .isBool() ) root["EULA"] = false;
190+
if (!root.isMember("ListOutputSize") || !root["ListOutputSize"] .isInt() ) root["ListOutputSize"] = 10;
191+
if (!root.isMember("ListOutputCont") || !root["ListOutputCont"] .isString()) root["ListOutputCont"] = u8"备份[%onum%] %date% %time% %size%";
192+
if (!root.isMember("ViewOutputCont") || !root["ViewOutputCont"] .isString()) root["ViewOutputCont"] = u8"备份[%onum%] %date% %time% %size% %exer%";
193+
if (!root.isMember("Admin_Player") || !root["Admin_Player"] .isArray() ) root["Admin_Player"] = example;
194+
if (!root.isMember("Backup_Player") || !root["Backup_Player"] .isArray() ) root["Backup_Player"] = example;
195+
if (!root.isMember("Back_Player") || !root["Back_Player"] .isArray() ) root["Back_Player"] = example;
198196
SWriteIntoFile(root, CONFIGFILE);
199-
if (root.empty() || !root.isObject())
200-
{
201-
L_ERROR("配置为空或配置不是对象类型");
202-
throw 110;
203-
return false;
204-
}
205197
if (!root["EULA"].asBool())
206198
{
207199
PRERR(u8"您未同意EULA,请在" << CONFIGFILE << u8"中将\"EULA\": false改为\"EULA\": true,进程即将结束");
@@ -212,13 +204,19 @@ namespace QuickBackupX
212204
this->acb = root["Allow_CB"].asBool();
213205
this->bop = root["BackupOutputPath"].asString();
214206
this->eula = root["EULA"].asBool();
207+
this->lops = root["ListOutputSize"].asInt();
208+
this->los = root["ListOutputCont"].asString();
209+
this->vos = root["ViewOutputCont"].asString();
215210
this->getJsonArray(root);
216211
Debug{
217212
L_INFO("正在读取配置: ");
218213
L_INFO(string("- Debug: ") + (this->debug ? "true" : "false"));
219214
L_INFO(string("- Allow_CB: ") + (this->acb ? "true" : "false"));
220-
L_INFO(string("- BackupOutputPath: ") + this->bop);
221215
L_INFO(string("- EULA: ") + (this->eula ? "true" : "false"));
216+
L_INFO(string("- BackupOutputPath: ") + this->bop);
217+
L_INFO(string("- ListOutputCont: ") + this->los);
218+
L_INFO(string("- ViewOutputCont: ") + this->vos);
219+
L_INFO(string("- ListOutputSize: ") + to_string(this->lops));
222220
L_INFO(string("- Admin_Player(") + to_string(this->admins.size()) + ") ");// + this->cfgjv["Admin_Player"].asString());
223221
L_INFO(string("- Backup_Player(") + to_string(this->backup.size()) + ") ");// + this->cfgjv["Backup_Player"].asString());
224222
L_INFO(string("- Back_Player(") + to_string(this->back.size()) + ") ");// +this->cfgjv["Back_Player"].asString());

QuickBackupX/config.h

+3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ namespace QuickBackupX
1818
bool debug = false;
1919
bool acb = false; // Allow Command Block
2020
bool eula = false; // Agree EULA
21+
int lops = 10;
2122
std::string bop = ""; // Backup Output Path
23+
std::string los = "";
24+
std::string vos = "";
2225
std::map<std::string, std::string> admins;
2326
//std::map<std::string, std::string> backupc; // Can Backup to Cloud Player Vector
2427
std::map<std::string, std::string> backup; // Can Backup Player Vector

QuickBackupX/pch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace QuickBackupX
4141
extern std::map<unsigned, bool> fids;
4242
// 常量定义
4343
const std::string QBXVERSIONTAG = "Beta";
44-
const std::string QBXVERSION = "4.1.1";
44+
const std::string QBXVERSION = "4.1.2";
4545
const std::string TEMPDIR = "./QuickBackupX/LEVEL_TEMP/";
4646
const std::string RESUMEDIR = "./QuickBackupX/RESUME_TEMP/";
4747
const std::string EULAFILE = "./QuickBackupX/EULA.txt";

README.md

+24-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
- [OpenSSL](https://github.com/openssl/openssl) Apache-2.0
2323
- [BDX SDK]()
2424

25+
## 注意!
26+
- 本插件所需要的目录都不要包含特殊字符
27+
2528
## 安装方法
2629
1.[Release](https://github.com/Jasonzyt/QuickBackupX/releases)下载插件文件(.dll)
2730
2. 将插件放入注入器的插件文件夹 BDX`[BDS路径]/bdxmod/` BDXCore`[BDS路径]/bdxcore_mod/` LiteLoader`[BDS路径]/plugins/`
@@ -51,7 +54,10 @@
5154
### 配置文件
5255
`[BDS路径]/QuickBackupX/config.json`
5356
- Allow_CB: 布尔值 是否允许命令方块执行QB命令(出于安全和实用考虑,目前仅支持Make)
54-
- BackupOutoutPath: 字符串 备份输出目录及[文件名格式](#文件名格式)
57+
- BackupOutoutPath: 字符串(不含空格) 备份输出目录及[文件名格式](#文件名格式)
58+
- ListOutputSize: 整型 List备份列表每页输出备份的数量(若填写值小于等于0,则不分页)
59+
- ListOutputCont: 字符串 ???
60+
- ViewOutputCont: 字符串 ???
5561
- Debug: 布尔值 是否输出调试信息
5662
- EULA: 布尔值 是否同意[EULA](EULA.txt)(不同意将无法启动服务端)
5763
- Admin_Player: 数组 拥有Admin权限的玩家
@@ -122,4 +128,20 @@
122128
"Debug" : true,
123129
"EULA" : true
124130
}
125-
```
131+
```
132+
133+
### 输出格式说明
134+
```
135+
// 此内容目前还未实现!!!
136+
%onum% 备份序号
137+
%date% 备份日期
138+
%time% 备份时间
139+
%sizeb% 备份存档大小(单位:Byte)
140+
%size% 备份存档大小
141+
%path% 备份存档路径
142+
%exer% 备份执行者
143+
%exert% 备份执行者类型
144+
%rmd5% 备份时的文件MD5值
145+
%nmd5% 当前的文件MD5值
146+
%md5ok% %rmd5和nmd5%是否匹配
147+
```

TODO.md

+2
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@
3131
- [ ] 玩家命令解析
3232
- [x] 在服务器没玩家的时候不执行tellraw命令
3333
- [x] 修复控制台命令输出一大堆的bug
34+
- [x] 在备份执行前执行save hold
35+
- [x] 自定义List输出每页大小

0 commit comments

Comments
 (0)