Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void loadChest(Inventory inv){
- final File file = new File(ChestRefill.INSTANCE.getPlugin().getDataFolder(), "data.yml");
- final YamlConfiguration yaml = YamlConfiguration.loadConfiguration(file);
- int id = 0;
- if(yaml.getConfigurationSection("chests") != null) {
- for (String key : yaml.getConfigurationSection("chests").getKeys(false)) {
- id = Integer.parseInt(key);
- }
- }
- int counter = 1;
- ItemStack[] contents;
- for (int length = (contents = inv.getContents()).length, i = 0; i < length; ++i) {
- final ItemStack is = contents[i];
- if (is != null) {
- yaml.set("chests." + id + ".inv.slot" + counter, is);
- ++counter;
- }
- }
- --counter;
- try {
- yaml.save(file);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment