mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 04:46:37 +00:00
添加优化排除文件夹
This commit is contained in:
@@ -953,10 +953,22 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
List<Path> modelJsonToOptimize = new ArrayList<>();
|
||||
Set<String> excludeTexture = new HashSet<>(Config.optimizeTextureExclude());
|
||||
Set<String> excludeJson = new HashSet<>(Config.optimizeJsonExclude());
|
||||
Set<String> excludeTexturePath = new HashSet<>(Config.optimizeTextureExcludePath());
|
||||
Set<String> excludeJsonPath = new HashSet<>(Config.optimizeJsonExcludePath());
|
||||
excludeTexture.addAll(this.parser.excludeTexture());
|
||||
excludeJson.addAll(this.parser.excludeJson());
|
||||
Predicate<Path> texturePathPredicate = p -> !excludeTexture.contains(CharacterUtils.replaceBackslashWithSlash(path.relativize(p).toString()));
|
||||
Predicate<Path> jsonPathPredicate = p -> !excludeJson.contains(CharacterUtils.replaceBackslashWithSlash(path.relativize(p).toString()));
|
||||
Predicate<Path> texturePathPredicate = p -> {
|
||||
Path relativize = path.relativize(p);
|
||||
boolean unFilteredFile = !excludeTexture.contains(CharacterUtils.replaceBackslashWithSlash(relativize.toString()));
|
||||
boolean unFilteredPath = !excludeTexturePath.contains(CharacterUtils.replaceBackslashWithSlash(String.valueOf(relativize.getParent())));
|
||||
return unFilteredFile && unFilteredPath;
|
||||
};
|
||||
Predicate<Path> jsonPathPredicate = p -> {
|
||||
Path relativize = path.relativize(p);
|
||||
boolean unFilteredFile = !excludeJson.contains(CharacterUtils.replaceBackslashWithSlash(relativize.toString()));
|
||||
boolean unFilteredPath = !excludeJsonPath.contains(CharacterUtils.replaceBackslashWithSlash(String.valueOf(relativize.getParent())));
|
||||
return unFilteredFile && unFilteredPath;
|
||||
};
|
||||
|
||||
if (Config.optimizeJson()) {
|
||||
Path metaPath = path.resolve("pack.mcmeta");
|
||||
|
||||
@@ -109,9 +109,11 @@ public class Config {
|
||||
protected boolean resource_pack$optimization$enable;
|
||||
protected boolean resource_pack$optimization$texture$enable;
|
||||
protected Set<String> resource_pack$optimization$texture$exlude;
|
||||
protected Set<String> resource_pack$optimization$texture$exclude_path;
|
||||
protected int resource_pack$optimization$texture$zopfli_iterations;
|
||||
protected boolean resource_pack$optimization$json$enable;
|
||||
protected Set<String> resource_pack$optimization$json$exclude;
|
||||
protected Set<String> resource_pack$optimization$json$exclude_path;
|
||||
|
||||
protected MinecraftVersion resource_pack$supported_version$min;
|
||||
protected MinecraftVersion resource_pack$supported_version$max;
|
||||
@@ -391,11 +393,19 @@ public class Config {
|
||||
if (!p.endsWith(".png")) return p + ".png";
|
||||
return p;
|
||||
}).collect(Collectors.toSet());
|
||||
resource_pack$optimization$texture$exclude_path = config.getStringList("resource-pack.optimization.texture.exclude-path").stream().map(p -> {
|
||||
if (p.endsWith("/")) return p.substring(0, p.length() - 1);
|
||||
return p;
|
||||
}).collect(Collectors.toSet());
|
||||
resource_pack$optimization$json$enable = config.getBoolean("resource-pack.optimization.json.enable", true);
|
||||
resource_pack$optimization$json$exclude = config.getStringList("resource-pack.optimization.json.exclude").stream().map(p -> {
|
||||
if (!p.endsWith(".json") && !p.endsWith(".mcmeta")) return p + ".json";
|
||||
return p;
|
||||
}).collect(Collectors.toSet());
|
||||
resource_pack$optimization$json$exclude_path = config.getStringList("resource-pack.optimization.json.exclude-path").stream().map(p -> {
|
||||
if (p.endsWith("/")) return p.substring(0, p.length() - 1);
|
||||
return p;
|
||||
}).collect(Collectors.toSet());
|
||||
resource_pack$validation$enable = config.getBoolean("resource-pack.validation.enable", true);
|
||||
resource_pack$validation$fix_atlas = config.getBoolean("resource-pack.validation.fix-atlas", true);
|
||||
resource_pack$exclude_core_shaders = config.getBoolean("resource-pack.exclude-core-shaders", false);
|
||||
@@ -1209,6 +1219,10 @@ public class Config {
|
||||
return instance.resource_pack$optimization$texture$exlude;
|
||||
}
|
||||
|
||||
public static Set<String> optimizeTextureExcludePath() {
|
||||
return instance.resource_pack$optimization$texture$exclude_path;
|
||||
}
|
||||
|
||||
public static boolean optimizeJson() {
|
||||
return instance.resource_pack$optimization$json$enable;
|
||||
}
|
||||
@@ -1217,6 +1231,10 @@ public class Config {
|
||||
return instance.resource_pack$optimization$json$exclude;
|
||||
}
|
||||
|
||||
public static Set<String> optimizeJsonExcludePath() {
|
||||
return instance.resource_pack$optimization$json$exclude_path;
|
||||
}
|
||||
|
||||
public static int zopfliIterations() {
|
||||
return instance.resource_pack$optimization$texture$zopfli_iterations;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user