feat: добавлена распаковка icmod файлов в папке mods
- добавлена распаковка icmod файлов папке mods
This commit is contained in:
@@ -107,9 +107,8 @@ public class InnerCoreServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void unzip(final File zipFile, final String uncompressedDirectory) {
|
public static void unzip(final ZipFile file, final String uncompressedDirectory) {
|
||||||
try {
|
try {
|
||||||
final ZipFile file = new ZipFile(zipFile);
|
|
||||||
final Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) file.entries();
|
final Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) file.entries();
|
||||||
|
|
||||||
while (entries.hasMoreElements()) {
|
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) {
|
static void getFolderRootFromUri(URI uri, String targetPath, Consumer<? super Path> action) {
|
||||||
Map<String, String> env = new HashMap<>();
|
Map<String, String> env = new HashMap<>();
|
||||||
env.put("create", "true");
|
env.put("create", "true");
|
||||||
@@ -193,14 +214,10 @@ public class InnerCoreServer {
|
|||||||
if (!innercoreDirectory.exists()) {
|
if (!innercoreDirectory.exists()) {
|
||||||
server.getLogger().info("Extracting internal package...");
|
server.getLogger().info("Extracting internal package...");
|
||||||
unpackResources("/innercore", innercoreDirectory.getPath());
|
unpackResources("/innercore", innercoreDirectory.getPath());
|
||||||
// final File zipFile = cloneFile("innercore.zip");
|
|
||||||
// if (zipFile != null) {
|
|
||||||
// unzip(zipFile, PATH);
|
|
||||||
// zipFile.deleteOnExit();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cloneFile("innercore_default_config.json");
|
cloneFile("innercore_default_config.json");
|
||||||
|
unzipMods(PATH+"/innercore/mods");
|
||||||
|
|
||||||
FileTools.init();
|
FileTools.init();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user