content: package com.andrei1058.bedwars.api.util;
  
  import java.io.*;
  import java.util.Enumeration;
  import java.util.zip.ZipEntry;
  import java.util.zip.ZipFile;
  import java.util.zip.ZipOutputStream;
  
  public final class ZipFileUtil {
      public static void zipDirectory(File dir, File zipFile) throws IOException {
          FileOutputStream fout = new FileOutputStream(zipFile);
          ZipOutputStream zout = new ZipOutputStream(fout);
          zipSubDirectory("", dir, zout);
          zout.close();
      }
  
      private static void zipSubDirectory(String basePath, File dir, ZipOutputStream zout) throws IOException {
          byte[] buffer = new byte[4096];
          File[] files = dir.listFiles();
          if (files == null) return;
          for (File file : files) {
              if (file.isDirectory()) {
                  String path = basePath + file.getName() + "/";
                  zout.putNextEntry(new ZipEntry(path));
                  zipSubDirectory(path, file, zout);
                  zout.closeEntry();
              } else {
                  FileInputStream fin = new FileInputStream(file);
                  zout.putNextEntry(new ZipEntry(basePath + file.getName()));
                  int length;
                  while ((length = fin.read(buffer)) > 0) {
                      zout.write(buffer, 0, length);
                  }
                  zout.closeEntry();
                  fin.close();
              }
          }
      }
  
      @SuppressWarnings("ResultOfMethodCallIgnored")
      public static void unzipFileIntoDirectory(File file, File jiniHomeParentDir) throws IOException {
          if (!file.exists()) return;
          @SuppressWarnings("resource")
          ZipFile zipFile = new ZipFile(file);
          Enumeration<?> files = zipFile.entries();
          File f;
          FileOutputStream fos = null;
  
          while (files.hasMoreElements()) {
              try {
                  ZipEntry entry = (ZipEntry) files.nextElement();
                  InputStream eis = zipFile.getInputStream(entry);
                  byte[] buffer = new byte[1024];
                  int bytesRead;
  
                  f = new File(jiniHomeParentDir.getAbsolutePath(), entry.getName());
  
                  if (entry.isDirectory()) {
                      f.mkdirs();
                      continue;
                  } else {
                      f.getParentFile().mkdirs();
                      f.createNewFile();
                  }
  
                  fos = new FileOutputStream(f);
  
                  while ((bytesRead = eis.read(buffer)) != -1) {
                      fos.write(buffer, 0, bytesRead);
                  }
              } catch (IOException e) {
                  e.printStackTrace();
              } finally {
                  if (fos != null) {
                      try {
                          fos.close();
                      } catch (IOException ignored) {
                          // ignore
                      }
                  }
              }
          }
      }
  }
  