mirror of
https://github.com/GeyserMC/PackConverter.git
synced 2025-12-19 14:59:21 +00:00
Add option to enforce pack.mcmeta check, off by default
This commit is contained in:
@@ -73,6 +73,7 @@ public class Main {
|
||||
System.setProperty("PackConverter.Debug", String.valueOf(debug));
|
||||
|
||||
new PackConverter()
|
||||
.enforcePackCheck(true)
|
||||
.input(Path.of(inputPath))
|
||||
.output(Path.of(outputPath))
|
||||
.packName(packName)
|
||||
|
||||
@@ -123,6 +123,7 @@ public class ThunderGUI extends JFrame {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
new PackConverter()
|
||||
.enforcePackCheck(true)
|
||||
.input(inputPath)
|
||||
.output(outputPath)
|
||||
.packName(packName.getText().isBlank() ? inputPath.getFileName().toString() : packName.getText())
|
||||
|
||||
@@ -61,6 +61,7 @@ public final class PackConverter {
|
||||
private String textureSubdirectory;
|
||||
|
||||
private boolean compressed;
|
||||
private boolean enforcePackCheck = false;
|
||||
|
||||
private final Map<Class<?>, List<ActionListener<?>>> actionListeners = new IdentityHashMap<>();
|
||||
|
||||
@@ -169,6 +170,17 @@ public final class PackConverter {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if PackConverter should enforce a check for `pack.mcmeta` in the input.
|
||||
*
|
||||
* @param enforcePackCheck whether the check should be done
|
||||
* @return this instance
|
||||
*/
|
||||
public PackConverter enforcePackCheck(boolean enforcePackCheck) {
|
||||
this.enforcePackCheck = enforcePackCheck;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a converter to the converter list.
|
||||
*
|
||||
@@ -294,10 +306,10 @@ public final class PackConverter {
|
||||
// Need to download the client jar, then use the
|
||||
// client jar to get the vanilla models and textures, so we can
|
||||
// ensure all parent models exist to convert them to Bedrock.
|
||||
VanillaPackProvider.create(vanillaPackPath, this.logListener);
|
||||
VanillaPackProvider.create(this.vanillaPackPath, this.logListener);
|
||||
|
||||
ZipUtils.openFileSystem(this.input, this.compressed, input -> {
|
||||
if (!Files.exists(input.resolve("pack.mcmeta"))) {
|
||||
if (this.enforcePackCheck && !Files.exists(input.resolve("pack.mcmeta"))) {
|
||||
logListener.error("Invalid Java Edition resource pack. No pack.mcmeta found.");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user