Removal of inventory item result conversions to arrays.
This commit is contained in:
@ -111,7 +111,7 @@ public class MultisellData
|
||||
return list;
|
||||
}
|
||||
|
||||
ItemInstance[] items;
|
||||
List<ItemInstance> items;
|
||||
if (listTemplate.getMaintainEnchantment())
|
||||
{
|
||||
items = player.getInventory().getUniqueItemsByEnchantLevel(false, false, false, true);
|
||||
|
@ -2873,10 +2873,9 @@ public class CTF implements EventTask
|
||||
player._haveFlagCTF = false;
|
||||
if (wpn != null)
|
||||
{
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
|
||||
player.getInventory().destroyItemByItemId("", _FLAG_IN_HAND_ITEM_ID, 1, player, null);
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequiped)
|
||||
for (ItemInstance element : player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart()))
|
||||
{
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
@ -7538,7 +7537,7 @@ public class PlayerInstance extends Playable
|
||||
wpn.getAugmentation().removeBonus(this);
|
||||
}
|
||||
|
||||
final ItemInstance[] unequiped = getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
|
||||
final List<ItemInstance> unequiped = getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequiped)
|
||||
{
|
||||
@ -7550,19 +7549,20 @@ public class PlayerInstance extends Playable
|
||||
broadcastUserInfo();
|
||||
|
||||
// this can be 0 if the user pressed the right mousebutton twice very fast
|
||||
if (unequiped.length > 0)
|
||||
if (!unequiped.isEmpty())
|
||||
{
|
||||
SystemMessage sm = null;
|
||||
if (unequiped[0].getEnchantLevel() > 0)
|
||||
final ItemInstance unequipedItem = unequiped.get(0);
|
||||
if (unequipedItem.getEnchantLevel() > 0)
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addNumber(unequiped[0].getEnchantLevel());
|
||||
sm.addItemName(unequiped[0].getItemId());
|
||||
sm.addNumber(unequipedItem.getEnchantLevel());
|
||||
sm.addItemName(unequipedItem.getItemId());
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_DISARMED);
|
||||
sm.addItemName(unequiped[0].getItemId());
|
||||
sm.addItemName(unequipedItem.getItemId());
|
||||
}
|
||||
sendPacket(sm);
|
||||
}
|
||||
@ -7577,7 +7577,7 @@ public class PlayerInstance extends Playable
|
||||
return false;
|
||||
}
|
||||
|
||||
final ItemInstance[] unequiped = getInventory().unEquipItemInBodySlotAndRecord(sld.getItem().getBodyPart());
|
||||
final List<ItemInstance> unequiped = getInventory().unEquipItemInBodySlotAndRecord(sld.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequiped)
|
||||
{
|
||||
@ -7589,19 +7589,20 @@ public class PlayerInstance extends Playable
|
||||
broadcastUserInfo();
|
||||
|
||||
// this can be 0 if the user pressed the right mousebutton twice very fast
|
||||
if (unequiped.length > 0)
|
||||
if (!unequiped.isEmpty())
|
||||
{
|
||||
SystemMessage sm = null;
|
||||
if (unequiped[0].getEnchantLevel() > 0)
|
||||
final ItemInstance item = unequiped.get(0);
|
||||
if (item.getEnchantLevel() > 0)
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addNumber(unequiped[0].getEnchantLevel());
|
||||
sm.addItemName(unequiped[0].getItemId());
|
||||
sm.addNumber(item.getEnchantLevel());
|
||||
sm.addItemName(item.getItemId());
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_DISARMED);
|
||||
sm.addItemName(unequiped[0].getItemId());
|
||||
sm.addItemName(item.getItemId());
|
||||
}
|
||||
sendPacket(sm);
|
||||
}
|
||||
@ -12063,9 +12064,8 @@ public class PlayerInstance extends Playable
|
||||
final ItemInstance rhand = getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
|
||||
if (rhand != null)
|
||||
{
|
||||
final ItemInstance[] unequipped = getInventory().unEquipItemInBodySlotAndRecord(rhand.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequipped)
|
||||
for (ItemInstance element : getInventory().unEquipItemInBodySlotAndRecord(rhand.getItem().getBodyPart()))
|
||||
{
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
@ -12079,9 +12079,8 @@ public class PlayerInstance extends Playable
|
||||
final ItemInstance chest = getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
|
||||
if (chest != null)
|
||||
{
|
||||
final ItemInstance[] unequipped = getInventory().unEquipItemInBodySlotAndRecord(chest.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequipped)
|
||||
for (ItemInstance element : getInventory().unEquipItemInBodySlotAndRecord(chest.getItem().getBodyPart()))
|
||||
{
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
@ -12095,9 +12094,8 @@ public class PlayerInstance extends Playable
|
||||
final ItemInstance legs = getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS);
|
||||
if (legs != null)
|
||||
{
|
||||
final ItemInstance[] unequipped = getInventory().unEquipItemInBodySlotAndRecord(legs.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequipped)
|
||||
for (ItemInstance element : getInventory().unEquipItemInBodySlotAndRecord(legs.getItem().getBodyPart()))
|
||||
{
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
@ -12410,9 +12408,8 @@ public class PlayerInstance extends Playable
|
||||
final ItemInstance rhand = getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
|
||||
if (rhand != null)
|
||||
{
|
||||
final ItemInstance[] unequipped = getInventory().unEquipItemInBodySlotAndRecord(rhand.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequipped)
|
||||
for (ItemInstance element : getInventory().unEquipItemInBodySlotAndRecord(rhand.getItem().getBodyPart()))
|
||||
{
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
@ -12426,9 +12423,8 @@ public class PlayerInstance extends Playable
|
||||
final ItemInstance chest = getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
|
||||
if (chest != null)
|
||||
{
|
||||
final ItemInstance[] unequipped = getInventory().unEquipItemInBodySlotAndRecord(chest.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequipped)
|
||||
for (ItemInstance element : getInventory().unEquipItemInBodySlotAndRecord(chest.getItem().getBodyPart()))
|
||||
{
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
@ -12442,9 +12438,8 @@ public class PlayerInstance extends Playable
|
||||
final ItemInstance legs = getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS);
|
||||
if (legs != null)
|
||||
{
|
||||
final ItemInstance[] unequipped = getInventory().unEquipItemInBodySlotAndRecord(legs.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequipped)
|
||||
for (ItemInstance element : getInventory().unEquipItemInBodySlotAndRecord(legs.getItem().getBodyPart()))
|
||||
{
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
@ -16130,7 +16125,7 @@ public class PlayerInstance extends Playable
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((_inventory.getAllItemsByItemId(itemId) == null) || (_inventory.getAllItemsByItemId(itemId).length == 0))
|
||||
if ((_inventory.getAllItemsByItemId(itemId) == null) || _inventory.getAllItemsByItemId(itemId).isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -16199,7 +16194,7 @@ public class PlayerInstance extends Playable
|
||||
{
|
||||
equippedItem.getAugmentation().removeBonus(this);
|
||||
}
|
||||
final ItemInstance[] items = getInventory().unEquipItemInSlotAndRecord(i);
|
||||
final List<ItemInstance> items = getInventory().unEquipItemInSlotAndRecord(i);
|
||||
if (equippedItem.isWear())
|
||||
{
|
||||
continue;
|
||||
@ -16218,7 +16213,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
sendPacket(sm);
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addItems(Arrays.asList(items));
|
||||
iu.addItems(items);
|
||||
sendPacket(iu);
|
||||
broadcastUserInfo();
|
||||
}
|
||||
|
@ -181,11 +181,11 @@ public abstract class Inventory extends ItemContainer
|
||||
|
||||
/**
|
||||
* Returns alterations in inventory
|
||||
* @return ItemInstance[] : array of alterated items
|
||||
* @return List<ItemInstance> : list of alterated items
|
||||
*/
|
||||
public ItemInstance[] getChangedItems()
|
||||
public List<ItemInstance> getChangedItems()
|
||||
{
|
||||
return _changed.toArray(new ItemInstance[_changed.size()]);
|
||||
return _changed;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1043,9 +1043,9 @@ public abstract class Inventory extends ItemContainer
|
||||
/**
|
||||
* Unequips item in body slot and returns alterations.
|
||||
* @param slot : int designating the slot of the paperdoll
|
||||
* @return ItemInstance[] : list of changes
|
||||
* @return List<ItemInstance> : list of changes
|
||||
*/
|
||||
public ItemInstance[] unEquipItemInBodySlotAndRecord(int slot)
|
||||
public List<ItemInstance> unEquipItemInBodySlotAndRecord(int slot)
|
||||
{
|
||||
final ChangeRecorder recorder = newRecorder();
|
||||
|
||||
@ -1080,9 +1080,9 @@ public abstract class Inventory extends ItemContainer
|
||||
/**
|
||||
* Unepquips item in slot and returns alterations
|
||||
* @param slot : int designating the slot
|
||||
* @return ItemInstance[] : list of items altered
|
||||
* @return List<ItemInstance> : list of items altered
|
||||
*/
|
||||
public ItemInstance[] unEquipItemInSlotAndRecord(int slot)
|
||||
public List<ItemInstance> unEquipItemInSlotAndRecord(int slot)
|
||||
{
|
||||
final ChangeRecorder recorder = newRecorder();
|
||||
|
||||
@ -1221,9 +1221,9 @@ public abstract class Inventory extends ItemContainer
|
||||
/**
|
||||
* Equips item and returns list of alterations
|
||||
* @param item : ItemInstance corresponding to the item
|
||||
* @return ItemInstance[] : list of alterations
|
||||
* @return List<ItemInstance> : list of alterations
|
||||
*/
|
||||
public ItemInstance[] equipItemAndRecord(ItemInstance item)
|
||||
public List<ItemInstance> equipItemAndRecord(ItemInstance item)
|
||||
{
|
||||
final ChangeRecorder recorder = newRecorder();
|
||||
|
||||
|
@ -92,12 +92,12 @@ public class PlayerInventory extends Inventory
|
||||
* @param allowEquipped
|
||||
* @return ItemInstance : items in inventory
|
||||
*/
|
||||
public ItemInstance[] getUniqueItems(boolean allowAdena, boolean allowAncientAdena, boolean allowEquipped)
|
||||
public List<ItemInstance> getUniqueItems(boolean allowAdena, boolean allowAncientAdena, boolean allowEquipped)
|
||||
{
|
||||
return getUniqueItems(allowAdena, allowAncientAdena, true, allowEquipped);
|
||||
}
|
||||
|
||||
public ItemInstance[] getUniqueItems(boolean allowAdena, boolean allowAncientAdena, boolean onlyAvailable, boolean allowEquipped)
|
||||
public List<ItemInstance> getUniqueItems(boolean allowAdena, boolean allowAncientAdena, boolean onlyAvailable, boolean allowEquipped)
|
||||
{
|
||||
final List<ItemInstance> list = new ArrayList<>();
|
||||
for (ItemInstance item : _items)
|
||||
@ -126,7 +126,7 @@ public class PlayerInventory extends Inventory
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new ItemInstance[list.size()]);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,12 +136,12 @@ public class PlayerInventory extends Inventory
|
||||
* @param allowEquipped
|
||||
* @return ItemInstance : items in inventory
|
||||
*/
|
||||
public ItemInstance[] getUniqueItemsByEnchantLevel(boolean allowAdena, boolean allowAncientAdena, boolean allowEquipped)
|
||||
public List<ItemInstance> getUniqueItemsByEnchantLevel(boolean allowAdena, boolean allowAncientAdena, boolean allowEquipped)
|
||||
{
|
||||
return getUniqueItemsByEnchantLevel(allowAdena, allowAncientAdena, true, allowEquipped);
|
||||
}
|
||||
|
||||
public ItemInstance[] getUniqueItemsByEnchantLevel(boolean allowAdena, boolean allowAncientAdena, boolean onlyAvailable, boolean allowEquipped)
|
||||
public List<ItemInstance> getUniqueItemsByEnchantLevel(boolean allowAdena, boolean allowAncientAdena, boolean onlyAvailable, boolean allowEquipped)
|
||||
{
|
||||
final List<ItemInstance> list = new ArrayList<>();
|
||||
for (ItemInstance item : _items)
|
||||
@ -171,15 +171,15 @@ public class PlayerInventory extends Inventory
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new ItemInstance[list.size()]);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of all items in inventory that have a given item id.
|
||||
* @param itemId
|
||||
* @return ItemInstance[] : matching items from inventory
|
||||
* @return List<ItemInstance> : matching items from inventory
|
||||
*/
|
||||
public ItemInstance[] getAllItemsByItemId(int itemId)
|
||||
public List<ItemInstance> getAllItemsByItemId(int itemId)
|
||||
{
|
||||
final List<ItemInstance> list = new ArrayList<>();
|
||||
for (ItemInstance item : _items)
|
||||
@ -189,16 +189,16 @@ public class PlayerInventory extends Inventory
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
return list.toArray(new ItemInstance[list.size()]);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of all items in inventory that have a given item id AND a given enchantment level.
|
||||
* @param itemId
|
||||
* @param enchantment
|
||||
* @return ItemInstance[] : matching items from inventory
|
||||
* @return List<ItemInstance> : matching items from inventory
|
||||
*/
|
||||
public ItemInstance[] getAllItemsByItemId(int itemId, int enchantment)
|
||||
public List<ItemInstance> getAllItemsByItemId(int itemId, int enchantment)
|
||||
{
|
||||
final List<ItemInstance> list = new ArrayList<>();
|
||||
for (ItemInstance item : _items)
|
||||
@ -208,7 +208,7 @@ public class PlayerInventory extends Inventory
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
return list.toArray(new ItemInstance[list.size()]);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,7 +216,7 @@ public class PlayerInventory extends Inventory
|
||||
* @param allowAdena
|
||||
* @return ItemInstance : items in inventory
|
||||
*/
|
||||
public ItemInstance[] getAvailableItems(boolean allowAdena)
|
||||
public List<ItemInstance> getAvailableItems(boolean allowAdena)
|
||||
{
|
||||
final List<ItemInstance> list = new ArrayList<>();
|
||||
for (ItemInstance item : _items)
|
||||
@ -226,14 +226,14 @@ public class PlayerInventory extends Inventory
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
return list.toArray(new ItemInstance[list.size()]);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all augmented items
|
||||
* @return
|
||||
*/
|
||||
public ItemInstance[] getAugmentedItems()
|
||||
public List<ItemInstance> getAugmentedItems()
|
||||
{
|
||||
final List<ItemInstance> list = new ArrayList<>();
|
||||
for (ItemInstance item : _items)
|
||||
@ -243,7 +243,7 @@ public class PlayerInventory extends Inventory
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
return list.toArray(new ItemInstance[list.size()]);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,7 +251,7 @@ public class PlayerInventory extends Inventory
|
||||
* @param tradeList
|
||||
* @return ItemInstance : items in inventory
|
||||
*/
|
||||
public TradeItem[] getAvailableItems(TradeList tradeList)
|
||||
public List<TradeItem> getAvailableItems(TradeList tradeList)
|
||||
{
|
||||
final List<TradeItem> list = new ArrayList<>();
|
||||
for (ItemInstance item : _items)
|
||||
@ -265,7 +265,7 @@ public class PlayerInventory extends Inventory
|
||||
}
|
||||
}
|
||||
}
|
||||
return list.toArray(new TradeItem[list.size()]);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -735,15 +735,14 @@ public class PlayerInventory extends Inventory
|
||||
|
||||
public boolean checkIfEquipped(int itemId)
|
||||
{
|
||||
final ItemInstance[] items = getAllItemsByItemId(itemId);
|
||||
if ((items == null) || (items.length == 0))
|
||||
if (_items == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ItemInstance item : items)
|
||||
for (ItemInstance item : _items)
|
||||
{
|
||||
if (item.isEquipped())
|
||||
if (item.isEquipped() && (item.getItemId() == itemId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -754,16 +753,15 @@ public class PlayerInventory extends Inventory
|
||||
|
||||
public int checkHowManyEquipped(int itemId)
|
||||
{
|
||||
final ItemInstance[] items = getAllItemsByItemId(itemId);
|
||||
if ((items == null) || (items.length == 0))
|
||||
if (_items == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (ItemInstance item : items)
|
||||
for (ItemInstance item : _items)
|
||||
{
|
||||
if (item.isEquipped())
|
||||
if (item.isEquipped() && (item.getItemId() == itemId))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
@ -792,15 +792,12 @@ public class ItemInstance extends WorldObject
|
||||
// unequip
|
||||
if (isEquipped())
|
||||
{
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getEquipSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
|
||||
for (ItemInstance element : unequiped)
|
||||
for (ItemInstance element : player.getInventory().unEquipItemInSlotAndRecord(getEquipSlot()))
|
||||
{
|
||||
player.checkSSMatch(null, element);
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
|
||||
player.sendPacket(iu);
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ public class Hero
|
||||
public synchronized void computeNewHeroes(List<StatSet> newHeroes)
|
||||
{
|
||||
updateHeroes(true);
|
||||
ItemInstance[] items;
|
||||
List<ItemInstance> items;
|
||||
InventoryUpdate iu;
|
||||
if (HEROES.size() != 0)
|
||||
{
|
||||
|
@ -300,31 +300,30 @@ public class MultiSellChoose implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // a) if enchantment is maintained, then get a list of items that exactly match this enchantment
|
||||
if (maintainEnchantment)
|
||||
else if (maintainEnchantment) // a) if enchantment is maintained, then get a list of items that exactly match this enchantment
|
||||
{
|
||||
// loop through this list and remove (one by one) each item until the required amount is taken.
|
||||
final ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId(), e.getEnchantmentLevel());
|
||||
final List<ItemInstance> inventoryContents = inv.getAllItemsByItemId(e.getItemId(), e.getEnchantmentLevel());
|
||||
for (int i = 0; i < (e.getItemCount() * _amount); i++)
|
||||
{
|
||||
if (inventoryContents[i].isAugmented())
|
||||
final ItemInstance item = inventoryContents.get(i);
|
||||
if (item.isAugmented())
|
||||
{
|
||||
augmentation.add(inventoryContents[i].getAugmentation());
|
||||
augmentation.add(item.getAugmentation());
|
||||
}
|
||||
|
||||
if (inventoryContents[i].isEquipped() && inventoryContents[i].isAugmented())
|
||||
if (item.isEquipped() && item.isAugmented())
|
||||
{
|
||||
inventoryContents[i].getAugmentation().removeBonus(player);
|
||||
item.getAugmentation().removeBonus(player);
|
||||
}
|
||||
|
||||
if (!player.destroyItem("Multisell", inventoryContents[i].getObjectId(), 1, player.getTarget(), true))
|
||||
if (!player.destroyItem("Multisell", item.getObjectId(), 1, player.getTarget(), true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
// b) enchantment is not maintained. Get the instances with the LOWEST enchantment level
|
||||
else // b) enchantment is not maintained. Get the instances with the LOWEST enchantment level
|
||||
{
|
||||
/*
|
||||
* NOTE: There are 2 ways to achieve the above goal. 1) Get all items that have the correct itemId, loop through them until the lowest enchantment level is found. Repeat all this for the next item until proper count of items is reached. 2) Get all items that have the correct
|
||||
@ -340,8 +339,8 @@ public class MultiSellChoose implements IClientIncomingPacket
|
||||
// choice 1. Small number of items exchanged. No sorting.
|
||||
for (int i = 1; i <= (e.getItemCount() * _amount); i++)
|
||||
{
|
||||
final ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId());
|
||||
itemToTake = inventoryContents[0];
|
||||
final List<ItemInstance> inventoryContents = inv.getAllItemsByItemId(e.getItemId());
|
||||
itemToTake = inventoryContents.get(0);
|
||||
// get item with the LOWEST enchantment level from the inventory...
|
||||
// +0 is lowest by default...
|
||||
if (itemToTake.getEnchantLevel() > 0)
|
||||
@ -351,8 +350,7 @@ public class MultiSellChoose implements IClientIncomingPacket
|
||||
if (inventoryContent.getEnchantLevel() < itemToTake.getEnchantLevel())
|
||||
{
|
||||
itemToTake = inventoryContent;
|
||||
// nothing will have enchantment less than 0. If a zero-enchanted
|
||||
// item is found, just take it
|
||||
// nothing will have enchantment less than 0. If a zero-enchanted item is found, just take it
|
||||
if (itemToTake.getEnchantLevel() == 0)
|
||||
{
|
||||
break;
|
||||
|
@ -165,9 +165,8 @@ public class RequestCrystallizeItem implements IClientIncomingPacket
|
||||
itemToRemove.getAugmentation().removeBonus(player);
|
||||
}
|
||||
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getEquipSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequiped)
|
||||
for (ItemInstance element : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getEquipSlot()))
|
||||
{
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
|
@ -117,14 +117,12 @@ public class RequestDestroyItem implements IClientIncomingPacket
|
||||
itemToRemove.getAugmentation().removeBonus(player);
|
||||
}
|
||||
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getEquipSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequiped)
|
||||
for (ItemInstance element : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getEquipSlot()))
|
||||
{
|
||||
player.checkSSMatch(null, element);
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
|
||||
player.sendPacket(iu);
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
@ -205,9 +205,8 @@ public class RequestDropItem implements IClientIncomingPacket
|
||||
item.getAugmentation().removeBonus(player);
|
||||
}
|
||||
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequiped)
|
||||
for (ItemInstance element : player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart()))
|
||||
{
|
||||
player.checkSSMatch(null, element);
|
||||
iu.addModifiedItem(element);
|
||||
|
@ -664,14 +664,12 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
item.getAugmentation().removeBonus(player);
|
||||
}
|
||||
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(item.getEquipSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance element : unequiped)
|
||||
for (ItemInstance element : player.getInventory().unEquipItemInSlotAndRecord(item.getEquipSlot()))
|
||||
{
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
player.sendPacket(iu);
|
||||
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PackageSendableList;
|
||||
|
||||
@ -57,7 +56,6 @@ public class RequestPackageSendableItemList implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemInstance[] items = player.getInventory().getAvailableItems(true);
|
||||
player.sendPacket(new PackageSendableList(items, _objectID, player.getAdena()));
|
||||
player.sendPacket(new PackageSendableList(player.getInventory().getAvailableItems(true), _objectID, player.getAdena()));
|
||||
}
|
||||
}
|
||||
|
@ -137,8 +137,7 @@ public class RequestRefineCancel implements IClientIncomingPacket
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
if (targetItem.isEquipped())
|
||||
{
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot());
|
||||
for (ItemInstance itm : unequiped)
|
||||
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -97,7 +99,7 @@ public class RequestUnEquipItem implements IClientIncomingPacket
|
||||
item.getAugmentation().removeBonus(player);
|
||||
}
|
||||
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
|
||||
final List<ItemInstance> unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
|
||||
|
||||
// show the update in the inventory
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
@ -107,23 +109,23 @@ public class RequestUnEquipItem implements IClientIncomingPacket
|
||||
iu.addModifiedItem(element);
|
||||
}
|
||||
player.sendPacket(iu);
|
||||
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// this can be 0 if the user pressed the right mouse button twice very fast
|
||||
if (unequiped.length > 0)
|
||||
if (!unequiped.isEmpty())
|
||||
{
|
||||
SystemMessage sm = null;
|
||||
if (unequiped[0].getEnchantLevel() > 0)
|
||||
final ItemInstance unequippedItem = unequiped.get(0);
|
||||
if (unequippedItem.getEnchantLevel() > 0)
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addNumber(unequiped[0].getEnchantLevel());
|
||||
sm.addItemName(unequiped[0].getItemId());
|
||||
sm.addNumber(unequippedItem.getEnchantLevel());
|
||||
sm.addItemName(unequippedItem.getItemId());
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_DISARMED);
|
||||
sm.addItemName(unequiped[0].getItemId());
|
||||
sm.addItemName(unequippedItem.getItemId());
|
||||
}
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@ -145,9 +144,6 @@ public class UseItem implements IClientIncomingPacket
|
||||
player.cancelActiveTrade();
|
||||
}
|
||||
|
||||
// NOTE: disabled due to deadlocks
|
||||
// synchronized (activeChar.getInventory())
|
||||
// {
|
||||
if (item.isWear())
|
||||
{
|
||||
// No unequipping wear-items
|
||||
@ -429,7 +425,7 @@ public class UseItem implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
// Equip or unEquip
|
||||
ItemInstance[] items = null;
|
||||
List<ItemInstance> items = null;
|
||||
final boolean isEquiped = item.isEquipped();
|
||||
SystemMessage sm = null;
|
||||
if (item.getItem().getType2() == Item.TYPE2_WEAPON)
|
||||
@ -645,13 +641,13 @@ public class UseItem implements IClientIncomingPacket
|
||||
{
|
||||
player.broadcastUserInfo();
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addItems(Arrays.asList(items));
|
||||
iu.addItems(items);
|
||||
player.sendPacket(iu);
|
||||
}
|
||||
else if ((item.getItem().getBodyPart() & Item.SLOT_HEAD) > 0)
|
||||
{
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addItems(Arrays.asList(items));
|
||||
iu.addItems(items);
|
||||
player.sendPacket(iu);
|
||||
player.sendPacket(new UserInfo(player));
|
||||
}
|
||||
@ -685,6 +681,5 @@ public class UseItem implements IClientIncomingPacket
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
@ -16,6 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
@ -25,11 +27,11 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
*/
|
||||
public class PackageSendableList implements IClientOutgoingPacket
|
||||
{
|
||||
private final ItemInstance[] _items;
|
||||
private final List<ItemInstance> _items;
|
||||
private final int _playerObjId;
|
||||
private final int _adena;
|
||||
|
||||
public PackageSendableList(ItemInstance[] items, int playerObjId, int adena)
|
||||
public PackageSendableList(List<ItemInstance> items, int playerObjId, int adena)
|
||||
{
|
||||
_items = items;
|
||||
_playerObjId = playerObjId;
|
||||
@ -43,7 +45,7 @@ public class PackageSendableList implements IClientOutgoingPacket
|
||||
|
||||
packet.writeD(_playerObjId);
|
||||
packet.writeD(_adena);
|
||||
packet.writeD(_items.length);
|
||||
packet.writeD(_items.size());
|
||||
for (ItemInstance item : _items) // format inside the for taken from SellList part use should be about the same
|
||||
{
|
||||
packet.writeH(item.getItem().getType1());
|
||||
|
@ -16,6 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.TradeList;
|
||||
@ -30,7 +32,7 @@ public class PrivateStoreManageListBuy implements IClientOutgoingPacket
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
private int _playerAdena;
|
||||
private final ItemInstance[] _itemList;
|
||||
private final List<ItemInstance> _itemList;
|
||||
private final TradeList.TradeItem[] _buyList;
|
||||
|
||||
public PrivateStoreManageListBuy(PlayerInstance player)
|
||||
@ -58,7 +60,7 @@ public class PrivateStoreManageListBuy implements IClientOutgoingPacket
|
||||
packet.writeD(_playerAdena);
|
||||
|
||||
// section2
|
||||
packet.writeD(_itemList.length); // inventory items for potential buy
|
||||
packet.writeD(_itemList.size()); // inventory items for potential buy
|
||||
for (ItemInstance item : _itemList)
|
||||
{
|
||||
packet.writeD(item.getItemId());
|
||||
|
@ -16,6 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.TradeList.TradeItem;
|
||||
@ -35,7 +37,7 @@ public class PrivateStoreManageListSell implements IClientOutgoingPacket
|
||||
private final PlayerInstance _player;
|
||||
private int _playerAdena;
|
||||
private final boolean _packageSale;
|
||||
private final TradeItem[] _itemList;
|
||||
private final List<TradeItem> _itemList;
|
||||
private final TradeItem[] _sellList;
|
||||
|
||||
public PrivateStoreManageListSell(PlayerInstance player)
|
||||
@ -69,7 +71,7 @@ public class PrivateStoreManageListSell implements IClientOutgoingPacket
|
||||
packet.writeD(_playerAdena);
|
||||
|
||||
// section2
|
||||
packet.writeD(_itemList.length); // for potential sells
|
||||
packet.writeD(_itemList.size()); // for potential sells
|
||||
for (TradeItem item : _itemList)
|
||||
{
|
||||
packet.writeD(item.getItem().getType2());
|
||||
|
@ -16,6 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
@ -27,7 +29,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
public class TradeStart implements IClientOutgoingPacket
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
private final ItemInstance[] _itemList;
|
||||
private final List<ItemInstance> _itemList;
|
||||
|
||||
public TradeStart(PlayerInstance player)
|
||||
{
|
||||
@ -47,7 +49,7 @@ public class TradeStart implements IClientOutgoingPacket
|
||||
OutgoingPackets.TRADE_START.writeId(packet);
|
||||
packet.writeD(_player.getActiveTradeList().getPartner().getObjectId());
|
||||
// writeD((_activeChar != null || _activeChar.getTransactionRequester() != null)? _activeChar.getTransactionRequester().getObjectId() : 0);
|
||||
packet.writeH(_itemList.length);
|
||||
packet.writeH(_itemList.size());
|
||||
for (ItemInstance item : _itemList)// int i = 0; i < count; i++)
|
||||
{
|
||||
packet.writeH(item.getItem().getType1()); // item type1
|
||||
|
Reference in New Issue
Block a user