Browse Source

Basic Gracia Part2 Support.

nBd 16 years ago
parent
commit
402de5abae

+ 36 - 12
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java

@@ -21,7 +21,7 @@ import net.sf.l2j.gameserver.model.L2ItemInstance;
 import net.sf.l2j.gameserver.model.L2World;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.network.SystemMessageId;
-import net.sf.l2j.gameserver.network.serverpackets.EnchantResult;
+import net.sf.l2j.gameserver.network.serverpackets.ExPutEnchantTargetItemResult;
 import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
 import net.sf.l2j.gameserver.network.serverpackets.ItemList;
 import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
@@ -37,9 +37,15 @@ public final class RequestEnchantItem extends L2GameClientPacket
 	protected static final Logger _log = Logger.getLogger(RequestEnchantItem.class.getName());
 	
 	private static final String _C__58_REQUESTENCHANTITEM = "[C] 58 RequestEnchantItem";
-
-	private static final int[] ENCHANT_SCROLLS = { 729, 730, 947, 948, 951, 952, 955, 956, 959, 960 };
-	private static final int[] BLESSED_SCROLLS = { 6569, 6570, 6571, 6572, 6573, 6574, 6575, 6576, 6577, 6578 };
+	
+	private static final int[] ENCHANT_SCROLLS =
+	{
+		729, 730, 947, 948, 951, 952, 955, 956, 959, 960
+	};
+	private static final int[] BLESSED_SCROLLS =
+	{
+		6569, 6570, 6571, 6572, 6573, 6574, 6575, 6576, 6577, 6578
+	};
 	
 	private int _objectId;
 	
