Advertisement
danik159

Untitled

Oct 18th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. package com.chickenstyle.luckyblock;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.ArrayList;
  6.  
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.ChatColor;
  9. import org.bukkit.configuration.file.YamlConfiguration;
  10. import org.bukkit.inventory.Inventory;
  11. import org.bukkit.inventory.ItemStack;
  12.  
  13.  
  14.  
  15. public class Items {
  16.  
  17. private static File file;
  18. private static YamlConfiguration config;
  19. public Items(Main main) {
  20. file = new File(main.getDataFolder(), "Items.yml");
  21. if (!file.exists()) {
  22. try {
  23. file.createNewFile();
  24. config = YamlConfiguration.loadConfiguration(file);
  25. Inventory open = Bukkit.createInventory(null, 54, ChatColor.GRAY + "" +ChatColor.BOLD + "Prizes!");
  26. config.set("items", open.getContents());
  27. try {
  28. config.save(file);
  29. config = YamlConfiguration.loadConfiguration(file);
  30. } catch (IOException e) {
  31. e.printStackTrace();
  32. }
  33. } catch (IOException e) {
  34. e.printStackTrace();
  35. }
  36.  
  37. }
  38.  
  39. }
  40. static public void setContent(ItemStack[] itemStacks) {
  41. config.set("items", itemStacks);
  42. try {
  43. config.save(file);
  44. config = YamlConfiguration.loadConfiguration(file);
  45. } catch (IOException e) {
  46. e.printStackTrace();
  47. }
  48. }
  49.  
  50.  
  51. @SuppressWarnings("unchecked")
  52. static public ArrayList<ItemStack> getContent() {
  53. ArrayList<ItemStack> items = (ArrayList<ItemStack>) config.getList("items");
  54. return items;
  55. }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement