public void switchStoragesItems( Player player, int sourceStorageType, int sourceItemObjId, int replaceStorageType, int replaceItemObjId) { Storage sourceStorage = player.getStorage(sourceStorageType); Storage replaceStorage = player.getStorage(replaceStorageType); Item sourceItem = sourceStorage.getItemByObjId(sourceItemObjId); if (sourceItem == null) return; Item replaceItem = replaceStorage.getItemByObjId(replaceItemObjId); if (replaceItem == null) return; int sourceSlot = sourceItem.getEquipmentSlot(); int replaceSlot = replaceItem.getEquipmentSlot(); sourceItem.setEquipmentSlot(replaceSlot); replaceItem.setEquipmentSlot(sourceSlot); sourceStorage.removeFromBag(sourceItem, false); replaceStorage.removeFromBag(replaceItem, false); Item newSourceItem = sourceStorage.putToBag(replaceItem); Item newReplaceItem = replaceStorage.putToBag(sourceItem); sendDeleteItemPacket(player, sourceStorageType, sourceItemObjId); sendStorageUpdatePacket(player, sourceStorageType, newSourceItem); sendDeleteItemPacket(player, replaceStorageType, replaceItemObjId); sendStorageUpdatePacket(player, replaceStorageType, newReplaceItem); }
/** * @param objId * @return int */ public int getSlotIdByObjId(int objId) { for (Item item : storageItems) { if (item.getObjectId() == objId) { return item.getEquipmentSlot(); } } return -1; }
/** * @param itemId * @return int */ public int getSlotIdByItemId(int itemId) { for (Item item : storageItems) { ItemTemplate itemTemplate = item.getItemTemplate(); if (itemTemplate.getTemplateId() == itemId) { return item.getEquipmentSlot(); } } return -1; }
@Override protected void writeImpl(AionChannelHandler cHandler) { writeD(playerId); short mask = 0; for (Item item : items) { mask |= item.getEquipmentSlot(); } writeH(mask); for (Item item : items) { writeD(item.getItemSkinTemplate().getTemplateId()); GodStone godStone = item.getGodStone(); writeD(godStone != null ? godStone.getItemId() : 0); writeD(item.getItemColor()); writeH(0x00); // unk (0x00) } }
/** * Loads item stones from DB for each item in a list if item is ARMOR or WEAPON * * @param itemList */ public void loadItemStones(Player player) { List<Item> itemList = new ArrayList<Item>(); itemList.addAll(player.getStorage(StorageType.CUBE.getId()).getStorageItems()); itemList.addAll(player.getStorage(StorageType.REGULAR_WAREHOUSE.getId()).getStorageItems()); itemList.addAll(player.getStorage(StorageType.ACCOUNT_WAREHOUSE.getId()).getStorageItems()); itemList.addAll(player.getEquipment().getEquippedItems()); for (Item item : itemList) { if (item.getItemTemplate().isArmor() || item.getItemTemplate().isWeapon()) { item.setItemStones(DAOManager.getDAO(ItemStoneListDAO.class).load(item.getObjectId())); // if item equipped - apply stats of item stone if (item.isEquipped() && item.getEquipmentSlot() != ItemSlot.MAIN_OFF_HAND.getSlotIdMask() && item.getEquipmentSlot() != ItemSlot.SUB_OFF_HAND.getSlotIdMask()) { for (ItemStone itemStone : item.getItemStones()) { ItemEquipmentListener.addStoneStats(itemStone, player.getGameStats()); } } } } }