@@ -53,8 +59,10 @@ public final class RequestEnchantItem extends L2GameClientPacket
 	protected void runImpl()
 	{
 		L2PcInstance activeChar = getClient().getActiveChar();
+		
 		if (activeChar == null || _objectId == 0)
 			return;
+		
 		if (activeChar.isOnline() == 0)
 		{
 			activeChar.setActiveEnchantItem(null);
@@ -70,6 +78,7 @@ public final class RequestEnchantItem extends L2GameClientPacket
 		
 		L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
 		L2ItemInstance scroll = activeChar.getActiveEnchantItem();
+		
 		if (item == null || scroll == null)
 		{
 			activeChar.setActiveEnchantItem(null);
@@ -81,8 +90,10 @@ public final class RequestEnchantItem extends L2GameClientPacket
 		{
 			activeChar.sendPacket(new SystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
 			activeChar.setActiveEnchantItem(null);
+			activeChar.sendPacket(new ExPutEnchantTargetItemResult(2));
 			return;
 		}
+		
 		if (item.isWear())
 		{
 			Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to enchant a weared Item", IllegalPlayerAction.PUNISH_KICK);
@@ -97,6 +108,7 @@ public final class RequestEnchantItem extends L2GameClientPacket
 				if (item.getOwnerId() != activeChar.getObjectId())
 				{
 					activeChar.setActiveEnchantItem(null);
+					activeChar.sendPacket(new ExPutEnchantTargetItemResult(2));
 					return;
 				}
 				break;
@@ -107,6 +119,7 @@ public final class RequestEnchantItem extends L2GameClientPacket
 				return;
 			}
 		}
+		
 		int itemType2 = item.getItem().getType2();
 		boolean enchantItem = false;
 		boolean blessedScroll = false;
@@ -201,8 +214,7 @@ public final class RequestEnchantItem extends L2GameClientPacket
 					case 960:
 					case 962:
 					case 6578:
-						if (itemType2 == L2Item.TYPE2_SHIELD_ARMOR
-						        || itemType2 == L2Item.TYPE2_ACCESSORY)
+						if (itemType2 == L2Item.TYPE2_SHIELD_ARMOR || itemType2 == L2Item.TYPE2_ACCESSORY)
 							enchantItem = true;
 						break;
 				}
@@ -213,6 +225,7 @@ public final class RequestEnchantItem extends L2GameClientPacket
 		{
 			activeChar.sendPacket(new SystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
 			activeChar.setActiveEnchantItem(null);
+			activeChar.sendPacket(new ExPutEnchantTargetItemResult(2));
 			return;
 		}
 		
@@ -226,6 +239,7 @@ public final class RequestEnchantItem extends L2GameClientPacket
 			activeChar.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
 			Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to enchant with a scroll he doesn't have", Config.DEFAULT_PUNISH);
 			activeChar.setActiveEnchantItem(null);
+			activeChar.sendPacket(new ExPutEnchantTargetItemResult(2));
 			return;
 		}
 		
@@ -298,24 +312,27 @@ public final class RequestEnchantItem extends L2GameClientPacket
 		if (item.getEnchantLevel() < Config.ENCHANT_SAFE_MAX || item.getItem().getBodyPart() == L2Item.SLOT_FULL_ARMOR && item.getEnchantLevel() < Config.ENCHANT_SAFE_MAX_FULL)
 			chance = 100;
 		
+		boolean failed = false;
+		
 		if (Rnd.get(100) < chance)
 		{
 			synchronized (item)
 			{
-				if (item.getOwnerId() != activeChar.getObjectId() // has just lost the item
-				        || item.getEnchantLevel() >= maxEnchantLevel && maxEnchantLevel != 0)
+				if (item.getOwnerId() != activeChar.getObjectId() || item.getEnchantLevel() >= maxEnchantLevel && maxEnchantLevel != 0)
 				{
 					activeChar.sendPacket(new SystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
 					activeChar.setActiveEnchantItem(null);
+					activeChar.sendPacket(new ExPutEnchantTargetItemResult(2));
 					return;
 				}
-				if (item.getLocation() != L2ItemInstance.ItemLocation.INVENTORY
-				        && item.getLocation() != L2ItemInstance.ItemLocation.PAPERDOLL)
+				if (item.getLocation() != L2ItemInstance.ItemLocation.INVENTORY && item.getLocation() != L2ItemInstance.ItemLocation.PAPERDOLL)
 				{
 					activeChar.sendPacket(new SystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
 					activeChar.setActiveEnchantItem(null);
+					activeChar.sendPacket(new ExPutEnchantTargetItemResult(2));
 					return;
 				}
+				
 				if (item.getEnchantLevel() == 0)
 				{
 					sm = new SystemMessage(SystemMessageId.S1_SUCCESSFULLY_ENCHANTED);
@@ -357,6 +374,8 @@ public final class RequestEnchantItem extends L2GameClientPacket
 				activeChar.sendPacket(sm);
 			}
 			
+			failed = true;
+			
 			if (!blessedScroll)
 			{
 				if (item.getEnchantLevel() > 0)
@@ -377,7 +396,7 @@ public final class RequestEnchantItem extends L2GameClientPacket
 				{
 					L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
 					InventoryUpdate iu = new InventoryUpdate();
-					for (L2ItemInstance itm: unequiped)
+					for (L2ItemInstance itm : unequiped)
 					{
 						iu.addModifiedItem(itm);
 					}
@@ -440,7 +459,12 @@ public final class RequestEnchantItem extends L2GameClientPacket
 		activeChar.sendPacket(su);
 		su = null;
 		
-		activeChar.sendPacket(new EnchantResult(item.getEnchantLevel()));
+		int result = 0;
+		
+		if (failed)
+			result = 1;
+		
+		activeChar.sendPacket(new ExPutEnchantTargetItemResult(result));
 		activeChar.sendPacket(new ItemList(activeChar, false));
 		activeChar.broadcastUserInfo();
 		activeChar.setActiveEnchantItem(null);

+ 29 - 29
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestExCancelEnchantItem.java

@@ -15,6 +15,7 @@
 package net.sf.l2j.gameserver.network.clientpackets;
 
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.network.serverpackets.ExPutEnchantTargetItemResult;
 
 /**
  *
@@ -22,36 +23,35 @@ import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  */
 public class RequestExCancelEnchantItem extends L2GameClientPacket
 {
-
-	/**
-     * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#getType()
-     */
-    @Override
-    public String getType()
-    {
-	    return "[C] D0:51 RequestExCancelEnchantItem";
-    }
-
 	/**
-     * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
-     */
-    @Override
-    protected void readImpl()
-    {
-	    // nothing (trigger)
-    }
-
+	 * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return "[C] D0:51 RequestExCancelEnchantItem";
+	}
+	
 	/**
-     * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
-     */
-    @Override
-    protected void runImpl()
-    {
-    	L2PcInstance activeChar = this.getClient().getActiveChar();
-	    if (activeChar != null)
-	    {
-	    	activeChar.sendMessage("RequestExCancelEnchantItem");
-	    }
-    }
+	 * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
+	 */
+	@Override
+	protected void readImpl()
+	{
+		// nothing (trigger)
+	}
 	
+	/**
+	 * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
+	 */
+	@Override
+	protected void runImpl()
+	{
+		L2PcInstance activeChar = this.getClient().getActiveChar();
+		if (activeChar != null)
+		{
+			activeChar.sendPacket(new ExPutEnchantTargetItemResult(2));
+			activeChar.setActiveEnchantItem(null);
+		}
+	}
 }

+ 155 - 31
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestExTryToPutEnchantTargetItem.java

@@ -14,7 +14,15 @@
  */
 package net.sf.l2j.gameserver.network.clientpackets;
 
+import net.sf.l2j.gameserver.model.L2ItemInstance;
+import net.sf.l2j.gameserver.model.L2World;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.network.SystemMessageId;
+import net.sf.l2j.gameserver.network.serverpackets.ExPutEnchantTargetItemResult;
+import net.sf.l2j.gameserver.network.serverpackets.RequestEnchant;
+import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
+import net.sf.l2j.gameserver.templates.L2Item;
+import net.sf.l2j.gameserver.templates.L2WeaponType;
 
 /**
  *
@@ -22,38 +30,154 @@ import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  */
 public class RequestExTryToPutEnchantTargetItem extends L2GameClientPacket
 {
-
-	private int _unk;
-
-	/**
-     * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#getType()
-     */
-    @Override
-    public String getType()
-    {
-	    return "[C] D0:4F RequestExTryToPutEnchantTargetItem";
-    }
-
+	
+	private int _objectId;
+	
 	/**
-     * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
-     */
-    @Override
-    protected void readImpl()
-    {
-	    _unk = readD();
-    }
-
+	 * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return "[C] D0:4F RequestExTryToPutEnchantTargetItem";
+	}
+	
 	/**
-     * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
-     */
-    @Override
-    protected void runImpl()
-    {
-    	L2PcInstance activeChar = this.getClient().getActiveChar();
-	    if (activeChar != null)
-	    {
-	    	activeChar.sendMessage("RequestExTryToPutEnchantTargetItem: "+_unk);
-	    }
-    }
+	 * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
+	 */
+	@Override
+	protected void readImpl()
+	{
+		_objectId = readD();
+	}
 	
+	/**
+	 * @see net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
+	 */
+	@Override
+	protected void runImpl()
+	{
+		L2PcInstance activeChar = getClient().getActiveChar();
+		
+		if (activeChar != null)
+		{
+			L2ItemInstance targetItem = (L2ItemInstance) L2World.getInstance().findObject(_objectId);
+			L2ItemInstance enchantScroll = activeChar.getActiveEnchantItem();
+			
+			if (targetItem == null || enchantScroll == null)
+				return;
+			
+			if (targetItem.isEtcItem() || targetItem.isWear() || targetItem.getItem().getItemType() == L2WeaponType.ROD || targetItem.isHeroItem() || targetItem.getItemId() >= 7816 && targetItem.getItemId() <= 7831
+					|| targetItem.isShadowItem() || targetItem.isCommonItem())
+			{
+				activeChar.sendPacket(new SystemMessage(SystemMessageId.DOES_NOT_FIT_SCROLL_CONDITIONS));
+				activeChar.setActiveEnchantItem(null);
+				activeChar.sendPacket(new ExPutEnchantTargetItemResult(2));
+				return;
+			}
+			
+			int itemType2 = targetItem.getItem().getType2();
+			boolean enchantItem = false;
+			
+			/** pretty code ;D */
+			switch (targetItem.getItem().getCrystalType())
+			{
+				case L2Item.CRYSTAL_A:
+					switch (enchantScroll.getItemId())
+					{
+						case 729:
+						case 731:
+						case 6569:
+							if (itemType2 == L2Item.TYPE2_WEAPON)
+								enchantItem = true;
+							break;
+						case 730:
+						case 732:
+						case 6570:
+							if (itemType2 == L2Item.TYPE2_SHIELD_ARMOR || itemType2 == L2Item.TYPE2_ACCESSORY)
+								enchantItem = true;
+							break;
+					}
+					break;
+				case L2Item.CRYSTAL_B:
+					switch (enchantScroll.getItemId())
+					{
+						case 947:
+						case 949:
+						case 6571:
+							if (itemType2 == L2Item.TYPE2_WEAPON)
+								enchantItem = true;
+							break;
+						case 948:
+						case 950:
+						case 6572:
+							if (itemType2 == L2Item.TYPE2_SHIELD_ARMOR || itemType2 == L2Item.TYPE2_ACCESSORY)
+								enchantItem = true;
+							break;
+					}
+					break;
+				case L2Item.CRYSTAL_C:
+					switch (enchantScroll.getItemId())
+					{
+						case 951:
+						case 953:
+						case 6573:
+							if (itemType2 == L2Item.TYPE2_WEAPON)
+								enchantItem = true;
+							break;
+						case 952:
+						case 954:
+						case 6574:
+							if (itemType2 == L2Item.TYPE2_SHIELD_ARMOR || itemType2 == L2Item.TYPE2_ACCESSORY)
+								enchantItem = true;
+							break;
+					}
+					break;
+				case L2Item.CRYSTAL_D:
+					switch (enchantScroll.getItemId())
+					{
+						case 955:
+						case 957:
+						case 6575:
+							if (itemType2 == L2Item.TYPE2_WEAPON)
+								enchantItem = true;
+							break;
+						case 956:
+						case 958:
+						case 6576:
+							if (itemType2 == L2Item.TYPE2_SHIELD_ARMOR || itemType2 == L2Item.TYPE2_ACCESSORY)
+								enchantItem = true;
+							break;
+					}
+					break;
+				case L2Item.CRYSTAL_S:
+				case L2Item.CRYSTAL_S80:
+					switch (enchantScroll.getItemId())
+					{
+						case 959:
+						case 961:
+						case 6577:
+							if (itemType2 == L2Item.TYPE2_WEAPON)
+								enchantItem = true;
+							break;
+						case 960:
+						case 962:
+						case 6578:
+							if (itemType2 == L2Item.TYPE2_SHIELD_ARMOR || itemType2 == L2Item.TYPE2_ACCESSORY)
+								enchantItem = true;
+							break;
+					}
+					break;
+			}
+			
+			if (!enchantItem)
+			{
+				activeChar.sendPacket(new SystemMessage(SystemMessageId.DOES_NOT_FIT_SCROLL_CONDITIONS));
+				activeChar.setActiveEnchantItem(null);
+				activeChar.sendPacket(new ExPutEnchantTargetItemResult(2));
+				return;
+			}
+			activeChar.sendPacket(new RequestEnchant(1));
+		}
+	}
 }

+ 50 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/serverpackets/ExPutEnchantSupportItemResult.java

@@ -0,0 +1,50 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.network.serverpackets;
+
+/**
+ *
+ * @author nBd
+ */
+public class ExPutEnchantSupportItemResult extends L2GameServerPacket
+{
+	private static final String _S__87_EXPUTENCHANTSUPPORTITEMRESULT = "[S] 87 ExPutEnchantSupportItemResult";
+	
+	/**
+	 * 
+	 */
+	public ExPutEnchantSupportItemResult()
+	{
+		
+	}
+	
+	/**
+	 * @see net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return _S__87_EXPUTENCHANTSUPPORTITEMRESULT;
+	}
+	
+	/**
+	 * @see net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket#writeImpl()
+	 */
+	@Override
+	protected void writeImpl()
+	{
+		
+	}
+}

+ 58 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/serverpackets/ExPutEnchantTargetItemResult.java

@@ -0,0 +1,58 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.network.serverpackets;
+
+/**
+ *
+ * @author nBd
+ */
+public class ExPutEnchantTargetItemResult extends L2GameServerPacket
+{
+	private static final String _S__87_EXPUTENCHANTTARGETITEMRESULT = "[S] 87 ExPutEnchantTargetItemResult";
+	
+	private int _result;
+	private int _unk1;
+	private int _unk2;
+	/**
+	 * 
+	 */
+	public ExPutEnchantTargetItemResult(int result)
+	{
+		_result = result;
+		_unk1 = 0;
+		_unk2 = 0;
+	}
+	
+	/**
+	 * @see net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return _S__87_EXPUTENCHANTTARGETITEMRESULT;
+	}
+	
+	/**
+	 * @see net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket#writeImpl()
+	 */
+	@Override
+	protected void writeImpl()
+	{
+		writeC(0x87);
+		writeD(_result);
+		writeD(_unk1);
+		writeD(_unk2);
+	}
+}

+ 10 - 11
L2_GameServer/java/net/sf/l2j/gameserver/network/serverpackets/GMViewItemList.java

@@ -17,7 +17,6 @@ package net.sf.l2j.gameserver.network.serverpackets;
 import net.sf.l2j.gameserver.model.L2ItemInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 
-
 /**
  *
  * @version $Revision: 1.1.2.1.2.3 $ $Date: 2005/03/27 15:29:57 $
@@ -29,16 +28,14 @@ public class GMViewItemList extends L2GameServerPacket
 	private L2ItemInstance[] _items;
 	private L2PcInstance _cha;
 	private String _playerName;
-
-
-
+	
 	public GMViewItemList(L2PcInstance cha)
 	{
 		_items = cha.getInventory().getItems();
 		_playerName = cha.getName();
 		_cha = cha;
 	}
-
+	
 	@Override
 	protected final void writeImpl()
 	{
@@ -47,17 +44,17 @@ public class GMViewItemList extends L2GameServerPacket
 		writeD(_cha.getInventoryLimit()); // inventory limit
 		writeH(0x01); // show window ??
 		writeH(_items.length);
-
+		
 		for (L2ItemInstance temp : _items)
 		{
 			if (temp == null || temp.getItem() == null)
 				continue;
-
+			
 			writeH(temp.getItem().getType1());
-
+			
 			writeD(temp.getObjectId());
 			writeD(temp.getItemId());
-            writeD(temp.getLocationSlot()); // T1
+			writeD(temp.getLocationSlot()); // T1
 			writeD(temp.getCount());
 			writeH(temp.getItem().getType2());
 			writeH(temp.getCustomType1());
@@ -70,7 +67,7 @@ public class GMViewItemList extends L2GameServerPacket
 			else
 				writeD(0x00);
 			writeD(temp.getMana());
-
+			
 			// T1
 			writeD(temp.getAttackElementType());
 			writeD(temp.getAttackElementPower());
@@ -78,9 +75,11 @@ public class GMViewItemList extends L2GameServerPacket
 			{
 				writeD(temp.getElementDefAttr(i));
 			}
+			// T2
+			writeD(0x00);
 		}
 	}
-
+	
 	/* (non-Javadoc)
 	 * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
 	 */

+ 106 - 105
L2_GameServer/java/net/sf/l2j/gameserver/network/serverpackets/GMViewWarehouseWithdrawList.java

@@ -1,105 +1,106 @@
-/*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package net.sf.l2j.gameserver.network.serverpackets;
-
-import net.sf.l2j.gameserver.model.L2ItemInstance;
-import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
-import net.sf.l2j.gameserver.templates.L2Weapon;
-
-/**
- * Sdh(h dddhh [dhhh] d)
- * Sdh ddddd ddddd ddddd ddddd
- * @version $Revision: 1.1.2.1.2.5 $ $Date: 2007/11/26 16:10:05 $
- */
-public class GMViewWarehouseWithdrawList extends L2GameServerPacket
-{
-	private static final String _S__95_GMViewWarehouseWithdrawList = "[S] 9b GMViewWarehouseWithdrawList";
-	private L2ItemInstance[] _items;
-	private String _playerName;
-	private L2PcInstance _activeChar;
-	private int _money;
-
-	public GMViewWarehouseWithdrawList(L2PcInstance cha)
-	{
-		_activeChar  = cha;
-		_items = _activeChar.getWarehouse().getItems();
-		_playerName = _activeChar.getName();
-		_money = _activeChar.getAdena();
-	}
-
-	@Override
-	protected final void writeImpl()
-	{
-		writeC(0x9b);
-		writeS(_playerName);
-		writeD(_money);
-		writeH(_items.length);
-		
-        for (L2ItemInstance item : _items)
-		{
-			writeH(item.getItem().getType1());
-
-			writeD(item.getObjectId());
-			writeD(item.getItemId());
-			writeD(item.getCount());
-			writeH(item.getItem().getType2());
-			writeH(item.getCustomType1());
-            
-            if (item.getItem().isEquipable())
-            {
-                writeD(item.getItem().getBodyPart());
-                writeH(item.getEnchantLevel());
-                
-                if (item.getItem() instanceof L2Weapon)
-                {
-                    writeH(((L2Weapon)item.getItem()).getSoulShotCount());
-                    writeH(((L2Weapon)item.getItem()).getSpiritShotCount());
-                }
-                else
-                {
-                    writeH(0x00);
-                    writeH(0x00);
-                }
-                
-                
-                if (item.isAugmented())
-                {
-                    writeD(0x0000FFFF & item.getAugmentation().getAugmentationId());
-                    writeD(item.getAugmentation().getAugmentationId() >> 16);
-                }
-                else
-                {
-                    writeQ(0);
-                }
-                writeD(item.getObjectId());
-                
-                writeD(item.getAttackElementType());
-                writeD(item.getAttackElementPower());
-                for (byte i = 0; i < 6; i++)
-                {
-                    writeD(item.getElementDefAttr(i));
-                }
-            }
-            
-            writeD(item.getMana());
-		}
-	}
-
-	@Override
-	public String getType()
-	{
-		return _S__95_GMViewWarehouseWithdrawList;
-	}
-}
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.network.serverpackets;
+
+import net.sf.l2j.gameserver.model.L2ItemInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.templates.L2Weapon;
+
+/**
+ * Sdh(h dddhh [dhhh] d)
+ * Sdh ddddd ddddd ddddd ddddd
+ * @version $Revision: 1.1.2.1.2.5 $ $Date: 2007/11/26 16:10:05 $
+ */
+public class GMViewWarehouseWithdrawList extends L2GameServerPacket
+{
+	private static final String _S__95_GMViewWarehouseWithdrawList = "[S] 9b GMViewWarehouseWithdrawList";
+	private L2ItemInstance[] _items;
+	private String _playerName;
+	private L2PcInstance _activeChar;
+	private int _money;
+	
+	public GMViewWarehouseWithdrawList(L2PcInstance cha)
+	{
+		_activeChar = cha;
+		_items = _activeChar.getWarehouse().getItems();
+		_playerName = _activeChar.getName();
+		_money = _activeChar.getAdena();
+	}
+	
+	@Override
+	protected final void writeImpl()
+	{
+		writeC(0x9b);
+		writeS(_playerName);
+		writeD(_money);
+		writeH(_items.length);
+		
+		for (L2ItemInstance item : _items)
+		{
+			writeH(item.getItem().getType1());
+			
+			writeD(item.getObjectId());
+			writeD(item.getItemId());
+			writeD(item.getCount());
+			writeH(item.getItem().getType2());
+			writeH(item.getCustomType1());
+			
+			if (item.getItem().isEquipable())
+			{
+				writeD(item.getItem().getBodyPart());
+				writeH(item.getEnchantLevel());
+				
+				if (item.getItem() instanceof L2Weapon)
+				{
+					writeH(((L2Weapon) item.getItem()).getSoulShotCount());
+					writeH(((L2Weapon) item.getItem()).getSpiritShotCount());
+				}
+				else
+				{
+					writeH(0x00);
+					writeH(0x00);
+				}
+				
+				if (item.isAugmented())
+				{
+					writeD(0x0000FFFF & item.getAugmentation().getAugmentationId());
+					writeD(item.getAugmentation().getAugmentationId() >> 16);
+				}
+				else
+				{
+					writeQ(0);
+				}
+				writeD(item.getObjectId());
+				
+				writeD(item.getAttackElementType());
+				writeD(item.getAttackElementPower());
+				for (byte i = 0; i < 6; i++)
+				{
+					writeD(item.getElementDefAttr(i));
+				}
+			}
+			
+			writeD(item.getMana());
+			// T2
+			writeD(0x00);
+		}
+	}
+	
+	@Override
+	public String getType()
+	{
+		return _S__95_GMViewWarehouseWithdrawList;
+	}
+}

+ 56 - 30
L2_GameServer/java/net/sf/l2j/gameserver/network/serverpackets/InventoryUpdate.java

@@ -22,7 +22,6 @@ import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.model.ItemInfo;
 import net.sf.l2j.gameserver.model.L2ItemInstance;
 
-
 /**
  *
  * 37                // Packet Identifier <BR>
@@ -52,9 +51,9 @@ public class InventoryUpdate extends L2GameServerPacket
 {
 	private static Logger _log = Logger.getLogger(InventoryUpdate.class.getName());
 	private static final String _S__37_INVENTORYUPDATE = "[S] 21 InventoryUpdate";
-
-    private List<ItemInfo> _items;
-
+	
+	private List<ItemInfo> _items;
+	
 	public InventoryUpdate()
 	{
 		_items = new FastList<ItemInfo>();
@@ -63,7 +62,7 @@ public class InventoryUpdate extends L2GameServerPacket
 			showDebug();
 		}
 	}
-
+	
 	/**
 	 * @param items
 	 */
@@ -75,22 +74,47 @@ public class InventoryUpdate extends L2GameServerPacket
 			showDebug();
 		}
 	}
-
-	public void addItem(L2ItemInstance item) { if (item != null) _items.add(new ItemInfo(item)); }
-	public void addNewItem(L2ItemInstance item) { if (item != null) _items.add(new ItemInfo(item, 1)); }
-	public void addModifiedItem(L2ItemInstance item) { if (item != null) _items.add(new ItemInfo(item, 2)); }
-	public void addRemovedItem(L2ItemInstance item) { if (item != null) _items.add(new ItemInfo(item, 3)); }
-	public void addItems(List<L2ItemInstance> items) { if (items != null) for (L2ItemInstance item : items) if (item != null) _items.add(new ItemInfo(item)); }
-
+	
+	public void addItem(L2ItemInstance item)
+	{
+		if (item != null)
+			_items.add(new ItemInfo(item));
+	}
+	
+	public void addNewItem(L2ItemInstance item)
+	{
+		if (item != null)
+			_items.add(new ItemInfo(item, 1));
+	}
+	
+	public void addModifiedItem(L2ItemInstance item)
+	{
+		if (item != null)
+			_items.add(new ItemInfo(item, 2));
+	}
+	
+	public void addRemovedItem(L2ItemInstance item)
+	{
+		if (item != null)
+			_items.add(new ItemInfo(item, 3));
+	}
+	
+	public void addItems(List<L2ItemInstance> items)
+	{
+		if (items != null)
+			for (L2ItemInstance item : items)
+				if (item != null)
+					_items.add(new ItemInfo(item));
+	}
+	
 	private void showDebug()
 	{
 		for (ItemInfo item : _items)
 		{
-			_log.fine("oid:" + Integer.toHexString(item.getObjectId()) +
-					" item:" + item.getItem().getName()+" last change:" + item.getChange());
+			_log.fine("oid:" + Integer.toHexString(item.getObjectId()) + " item:" + item.getItem().getName() + " last change:" + item.getChange());
 		}
 	}
-
+	
 	@Override
 	protected final void writeImpl()
 	{
@@ -99,19 +123,19 @@ public class InventoryUpdate extends L2GameServerPacket
 		writeH(count);
 		for (ItemInfo item : _items)
 		{
-			writeH(item.getChange());               // Update type : 01-add, 02-modify, 03-remove
-			writeH(item.getItem().getType1());      // Item Type 1 : 00-weapon/ring/earring/necklace, 01-armor/shield, 04-item/questitem/adena
-
-			writeD(item.getObjectId());             // ObjectId
-			writeD(item.getItem().getItemId());     // ItemId
-            writeD(item.getLocation());             // T1
-			writeD(item.getCount());                // Quantity
-			writeH(item.getItem().getType2());      // Item Type 2 : 00-weapon, 01-shield/armor, 02-ring/earring/necklace, 03-questitem, 04-adena, 05-item
-			writeH(item.getCustomType1());          // Filler (always 0)
-			writeH(item.getEquipped());             // Equipped    : 00-No, 01-yes
-			writeD(item.getItem().getBodyPart());	// Slot        : 0006-lr.ear, 0008-neck, 0030-lr.finger, 0040-head, 0100-l.hand, 0200-gloves, 0400-chest, 0800-pants, 1000-feet, 4000-r.hand, 8000-r.hand
-			writeH(item.getEnchant());	            // Enchant level (pet level shown in control item)
-			writeH(item.getCustomType2());          // Pet name exists or not shown in control item
+			writeH(item.getChange()); // Update type : 01-add, 02-modify, 03-remove
+			writeH(item.getItem().getType1()); // Item Type 1 : 00-weapon/ring/earring/necklace, 01-armor/shield, 04-item/questitem/adena
+			
+			writeD(item.getObjectId()); // ObjectId
+			writeD(item.getItem().getItemId()); // ItemId
+			writeD(item.getLocation()); // T1
+			writeD(item.getCount()); // Quantity
+			writeH(item.getItem().getType2()); // Item Type 2 : 00-weapon, 01-shield/armor, 02-ring/earring/necklace, 03-questitem, 04-adena, 05-item
+			writeH(item.getCustomType1()); // Filler (always 0)
+			writeH(item.getEquipped()); // Equipped    : 00-No, 01-yes
+			writeD(item.getItem().getBodyPart()); // Slot        : 0006-lr.ear, 0008-neck, 0030-lr.finger, 0040-head, 0100-l.hand, 0200-gloves, 0400-chest, 0800-pants, 1000-feet, 4000-r.hand, 8000-r.hand
+			writeH(item.getEnchant()); // Enchant level (pet level shown in control item)
+			writeH(item.getCustomType2()); // Pet name exists or not shown in control item
 			writeD(item.getAugmentationBonus());
 			writeD(item.getMana());
 			
@@ -122,14 +146,16 @@ public class InventoryUpdate extends L2GameServerPacket
 			{
 				writeD(item.getElementDefAttr(i));
 			}
+			// T2
+			writeD(0x00);
 		}
 	}
-
+	
 	/* (non-Javadoc)
 	 * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
 	 */
 	@Override
-    public String getType()
+	public String getType()
 	{
 		return _S__37_INVENTORYUPDATE;
 	}

+ 18 - 18
L2_GameServer/java/net/sf/l2j/gameserver/network/serverpackets/ItemList.java

@@ -20,7 +20,6 @@ import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.model.L2ItemInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 
-
 /**
  *
  *
@@ -53,7 +52,7 @@ public final class ItemList extends L2GameServerPacket
 	private static final String _S__27_ITEMLIST = "[S] 11 ItemList";
 	private L2ItemInstance[] _items;
 	private boolean _showWindow;
-
+	
 	public ItemList(L2PcInstance cha, boolean showWindow)
 	{
 		_items = cha.getInventory().getItems();
@@ -63,7 +62,7 @@ public final class ItemList extends L2GameServerPacket
 			showDebug();
 		}
 	}
-
+	
 	public ItemList(L2ItemInstance[] items, boolean showWindow)
 	{
 		_items = items;
@@ -73,44 +72,43 @@ public final class ItemList extends L2GameServerPacket
 			showDebug();
 		}
 	}
-
+	
 	private void showDebug()
 	{
 		for (L2ItemInstance temp : _items)
 		{
-			_log.fine("item:" + temp.getItem().getName() +
-					" type1:" + temp.getItem().getType1() + " type2:" + temp.getItem().getType2());
+			_log.fine("item:" + temp.getItem().getName() + " type1:" + temp.getItem().getType1() + " type2:" + temp.getItem().getType2());
 		}
 	}
-
+	
 	@Override
 	protected final void writeImpl()
 	{
 		writeC(0x11);
 		writeH(_showWindow ? 0x01 : 0x00);
-
+		
 		int count = _items.length;
 		writeH(count);
-
+		
 		for (L2ItemInstance temp : _items)
 		{
 			if (temp == null || temp.getItem() == null)
 				continue;
-
+			
 			writeH(temp.getItem().getType1()); // item type1
-
+			
 			writeD(temp.getObjectId());
 			writeD(temp.getItemId());
 			writeD(temp.getLocationSlot()); // T1
-            writeD(temp.getCount());
-			writeH(temp.getItem().getType2());	// item type2
-			writeH(temp.getCustomType1());	// item type3
+			writeD(temp.getCount());
+			writeH(temp.getItem().getType2()); // item type2
+			writeH(temp.getCustomType1()); // item type3
 			writeH(temp.isEquipped() ? 0x01 : 0x00);
 			writeD(temp.getItem().getBodyPart());
-
-			writeH(temp.getEnchantLevel());	// enchant level
+			
+			writeH(temp.getEnchantLevel()); // enchant level
 			//race tickets
-			writeH(temp.getCustomType2());	// item type3
+			writeH(temp.getCustomType2()); // item type3
 			
 			if (temp.isAugmented())
 				writeD(temp.getAugmentation().getAugmentationId());
@@ -126,6 +124,8 @@ public final class ItemList extends L2GameServerPacket
 			{
 				writeD(temp.getElementDefAttr(i));
 			}
+			// T2
+			writeD(0x00);
 		}
 	}
 	
@@ -133,7 +133,7 @@ public final class ItemList extends L2GameServerPacket
 	 * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
 	 */
 	@Override
-    public String getType()
+	public String getType()
 	{
 		return _S__27_ITEMLIST;
 	}

+ 53 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/serverpackets/RequestEnchant.java

@@ -0,0 +1,53 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.network.serverpackets;
+
+/**
+ *
+ * @author nBd
+ */
+public class RequestEnchant extends L2GameServerPacket
+{
+	private int _unk;
+	private static final String _S__FE_81_REQUESTENCHANT = "[S] FE:81 RequestEnchant";
+	
+	/**
+	 * 
+	 */
+	public RequestEnchant(int value)
+	{
+		_unk = value;
+	}
+	
+	/**
+	 * @see net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return _S__FE_81_REQUESTENCHANT;
+	}
+	
+	/**
+	 * @see net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket#writeImpl()
+	 */
+	@Override
+	protected void writeImpl()
+	{
+		writeC(0xFE);
+		writeH(0x81);
+		writeD(_unk);
+	}
+}

+ 701 - 690
L2_GameServer/java/net/sf/l2j/gameserver/network/serverpackets/SortedWareHouseWithdrawalList.java

@@ -40,694 +40,705 @@ import net.sf.l2j.gameserver.templates.L2WarehouseItem;
 
 public class SortedWareHouseWithdrawalList extends L2GameServerPacket
 {
-   public static final int PRIVATE = 1;
-   public static final int CLAN = 2;
-   public static final int CASTLE = 3; //not sure
-   public static final int FREIGHT = 4; //not sure
-   private static Logger _log = Logger.getLogger(SortedWareHouseWithdrawalList.class.getName());
-   private static final String _S__54_SORTEDWAREHOUSEWITHDRAWALLIST = "[S] 42 SortedWareHouseWithdrawalList";
-   private L2PcInstance _activeChar;
-   private int _playerAdena;
-   private List<L2WarehouseItem> _objects = new FastList<L2WarehouseItem>();
-   private int _whType;
-   private byte _sortorder;
-   private WarehouseListType _itemtype;
-   
-   public static enum WarehouseListType
-    {
-        WEAPON,
-        ARMOR,
-        ETCITEM,
-        MATERIAL,
-        RECIPE,
-        AMULETT,
-        SPELLBOOK,
-        SHOT,
-        SCROLL,
-        CONSUMABLE,
-        SEED,
-        POTION,
-        QUEST,
-        PET,
-        OTHER,
-        ALL
-    }
-   
-   /** sort order A..Z */
-    public static final byte A2Z = 1; 
-    /** sort order Z..A */
-    public static final byte Z2A = -1;
-    /** sort order Grade non..S */
-    public static final byte GRADE = 2;
-    /** sort order Recipe Level 1..9 */ 
-    public static final byte LEVEL = 3;
-    /** sort order type */
-    public static final byte TYPE = 4;
-    /** sort order body part (wearing) */
-    public static final byte WEAR = 5;
-    /** Maximum Items to put into list */
-    public static final int MAX_SORT_LIST_ITEMS = 300;
-
-    /**
-     * This will instantiate the Warehouselist the Player asked for
-     * @param player who calls for the itemlist
-     * @param type is the Warehouse Type
-     * @param itemtype is the Itemtype to sort for
-     * @param sortorder is the integer Sortorder like 1 for A..Z (use public constant)
-     */
-   public SortedWareHouseWithdrawalList(L2PcInstance player, int type, WarehouseListType itemtype, byte sortorder)
-   {
-        _activeChar = player;
-       _whType = type;
-        _itemtype = itemtype;
-        _sortorder = sortorder;
-
-        _playerAdena = _activeChar.getAdena();
-        if (_activeChar.getActiveWarehouse() == null)
-        {
-            // Something went wrong!
-            _log.warning("error while sending withdraw request to: " + _activeChar.getName());
-            return;
-        }
-
-        switch (_itemtype)
-        {
-            case WEAPON:
-                _objects = createWeaponList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case ARMOR:
-                _objects = createArmorList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case ETCITEM:
-                _objects = createEtcItemList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case MATERIAL:
-                _objects = createMatList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case RECIPE:
-                _objects = createRecipeList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case AMULETT:
-                _objects = createAmulettList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case SPELLBOOK:
-                _objects = createSpellbookList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case CONSUMABLE:
-                _objects = createConsumableList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case SHOT:
-                _objects = createShotList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case SCROLL:
-                _objects = createScrollList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case SEED:
-                _objects = createSeedList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case OTHER:
-                _objects = createOtherList(_activeChar.getActiveWarehouse().getItems());
-                break;
-            case ALL:
-                default:
-                    _objects = createAllList(_activeChar.getActiveWarehouse().getItems());
-                break;
-        }
-
-        try
-        {
-            switch (_sortorder)
-            {
-                case A2Z:
-                case Z2A:
-                    Collections.sort(_objects, new WarehouseItemNameComparator(_sortorder));
-                    break;
-                case GRADE:
-                    if (_itemtype == WarehouseListType.ARMOR || _itemtype == WarehouseListType.WEAPON)
-                    {
-                        Collections.sort(_objects, new WarehouseItemNameComparator(A2Z));
-                        Collections.sort(_objects, new WarehouseItemGradeComparator(A2Z));
-                    }
-                    break;
-                case LEVEL:
-                    if (_itemtype == WarehouseListType.RECIPE)
-                    {
-                        Collections.sort(_objects, new WarehouseItemNameComparator(A2Z));
-                        Collections.sort(_objects, new WarehouseItemRecipeComparator(A2Z));
-                    }
-                    break;
-                case TYPE:
-                    if (_itemtype==WarehouseListType.MATERIAL)
-                    {
-                        Collections.sort(_objects, new WarehouseItemNameComparator(A2Z));
-                        Collections.sort(_objects, new WarehouseItemTypeComparator(A2Z));
-                    }
-                    break;
-                case WEAR:
-                    if (_itemtype==WarehouseListType.ARMOR)
-                    {
-                        Collections.sort(_objects, new WarehouseItemNameComparator(A2Z));
-                        Collections.sort(_objects, new WarehouseItemBodypartComparator(A2Z));
-                    }
-                    break;
-            }
-        }
-        catch(Exception e) {}
-    }
-   
-   /**
-     * This public method return the integer of the Sortorder by its name.
-     * If you want to have another, add the Comparator and the Constant.
-     * @param order
-     * @return the integer of the sortorder or 1 as default value
-     */
-    public static byte getOrder(String order)
-    {
-        if (order == null)
-            return A2Z;
-        else if (order.startsWith("A2Z"))
-            return A2Z;
-        else if (order.startsWith("Z2A"))
-            return Z2A;
-        else if (order.startsWith("GRADE"))
-            return GRADE;
-        else if (order.startsWith("TYPE"))
-            return TYPE;
-        else if (order.startsWith("WEAR"))
-            return WEAR;
-        else
-        {
-            try
-            {
-                return Byte.parseByte(order);
-            }
-            catch (NumberFormatException ex) {return A2Z;}
-        }
-    }
-
-    /**
-     * This is the common Comparator to sort the items by Name
-     */
-    private static class WarehouseItemNameComparator implements Comparator<L2WarehouseItem>
-    {
-        private byte order = 0;
-        
-        protected WarehouseItemNameComparator(byte sortOrder)
-        {
-            order = sortOrder;
-        }
-        
-        public int compare(L2WarehouseItem o1, L2WarehouseItem o2)
-        {
-            if (o1.getType2() == L2Item.TYPE2_MONEY && o2.getType2() != L2Item.TYPE2_MONEY)
-                return (order == A2Z ? Z2A : A2Z);
-            if (o2.getType2() == L2Item.TYPE2_MONEY && o1.getType2() != L2Item.TYPE2_MONEY)
-                return (order == A2Z ? A2Z : Z2A);
-            String s1 = o1.getItemName();
-            String s2 = o2.getItemName();
-            return (order == A2Z ? s1.compareTo(s2) : s2.compareTo(s1));
-        }
-    }
-
-    /**
-     * This Comparator is used to sort by Recipe Level
-     */
-    private static class WarehouseItemRecipeComparator implements Comparator<L2WarehouseItem>
-    {
-        private int order = 0;
-
-        private RecipeController rc = null;
-
-        protected WarehouseItemRecipeComparator(int sortOrder)
-        {
-            order = sortOrder;
-            rc = RecipeController.getInstance();
-        }
-
-        public int compare(L2WarehouseItem o1, L2WarehouseItem o2)
-        {
-            if (o1.getType2() == L2Item.TYPE2_MONEY && o2.getType2() != L2Item.TYPE2_MONEY)
-                return (order == A2Z ? Z2A : A2Z);
-            if (o2.getType2() == L2Item.TYPE2_MONEY && o1.getType2() != L2Item.TYPE2_MONEY)
-                return (order == A2Z ? A2Z : Z2A);
-            if ((o1.isEtcItem() && o1.getItemType() == L2EtcItemType.RECEIPE) && (o2.isEtcItem() && o2.getItemType() == L2EtcItemType.RECEIPE))
-            {
-                try
-                {
-                    L2RecipeList rp1 = rc.getRecipeByItemId(o1.getItemId());
-                    L2RecipeList rp2 = rc.getRecipeByItemId(o2.getItemId());
-
-                    if (rp1 == null) return (order == A2Z ? A2Z : Z2A);
-                    if (rp2 == null) return (order == A2Z ? Z2A : A2Z);
-
-                    Integer i1 = rp1.getLevel();
-                    Integer i2 = rp2.getLevel();
-
-                    return (order == A2Z ? i1.compareTo(i2) : i2.compareTo(i1));
-                }
-                catch(Exception e) {return 0;}
-            }
-            else
-            {
-                String s1 = o1.getItemName();
-                String s2 = o2.getItemName();
-                return (order == A2Z ? s1.compareTo(s2) : s2.compareTo(s1));
-            }
-        }
-    }
-
-    /**
-     * This Comparator is used to sort the Items by BodyPart
-     */
-    private static class WarehouseItemBodypartComparator implements Comparator<L2WarehouseItem>
-    {
-        private byte order = 0;
-
-        protected WarehouseItemBodypartComparator(byte sortOrder)
-        {
-            order = sortOrder;
-        }
-
-        public int compare(L2WarehouseItem o1, L2WarehouseItem o2)
-        {
-            if (o1.getType2() == L2Item.TYPE2_MONEY && o2.getType2() != L2Item.TYPE2_MONEY)
-                return (order==A2Z ? Z2A : A2Z);
-            if (o2.getType2() == L2Item.TYPE2_MONEY && o1.getType2() != L2Item.TYPE2_MONEY)
-                return (order==A2Z ? A2Z : Z2A);
-            Integer i1 = o1.getBodyPart();
-            Integer i2 = o2.getBodyPart();
-            return (order == A2Z ? i1.compareTo(i2) : i2.compareTo(i1));
-        }
-    }
-
-    /**
-     * This Comparator is used to sort by the Item Grade (e.g. Non..S-Grade)
-     */
-    private static class WarehouseItemGradeComparator implements Comparator<L2WarehouseItem>
-    {
-        byte order = 0;
-
-        protected WarehouseItemGradeComparator(byte sortOrder)
-        {
-            order = sortOrder;
-        }
-
-        public int compare(L2WarehouseItem o1, L2WarehouseItem o2)
-        {
-            if (o1.getType2() == L2Item.TYPE2_MONEY && o2.getType2() != L2Item.TYPE2_MONEY)
-                return (order == A2Z ? Z2A : A2Z);
-            if (o2.getType2() == L2Item.TYPE2_MONEY && o1.getType2() != L2Item.TYPE2_MONEY)
-                return (order ==A2Z ? A2Z : Z2A);
-            Integer i1 = o1.getItemGrade();
-            Integer i2 = o2.getItemGrade();
-            return (order == A2Z ? i1.compareTo(i2) : i2.compareTo(i1));
-        }
-    }
-
-    /**
-     * This Comparator will sort by Item Type. Unfortunatly this will only have a
-     * good result if the Database Table for the ETCITEM.TYPE column is fixed!
-     */
-    private static class WarehouseItemTypeComparator implements Comparator<L2WarehouseItem>
-    {
-        byte order = 0;
-
-        protected WarehouseItemTypeComparator(byte sortOrder)
-        {
-            order = sortOrder;
-        }
-
-        public int compare(L2WarehouseItem o1, L2WarehouseItem o2)
-        {
-            if (o1.getType2() == L2Item.TYPE2_MONEY && o2.getType2() != L2Item.TYPE2_MONEY)
-                return (order == A2Z ? Z2A : A2Z);
-            if (o2.getType2() == L2Item.TYPE2_MONEY && o1.getType2() != L2Item.TYPE2_MONEY)
-                return (order== A2Z ? A2Z : Z2A);
-            try
-            {
-                Integer i1 = o1.getItem().getMaterialType();
-                Integer i2 = o2.getItem().getMaterialType();
-                return (order==A2Z ? i1.compareTo(i2) : i2.compareTo(i1));
-            }
-            catch(Exception e) {return 0;}
-        }
-    }
-
-    // ========================================================================
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Weapon</li>
-     * <li>Arrow</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createWeaponList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (item.isWeapon() || item.getItem().getType2() == L2Item.TYPE2_WEAPON || (item.isEtcItem() && item.getItemType() == L2EtcItemType.ARROW) || item.getItem().getType2() == L2Item.TYPE2_MONEY )
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Armor</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createArmorList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (item.isArmor() || item.getItem().getType2() == L2Item.TYPE2_MONEY)
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Everything which is no Weapon/Armor</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createEtcItemList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (item.isEtcItem() || item.getItem().getType2() == L2Item.TYPE2_MONEY)
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Materials</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createMatList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if(item.isEtcItem() && item.getEtcItem().getItemType() == L2EtcItemType.MATERIAL || item.getItem().getType2() == L2Item.TYPE2_MONEY)
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Recipes</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createRecipeList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (item.isEtcItem() && item.getEtcItem().getItemType() == L2EtcItemType.RECEIPE || item.getItem().getType2() == L2Item.TYPE2_MONEY)
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Amulett</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createAmulettList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (item.isEtcItem() && (item.getEtcItem().getItemType() == L2EtcItemType.SPELLBOOK && item.getItemName().toUpperCase().startsWith("AMULET")) || item.getItem().getType2() == L2Item.TYPE2_MONEY)
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Spellbook & Dwarven Drafts</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createSpellbookList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (item.isEtcItem() && (item.getEtcItem().getItemType() == L2EtcItemType.SPELLBOOK && !item.getItemName().toUpperCase().startsWith("AMULET")) || item.getItem().getType2() == L2Item.TYPE2_MONEY )
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Consumables (Potions, Shots, ...)</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createConsumableList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (item.isEtcItem() && (item.getEtcItem().getItemType() == L2EtcItemType.SCROLL || item.getEtcItem().getItemType() == L2EtcItemType.SHOT) || item.getItem().getType2() == L2Item.TYPE2_MONEY)
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Shots</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createShotList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (item.isEtcItem() && item.getEtcItem().getItemType()==L2EtcItemType.SHOT || item.getItem().getType2() == L2Item.TYPE2_MONEY)
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Scrolls/Potions</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createScrollList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (item.isEtcItem() && item.getEtcItem().getItemType() == L2EtcItemType.SCROLL || item.getItem().getType2() == L2Item.TYPE2_MONEY)
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Seeds</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createSeedList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (item.isEtcItem() && item.getEtcItem().getItemType() == L2EtcItemType.SEED || item.getItem().getType2() == L2Item.TYPE2_MONEY)
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>Everything which is no Weapon/Armor, Material, Recipe, Spellbook, Scroll or Shot</li>
-     * <li>Money</li>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createOtherList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if( item.isEtcItem() && 
-                ( item.getEtcItem().getItemType() != L2EtcItemType.MATERIAL &&
-                  item.getEtcItem().getItemType() != L2EtcItemType.RECEIPE && 
-                  item.getEtcItem().getItemType() != L2EtcItemType.SPELLBOOK && 
-                  item.getEtcItem().getItemType() != L2EtcItemType.SCROLL && 
-                  item.getEtcItem().getItemType() != L2EtcItemType.SHOT
-                ) || item.getItem().getType2() == L2Item.TYPE2_MONEY )
-            {
-                if (_list.size() < MAX_SORT_LIST_ITEMS)
-                    _list.add(new L2WarehouseItem(item));
-                else
-                    continue;
-            }
-        }
-        return _list;
-    }
-
-    /**
-     * This method is used to limit the given Warehouse List to:
-     * <li>no limit</li>
-     * This may sound strange but we return the given Array as a List<L2WarehouseItem>
-     * @param _items complete Warehouse List
-     * @return limited Item List
-     */
-    private List<L2WarehouseItem> createAllList(L2ItemInstance[] _items)
-    {
-        List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
-        for (L2ItemInstance item : _items)
-        {
-            if (_list.size() < MAX_SORT_LIST_ITEMS)
-                _list.add(new L2WarehouseItem(item));
-            else
-                continue;
-        }
-        return _list;
-    }
-
-   @Override
-   protected final void writeImpl()
-   {
-       writeC(0x42);
-       /* 0x01-Private Warehouse  
-       * 0x02-Clan Warehouse  
-       * 0x03-Castle Warehouse  
-       * 0x04-Warehouse */  
-       writeH(_whType);
-       writeD(_playerAdena);
-       writeH(_objects.size());
-
-       for (L2WarehouseItem item : _objects)
-       {
-           writeH(item.getItem().getType1()); // item type1 //unconfirmed, works
-           writeD(item.getObjectId());
-           writeD(item.getItemId()); //unconfirmed, works
-           writeD(item.getCount()); //unconfirmed, works
-           writeH(item.getItem().getType2());  // item type2 //unconfirmed, works
-           writeH(item.getCustomType1());  // ?
-           writeD(item.getItem().getBodyPart());   // ?
-           writeH(item.getEnchantLevel()); // enchant level -confirmed
-           writeH(item.getCustomType2());  // ?
-           writeH(0x00);  // ?
-           writeD(item.getObjectId()); // item id - confimed       
-           if (item.isAugmented())
-           {
-               writeD(0x0000FFFF&item.getAugmentationId());
-               writeD(item.getAugmentationId()>>16);
-           }
-           else
-               writeQ(0x00);
-
-           writeD(item.getAttackElementType());
-           writeD(item.getAttackElementPower());
-           for (byte i = 0; i < 6; i++)
-           {
-               writeD(item.getElementDefAttr(i));
-           }
-
-           writeD(item.getMana());
-       }
-   }
-
-   /* (non-Javadoc)
-    * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
-    */
-   @Override
-   public String getType()
-   {
-       return _S__54_SORTEDWAREHOUSEWITHDRAWALLIST;
-   }
+	public static final int PRIVATE = 1;
+	public static final int CLAN = 2;
+	public static final int CASTLE = 3; //not sure
+	public static final int FREIGHT = 4; //not sure
+	private static Logger _log = Logger.getLogger(SortedWareHouseWithdrawalList.class.getName());
+	private static final String _S__54_SORTEDWAREHOUSEWITHDRAWALLIST = "[S] 42 SortedWareHouseWithdrawalList";
+	private L2PcInstance _activeChar;
+	private int _playerAdena;
+	private List<L2WarehouseItem> _objects = new FastList<L2WarehouseItem>();
+	private int _whType;
+	private byte _sortorder;
+	private WarehouseListType _itemtype;
+	
+	public static enum WarehouseListType
+	{
+		WEAPON,
+		ARMOR,
+		ETCITEM,
+		MATERIAL,
+		RECIPE,
+		AMULETT,
+		SPELLBOOK,
+		SHOT,
+		SCROLL,
+		CONSUMABLE,
+		SEED,
+		POTION,
+		QUEST,
+		PET,
+		OTHER,
+		ALL
+	}
+	
+	/** sort order A..Z */
+	public static final byte A2Z = 1;
+	/** sort order Z..A */
+	public static final byte Z2A = -1;
+	/** sort order Grade non..S */
+	public static final byte GRADE = 2;
+	/** sort order Recipe Level 1..9 */
+	public static final byte LEVEL = 3;
+	/** sort order type */
+	public static final byte TYPE = 4;
+	/** sort order body part (wearing) */
+	public static final byte WEAR = 5;
+	/** Maximum Items to put into list */
+	public static final int MAX_SORT_LIST_ITEMS = 300;
+	
+	/**
+	 * This will instantiate the Warehouselist the Player asked for
+	 * @param player who calls for the itemlist
+	 * @param type is the Warehouse Type
+	 * @param itemtype is the Itemtype to sort for
+	 * @param sortorder is the integer Sortorder like 1 for A..Z (use public constant)
+	 */
+	public SortedWareHouseWithdrawalList(L2PcInstance player, int type, WarehouseListType itemtype, byte sortorder)
+	{
+		_activeChar = player;
+		_whType = type;
+		_itemtype = itemtype;
+		_sortorder = sortorder;
+		
+		_playerAdena = _activeChar.getAdena();
+		if (_activeChar.getActiveWarehouse() == null)
+		{
+			// Something went wrong!
+			_log.warning("error while sending withdraw request to: " + _activeChar.getName());
+			return;
+		}
+		
+		switch (_itemtype)
+		{
+			case WEAPON:
+				_objects = createWeaponList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case ARMOR:
+				_objects = createArmorList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case ETCITEM:
+				_objects = createEtcItemList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case MATERIAL:
+				_objects = createMatList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case RECIPE:
+				_objects = createRecipeList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case AMULETT:
+				_objects = createAmulettList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case SPELLBOOK:
+				_objects = createSpellbookList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case CONSUMABLE:
+				_objects = createConsumableList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case SHOT:
+				_objects = createShotList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case SCROLL:
+				_objects = createScrollList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case SEED:
+				_objects = createSeedList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case OTHER:
+				_objects = createOtherList(_activeChar.getActiveWarehouse().getItems());
+				break;
+			case ALL:
+			default:
+				_objects = createAllList(_activeChar.getActiveWarehouse().getItems());
+				break;
+		}
+		
+		try
+		{
+			switch (_sortorder)
+			{
+				case A2Z:
+				case Z2A:
+					Collections.sort(_objects, new WarehouseItemNameComparator(_sortorder));
+					break;
+				case GRADE:
+					if (_itemtype == WarehouseListType.ARMOR || _itemtype == WarehouseListType.WEAPON)
+					{
+						Collections.sort(_objects, new WarehouseItemNameComparator(A2Z));
+						Collections.sort(_objects, new WarehouseItemGradeComparator(A2Z));
+					}
+					break;
+				case LEVEL:
+					if (_itemtype == WarehouseListType.RECIPE)
+					{
+						Collections.sort(_objects, new WarehouseItemNameComparator(A2Z));
+						Collections.sort(_objects, new WarehouseItemRecipeComparator(A2Z));
+					}
+					break;
+				case TYPE:
+					if (_itemtype == WarehouseListType.MATERIAL)
+					{
+						Collections.sort(_objects, new WarehouseItemNameComparator(A2Z));
+						Collections.sort(_objects, new WarehouseItemTypeComparator(A2Z));
+					}
+					break;
+				case WEAR:
+					if (_itemtype == WarehouseListType.ARMOR)
+					{
+						Collections.sort(_objects, new WarehouseItemNameComparator(A2Z));
+						Collections.sort(_objects, new WarehouseItemBodypartComparator(A2Z));
+					}
+					break;
+			}
+		}
+		catch (Exception e)
+		{
+		}
+	}
+	
+	/**
+	  * This public method return the integer of the Sortorder by its name.
+	  * If you want to have another, add the Comparator and the Constant.
+	  * @param order
+	  * @return the integer of the sortorder or 1 as default value
+	  */
+	public static byte getOrder(String order)
+	{
+		if (order == null)
+			return A2Z;
+		else if (order.startsWith("A2Z"))
+			return A2Z;
+		else if (order.startsWith("Z2A"))
+			return Z2A;
+		else if (order.startsWith("GRADE"))
+			return GRADE;
+		else if (order.startsWith("TYPE"))
+			return TYPE;
+		else if (order.startsWith("WEAR"))
+			return WEAR;
+		else
+		{
+			try
+			{
+				return Byte.parseByte(order);
+			}
+			catch (NumberFormatException ex)
+			{
+				return A2Z;
+			}
+		}
+	}
+	
+	/**
+	 * This is the common Comparator to sort the items by Name
+	 */
+	private static class WarehouseItemNameComparator implements Comparator<L2WarehouseItem>
+	{
+		private byte order = 0;
+		
+		protected WarehouseItemNameComparator(byte sortOrder)
+		{
+			order = sortOrder;
+		}
+		
+		public int compare(L2WarehouseItem o1, L2WarehouseItem o2)
+		{
+			if (o1.getType2() == L2Item.TYPE2_MONEY && o2.getType2() != L2Item.TYPE2_MONEY)
+				return (order == A2Z ? Z2A : A2Z);
+			if (o2.getType2() == L2Item.TYPE2_MONEY && o1.getType2() != L2Item.TYPE2_MONEY)
+				return (order == A2Z ? A2Z : Z2A);
+			String s1 = o1.getItemName();
+			String s2 = o2.getItemName();
+			return (order == A2Z ? s1.compareTo(s2) : s2.compareTo(s1));
+		}
+	}
+	
+	/**
+	 * This Comparator is used to sort by Recipe Level
+	 */
+	private static class WarehouseItemRecipeComparator implements Comparator<L2WarehouseItem>
+	{
+		private int order = 0;
+		
+		private RecipeController rc = null;
+		
+		protected WarehouseItemRecipeComparator(int sortOrder)
+		{
+			order = sortOrder;
+			rc = RecipeController.getInstance();
+		}
+		
+		public int compare(L2WarehouseItem o1, L2WarehouseItem o2)
+		{
+			if (o1.getType2() == L2Item.TYPE2_MONEY && o2.getType2() != L2Item.TYPE2_MONEY)
+				return (order == A2Z ? Z2A : A2Z);
+			if (o2.getType2() == L2Item.TYPE2_MONEY && o1.getType2() != L2Item.TYPE2_MONEY)
+				return (order == A2Z ? A2Z : Z2A);
+			if ((o1.isEtcItem() && o1.getItemType() == L2EtcItemType.RECEIPE) && (o2.isEtcItem() && o2.getItemType() == L2EtcItemType.RECEIPE))
+			{
+				try
+				{
+					L2RecipeList rp1 = rc.getRecipeByItemId(o1.getItemId());
+					L2RecipeList rp2 = rc.getRecipeByItemId(o2.getItemId());
+					
+					if (rp1 == null)
+						return (order == A2Z ? A2Z : Z2A);
+					if (rp2 == null)
+						return (order == A2Z ? Z2A : A2Z);
+					
+					Integer i1 = rp1.getLevel();
+					Integer i2 = rp2.getLevel();
+					
+					return (order == A2Z ? i1.compareTo(i2) : i2.compareTo(i1));
+				}
+				catch (Exception e)
+				{
+					return 0;
+				}
+			}
+			else
+			{
+				String s1 = o1.getItemName();
+				String s2 = o2.getItemName();
+				return (order == A2Z ? s1.compareTo(s2) : s2.compareTo(s1));
+			}
+		}
+	}
+	
+	/**
+	 * This Comparator is used to sort the Items by BodyPart
+	 */
+	private static class WarehouseItemBodypartComparator implements Comparator<L2WarehouseItem>
+	{
+		private byte order = 0;
+		
+		protected WarehouseItemBodypartComparator(byte sortOrder)
+		{
+			order = sortOrder;
+		}
+		
+		public int compare(L2WarehouseItem o1, L2WarehouseItem o2)
+		{
+			if (o1.getType2() == L2Item.TYPE2_MONEY && o2.getType2() != L2Item.TYPE2_MONEY)
+				return (order == A2Z ? Z2A : A2Z);
+			if (o2.getType2() == L2Item.TYPE2_MONEY && o1.getType2() != L2Item.TYPE2_MONEY)
+				return (order == A2Z ? A2Z : Z2A);
+			Integer i1 = o1.getBodyPart();
+			Integer i2 = o2.getBodyPart();
+			return (order == A2Z ? i1.compareTo(i2) : i2.compareTo(i1));
+		}
+	}
+	
+	/**
+	 * This Comparator is used to sort by the Item Grade (e.g. Non..S-Grade)
+	 */
+	private static class WarehouseItemGradeComparator implements Comparator<L2WarehouseItem>
+	{
+		byte order = 0;
+		
+		protected WarehouseItemGradeComparator(byte sortOrder)
+		{
+			order = sortOrder;
+		}
+		
+		public int compare(L2WarehouseItem o1, L2WarehouseItem o2)
+		{
+			if (o1.getType2() == L2Item.TYPE2_MONEY && o2.getType2() != L2Item.TYPE2_MONEY)
+				return (order == A2Z ? Z2A : A2Z);
+			if (o2.getType2() == L2Item.TYPE2_MONEY && o1.getType2() != L2Item.TYPE2_MONEY)
+				return (order == A2Z ? A2Z : Z2A);
+			Integer i1 = o1.getItemGrade();
+			Integer i2 = o2.getItemGrade();
+			return (order == A2Z ? i1.compareTo(i2) : i2.compareTo(i1));
+		}
+	}
+	
+	/**
+	 * This Comparator will sort by Item Type. Unfortunatly this will only have a
+	 * good result if the Database Table for the ETCITEM.TYPE column is fixed!
+	 */
+	private static class WarehouseItemTypeComparator implements Comparator<L2WarehouseItem>
+	{
+		byte order = 0;
+		
+		protected WarehouseItemTypeComparator(byte sortOrder)
+		{
+			order = sortOrder;
+		}
+		
+		public int compare(L2WarehouseItem o1, L2WarehouseItem o2)
+		{
+			if (o1.getType2() == L2Item.TYPE2_MONEY && o2.getType2() != L2Item.TYPE2_MONEY)
+				return (order == A2Z ? Z2A : A2Z);
+			if (o2.getType2() == L2Item.TYPE2_MONEY && o1.getType2() != L2Item.TYPE2_MONEY)
+				return (order == A2Z ? A2Z : Z2A);
+			try
+			{
+				Integer i1 = o1.getItem().getMaterialType();
+				Integer i2 = o2.getItem().getMaterialType();
+				return (order == A2Z ? i1.compareTo(i2) : i2.compareTo(i1));
+			}
+			catch (Exception e)
+			{
+				return 0;
+			}
+		}
+	}
+	
+	// ========================================================================
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Weapon</li>
+	 * <li>Arrow</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createWeaponList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isWeapon() || item.getItem().getType2() == L2Item.TYPE2_WEAPON || (item.isEtcItem() && item.getItemType() == L2EtcItemType.ARROW) || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Armor</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createArmorList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isArmor() || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Everything which is no Weapon/Armor</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createEtcItemList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isEtcItem() || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Materials</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createMatList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isEtcItem() && item.getEtcItem().getItemType() == L2EtcItemType.MATERIAL || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Recipes</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createRecipeList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isEtcItem() && item.getEtcItem().getItemType() == L2EtcItemType.RECEIPE || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Amulett</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createAmulettList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isEtcItem() && (item.getEtcItem().getItemType() == L2EtcItemType.SPELLBOOK && item.getItemName().toUpperCase().startsWith("AMULET")) || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Spellbook & Dwarven Drafts</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createSpellbookList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isEtcItem() && (item.getEtcItem().getItemType() == L2EtcItemType.SPELLBOOK && !item.getItemName().toUpperCase().startsWith("AMULET")) || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Consumables (Potions, Shots, ...)</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createConsumableList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isEtcItem() && (item.getEtcItem().getItemType() == L2EtcItemType.SCROLL || item.getEtcItem().getItemType() == L2EtcItemType.SHOT) || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Shots</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createShotList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isEtcItem() && item.getEtcItem().getItemType() == L2EtcItemType.SHOT || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Scrolls/Potions</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createScrollList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isEtcItem() && item.getEtcItem().getItemType() == L2EtcItemType.SCROLL || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Seeds</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createSeedList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isEtcItem() && item.getEtcItem().getItemType() == L2EtcItemType.SEED || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>Everything which is no Weapon/Armor, Material, Recipe, Spellbook, Scroll or Shot</li>
+	 * <li>Money</li>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createOtherList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (item.isEtcItem()
+					&& (item.getEtcItem().getItemType() != L2EtcItemType.MATERIAL && item.getEtcItem().getItemType() != L2EtcItemType.RECEIPE && item.getEtcItem().getItemType() != L2EtcItemType.SPELLBOOK
+							&& item.getEtcItem().getItemType() != L2EtcItemType.SCROLL && item.getEtcItem().getItemType() != L2EtcItemType.SHOT) || item.getItem().getType2() == L2Item.TYPE2_MONEY)
+			{
+				if (_list.size() < MAX_SORT_LIST_ITEMS)
+					_list.add(new L2WarehouseItem(item));
+				else
+					continue;
+			}
+		}
+		return _list;
+	}
+	
+	/**
+	 * This method is used to limit the given Warehouse List to:
+	 * <li>no limit</li>
+	 * This may sound strange but we return the given Array as a List<L2WarehouseItem>
+	 * @param _items complete Warehouse List
+	 * @return limited Item List
+	 */
+	private List<L2WarehouseItem> createAllList(L2ItemInstance[] _items)
+	{
+		List<L2WarehouseItem> _list = new FastList<L2WarehouseItem>();
+		for (L2ItemInstance item : _items)
+		{
+			if (_list.size() < MAX_SORT_LIST_ITEMS)
+				_list.add(new L2WarehouseItem(item));
+			else
+				continue;
+		}
+		return _list;
+	}
+	
+	@Override
+	protected final void writeImpl()
+	{
+		writeC(0x42);
+		/* 0x01-Private Warehouse  
+		* 0x02-Clan Warehouse  
+		* 0x03-Castle Warehouse  
+		* 0x04-Warehouse */
+		writeH(_whType);
+		writeD(_playerAdena);
+		writeH(_objects.size());
+		
+		for (L2WarehouseItem item : _objects)
+		{
+			writeH(item.getItem().getType1()); // item type1 //unconfirmed, works
+			writeD(item.getObjectId());
+			writeD(item.getItemId()); //unconfirmed, works
+			writeD(item.getCount()); //unconfirmed, works
+			writeH(item.getItem().getType2()); // item type2 //unconfirmed, works
+			writeH(item.getCustomType1()); // ?
+			writeD(item.getItem().getBodyPart()); // ?
+			writeH(item.getEnchantLevel()); // enchant level -confirmed
+			writeH(item.getCustomType2()); // ?
+			writeH(0x00); // ?
+			writeD(item.getObjectId()); // item id - confimed       
+			if (item.isAugmented())
+			{
+				writeD(0x0000FFFF & item.getAugmentationId());
+				writeD(item.getAugmentationId() >> 16);
+			}
+			else
+				writeQ(0x00);
+			
+			writeD(item.getAttackElementType());
+			writeD(item.getAttackElementPower());
+			for (byte i = 0; i < 6; i++)
+			{
+				writeD(item.getElementDefAttr(i));
+			}
+			
+			writeD(item.getMana());
+			// T2
+			writeD(0x00);
+		}
+	}
+	
+	/* (non-Javadoc)
+	 * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return _S__54_SORTEDWAREHOUSEWITHDRAWALLIST;
+	}
 }

+ 20 - 17
L2_GameServer/java/net/sf/l2j/gameserver/network/serverpackets/WareHouseDepositList.java

@@ -38,42 +38,43 @@ public final class WareHouseDepositList extends L2GameServerPacket
 	private int _playerAdena;
 	private FastList<L2ItemInstance> _items;
 	private int _whType;
-
+	
 	public WareHouseDepositList(L2PcInstance player, int type)
 	{
 		_activeChar = player;
 		_whType = type;
 		_playerAdena = _activeChar.getAdena();
 		_items = new FastList<L2ItemInstance>();
-
+		
 		for (L2ItemInstance temp : _activeChar.getInventory().getAvailableItems(true))
 			_items.add(temp);
-
+		
 		// augmented and shadow items can be stored in private wh
 		if (_whType == PRIVATE)
 		{
-			for (L2ItemInstance temp :player.getInventory().getItems())
+			for (L2ItemInstance temp : player.getInventory().getItems())
 			{
 				if (temp != null && !temp.isEquipped() && (temp.isShadowItem() || temp.isAugmented()))
 					_items.add(temp);
 			}
 		}
 	}
-
+	
 	@Override
 	protected final void writeImpl()
 	{
 		writeC(0x41);
 		/* 0x01-Private Warehouse
-        * 0x02-Clan Warehouse
-        * 0x03-Castle Warehouse
-        * 0x04-Warehouse */
-        writeH(_whType);
+		* 0x02-Clan Warehouse
+		* 0x03-Castle Warehouse
+		* 0x04-Warehouse */
+		writeH(_whType);
 		writeD(_playerAdena);
 		int count = _items.size();
-		if (Config.DEBUG) _log.fine("count:"+count);
+		if (Config.DEBUG)
+			_log.fine("count:" + count);
 		writeH(count);
-
+		
 		for (L2ItemInstance item : _items)
 		{
 			writeH(item.getItem().getType1());
@@ -85,27 +86,29 @@ public final class WareHouseDepositList extends L2GameServerPacket
 			writeD(item.getItem().getBodyPart());
 			writeH(item.getEnchantLevel());
 			writeH(item.getCustomType2());
-			writeH(0x00);	// ? 200
+			writeH(0x00); // ? 200
 			writeD(item.getObjectId());
 			if (item.isAugmented())
 			{
-				writeD(0x0000FFFF&item.getAugmentation().getAugmentationId());
-				writeD(item.getAugmentation().getAugmentationId()>>16);
+				writeD(0x0000FFFF & item.getAugmentation().getAugmentationId());
+				writeD(item.getAugmentation().getAugmentationId() >> 16);
 			}
 			else
 				writeQ(0x00);
-
+			
 			writeD(item.getAttackElementType());
 			writeD(item.getAttackElementPower());
 			for (byte i = 0; i < 6; i++)
 			{
 				writeD(item.getElementDefAttr(i));
 			}
-
+			
 			writeD(item.getMana());
+			// T2
+			writeD(0x00);
 		}
 	}
