9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-19 15:09:15 +00:00

修复低版本资源包生成

This commit is contained in:
XiaoMoMi
2025-12-17 03:46:16 +08:00
parent f8f9fcf727
commit 13f1c4c51b
5 changed files with 16 additions and 9 deletions

View File

@@ -184,6 +184,7 @@ tasks {
* Register Run Dev Server Tasks * Register Run Dev Server Tasks
*/ */
listOf( listOf(
"1.21.11",
"1.21.10", "1.21.10",
"1.21.8", "1.21.8",
"1.21.5", "1.21.5",

View File

@@ -43,7 +43,7 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
Component.text(reloadResult.syncTime()) Component.text(reloadResult.syncTime())
); );
}); });
} catch (Exception e) { } catch (Throwable e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_FAILURE); handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_FAILURE);
plugin().logger().warn("Failed to reload config", e); plugin().logger().warn("Failed to reload config", e);
} }
@@ -56,7 +56,7 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
Component.text(reloadResult.syncTime()) Component.text(reloadResult.syncTime())
); );
}); });
} catch (Exception e) { } catch (Throwable e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_FAILURE); handleFeedback(context, MessageConstants.COMMAND_RELOAD_CONFIG_FAILURE);
plugin().logger().warn("Failed to reload config", e); plugin().logger().warn("Failed to reload config", e);
} }
@@ -68,7 +68,7 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
long time2 = System.currentTimeMillis(); long time2 = System.currentTimeMillis();
long packTime = time2 - time1; long packTime = time2 - time1;
handleFeedback(context, MessageConstants.COMMAND_RELOAD_PACK_SUCCESS, Component.text(packTime)); handleFeedback(context, MessageConstants.COMMAND_RELOAD_PACK_SUCCESS, Component.text(packTime));
} catch (Exception e) { } catch (Throwable e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_PACK_FAILURE); handleFeedback(context, MessageConstants.COMMAND_RELOAD_PACK_FAILURE);
plugin().logger().warn("Failed to generate resource pack", e); plugin().logger().warn("Failed to generate resource pack", e);
} }
@@ -88,7 +88,7 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
Component.text(reloadResult.syncTime()), Component.text(reloadResult.syncTime()),
Component.text(packTime) Component.text(packTime)
); );
} catch (Exception e) { } catch (Throwable e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_PACK_FAILURE); handleFeedback(context, MessageConstants.COMMAND_RELOAD_PACK_FAILURE);
plugin().logger().warn("Failed to generate resource pack", e); plugin().logger().warn("Failed to generate resource pack", e);
} finally { } finally {

View File

@@ -740,7 +740,7 @@ public abstract class AbstractPackManager implements PackManager {
} }
@Override @Override
public void generateResourcePack() throws IOException { public void generateResourcePack() throws Exception {
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.start")); this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.start"));
long time1 = System.currentTimeMillis(); long time1 = System.currentTimeMillis();
@@ -3039,7 +3039,7 @@ public abstract class AbstractPackManager implements PackManager {
} }
private void processZipFile(Path zipFile, Path sourceFolder, @Nullable FileSystem fs, private void processZipFile(Path zipFile, Path sourceFolder, @Nullable FileSystem fs,
Map<String, List<Path>> conflictChecker, Map<Path, CachedAssetFile> previousFiles) throws IOException { Map<String, List<Path>> conflictChecker, Map<Path, CachedAssetFile> previousFiles) {
try (FileSystem zipFs = FileSystems.newFileSystem(zipFile)) { try (FileSystem zipFs = FileSystems.newFileSystem(zipFile)) {
long zipLastModified = Files.getLastModifiedTime(zipFile).toMillis(); long zipLastModified = Files.getLastModifiedTime(zipFile).toMillis();
long zipSize = Files.size(zipFile); long zipSize = Files.size(zipFile);
@@ -3064,11 +3064,17 @@ public abstract class AbstractPackManager implements PackManager {
cachedAssetFiles.put(sourcePath, cachedAsset); cachedAssetFiles.put(sourcePath, cachedAsset);
} }
if (fs != null) { if (fs != null) {
updateConflictChecker(fs, conflictChecker, entry, sourcePath, entryPathInZip, cachedAsset.data()); try {
updateConflictChecker(fs, conflictChecker, entry, sourcePath, entryPathInZip, cachedAsset.data());
} catch (Exception e) {
AbstractPackManager.this.plugin.logger().warn("Failed to update conflict checker", e);
}
} }
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
}); });
} catch (Exception e) {
this.plugin.logger().warn("Failed to process zip file " + zipFile, e);
} }
} }

View File

@@ -44,7 +44,7 @@ public interface PackManager extends Manageable {
void clearResourceConfigs(); void clearResourceConfigs();
void generateResourcePack() throws IOException; void generateResourcePack() throws Exception;
Path resourcePackPath(); Path resourcePackPath();

View File

@@ -100,7 +100,7 @@ public class ResolutionMergePackMcMeta implements Resolution {
newLanguage.add(entry.getKey(), entry.getValue()); newLanguage.add(entry.getKey(), entry.getValue());
} }
}); });
if (!newLanguage.isEmpty()) { if (!newLanguage.asMap().isEmpty()) { // 兼容低版本gson
merged.add("language", newLanguage); merged.add("language", newLanguage);
} }
// 第七步,合并其他未知元素 // 第七步,合并其他未知元素