@SuppressWarnings("unchecked")
	public static String pack(ItemStack is) {
		JSONObject obj = new JSONObject();
		
		obj.put("amount",  new Integer(is.getAmount()));
		obj.put("durability",  new Short(is.getDurability()));
		
		MaterialData md = is.getData();

		obj.put("material",  md.getItemType().name());
		
		if( is.hasItemMeta() ) {
			ItemMeta im = is.getItemMeta();
			
			if( im.hasLore() ) {
				ArrayList<String> lores = (ArrayList<String>)im.getLore();
				
				JSONArray l1 = new JSONArray();
				
				for( String lore : lores ) {
					l1.add(lore);
				}
				
				obj.put("lores",  l1);
			}
			
			if( im.hasDisplayName()) {
				obj.put("displayName",  im.getDisplayName());
			}
			
			if( im.hasEnchants() ) {
				JSONArray l2 = new JSONArray();
				
				Map<Enchantment,Integer> enchants = im.getEnchants();
				
				for( Entry<Enchantment, Integer> enchant : enchants.entrySet() ) {
					JSONObject o2 = new JSONObject();
					
					o2.put("enchantName", enchant.getKey().getName());
					o2.put("enchantPower",  enchant.getValue());
					
					l2.add(o2);
				}
				
				obj.put("enchantments",  l2);
			}
			
			if( md.getItemType() == Material.ENCHANTED_BOOK ) {
				EnchantmentStorageMeta esm = (EnchantmentStorageMeta)is.getItemMeta();
				
				if( esm.hasStoredEnchants() ) {
					JSONArray l2 = new JSONArray();
					
					Map<Enchantment,Integer> enchants = esm.getStoredEnchants();
					
					for( Entry<Enchantment, Integer> enchant : enchants.entrySet() ) {
						JSONObject o2 = new JSONObject();
						
						o2.put("enchantName", enchant.getKey().getName());
						o2.put("enchantPower",  enchant.getValue());
						
						l2.add(o2);
					}
					
					obj.put("storedEnchants",  l2);
				}
				
			}			
		}
		
		return obj.toJSONString();
	}