Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void saveInventory(Inventory inv, File file, boolean override){
- if(inv == null || file == null) return;
- if(file.exists() && override) file.delete();
- FileConfiguration conf = YamlConfiguration.loadConfiguration(file);
- ItemStack[] contents = inv.getContents();
- for(int i = 0; i < contents.length; i++){
- ItemStack item = contents[i];
- if(item != null) if(item.getType() != Material.AIR) conf.set("Slot." + i, item);
- }
- try {
- conf.save(file);
- }
- catch(IOException e){
- return;
- }
- }
- public static List<ItemStack> getKit(String name){
- if(name == null) return null;
- ItemStack[] items = null;
- FileConfiguration conf = YamlConfiguration.loadConfiguration(new File("plugins/BetterKits/" + getConfigName(name)));
- if(conf.contains("Slot") && conf.isConfigurationSection("Slot")){
- int size = conf.getInt("Slot", 27);
- items = new ItemStack[size];
- for(int i = 0; i < size; i++){
- if(conf.contains("Slot." + i)) items[i] = conf.getItemStack("Slot." + i);
- else items[i] = new ItemStack(Material.AIR);
- }
- }
- List<ItemStack> kit = new ArrayList<ItemStack>();
- for(ItemStack i : items) {
- if(i != null) {
- kit.add(i);
- }
- }
- kit.removeAll(Collections.singleton(null));
- return kit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement