9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 01:49:30 +00:00

Merge pull request #186 from jhqwqmc/dev

feat(core): 优化资源包文件过滤机制
This commit is contained in:
XiaoMoMi
2025-05-24 17:13:59 +08:00
committed by GitHub
5 changed files with 15 additions and 8 deletions

View File

@@ -65,6 +65,11 @@ resource-pack:
- BetterModel/build
merge-external-zip-files:
- CustomNameplates/resourcepack.zip
exclude-file-suffixes:
- "md"
- "psd"
- "bbmodel"
- "db"
delivery:
# Send the resource pack on joining the server
send-on-join: true

View File

@@ -1208,7 +1208,7 @@ public abstract class AbstractPackManager implements PackManager {
private void processRegularFile(Path file, BasicFileAttributes attrs, Path sourceFolder, @Nullable FileSystem fs,
Map<String, List<Path>> conflictChecker, Map<Path, CachedAssetFile> previousFiles) throws IOException {
if (!ALLOWED_FILE_EXTENSIONS.contains(FileUtils.getExtension(file))) {
if (Config.excludeFileSuffixes().contains(FileUtils.getExtension(file))) {
return;
}
CachedAssetFile cachedAsset = previousFiles.get(file);
@@ -1237,7 +1237,7 @@ public abstract class AbstractPackManager implements PackManager {
if (entryAttrs.isDirectory()) {
return FileVisitResult.CONTINUE;
}
if (!ALLOWED_FILE_EXTENSIONS.contains(FileUtils.getExtension(entry))) {
if (Config.excludeFileSuffixes().contains(FileUtils.getExtension(entry))) {
return FileVisitResult.CONTINUE;
}
Path entryPathInZip = zipRoot.relativize(entry);

View File

@@ -14,7 +14,6 @@ import java.util.List;
import java.util.Set;
public interface PackManager extends Manageable {
Set<String> ALLOWED_FILE_EXTENSIONS = new HashSet<>(List.of("png", "txt", "json", "fsh", "vsh", "mcmeta", "zip", "ogg"));
void loadResources(boolean recipe);

View File

@@ -34,10 +34,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
public class Config {
@@ -59,6 +56,7 @@ public class Config {
protected List<ResolutionConditional> resource_pack$duplicated_files_handler;
protected List<String> resource_pack$merge_external_folders;
protected List<String> resource_pack$merge_external_zips;
protected Set<String> resource_pack$exclude_file_suffixes;
protected boolean resource_pack$protection$crash_tools$method_1;
protected boolean resource_pack$protection$crash_tools$method_2;
@@ -220,6 +218,7 @@ public class Config {
resource_pack$supported_version$max = getVersion(config.get("resource-pack.supported-version.max", "LATEST").toString());
resource_pack$merge_external_folders = config.getStringList("resource-pack.merge-external-folders");
resource_pack$merge_external_zips = config.getStringList("resource-pack.merge-external-zip-files");
resource_pack$exclude_file_suffixes = new HashSet<>(config.getStringList("resource-pack.exclude-file-suffixes", List.of("md", "psd", "bbmodel", "db")));
resource_pack$delivery$send_on_join = config.getBoolean("resource-pack.delivery.send-on-join", true);
resource_pack$delivery$resend_on_upload = config.getBoolean("resource-pack.delivery.resend-on-upload", true);
resource_pack$delivery$kick_if_declined = config.getBoolean("resource-pack.delivery.kick-if-declined", true);
@@ -469,6 +468,10 @@ public class Config {
return instance.resource_pack$merge_external_zips;
}
public static Set<String> excludeFileSuffixes() {
return instance.resource_pack$exclude_file_suffixes;
}
public static boolean kickOnDeclined() {
return instance.resource_pack$delivery$kick_if_declined;
}

View File

@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=0.0.54.8
config_version=33
config_version=34
lang_version=14
project_group=net.momirealms
latest_supported_version=1.21.5