package me.rkfg.pfe;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

public class SettingsStorage {

    private Properties properties = new Properties();
    private Collection<String> trackers;
    private boolean dht;
    private int seedRatio;
    private long seedingTimeout;
    private boolean seedAfterDownload;

    public SettingsStorage() {
        try {
            File settingsFile = null;
            String settingsFilename = System.getProperty("pfe.settings");
            if (settingsFilename == null) {
                settingsFilename = "pfe_settings.ini";
            }
            settingsFile = new File(settingsFilename);
            properties.load(new FileInputStream(settingsFile));
            dht = Boolean.valueOf(properties.getProperty("enable_dht", "false"));
            seedRatio = Integer.valueOf(properties.getProperty("seeding_ratio", "3"));
            trackers = Arrays.asList(properties.getProperty("trackers", "").split("\\|"));
            seedingTimeout = TimeUnit.SECONDS.toNanos(Integer.valueOf(properties.getProperty("seeding_timeout", "60")));
            seedAfterDownload = Boolean.valueOf(properties.getProperty("seed_after_download", "false"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public Collection<String> getTrackers() {
        return trackers;
    }

    public boolean isDht() {
        return dht;
    }

    public int getSeedRatio() {
        return seedRatio;
    }

    public long getSeedingTimeout() {
        return seedingTimeout;
    }

    public boolean isSeedAfterDownload() {
        return seedAfterDownload;
    }

}

@@ -505,26 +505,8 @@
 ) %7B%0A
-        try %7B%0A    
     
@@ -535,20 +535,16 @@
 = null;%0A
-    
         
@@ -613,20 +613,16 @@
         
-  
-  
 if (sett
@@ -641,28 +641,24 @@
  == null) %7B%0A
-    
             
@@ -704,26 +704,18 @@
         
-  
-  %7D%0A    
+%7D%0A
         
@@ -761,24 +761,34 @@
 e);%0A    
+    try %7B%0A
         
 properti
@@ -779,16 +779,20 @@
         
+    
 properti
@@ -831,32 +831,105 @@
 ingsFile));%0A    
+    %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A
         dht = Bo
@@ -994,28 +994,24 @@
 ));%0A        
- 
-   
 seedRatio = 
@@ -1069,28 +1069,24 @@
 io%22, %223%22));%0A
-    
         trac
@@ -1156,32 +1156,70 @@
 it(%22%5C%5C%7C%22));%0A    
+    if (trackers == null) %7B%0A        %7D%0A
         seedingT
@@ -1323,28 +1323,24 @@
 ));%0A        
-    
 seedAfterDow
@@ -1424,85 +1424,8 @@
 ));%0A
-        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A
     

Use default values if no settings file found.