Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: /l2j-private/l2j-private/java/com/l2jarchid/Config.java
- ===================================================================
- --- /l2j-private/l2j-private/java/com/l2jarchid/Config.java (revision 301)
- +++ /l2j-private/l2j-private/java/com/l2jarchid/Config.java (revision 310)
- @@ -2110,4 +2110,6 @@
- public static float POLE_VS_ROBE;
- public static boolean L2F_SAVE_BUFF_AFTER_DEATH;
- + public static boolean L2F_ENABLE_WAREHOUSESORTING;
- +
- // *******************************************************************************************
- public static void loadL2JArchidConfig()
- @@ -2383,4 +2385,8 @@
- L2F_SAVE_BUFF_AFTER_DEATH = Boolean.parseBoolean(L2JArchidSettings.getProperty("SaveBuffsAfterDeath", "False"));
- + L2F_ENABLE_WAREHOUSESORTING = Boolean.valueOf(L2JArchidSettings.getProperty("EnableWarehouseSorting", "False"));
- +
- +
- +
- }
- Index: /l2j-private/l2j-private/java/com/l2jarchid/gameserver/network/serverpackets/SortedWareHouseWithdrawalList.java
- ===================================================================
- --- /l2j-private/l2j-private/java/com/l2jarchid/gameserver/network/serverpackets/SortedWareHouseWithdrawalList.java (revision 310)
- +++ /l2j-private/l2j-private/java/com/l2jarchid/gameserver/network/serverpackets/SortedWareHouseWithdrawalList.java (revision 310)
- @@ -0,0 +1,731 @@
- +/*
- + * 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 2, 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, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * http://www.gnu.org/copyleft/gpl.html
- + */
- +package com.l2jarchid.gameserver.network.serverpackets;
- +
- +import java.util.Collections;
- +import java.util.Comparator;
- +import java.util.List;
- +import java.util.logging.Logger;
- +
- +import javolution.util.FastList;
- +import com.l2jarchid.gameserver.RecipeController;
- +import com.l2jarchid.gameserver.model.L2ItemInstance;
- +import com.l2jarchid.gameserver.model.L2RecipeList;
- +import com.l2jarchid.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jarchid.gameserver.templates.L2EtcItemType;
- +import com.l2jarchid.gameserver.templates.L2Item;
- +import com.l2jarchid.gameserver.templates.L2WarehouseItem;
- +
- +/**
- + * 0x42 WarehouseWithdrawalList dh (h dddhh dhhh d)
- + *
- + * @version $Revision: 1.3.2.1.2.5 $ $Date: 2005/03/29 23:15:10 $
- + */
- +
- +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;
- +
- + private int ENDmarker = 0x00;
- +
- + /**
- + * 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(0x00);
- + //writeD(item.getObjectId());
- + writeD(item.getItemId()); //unconfirmed, works
- + writeD(item.getCount()); //unconfirmed, works
- + writeH(item.getItem().getType2()); // item type2 //unconfirmed, works
- + writeH(0x00); // ?
- + //writeH(item.getCustomType1()); // ?
- + writeD(item.getItem().getBodyPart()); // ?
- + writeH(item.getEnchantLevel()); // enchant level -confirmed
- + writeH(0x00); // ?
- + writeH(0x00); // ?
- + //writeH(item.getCustomType2()); // ?
- + //writeH(ENDmarker); // ?
- + writeD(item.getObjectId()); // item id - confimed
- + if (item.isAugmented())
- + {
- + writeD(0x0000FFFF&item.getAugmentationId());
- + writeD(item.getAugmentationId()>>16);
- + }
- + else writeQ(0x00);
- + //writeD(item.getMana());
- +
- + }
- + }
- +
- + /* (non-Javadoc)
- + * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
- + */
- + @Override
- + public String getType()
- + {
- + return _S__54_SORTEDWAREHOUSEWITHDRAWALLIST;
- + }
- +}
- Index: /l2j-private/l2j-private/java/com/l2jarchid/gameserver/model/L2ItemInstance.java
- ===================================================================
- --- /l2j-private/l2j-private/java/com/l2jarchid/gameserver/model/L2ItemInstance.java (revision 258)
- +++ /l2j-private/l2j-private/java/com/l2jarchid/gameserver/model/L2ItemInstance.java (revision 310)
- @@ -410,4 +410,13 @@
- /**
- + * Returns true if item is an EtcItem
- + * @return boolean
- + */
- + public boolean isEtcItem()
- + {
- + return (_item instanceof L2EtcItem);
- + }
- +
- + /**
- * Returns true if item is a Weapon/Shield
- *
- @@ -427,4 +436,17 @@
- {
- return (_item instanceof L2Armor);
- + }
- +
- + /**
- + * Returns the characteristics of the L2EtcItem
- + * @return L2EtcItem
- + */
- + public L2EtcItem getEtcItem()
- + {
- + if (_item instanceof L2EtcItem)
- + {
- + return (L2EtcItem) _item;
- + }
- + return null;
- }
- Index: /l2j-private/l2j-private/java/com/l2jarchid/gameserver/model/actor/instance/L2CastleWarehouseInstance.java
- ===================================================================
- --- /l2j-private/l2j-private/java/com/l2jarchid/gameserver/model/actor/instance/L2CastleWarehouseInstance.java (revision 200)
- +++ /l2j-private/l2j-private/java/com/l2jarchid/gameserver/model/actor/instance/L2CastleWarehouseInstance.java (revision 310)
- @@ -1,11 +1,14 @@
- package com.l2jarchid.gameserver.model.actor.instance;
- +import com.l2jarchid.Config;
- import com.l2jarchid.gameserver.model.L2Clan;
- import com.l2jarchid.gameserver.network.SystemMessageId;
- import com.l2jarchid.gameserver.network.serverpackets.ActionFailed;
- import com.l2jarchid.gameserver.network.serverpackets.NpcHtmlMessage;
- +import com.l2jarchid.gameserver.network.serverpackets.SortedWareHouseWithdrawalList;
- import com.l2jarchid.gameserver.network.serverpackets.SystemMessage;
- import com.l2jarchid.gameserver.network.serverpackets.WareHouseDepositList;
- import com.l2jarchid.gameserver.network.serverpackets.WareHouseWithdrawalList;
- +import com.l2jarchid.gameserver.network.serverpackets.SortedWareHouseWithdrawalList.WarehouseListType;
- import com.l2jarchid.gameserver.templates.L2NpcTemplate;
- @@ -38,5 +41,8 @@
- }
- - player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.PRIVATE));
- + if (Config.L2F_ENABLE_WAREHOUSESORTING)
- + player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.PRIVATE,WarehouseListType.ALL,SortedWareHouseWithdrawalList.A2Z));
- + else
- + player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.PRIVATE));
- }
- @@ -84,5 +90,8 @@
- } else {
- player.setActiveWarehouse(player.getClan().getWarehouse());
- - player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN));
- + if (Config.L2F_ENABLE_WAREHOUSESORTING)
- + player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN,WarehouseListType.ALL,SortedWareHouseWithdrawalList.A2Z));
- + else
- + player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN));
- }
- }
- Index: /l2j-private/l2j-private/java/com/l2jarchid/gameserver/model/actor/instance/L2WarehouseInstance.java
- ===================================================================
- --- /l2j-private/l2j-private/java/com/l2jarchid/gameserver/model/actor/instance/L2WarehouseInstance.java (revision 200)
- +++ /l2j-private/l2j-private/java/com/l2jarchid/gameserver/model/actor/instance/L2WarehouseInstance.java (revision 310)
- @@ -27,7 +27,9 @@
- import com.l2jarchid.gameserver.network.serverpackets.ActionFailed;
- import com.l2jarchid.gameserver.network.serverpackets.PackageToList;
- +import com.l2jarchid.gameserver.network.serverpackets.SortedWareHouseWithdrawalList;
- import com.l2jarchid.gameserver.network.serverpackets.SystemMessage;
- import com.l2jarchid.gameserver.network.serverpackets.WareHouseDepositList;
- import com.l2jarchid.gameserver.network.serverpackets.WareHouseWithdrawalList;
- +import com.l2jarchid.gameserver.network.serverpackets.SortedWareHouseWithdrawalList.WarehouseListType;
- import com.l2jarchid.gameserver.templates.L2NpcTemplate;
- @@ -77,4 +79,7 @@
- if (Config.DEBUG) _log.fine("Showing stored items");
- + if (Config.L2F_ENABLE_WAREHOUSESORTING)
- + player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.PRIVATE,WarehouseListType.ALL,SortedWareHouseWithdrawalList.A2Z));
- + else
- player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.PRIVATE));
- }
- @@ -125,4 +130,7 @@
- player.setActiveWarehouse(player.getClan().getWarehouse());
- if (Config.DEBUG) _log.fine("Showing items to deposit - clan");
- + if (Config.L2F_ENABLE_WAREHOUSESORTING)
- + player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN,WarehouseListType.ALL,SortedWareHouseWithdrawalList.A2Z));
- + else
- player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN));
- }
- @@ -149,4 +157,7 @@
- }
- player.setActiveWarehouse(freight);
- + if (Config.L2F_ENABLE_WAREHOUSESORTING)
- + player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.FREIGHT,WarehouseListType.ALL,SortedWareHouseWithdrawalList.A2Z));
- + else
- player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.FREIGHT));
- }
- Index: /l2j-private/l2j-private/java/com/l2jarchid/gameserver/templates/L2WarehouseItem.java
- ===================================================================
- --- /l2j-private/l2j-private/java/com/l2jarchid/gameserver/templates/L2WarehouseItem.java (revision 310)
- +++ /l2j-private/l2j-private/java/com/l2jarchid/gameserver/templates/L2WarehouseItem.java (revision 310)
- @@ -0,0 +1,243 @@
- +/*
- + * 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 2, 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, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * http://www.gnu.org/copyleft/gpl.html
- + */
- +package com.l2jarchid.gameserver.templates;
- +
- +import com.l2jarchid.gameserver.model.L2ItemInstance;
- +
- +/**
- + * This class contains L2ItemInstance<BR>
- + * Use to sort L2ItemInstance of :
- + * <LI>L2Armor</LI>
- + * <LI>L2EtcItem</LI>
- + * <LI>L2Weapon</LI>
- + * @version $Revision: 1.7.2.2.2.5 $ $Date: 2005/04/06 18:25:18 $
- + */
- +public class L2WarehouseItem
- +{
- + private L2Item _item;
- + private int _object;
- + private int _count;
- + private int _owner;
- + private int _enchant;
- + private int _grade;
- + private boolean _isAugmented;
- + private int _augmentationId;
- + private int _customType1;
- + private int _customType2;
- + private int _mana;
- +
- +
- + public L2WarehouseItem(L2ItemInstance item)
- + {
- + _item = item.getItem();
- + _object = item.getObjectId();
- + _count = item.getCount();
- + _owner = item.getOwnerId();
- + _enchant = item.getEnchantLevel();
- + _customType1 = item.getCustomType1();
- + _customType2 = item.getCustomType2();
- + _grade = item.getItem().getItemGrade();
- + if (item.isAugmented())
- + {
- + _isAugmented = true;
- + _augmentationId = item.getAugmentation().getAugmentationId();
- + }
- + else
- + _isAugmented = false;
- + _mana = item.getMana();
- + }
- +
- + /**
- + * Returns the item.
- + * @return L2Item
- + */
- + public L2Item getItem()
- + {
- + return _item;
- + }
- +
- + /**
- + * Returns the unique objectId
- + * @return int
- + */
- + public final int getObjectId()
- + {
- + return _object;
- + }
- +
- + /**
- + * Returns the owner
- + * @return int
- + */
- + public final int getOwnerId()
- + {
- + return _owner;
- + }
- +
- + /**
- + * Returns the count
- + * @return int
- + */
- + public final int getCount()
- + {
- + return _count;
- + }
- +
- + /**
- + * Returns the first type
- + * @return int
- + */
- + public final int getType1()
- + {
- + return _item.getType1();
- + }
- +
- + /**
- + * Returns the second type
- + * @return int
- + */
- + public final int getType2()
- + {
- + return _item.getType2();
- + }
- +
- + /**
- + * Returns the second type
- + * @return int
- + */
- + @SuppressWarnings("unchecked")
- + public final Enum getItemType()
- + {
- + return _item.getItemType();
- + }
- +
- + /**
- + * Returns the ItemId
- + * @return int
- + */
- + public final int getItemId()
- + {
- + return _item.getItemId();
- + }
- +
- + /**
- + * Returns the part of body used with this item
- + * @return int
- + */
- + public final int getBodyPart()
- + {
- + return _item.getBodyPart();
- + }
- +
- + /**
- + * Returns the enchant level
- + * @return int
- + */
- + public final int getEnchantLevel()
- + {
- + return _enchant;
- + }
- +
- + /**
- + * Returns the item grade
- + * @return int
- + */
- + public final int getItemGrade()
- + {
- + return _grade;
- + }
- +
- + /**
- + * Returns true if it is a weapon
- + * @return boolean
- + */
- + public final boolean isWeapon()
- + {
- + return (_item instanceof L2Weapon);
- + }
- +
- + /**
- + * Returns true if it is an armor
- + * @return boolean
- + */
- + public final boolean isArmor()
- + {
- + return (_item instanceof L2Armor);
- + }
- +
- + /**
- + * Returns true if it is an EtcItem
- + * @return boolean
- + */
- + public final boolean isEtcItem()
- + {
- + return (_item instanceof L2EtcItem);
- + }
- +
- + /**
- + * Returns the name of the item
- + * @return String
- + */
- + public String getItemName()
- + {
- + return _item.getName();
- + }
- +
- + public boolean isAugmented()
- + {
- + return _isAugmented;
- + }
- +
- + public int getAugmentationId()
- + {
- + return _augmentationId;
- + }
- +
- + /**
- + * Returns the name of the item
- + * @return String
- + * @deprecated beware to use getItemName() instead because getName() is final in L2Object and could not be overridden! Allover L2Object.getName() may return null!
- + */
- + public String getName()
- + {
- + return _item.getName();
- + }
- +
- + public final int getCustomType1()
- + {
- + return _customType1;
- + }
- + public final int getCustomType2()
- + {
- + return _customType2;
- + }
- + public final int getMana()
- + {
- + return _mana;
- + }
- +
- + /**
- + * Returns the name of the item
- + * @return String
- + */
- + public String toString()
- + {
- + return _item.toString();
- + }
- +}
- Index: /l2j-private/l2j-private/config/l2jarchid-customs.properties
- ===================================================================
- --- /l2j-private/l2j-private/config/l2jarchid-customs.properties (revision 301)
- +++ /l2j-private/l2j-private/config/l2jarchid-customs.properties (revision 310)
- @@ -441,2 +441,9 @@
- # ---------------------------------------------------------------------------
- SaveBuffsAfterDeath = false
- +
- +# ---------------------------------------------------------------------------
- +# Warehouse Sorting
- +# Shows Withdraw Window sorted by A to Z
- +# ---------------------------------------------------------------------------
- +EnableWarehouseSorting = False
- +
Advertisement
Add Comment
Please, Sign In to add comment