Guest User

Untitled

a guest
Jan 12th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. public static loadAchievements (String achivFile) throws FileMissingException
  2. {
  3. // Load sprites as described in achievementFile
  4. File file = new File(achivFile);
  5.  
  6. if(!file.isFile()) {
  7. throw new FileMissingException("Couldn't load the achievement file: " + achivFile);
  8. }
  9.  
  10.  
  11.  
  12. // Map for achievement information
  13. achievementMap = new HashMap<String, AchivInfo>();
  14.  
  15.  
  16.  
  17. try {
  18. FileReader fileReader = new FileReader(achivFile);
  19. BufferedReader reader = new BufferedReader(fileReader);
  20.  
  21. String line = null;
  22.  
  23. while ((line = reader.readLine()) != null) {
  24. //skip empty lines
  25. if (line.isEmpty())
  26. continue;
  27.  
  28. // ; is for comments
  29. if (line.startsWith(";"))
  30. continue;
  31.  
  32. // create a NEW archivInfo
  33. if (line = "NEW")
  34. ArchivInfo ai = new AchivInfo();
  35.  
  36. String[] split = line.split(":");
  37. if (split.length == 2) {
  38. final String key = split[0].trim();
  39. final String val = split[1].trim();
  40.  
  41. System.out.println("k: " + key + " v: " + val);
  42.  
  43. // TODO alot
  44.  
  45. switch(key) {
  46. case "id":
  47. break;
  48. case "detail":
  49. break;
  50. case "howto":
  51. break;
  52. case "image":
  53. break;
  54. }
  55.  
  56.  
  57.  
  58. }
  59. }
  60. } catch (IOException e) {
  61. // rethrow a more descriptive error
  62. System.out.println("ouch we caught an exception!");
  63. }
  64.  
  65. reader.close();
  66. }
Add Comment
Please, Sign In to add comment