-
+	
 	/* (non-Javadoc)
 	 * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
 	 */

+ 24 - 22
L2_GameServer/java/net/sf/l2j/gameserver/network/serverpackets/WareHouseWithdrawalList.java

@@ -37,39 +37,39 @@ public final class WareHouseWithdrawalList extends L2GameServerPacket
 	private int _playerAdena;
 	private L2ItemInstance[] _items;
 	private int _whType;
-
+	
 	public WareHouseWithdrawalList(L2PcInstance player, int type)
 	{
 		_activeChar = player;
 		_whType = type;
-
+		
 		_playerAdena = _activeChar.getAdena();
 		if (_activeChar.getActiveWarehouse() == null)
 		{
-            // Something went wrong!
-            _log.warning("error while sending withdraw request to: " + _activeChar.getName());
-            return;
+			// Something went wrong!
+			_log.warning("error while sending withdraw request to: " + _activeChar.getName());
+			return;
 		}
-		else _items = _activeChar.getActiveWarehouse().getItems();
-
+		else
+			_items = _activeChar.getActiveWarehouse().getItems();
+		
 		if (Config.DEBUG)
 			for (L2ItemInstance item : _items)
-				_log.fine("item:" + item.getItem().getName() +
-						" type1:" + item.getItem().getType1() + " type2:" + item.getItem().getType2());
+				_log.fine("item:" + item.getItem().getName() + " type1:" + item.getItem().getType1() + " type2:" + item.getItem().getType2());
 	}
