Ejemplo n.º 1
0
  private void loadGroups() {
    FileInputStream inputStream;
    InputStreamReader reader;
    Scanner scanner = null;
    try {
      inputStream = new FileInputStream(currentGroupFileName);
      reader = new InputStreamReader(inputStream, "UTF-8");

      scanner = new Scanner(reader);

      String line = "";
      while (scanner.hasNextLine()) {
        line = scanner.nextLine();

        // Check for comments.
        if (line.startsWith("#") || line.startsWith("//")) continue;

        String[] data = line.split(":");

        if (data.length < 2) continue;

        if (data.length >= 2) {
          Group newGroup = new Group(data[0]);

          groups.add(newGroup);

          newGroup.setColor(ChatColor.getByCode(Integer.parseInt(data[1])));

          if (Kikkit.IsDebugging)
            Kikkit.MinecraftLog.info("    Added group: " + newGroup.getName());

          if (data.length > 2) {
            String[] commands = data[2].split(",");

            // TODO: Why must we do a foreach here?
            // Because java doesn't understand IEnumerable
            for (String str : commands) {
              if (Kikkit.IsDebugging) Kikkit.MinecraftLog.info("        command: " + str);
              newGroup.Commands.add(str);
            }
          }
        }
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      Kikkit.MinecraftLog.info(e.getMessage());
    } finally {
      if (scanner != null) scanner.close();
    }
  }