Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.chickenstyle.luckyblock;
- import java.io.File;
- import java.io.IOException;
- import java.util.ArrayList;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- public class Items {
- private static File file;
- private static YamlConfiguration config;
- public Items(Main main) {
- file = new File(main.getDataFolder(), "Items.yml");
- if (!file.exists()) {
- try {
- file.createNewFile();
- config = YamlConfiguration.loadConfiguration(file);
- Inventory open = Bukkit.createInventory(null, 54, ChatColor.GRAY + "" +ChatColor.BOLD + "Prizes!");
- config.set("items", open.getContents());
- try {
- config.save(file);
- config = YamlConfiguration.loadConfiguration(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- static public void setContent(ItemStack[] itemStacks) {
- config.set("items", itemStacks);
- try {
- config.save(file);
- config = YamlConfiguration.loadConfiguration(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- @SuppressWarnings("unchecked")
- static public ArrayList<ItemStack> getContent() {
- ArrayList<ItemStack> items = (ArrayList<ItemStack>) config.getList("items");
- return items;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement