Ejemplo n.º 1
0
  /**
   * Find mod files in the "mods" folder
   *
   * @param modFolder Folder to search
   * @param modFiles List of mod files to load
   */
  protected void findModFiles(File modFolder, LinkedList<File> modFiles) {
    List<String> supportedVerions = Arrays.asList(SUPPORTED_VERSIONS);

    for (File modFile : modFolder.listFiles(this)) {
      try {
        // Check for a version file
        ZipFile modZip = new ZipFile(modFile);
        ZipEntry version = modZip.getEntry("version.txt");

        if (version != null) {
          // Read the version string
          InputStream versionStream = modZip.getInputStream(version);
          BufferedReader versionReader = new BufferedReader(new InputStreamReader(versionStream));
          String strVersion = versionReader.readLine();
          versionReader.close();

          // Only add the mod if the version matches and we were able to successfully add it to the
          // class path
          if (supportedVerions.contains(strVersion) && addURLToClassPath(modFile.toURI().toURL())) {
            modFiles.add(modFile);
          }
        }

        modZip.close();
      } catch (Exception ex) {
        logger.warning(
            "Error enumerating '"
                + modFile.getAbsolutePath()
                + "': Invalid zip file or error reading file");
      }
    }
  }
 void registerAnimation(List<TextureAtlasSprite> animations) {
   if (animations.contains(icon)) {
     return;
   }
   animations.add(icon);
   if (icon.animationFrames == null) {
     icon.animationFrames = new ArrayList<int[]>();
   }
   if (icon.animationFrames.isEmpty()) {
     int[] dummyRGB = new int[width * height];
     Arrays.fill(dummyRGB, 0xffff00ff);
     icon.animationFrames.add(dummyRGB);
   }
   logger.fine("registered %s animation", name);
 }