Advertisement
Guest User

Untitled

a guest
Oct 9th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. public class Methods
  2. {
  3.  
  4. private static Main plugin = Main.getPlugin(Main.class);
  5.  
  6.  
  7. @SuppressWarnings("unchecked")
  8. public void loadCreativeInventory(Player p) {
  9. File CreativeInventory = new File(plugin.getDataFolder() + File.separator + "Inventories" + File.separator + "Inventories_" + p.getUniqueId() + File.separator + "creative.yml");
  10. FileConfiguration data = YamlConfiguration.loadConfiguration(CreativeInventory);
  11. ArrayList<ItemStack> content = (ArrayList<ItemStack>) data.getList(p.getName());
  12. ItemStack[] items = new ItemStack[content.size()];
  13. for (int i = 0; i < content.size(); i++) {
  14. ItemStack item = content.get(i);
  15. if (item != null) {
  16. items[i] = item;
  17. } else {
  18. items[i] = null;
  19. }
  20. }
  21. p.getInventory().setContents(items);
  22. }
  23.  
  24. @SuppressWarnings("unchecked")
  25. public void loadSurvivalInventory(Player p) {
  26. File CreativeInventory = new File(plugin.getDataFolder() + File.separator + "Inventories" + File.separator + "Inventories_" + p.getUniqueId() + File.separator + "survival.yml");
  27. FileConfiguration data = YamlConfiguration.loadConfiguration(CreativeInventory);
  28. ArrayList<ItemStack> content = (ArrayList<ItemStack>) data.getList(p.getName());
  29. ItemStack[] items = new ItemStack[content.size()];
  30. for (int i = 0; i < content.size(); i++) {
  31. ItemStack item = content.get(i);
  32. if (item != null) {
  33. items[i] = item;
  34. } else {
  35. items[i] = null;
  36. }
  37. }
  38. p.getInventory().setContents(items);
  39. }
  40.  
  41. public void saveCreativeInventory(Player p) {
  42. File CreativeInventory = new File(plugin.getDataFolder() + File.separator + "Inventories" + File.separator + "Inventories_" + p.getUniqueId() + File.separator + "creative.yml");
  43. FileConfiguration data = YamlConfiguration.loadConfiguration(CreativeInventory);
  44. data.set(p.getName(), p.getInventory().getContents());
  45. try {
  46. data.save(CreativeInventory);
  47. } catch (IOException e) {
  48. e.printStackTrace();
  49. }
  50. }
  51.  
  52. public void saveSurvivalInventory(Player p) {
  53. File Survivalnventory = new File(plugin.getDataFolder() + File.separator + "Inventories" + File.separator + "Inventories_" + p.getUniqueId() + File.separator + "survival.yml");
  54. FileConfiguration data = YamlConfiguration.loadConfiguration(Survivalnventory);
  55. data.set(p.getName(), p.getInventory().getContents());
  56. try {
  57. data.save(Survivalnventory);
  58. } catch (IOException e) {
  59. e.printStackTrace();
  60. }
  61. }
  62.  
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement