feat: add option to disable additional processors
This commit is contained in:
parent
e8d0b38121
commit
fde5e2a61f
|
@ -47,13 +47,15 @@ public class Resclone implements ModInitializer {
|
||||||
PROCESSORS.clear();
|
PROCESSORS.clear();
|
||||||
DOWNLOADED_PACKS.clear();
|
DOWNLOADED_PACKS.clear();
|
||||||
|
|
||||||
addProcessor(new RootPathProcessor()); //This should be run before any other processor to make sure the path is valid
|
addProcessor(new RootPathProcessor()); //This should be run before any other processor to make sure the root is correct
|
||||||
addFetcher(new BasicFileFetcher());
|
addFetcher(new BasicFileFetcher());
|
||||||
addFetcher(new GitHubFetcher());
|
addFetcher(new GitHubFetcher());
|
||||||
addFetcher(new CurseforgeFetcher());
|
addFetcher(new CurseforgeFetcher());
|
||||||
addFetcher(new ModrinthFetcher());
|
addFetcher(new ModrinthFetcher());
|
||||||
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) addProcessor(new PruneVanillaProcessor());
|
if (RescloneConfig.filterPacks) {
|
||||||
addProcessor(new RemoveEmptyProcessor());
|
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) addProcessor(new PruneVanillaProcessor());
|
||||||
|
addProcessor(new RemoveEmptyProcessor());
|
||||||
|
}
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
LOGGER.info("Installed {} resource pack{}.", packCount, packCount == 1 ? "" : "s");
|
LOGGER.info("Installed {} resource pack{}.", packCount, packCount == 1 ? "" : "s");
|
||||||
|
@ -86,6 +88,7 @@ public class Resclone implements ModInitializer {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
|
//TODO migrate this to try-with-resources once JVM is updated
|
||||||
ExecutorService pool = Executors.newFixedThreadPool(RescloneConfig.packs.size());
|
ExecutorService pool = Executors.newFixedThreadPool(RescloneConfig.packs.size());
|
||||||
for (PackMetaUnloaded s : RescloneConfig.packs) {
|
for (PackMetaUnloaded s : RescloneConfig.packs) {
|
||||||
pool.submit(generateTask(s, metas));
|
pool.submit(generateTask(s, metas));
|
||||||
|
|
|
@ -18,11 +18,13 @@ import java.util.Set;
|
||||||
public class RescloneConfig implements JfCustomConfig {
|
public class RescloneConfig implements JfCustomConfig {
|
||||||
public static Set<PackMetaUnloaded> packs;
|
public static Set<PackMetaUnloaded> packs;
|
||||||
public static boolean pruneUnused;
|
public static boolean pruneUnused;
|
||||||
|
public static boolean filterPacks;
|
||||||
public static boolean logProcessing;
|
public static boolean logProcessing;
|
||||||
|
|
||||||
private static final String ERR_DUPLICATE = "Unexpected duplicate \"%s\" in Resclone config";
|
private static final String ERR_DUPLICATE = "Unexpected duplicate \"%s\" in Resclone config";
|
||||||
private static final String PACKS = "packs";
|
private static final String PACKS = "packs";
|
||||||
private static final String PRUNE_UNUSED = "pruneUnused";
|
private static final String PRUNE_UNUSED = "pruneUnused";
|
||||||
|
private static final String FILTER_PACKS = "filterPacks";
|
||||||
private static final String LOG_PROCESSING = "logProcessing";
|
private static final String LOG_PROCESSING = "logProcessing";
|
||||||
private static final Type META_SET = new TypeToken<Set<PackMetaUnloaded>>(){}.getType();
|
private static final Type META_SET = new TypeToken<Set<PackMetaUnloaded>>(){}.getType();
|
||||||
|
|
||||||
|
@ -30,6 +32,7 @@ public class RescloneConfig implements JfCustomConfig {
|
||||||
if (!Files.exists(path)) {
|
if (!Files.exists(path)) {
|
||||||
packs = new HashSet<>();
|
packs = new HashSet<>();
|
||||||
pruneUnused = true;
|
pruneUnused = true;
|
||||||
|
filterPacks = true;
|
||||||
logProcessing = false;
|
logProcessing = false;
|
||||||
write(path);
|
write(path);
|
||||||
return;
|
return;
|
||||||
|
@ -47,6 +50,7 @@ public class RescloneConfig implements JfCustomConfig {
|
||||||
reader.beginObject();
|
reader.beginObject();
|
||||||
Set<PackMetaUnloaded> packs = null;
|
Set<PackMetaUnloaded> packs = null;
|
||||||
Boolean pruneUnused = null;
|
Boolean pruneUnused = null;
|
||||||
|
Boolean filterPacks = null;
|
||||||
Boolean logProcessing = null;
|
Boolean logProcessing = null;
|
||||||
while (reader.peek() != JsonToken.END_OBJECT) {
|
while (reader.peek() != JsonToken.END_OBJECT) {
|
||||||
final String name = reader.nextName();
|
final String name = reader.nextName();
|
||||||
|
@ -59,6 +63,10 @@ public class RescloneConfig implements JfCustomConfig {
|
||||||
if (pruneUnused != null) throw new JsonParseException(ERR_DUPLICATE.formatted(PRUNE_UNUSED));
|
if (pruneUnused != null) throw new JsonParseException(ERR_DUPLICATE.formatted(PRUNE_UNUSED));
|
||||||
pruneUnused = reader.nextBoolean();
|
pruneUnused = reader.nextBoolean();
|
||||||
}
|
}
|
||||||
|
case FILTER_PACKS -> {
|
||||||
|
if (filterPacks != null) throw new JsonParseException(ERR_DUPLICATE.formatted(FILTER_PACKS));
|
||||||
|
filterPacks = reader.nextBoolean();
|
||||||
|
}
|
||||||
case LOG_PROCESSING -> {
|
case LOG_PROCESSING -> {
|
||||||
if (logProcessing != null) throw new JsonParseException(ERR_DUPLICATE.formatted(LOG_PROCESSING));
|
if (logProcessing != null) throw new JsonParseException(ERR_DUPLICATE.formatted(LOG_PROCESSING));
|
||||||
logProcessing = reader.nextBoolean();
|
logProcessing = reader.nextBoolean();
|
||||||
|
@ -72,12 +80,17 @@ public class RescloneConfig implements JfCustomConfig {
|
||||||
pruneUnused = true;
|
pruneUnused = true;
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
}
|
}
|
||||||
|
if (filterPacks == null) {
|
||||||
|
filterPacks = true;
|
||||||
|
updateRequired = true;
|
||||||
|
}
|
||||||
if (logProcessing == null) {
|
if (logProcessing == null) {
|
||||||
logProcessing = false;
|
logProcessing = false;
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
}
|
}
|
||||||
RescloneConfig.packs = packs;
|
RescloneConfig.packs = packs;
|
||||||
RescloneConfig.pruneUnused = pruneUnused;
|
RescloneConfig.pruneUnused = pruneUnused;
|
||||||
|
RescloneConfig.filterPacks = filterPacks;
|
||||||
RescloneConfig.logProcessing = logProcessing;
|
RescloneConfig.logProcessing = logProcessing;
|
||||||
} else throw new JsonParseException("Expected Resclone config to be an object or array");
|
} else throw new JsonParseException("Expected Resclone config to be an object or array");
|
||||||
}
|
}
|
||||||
|
@ -91,10 +104,13 @@ public class RescloneConfig implements JfCustomConfig {
|
||||||
.comment("The packs to be loaded by resclone")
|
.comment("The packs to be loaded by resclone")
|
||||||
.name(PACKS);
|
.name(PACKS);
|
||||||
GsonHolders.CONFIG.getGson().toJson(packs, META_SET, writer);
|
GsonHolders.CONFIG.getGson().toJson(packs, META_SET, writer);
|
||||||
writer.comment("Whether to prune unused packs from the cache")
|
writer.comment("Automatically remove all downloaded packs that are not in the config to free up unneeded space")
|
||||||
.name(PRUNE_UNUSED)
|
.name(PRUNE_UNUSED)
|
||||||
.value(pruneUnused)
|
.value(pruneUnused)
|
||||||
.comment("Whether to log processing of packs")
|
.comment("Whether to filter packs to remove files unchanged from vanilla and empty directories")
|
||||||
|
.name(FILTER_PACKS)
|
||||||
|
.value(filterPacks)
|
||||||
|
.comment("Log automatic processing steps applied to downloaded packs")
|
||||||
.name(LOG_PROCESSING)
|
.name(LOG_PROCESSING)
|
||||||
.value(logProcessing)
|
.value(logProcessing)
|
||||||
.endObject();
|
.endObject();
|
||||||
|
@ -119,6 +135,7 @@ public class RescloneConfig implements JfCustomConfig {
|
||||||
}).setPath(path)
|
}).setPath(path)
|
||||||
.<Set<PackMetaUnloaded>>value(PACKS, new HashSet<>(), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, io.gitlab.jfronny.libjf.config.api.v2.type.Type.ofClass(META_SET), 100, () -> packs, p -> packs = p)
|
.<Set<PackMetaUnloaded>>value(PACKS, new HashSet<>(), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, io.gitlab.jfronny.libjf.config.api.v2.type.Type.ofClass(META_SET), 100, () -> packs, p -> packs = p)
|
||||||
.value(PRUNE_UNUSED, pruneUnused, () -> pruneUnused, p -> pruneUnused = p)
|
.value(PRUNE_UNUSED, pruneUnused, () -> pruneUnused, p -> pruneUnused = p)
|
||||||
|
.value(FILTER_PACKS, filterPacks, () -> filterPacks, p -> filterPacks = p)
|
||||||
.value(LOG_PROCESSING, logProcessing, () -> logProcessing, p -> logProcessing = p)
|
.value(LOG_PROCESSING, logProcessing, () -> logProcessing, p -> logProcessing = p)
|
||||||
).load();
|
).load();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
"resclone.jfconfig.packs.tooltip": "The packs to download and add",
|
"resclone.jfconfig.packs.tooltip": "The packs to download and add",
|
||||||
"resclone.jfconfig.pruneUnused": "Prune Unused",
|
"resclone.jfconfig.pruneUnused": "Prune Unused",
|
||||||
"resclone.jfconfig.pruneUnused.tooltip": "Automatically remove all downloaded packs that are not in the config to free up unneeded space",
|
"resclone.jfconfig.pruneUnused.tooltip": "Automatically remove all downloaded packs that are not in the config to free up unneeded space",
|
||||||
|
"resclone.jfconfig.filterPacks": "Filter Packs",
|
||||||
|
"resclone.jfconfig.filterPacks.tooltip": "Whether to filter packs to remove files unchanged from vanilla and empty directories",
|
||||||
"resclone.jfconfig.logProcessing": "Log Processing",
|
"resclone.jfconfig.logProcessing": "Log Processing",
|
||||||
"resclone.jfconfig.logProcessing.tooltip": "Log automatic processing steps applied to downloaded packs"
|
"resclone.jfconfig.logProcessing.tooltip": "Log automatic processing steps applied to downloaded packs"
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user