fix: change the time to process the files
This commit is contained in:
+15
-10
@@ -368,12 +368,7 @@ class FileProcessor {
|
|||||||
hash: hash
|
hash: hash
|
||||||
});
|
});
|
||||||
|
|
||||||
// 如果是 nbt 或 litematic 文件,立即开始转换
|
// 延迟转换:在生成 ZIP 时再处理 nbt / litematic 文件,避免添加阶段阻塞
|
||||||
const fileName = file.name.toLowerCase();
|
|
||||||
if (fileName.endsWith('.nbt') || fileName.endsWith('.litematic')) {
|
|
||||||
await this.convertFile(file, hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,15 +648,25 @@ world.beforeEvents.chatSend.subscribe((event) => {
|
|||||||
for (const item of files) {
|
for (const item of files) {
|
||||||
let arrayBuffer;
|
let arrayBuffer;
|
||||||
let fileName = item.name;
|
let fileName = item.name;
|
||||||
|
const fileNameLower = item.name.toLowerCase();
|
||||||
// 检查是否有转换后的文件
|
|
||||||
const converted = this.fileProcessor.convertedFiles.get(item.hash);
|
const converted = this.fileProcessor.convertedFiles.get(item.hash);
|
||||||
|
|
||||||
if (converted) {
|
if (converted) {
|
||||||
// 使用转换后的文件
|
// 使用已转换的 mcstructure 文件
|
||||||
arrayBuffer = converted.data;
|
arrayBuffer = converted.data;
|
||||||
fileName = converted.name;
|
fileName = converted.name;
|
||||||
|
} else if (fileNameLower.endsWith('.nbt') || fileNameLower.endsWith('.litematic')) {
|
||||||
|
// 延迟转换
|
||||||
|
await this.fileProcessor.convertFile(item.file, item.hash);
|
||||||
|
const convertedAfter = this.fileProcessor.convertedFiles.get(item.hash);
|
||||||
|
if (convertedAfter) {
|
||||||
|
arrayBuffer = convertedAfter.data;
|
||||||
|
fileName = convertedAfter.name;
|
||||||
|
} else {
|
||||||
|
// 转换失败,回退为原始文件
|
||||||
|
arrayBuffer = await item.file.arrayBuffer();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 使用原始文件(已经是 mcstructure 格式)
|
|
||||||
arrayBuffer = await item.file.arrayBuffer();
|
arrayBuffer = await item.file.arrayBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user