package io.github.Cnly.Crafter.Crafter.utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public class ItemUtils
{
    
    private ItemUtils()
    {
        throw new AssertionError("This is a util class");
    }
    
    @SuppressWarnings("deprecation")
    public static ItemStack getItemByIdString(String idString)
    {
        
        if (idString.contains(":"))
        {
            String[] split = idString.split(":");
            return new ItemStack(Integer.parseInt(split[0]), 1,
                    Short.parseShort(split[1]));
        }
        else
        {
            return new ItemStack(Integer.parseInt(idString));
        }
        
    }
    
    public static String getIdString(ItemStack is)
    {
        
        @SuppressWarnings("deprecation")
        String result = String.valueOf(is.getTypeId());
        short durability = is.getDurability();
        
        if (0 != durability)
            result += ":" + String.valueOf(durability);
        
        return result;
    }
    
    public static List<String> getLores(ItemStack item)
    {
        
        if (!item.hasItemMeta())
            return Collections.emptyList();
        
        ItemMeta meta = item.getItemMeta();
        
        if (!meta.hasLore())
            return Collections.emptyList();
        
        return meta.getLore();
    }
    
    public static void addLore(ItemStack item, String lore)
    {
        
        ItemMeta meta = item.getItemMeta();
        List<String> lores = meta.hasLore() ? meta.getLore()
                : new ArrayList<String>();
        lores.add(lore);
        meta.setLore(lores);
        item.setItemMeta(meta);
        
    }
    
    public static void setLores(ItemStack item, List<String> lores)
    {
        
        ItemMeta meta = item.getItemMeta();
        meta.setLore(lores);
        item.setItemMeta(meta);
        
    }
    
    public static String getDisplayName(ItemStack item)
    {
        
        ItemMeta meta = item.getItemMeta();
        
        if (!meta.hasDisplayName())
            return null;
        
        return meta.getDisplayName();
    }
    
    public static void setDisplayName(ItemStack item, String displayName)
    {
        
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(displayName);
        item.setItemMeta(meta);
        
    }
    
}

@@ -1482,20 +1482,25 @@
  static 
-void
+ItemStack
  addLore
@@ -1779,32 +1779,53 @@
 meta);%0A        %0A
+        return item;%0A
     %7D%0A    %0A    p
@@ -1833,28 +1833,33 @@
 blic static 
-void
+ItemStack
  setLores(It
@@ -2013,32 +2013,53 @@
 meta);%0A        %0A
+        return item;%0A
     %7D%0A    %0A    p
@@ -2318,12 +2318,17 @@
 tic 
-void
+ItemStack
  set
@@ -2509,29 +2509,50 @@
 meta);%0A        %0A
+        return item;%0A
     %7D%0A    %0A%7D%0A

Change return types for some methods