Advertisement
Jnk1296

setNationEco

Mar 30th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. // Change the Nation Economy
  2.     public static void setNationEco(double value, double limit) {
  3.         genNationFiles();
  4.         ArrayList<String> fileName = new ArrayList<String>();
  5.        
  6.         try {
  7.             FileInputStream fstream = new FileInputStream(Nations);
  8.             DataInputStream in = new DataInputStream(fstream);
  9.             BufferedReader br = new BufferedReader(new InputStreamReader(in));
  10.             String strLine;
  11.            
  12.             // Load HIVE file regex2.hive
  13.             while ((strLine = br.readLine()) != null) {
  14.                 fileName.add(strLine);
  15.             }
  16.            
  17.             for (String s:fileName) {
  18.                 ArrayList<String> lines = new ArrayList<String>();
  19.                 File currentFile = new File(path + "/" + s);
  20.                
  21.                 FileInputStream fstream2 = new FileInputStream(currentFile);
  22.                 DataInputStream in2 = new DataInputStream(fstream2);
  23.                 BufferedReader br2 = new BufferedReader(new InputStreamReader(in2));
  24.                 String strLine2;
  25.                
  26.                 while ((strLine2 = br2.readLine()) != null) {
  27.                     lines.add(strLine2);
  28.                 }
  29.                
  30.                 br2.close();
  31.                
  32.                 for (String ss:lines) {
  33.                     if (ss.startsWith("money:")) {
  34.                         String strCheck = ss;
  35.                         strCheck.replace("money: ", "");
  36.                         double moneyVal = Double.parseDouble(strCheck);
  37.                        
  38.                         if (moneyVal >= moneyLimit) {
  39.                             ss = "money: " + changeAmountNation;
  40.                         }
  41.                     }
  42.                 }
  43.                
  44.                 FileWriter f = null;
  45.                
  46.                 // If regex0.hive exists, delete it
  47.                 if (currentFile.exists()) currentFile.delete();
  48.                
  49.                 try {
  50.                     // Create the file
  51.                     currentFile.createNewFile();
  52.                    
  53.                     // Create the file writer
  54.                     f = new FileWriter(currentFile, true);
  55.                    
  56.                     // Write each file name to regex0.hive
  57.                     for (String ss:lines) {
  58.                         f.write(ss + "\r\n");
  59.                     }
  60.                    
  61.                     // Close the file writer
  62.                     f.close();
  63.                 } catch (Exception e) {
  64.                     e.printStackTrace();
  65.                 }
  66.                
  67.             }
  68.            
  69.             br.close();
  70.         } catch (Exception e) {
  71.             e.printStackTrace();
  72.             System.exit(0);
  73.         }
  74.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement