fix: change the time to process the files

This commit is contained in:
2026-05-23 03:47:06 +08:00
Unverified
parent cc26f0a69a
commit 9c2bba523a
+15 -10
View File
@@ -368,12 +368,7 @@ class FileProcessor {
hash: hash
});
// 如果是 nbt litematic 文件,立即开始转换
const fileName = file.name.toLowerCase();
if (fileName.endsWith('.nbt') || fileName.endsWith('.litematic')) {
await this.convertFile(file, hash);
}
// 延迟转换:在生成 ZIP 时再处理 nbt / litematic 文件,避免添加阶段阻塞
return true;
}
@@ -653,15 +648,25 @@ world.beforeEvents.chatSend.subscribe((event) => {
for (const item of files) {
let arrayBuffer;
let fileName = item.name;
// 检查是否有转换后的文件
const fileNameLower = item.name.toLowerCase();
const converted = this.fileProcessor.convertedFiles.get(item.hash);
if (converted) {
// 使用转换的文件
// 使用转换的 mcstructure 文件
arrayBuffer = converted.data;
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 {
// 使用原始文件(已经是 mcstructure 格式)
arrayBuffer = await item.file.arrayBuffer();
}