Guest User

Untitled

a guest
Nov 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. private static int preChecks() {
  2. try {
  3. String dir = WPlanner.class.getProtectionDomain().getCodeSource().getLocation().getPath();
  4. if (dir.endsWith(".jar"))
  5. dir = dir.substring(0, dir.lastIndexOf("/") + 1);
  6. JOptionPane.showMessageDialog(null, dir);
  7. System.out.println(dir);
  8.  
  9. /*
  10. * When dir == /C:/Users/Blake/Documents/workspace/WPlanner/bin/
  11. * == ./
  12. * it loads "/data/objects/" fine
  13. * When dir == /C:/Program%20Files%20(x86)/TestProgram/WPlanner/
  14. * it doesn't
  15. */
  16.  
  17. OBJECTS_FOLDER = dir + OBJECTS_FOLDER;
  18. FENCES_FOLDER = dir + FENCES_FOLDER;
  19.  
  20. if (Preferences.userRoot().nodeExists(WURM_REGISTRY))
  21. if (Preferences.userRoot().node(WURM_REGISTRY).get("wurm_dir", "FAIL").equals("FAIL"))
  22. return 3;
  23. else
  24. if ((new File(OBJECTS_FOLDER)).exists())
  25. if ((new File(FENCES_FOLDER)).exists())
  26. return 1;
  27. else
  28. return 9;
  29. else
  30. return 8;
  31. else
  32. return 2;
  33. } catch (BackingStoreException e) {
  34. e.printStackTrace();
  35. }
  36. return 5;
  37. }
Add Comment
Please, Sign In to add comment