-
+	
 	@Override
 	protected final void writeImpl()
 	{
 		writeC(0x42);
 		/* 0x01-Private Warehouse
-	    * 0x02-Clan Warehouse
-	    * 0x03-Castle Warehouse
-	    * 0x04-Warehouse */
-	    writeH(_whType);
+		* 0x02-Clan Warehouse
+		* 0x03-Castle Warehouse
+		* 0x04-Warehouse */
+		writeH(_whType);
 		writeD(_playerAdena);
 		writeH(_items.length);
-
+		
 		for (L2ItemInstance item : _items)
 		{
 			writeH(item.getItem().getType1());
@@ -77,31 +77,33 @@ public final class WareHouseWithdrawalList extends L2GameServerPacket
 			writeD(item.getItemId());
 			writeD(item.getCount());
 			writeH(item.getItem().getType2());
-			writeH(item.getCustomType1()); 
+			writeH(item.getCustomType1());
 			writeD(item.getItem().getBodyPart());
 			writeH(item.getEnchantLevel());
 			writeH(item.getCustomType2());
-			writeH(0x00);	// ?
+			writeH(0x00); // ?
 			writeD(item.getObjectId());
 			if (item.isAugmented())
 			{
-				writeD(0x0000FFFF&item.getAugmentation().getAugmentationId());
-				writeD(item.getAugmentation().getAugmentationId()>>16);
+				writeD(0x0000FFFF & item.getAugmentation().getAugmentationId());
+				writeD(item.getAugmentation().getAugmentationId() >> 16);
 			}
 			else
 				writeQ(0x00);
-
+			
 			writeD(item.getAttackElementType());
 			writeD(item.getAttackElementPower());
 			for (byte i = 0; i < 6; i++)
 			{
 				writeD(item.getElementDefAttr(i));
 			}
-
+			
 			writeD(item.getMana());
+			// T2
+			writeD(0x00);
 		}
 	}
-
+	
 	/* (non-Javadoc)
 	 * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
 	 */