Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Methods
- {
- private static Main plugin = Main.getPlugin(Main.class);
- @SuppressWarnings("unchecked")
- public void loadCreativeInventory(Player p) {
- File CreativeInventory = new File(plugin.getDataFolder() + File.separator + "Inventories" + File.separator + "Inventories_" + p.getUniqueId() + File.separator + "creative.yml");
- FileConfiguration data = YamlConfiguration.loadConfiguration(CreativeInventory);
- ArrayList<ItemStack> content = (ArrayList<ItemStack>) data.getList(p.getName());
- ItemStack[] items = new ItemStack[content.size()];
- for (int i = 0; i < content.size(); i++) {
- ItemStack item = content.get(i);
- if (item != null) {
- items[i] = item;
- } else {
- items[i] = null;
- }
- }
- p.getInventory().setContents(items);
- }
- @SuppressWarnings("unchecked")
- public void loadSurvivalInventory(Player p) {
- File CreativeInventory = new File(plugin.getDataFolder() + File.separator + "Inventories" + File.separator + "Inventories_" + p.getUniqueId() + File.separator + "survival.yml");
- FileConfiguration data = YamlConfiguration.loadConfiguration(CreativeInventory);
- ArrayList<ItemStack> content = (ArrayList<ItemStack>) data.getList(p.getName());
- ItemStack[] items = new ItemStack[content.size()];
- for (int i = 0; i < content.size(); i++) {
- ItemStack item = content.get(i);
- if (item != null) {
- items[i] = item;
- } else {
- items[i] = null;
- }
- }
- p.getInventory().setContents(items);
- }
- public void saveCreativeInventory(Player p) {
- File CreativeInventory = new File(plugin.getDataFolder() + File.separator + "Inventories" + File.separator + "Inventories_" + p.getUniqueId() + File.separator + "creative.yml");
- FileConfiguration data = YamlConfiguration.loadConfiguration(CreativeInventory);
- data.set(p.getName(), p.getInventory().getContents());
- try {
- data.save(CreativeInventory);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public void saveSurvivalInventory(Player p) {
- File Survivalnventory = new File(plugin.getDataFolder() + File.separator + "Inventories" + File.separator + "Inventories_" + p.getUniqueId() + File.separator + "survival.yml");
- FileConfiguration data = YamlConfiguration.loadConfiguration(Survivalnventory);
- data.set(p.getName(), p.getInventory().getContents());
- try {
- data.save(Survivalnventory);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement