mirror of
https://github.com/xSquishyLiam/mc-GeyserModelEnginePackGenerator-extension.git
synced 2025-12-19 14:59:16 +00:00
auto create folders just need to sort out the json files to auto create
This commit is contained in:
@@ -4,6 +4,7 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import re.imc.geysermodelenginepackgenerator.GeyserModelEnginePackGenerator;
|
||||
import re.imc.geysermodelenginepackgenerator.util.FileConfiguration;
|
||||
import re.imc.geysermodelenginepackgenerator.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -21,6 +22,9 @@ public class TemplatesManager {
|
||||
this.extension = extension;
|
||||
|
||||
loadTemplates();
|
||||
|
||||
FileUtils.createFiles(extension,"ResourcePack/Templates/material.json");
|
||||
FileUtils.createFiles(extension,"ResourcePack/Templates/packmanifest.json");
|
||||
}
|
||||
|
||||
private void loadTemplates() {
|
||||
|
||||
@@ -37,13 +37,7 @@ public class FileConfiguration {
|
||||
|
||||
Path config = this.dataDirectory.resolve(fileName);
|
||||
|
||||
if (!Files.exists(config)) {
|
||||
try (InputStream resourceAsStream = this.extension.getClass().getClassLoader().getResourceAsStream("Extension/" + fileName)) {
|
||||
Files.copy(resourceAsStream, config);
|
||||
} catch (IOException err) {
|
||||
throw new RuntimeException(err);
|
||||
}
|
||||
}
|
||||
FileUtils.createFiles(extension, fileName);
|
||||
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(config).build();
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package re.imc.geysermodelenginepackgenerator.util;
|
||||
|
||||
import re.imc.geysermodelenginepackgenerator.GeyserModelEnginePackGenerator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,4 +26,23 @@ public class FileUtils {
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
public static void createFiles(GeyserModelEnginePackGenerator extension, String fileName) {
|
||||
Path config = extension.dataFolder().resolve(fileName);
|
||||
extension.logger().warning(config.toString());
|
||||
if (Files.exists(config)) return;
|
||||
|
||||
try {
|
||||
Path parentDirectory = config.getParent();
|
||||
if (parentDirectory != null && !Files.exists(parentDirectory)) Files.createDirectories(parentDirectory);
|
||||
|
||||
try (InputStream resourceAsStream = extension.getClass().getClassLoader().getResourceAsStream("Extension/" + fileName)) {
|
||||
Files.copy(resourceAsStream, config);
|
||||
} catch (IOException err) {
|
||||
throw new RuntimeException(err);
|
||||
}
|
||||
} catch (IOException err) {
|
||||
throw new RuntimeException(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ id: geysermodelenginepackgenerator
|
||||
main: re.imc.geysermodelenginepackgenerator.GeyserModelEnginePackGenerator
|
||||
api: 2.7.0
|
||||
version: 1.0.0
|
||||
authors: [zimzaza4]
|
||||
authors:
|
||||
- zimzaza4
|
||||
- xSquishyLiam
|
||||
Reference in New Issue
Block a user