Guest User

Untitled

a guest
Feb 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. public void setItems(Inventory inv)
  2. {
  3. try
  4. {
  5. if (!kit.getDataFolder().exists())
  6. {
  7. kit.getDataFolder().mkdirs();
  8. }
  9.  
  10. Logger.log("1");
  11.  
  12. File folder = files.getFolder("GUI Menu");
  13. Logger.log("2");
  14. if (!folder.exists())
  15. {
  16. files.createFolder("GUI Menu");
  17. }
  18. File[] fileList = folder.listFiles();
  19. Logger.log("3");
  20. while (fileList.length != 0)
  21. {
  22. Logger.log("4");
  23. for (File forFile : fileList)
  24. {
  25. Logger.log("5");
  26. File file = files.getGuiItem(forFile);
  27. Logger.log("6");
  28. if(!file.exists())
  29. {
  30. Logger.log("Cannot open Inventory for the file");
  31. return;
  32. }
  33. Logger.log("7");
  34. BufferedReader br = new BufferedReader(new FileReader(file));
  35. Scanner scanner = new Scanner(file);
  36. Logger.log("8");
  37. String line;
  38. Logger.log("9");
  39. while ((line = scanner.) != null)
  40. {
  41. Logger.log("10");
  42. ItemStack item;
  43.  
  44. if (line.contains("Item ID: "))
  45. {
  46. Logger.log("11");
  47. String[] tSplit = line.split(": ");
  48. String split = tSplit[1];
  49. Logger.log("12");
  50. if (StringCheck.isInteger(split))
  51. {
  52. Logger.log("13");
  53. Material mat = Material.matchMaterial(split);
  54.  
  55. ItemStack item1 = new ItemStack(mat, 1);
  56. item = item1;
  57. Logger.log("14");
  58.  
  59. if (line.contains("Kit Name: "))
  60. {
  61. String[] jSplit = line.split(": ");
  62. String j2split = jSplit[1];
  63. Logger.log("15");
  64.  
  65. if (item != null && !item.equals(Material.AIR))
  66. {
  67. ItemMeta meta = item.getItemMeta();
  68.  
  69. meta.setDisplayName(Color.add("&6" + j2split + "&e Kit"));
  70. item.setItemMeta(meta);
  71. Logger.log("16");
  72.  
  73. if (line.contains("Price: "))
  74. {
  75. String[] pSplit = line.split(": ");
  76. String p2split = pSplit[1];
  77. Logger.log("17");
  78.  
  79. if (item != null && !item.equals(Material.AIR))
  80. {
  81. this.setLore(item, "&ePrice: &6" + p2split);
  82.  
  83. if (line.contains("Slot Number: "))
  84. {
  85. Logger.log("18");
  86. String[] fSplit = line.split(": ");
  87. String f2split = fSplit[1];
  88. if (StringCheck.isInteger(f2split))
  89. {
  90. Logger.log("19");
  91. if (item != null && !item.equals(Material.AIR))
  92. {
  93. Logger.log("20");
  94. if (inv.getItem(Integer.parseInt(split)) == null || inv.getItem(Integer.parseInt(split)).equals(Material.AIR))
  95. {
  96. inv.setItem(Integer.parseInt(split), item);
  97. }
  98. }
  99.  
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. br.close();
  110. }
  111. }
  112. } catch (Exception e)
  113. {
  114. e.printStackTrace();
  115. }
  116. }
Add Comment
Please, Sign In to add comment