Ejemplo n.º 1
0
  public void onEnable(File dir) {
    Command.addCommands(this, cmd = new CmdRSS());

    ArrayList<String> lines = FileLine.read(new File(dir, "rss.cfg"));
    int n = 4;
    for (int i = 0; i < lines.size(); i += n) {
      try {
        URL url = new URL(lines.get(i));
        long time = Long.parseLong(lines.get(i + 1));
        Date date = time <= 0 ? null : new Date(time);
        long interval;
        String[] channels;
        try {
          interval = Long.parseLong(lines.get(i + 2));
          channels = lines.get(i + 3).split(" ");
        } catch (NumberFormatException e) {
          n = 3;
          interval = (5 * 60 * 1000);
          channels = lines.get(i + 2).split(" ");
        }
        feeds.add(new Feed(url, interval, date, channels));
      } catch (MalformedURLException e) {
        continue;
      }
    }
    startUpdater();
  }
Ejemplo n.º 2
0
 public void onDataSave(File dir) {
   ArrayList<String> lines = new ArrayList<String>();
   for (Feed feed : feeds) {
     lines.add(feed.getURL().toString());
     lines.add(Long.toString((feed.getDate() != null) ? feed.getDate().getTime() : 0L));
     lines.add(Long.toString(feed.getInterval()));
     lines.add(StringTools.implode(feed.channels.toArray(new String[feed.channels.size()]), " "));
   }
   FileLine.write(new File(dir, "rss.cfg"), lines);
 }