feat: добавлена распаковка icmod файлов в папке mods
- добавлена распаковка icmod файлов папке mods
This commit is contained in:
@@ -107,9 +107,8 @@ public class InnerCoreServer {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void unzip(final File zipFile, final String uncompressedDirectory) {
|
||||
public static void unzip(final ZipFile file, final String uncompressedDirectory) {
|
||||
try {
|
||||
final ZipFile file = new ZipFile(zipFile);
|
||||
final Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) file.entries();
|
||||
|
||||
while (entries.hasMoreElements()) {
|
||||
@@ -126,6 +125,28 @@ public class InnerCoreServer {
|
||||
}
|
||||
}
|
||||
|
||||
public static void unzipMods(final String path) throws IOException {
|
||||
final File directory_mods = new File(path);
|
||||
final File[] files = directory_mods.listFiles();
|
||||
if(files == null) return;
|
||||
|
||||
for(final File file : files){
|
||||
final String name = file.getName();
|
||||
if(file.isFile() && name.endsWith(".icmod")){
|
||||
server.getLogger().info("Unzip mod "+name);
|
||||
|
||||
final ZipFile zipFile = new ZipFile(file);
|
||||
if(zipFile.getEntry("build.config") == null)
|
||||
unzip(zipFile, path+"/");
|
||||
else {
|
||||
final String nameFolder = name.replace(".icmod", "");
|
||||
new File(path + "/" + nameFolder).mkdir();
|
||||
unzip(zipFile, path + "/" + nameFolder + "/");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void getFolderRootFromUri(URI uri, String targetPath, Consumer<? super Path> action) {
|
||||
Map<String, String> env = new HashMap<>();
|
||||
env.put("create", "true");
|
||||
@@ -193,14 +214,10 @@ public class InnerCoreServer {
|
||||
if (!innercoreDirectory.exists()) {
|
||||
server.getLogger().info("Extracting internal package...");
|
||||
unpackResources("/innercore", innercoreDirectory.getPath());
|
||||
// final File zipFile = cloneFile("innercore.zip");
|
||||
// if (zipFile != null) {
|
||||
// unzip(zipFile, PATH);
|
||||
// zipFile.deleteOnExit();
|
||||
// }
|
||||
}
|
||||
|
||||
cloneFile("innercore_default_config.json");
|
||||
unzipMods(PATH+"/innercore/mods");
|
||||
|
||||
FileTools.init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user