Guest User

Untitled

a guest
Jun 25th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileInputStream;
  3. import java.io.FileOutputStream;
  4. import java.io.DataInputStream;
  5. import java.io.BufferedWriter;
  6. import java.io.FileWriter;
  7.  
  8. public class EconomyReset
  9. {
  10.  
  11. private static File charDir = new File("Data/characters/");
  12.  
  13. public static void main(String[] args)
  14. {
  15. if(charDir.exists() && charDir.isDirectory())
  16. {
  17. File[] charFiles = charDir.listFiles();
  18. for(int i = 0; i < charFiles.length; i++)
  19. {
  20. resetEcoChar(charFiles[i]);
  21. System.out.println("Reset player economy levels for... "+charFiles[i].toString());
  22. }
  23. }
  24. }
  25.  
  26. private static void resetEcoChar(File charFile)
  27. {
  28. try
  29. {
  30.  
  31. String cheatStatus, tempData, tempAdd = ""; int curEquip = 0, curItem = 0, curBank = 0;
  32. File tempCharFile = new File(charDir.toString()+"ECOBOOST$TEMP");
  33. DataInputStream fileStream = new DataInputStream(new FileInputStream(charFile));
  34. BufferedWriter tempOut = new BufferedWriter(new FileWriter(tempCharFile));
  35.  
  36. while((tempData = fileStream.readLine()) != null)
  37. {
  38. if((!tempData.trim().startsWith("character-item =")) && (!tempData.trim().startsWith("character-bank =")))
  39. {
  40. tempAdd = tempData.trim();
  41.  
  42. if(tempData.trim().startsWith("character-equip ="))
  43. {
  44. tempAdd = "character-equip = "+curEquip+"\t-1\t0";
  45. curEquip++;
  46. }
  47. tempOut.write(tempAdd); tempOut.newLine();
  48. }
  49. }
  50. fileStream.close(); tempOut.close();
  51. charFile.delete();
  52. tempCharFile.renameTo(charFile);
  53. }
  54. catch(Exception e) { e.printStackTrace();
  55. }
  56. }
  57. }
Add Comment
Please, Sign In to add comment