Exemple #1
0
  private static void disactiveModsByType(
      ArrayList<String> paramArrayOfString, String paramString) {
    restoreModsByType(paramString);

    System.out.println("禁用不活动的文件: " + paramString);
    if ((paramArrayOfString == null) || (paramArrayOfString.size() <= 0)) return;
    File[] files = new File(Utilities.getGameDir(), paramString).listFiles();
    if (files == null) {
      System.out.println("没有文件: " + paramString);
      return;
    }
    for (File file : files)
      if (!file.isDirectory()) {
        String name = file.getName();

        if ((!paramArrayOfString.contains(name))
            || ((!name.toLowerCase().endsWith(".zip")) && (!name.toLowerCase().endsWith(".jar"))))
          continue;

        String newName = name + "X";
        File newFile = new File(file.getParentFile(), newName);

        if (newFile.exists()) newFile.delete();
        if (file.renameTo(newFile))
          System.out.println("已禁用: " + name + ", 新名称: " + newFile.getName());
        else System.out.println("无法禁用: " + name);
      }
  }
Exemple #2
0
  private static void restoreModsByType(String paramString) {
    System.out.println("还原被禁用的文件: " + paramString);
    File[] files = new File(Utilities.getGameDir(), paramString).listFiles();
    if (files == null) return;
    for (File file : files)
      if (!file.isDirectory()) {
        String name = file.getName();
        String lowName = name.toLowerCase();
        if ((!lowName.endsWith(".zipx")) && (!lowName.endsWith(".jarx"))) continue;
        String newName = name.substring(0, name.length() - 1);

        File newFile = new File(file.getParentFile(), newName);
        if (newFile.exists()) file.delete();
        else if (!file.renameTo(newFile))
          System.out.println(
              "无法重命名: " + file.getName() + " 到: " + newFile.getName() + " 在: " + file.getParent());
      }
  }