Inventory concurrency related adjustments.
This commit is contained in:
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -684,6 +686,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -713,9 +730,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -684,6 +686,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -713,9 +730,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -2296,8 +2296,7 @@ public class Attackable extends NpcInstance
|
|||||||
|
|
||||||
crystalQTY = 0;
|
crystalQTY = 0;
|
||||||
|
|
||||||
final ItemInstance[] inv = player.getInventory().getItems();
|
for (ItemInstance item : player.getInventory().getItems())
|
||||||
for (ItemInstance item : inv)
|
|
||||||
{
|
{
|
||||||
final int itemId = item.getItemId();
|
final int itemId = item.getItemId();
|
||||||
for (int id : SoulCrystal.SOUL_CRYSTAL_TABLE)
|
for (int id : SoulCrystal.SOUL_CRYSTAL_TABLE)
|
||||||
|
@@ -659,9 +659,7 @@ public class PetInstance extends Summon
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Inventory petInventory = _inventory;
|
for (ItemInstance item : _inventory.getItems())
|
||||||
final ItemInstance[] items = petInventory.getItems();
|
|
||||||
for (ItemInstance item : items)
|
|
||||||
{
|
{
|
||||||
final ItemInstance giveit = item;
|
final ItemInstance giveit = item;
|
||||||
if (((giveit.getItem().getWeight() * giveit.getCount()) + getOwner().getInventory().getTotalWeight()) < getOwner().getMaxLoad())
|
if (((giveit.getItem().getWeight() * giveit.getCount()) + getOwner().getInventory().getTotalWeight()) < getOwner().getMaxLoad())
|
||||||
@@ -754,8 +752,7 @@ public class PetInstance extends Summon
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final ItemInstance[] items = _inventory.getItems();
|
for (ItemInstance item : _inventory.getItems())
|
||||||
for (ItemInstance item : items)
|
|
||||||
{
|
{
|
||||||
dropItemHere(item);
|
dropItemHere(item);
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,10 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -42,12 +45,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items;
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
|
|
||||||
protected ItemContainer()
|
|
||||||
{
|
|
||||||
_items = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract Creature getOwner();
|
protected abstract Creature getOwner();
|
||||||
|
|
||||||
@@ -75,12 +73,9 @@ public abstract class ItemContainer
|
|||||||
* Returns the list of items in inventory
|
* Returns the list of items in inventory
|
||||||
* @return ItemInstance : items in inventory
|
* @return ItemInstance : items in inventory
|
||||||
*/
|
*/
|
||||||
public ItemInstance[] getItems()
|
public Collection<ItemInstance> getItems()
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items;
|
||||||
{
|
|
||||||
return _items.toArray(new ItemInstance[_items.size()]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -495,7 +490,7 @@ public abstract class ItemContainer
|
|||||||
* @param actor : PlayerInstance Player requesting the item destroy
|
* @param actor : PlayerInstance Player requesting the item destroy
|
||||||
* @param reference : WorldObject Object referencing current action like NPC selling item or previous item in transformation
|
* @param reference : WorldObject Object referencing current action like NPC selling item or previous item in transformation
|
||||||
*/
|
*/
|
||||||
public synchronized void destroyAllItems(String process, PlayerInstance actor, WorldObject reference)
|
public void destroyAllItems(String process, PlayerInstance actor, WorldObject reference)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
@@ -527,10 +522,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -539,10 +531,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void removeItem(ItemInstance item)
|
protected void removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.remove(item);
|
||||||
{
|
|
||||||
_items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -577,17 +566,13 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void updateDatabase()
|
public void updateDatabase()
|
||||||
{
|
{
|
||||||
if (getOwner() != null)
|
if ((getOwner() != null) && (_items != null))
|
||||||
{
|
{
|
||||||
final List<ItemInstance> items = _items;
|
for (ItemInstance item : _items)
|
||||||
if (items != null)
|
|
||||||
{
|
{
|
||||||
for (ItemInstance item : items)
|
if (item != null)
|
||||||
{
|
{
|
||||||
if (item != null)
|
item.updateDatabase();
|
||||||
{
|
|
||||||
item.updateDatabase();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package org.l2jmobius.gameserver.model.itemcontainer;
|
package org.l2jmobius.gameserver.model.itemcontainer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
@@ -78,17 +79,17 @@ public class PlayerFreight extends ItemContainer
|
|||||||
* @return ItemInstance : items in inventory
|
* @return ItemInstance : items in inventory
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemInstance[] getItems()
|
public Collection<ItemInstance> getItems()
|
||||||
{
|
{
|
||||||
final List<ItemInstance> list = new ArrayList<>();
|
final List<ItemInstance> result = new ArrayList<>();
|
||||||
for (ItemInstance item : _items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
if ((item.getEquipSlot() == 0) || (item.getEquipSlot() == _activeLocationId))
|
if ((item.getEquipSlot() == 0) || (item.getEquipSlot() == _activeLocationId))
|
||||||
{
|
{
|
||||||
list.add(item);
|
result.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list.toArray(new ItemInstance[list.size()]);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
@@ -26,7 +28,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
|||||||
*/
|
*/
|
||||||
public class GMViewItemList implements IClientOutgoingPacket
|
public class GMViewItemList implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final ItemInstance[] _items;
|
private final Collection<ItemInstance> _items;
|
||||||
private final PlayerInstance _player;
|
private final PlayerInstance _player;
|
||||||
private final String _playerName;
|
private final String _playerName;
|
||||||
|
|
||||||
@@ -44,7 +46,7 @@ public class GMViewItemList implements IClientOutgoingPacket
|
|||||||
packet.writeS(_playerName);
|
packet.writeS(_playerName);
|
||||||
packet.writeD(_player.getInventoryLimit()); // inventory limit
|
packet.writeD(_player.getInventoryLimit()); // inventory limit
|
||||||
packet.writeH(0x01); // show window ??
|
packet.writeH(0x01); // show window ??
|
||||||
packet.writeH(_items.length);
|
packet.writeH(_items.size());
|
||||||
|
|
||||||
for (ItemInstance temp : _items)
|
for (ItemInstance temp : _items)
|
||||||
{
|
{
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.Item;
|
import org.l2jmobius.gameserver.model.items.Item;
|
||||||
@@ -29,7 +31,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
|||||||
*/
|
*/
|
||||||
public class GMViewWarehouseWithdrawList implements IClientOutgoingPacket
|
public class GMViewWarehouseWithdrawList implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final ItemInstance[] _items;
|
private final Collection<ItemInstance> _items;
|
||||||
private final String _playerName;
|
private final String _playerName;
|
||||||
private final PlayerInstance _player;
|
private final PlayerInstance _player;
|
||||||
private final int _money;
|
private final int _money;
|
||||||
@@ -48,7 +50,7 @@ public class GMViewWarehouseWithdrawList implements IClientOutgoingPacket
|
|||||||
OutgoingPackets.GM_VIEW_WAREHOUSE_WITHDRAW_LIST.writeId(packet);
|
OutgoingPackets.GM_VIEW_WAREHOUSE_WITHDRAW_LIST.writeId(packet);
|
||||||
packet.writeS(_playerName);
|
packet.writeS(_playerName);
|
||||||
packet.writeD(_money);
|
packet.writeD(_money);
|
||||||
packet.writeH(_items.length);
|
packet.writeH(_items.size());
|
||||||
|
|
||||||
for (ItemInstance item : _items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
@@ -29,7 +31,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
|||||||
*/
|
*/
|
||||||
public class ItemList implements IClientOutgoingPacket
|
public class ItemList implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final ItemInstance[] _items;
|
private final Collection<ItemInstance> _items;
|
||||||
private final boolean _showWindow;
|
private final boolean _showWindow;
|
||||||
|
|
||||||
public ItemList(PlayerInstance player, boolean showWindow)
|
public ItemList(PlayerInstance player, boolean showWindow)
|
||||||
@@ -38,7 +40,7 @@ public class ItemList implements IClientOutgoingPacket
|
|||||||
_showWindow = showWindow;
|
_showWindow = showWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemList(ItemInstance[] items, boolean showWindow)
|
public ItemList(Collection<ItemInstance> items, boolean showWindow)
|
||||||
{
|
{
|
||||||
_items = items;
|
_items = items;
|
||||||
_showWindow = showWindow;
|
_showWindow = showWindow;
|
||||||
@@ -49,7 +51,7 @@ public class ItemList implements IClientOutgoingPacket
|
|||||||
{
|
{
|
||||||
OutgoingPackets.ITEM_LIST.writeId(packet);
|
OutgoingPackets.ITEM_LIST.writeId(packet);
|
||||||
packet.writeH(_showWindow ? 0x01 : 0x00);
|
packet.writeH(_showWindow ? 0x01 : 0x00);
|
||||||
packet.writeH(_items.length);
|
packet.writeH(_items.size());
|
||||||
for (ItemInstance temp : _items)
|
for (ItemInstance temp : _items)
|
||||||
{
|
{
|
||||||
if ((temp == null) || (temp.getItem() == null))
|
if ((temp == null) || (temp.getItem() == null))
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
@@ -26,11 +28,11 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
|||||||
*/
|
*/
|
||||||
public class PetItemList implements IClientOutgoingPacket
|
public class PetItemList implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final PetInstance _activeChar;
|
private final Collection<ItemInstance> _items;
|
||||||
|
|
||||||
public PetItemList(PetInstance character)
|
public PetItemList(PetInstance character)
|
||||||
{
|
{
|
||||||
_activeChar = character;
|
_items = character.getInventory().getItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,11 +40,8 @@ public class PetItemList implements IClientOutgoingPacket
|
|||||||
{
|
{
|
||||||
OutgoingPackets.PET_ITEM_LIST.writeId(packet);
|
OutgoingPackets.PET_ITEM_LIST.writeId(packet);
|
||||||
|
|
||||||
final ItemInstance[] items = _activeChar.getInventory().getItems();
|
packet.writeH(_items.size());
|
||||||
final int count = items.length;
|
for (ItemInstance temp : _items)
|
||||||
packet.writeH(count);
|
|
||||||
|
|
||||||
for (ItemInstance temp : items)
|
|
||||||
{
|
{
|
||||||
packet.writeH(temp.getItem().getType1()); // item type1
|
packet.writeH(temp.getItem().getType1()); // item type1
|
||||||
packet.writeD(temp.getObjectId());
|
packet.writeD(temp.getObjectId());
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.TradeList;
|
import org.l2jmobius.gameserver.model.TradeList;
|
||||||
import org.l2jmobius.gameserver.model.TradeList.TradeItem;
|
import org.l2jmobius.gameserver.model.TradeList.TradeItem;
|
||||||
@@ -28,7 +30,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
|||||||
*/
|
*/
|
||||||
public class TradeUpdate implements IClientOutgoingPacket
|
public class TradeUpdate implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final ItemInstance[] _items;
|
private final Collection<ItemInstance> _items;
|
||||||
private final TradeItem[] _tradeItems;
|
private final TradeItem[] _tradeItems;
|
||||||
|
|
||||||
public TradeUpdate(TradeList trade, PlayerInstance player)
|
public TradeUpdate(TradeList trade, PlayerInstance player)
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
@@ -34,7 +36,7 @@ public class WareHouseWithdrawalList implements IClientOutgoingPacket
|
|||||||
|
|
||||||
private PlayerInstance _player;
|
private PlayerInstance _player;
|
||||||
private int _playerAdena;
|
private int _playerAdena;
|
||||||
private ItemInstance[] _items;
|
private Collection<ItemInstance> _items;
|
||||||
private int _whType;
|
private int _whType;
|
||||||
|
|
||||||
public WareHouseWithdrawalList(PlayerInstance player, int type)
|
public WareHouseWithdrawalList(PlayerInstance player, int type)
|
||||||
@@ -60,8 +62,7 @@ public class WareHouseWithdrawalList implements IClientOutgoingPacket
|
|||||||
*/
|
*/
|
||||||
packet.writeH(_whType);
|
packet.writeH(_whType);
|
||||||
packet.writeD(_playerAdena);
|
packet.writeD(_playerAdena);
|
||||||
packet.writeH(_items.length);
|
packet.writeH(_items.size());
|
||||||
|
|
||||||
for (ItemInstance item : _items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
packet.writeH(item.getItem().getType1()); // item type1 //unconfirmed, works
|
packet.writeH(item.getItem().getType1()); // item type1 //unconfirmed, works
|
||||||
|
@@ -2648,8 +2648,7 @@ public class Attackable extends NpcInstance
|
|||||||
|
|
||||||
crystalQTY = 0;
|
crystalQTY = 0;
|
||||||
|
|
||||||
final ItemInstance[] inv = player.getInventory().getItems();
|
for (ItemInstance item : player.getInventory().getItems())
|
||||||
for (ItemInstance item : inv)
|
|
||||||
{
|
{
|
||||||
final int itemId = item.getItemId();
|
final int itemId = item.getItemId();
|
||||||
for (int id : SoulCrystal.SOUL_CRYSTAL_TABLE)
|
for (int id : SoulCrystal.SOUL_CRYSTAL_TABLE)
|
||||||
|
@@ -668,9 +668,7 @@ public class PetInstance extends Summon
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Inventory petInventory = _inventory;
|
for (ItemInstance item : _inventory.getItems())
|
||||||
final ItemInstance[] items = petInventory.getItems();
|
|
||||||
for (ItemInstance item : items)
|
|
||||||
{
|
{
|
||||||
final ItemInstance giveit = item;
|
final ItemInstance giveit = item;
|
||||||
if (((giveit.getItem().getWeight() * giveit.getCount()) + getOwner().getInventory().getTotalWeight()) < getOwner().getMaxLoad())
|
if (((giveit.getItem().getWeight() * giveit.getCount()) + getOwner().getInventory().getTotalWeight()) < getOwner().getMaxLoad())
|
||||||
@@ -763,8 +761,7 @@ public class PetInstance extends Summon
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final ItemInstance[] items = _inventory.getItems();
|
for (ItemInstance item : _inventory.getItems())
|
||||||
for (ItemInstance item : items)
|
|
||||||
{
|
{
|
||||||
dropItemHere(item);
|
dropItemHere(item);
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,10 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
@@ -42,12 +45,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items;
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
|
|
||||||
protected ItemContainer()
|
|
||||||
{
|
|
||||||
_items = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract Creature getOwner();
|
protected abstract Creature getOwner();
|
||||||
|
|
||||||
@@ -75,12 +73,9 @@ public abstract class ItemContainer
|
|||||||
* Returns the list of items in inventory
|
* Returns the list of items in inventory
|
||||||
* @return ItemInstance : items in inventory
|
* @return ItemInstance : items in inventory
|
||||||
*/
|
*/
|
||||||
public ItemInstance[] getItems()
|
public Collection<ItemInstance> getItems()
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items;
|
||||||
{
|
|
||||||
return _items.toArray(new ItemInstance[_items.size()]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -498,7 +493,7 @@ public abstract class ItemContainer
|
|||||||
* @param actor : PlayerInstance Player requesting the item destroy
|
* @param actor : PlayerInstance Player requesting the item destroy
|
||||||
* @param reference : WorldObject Object referencing current action like NPC selling item or previous item in transformation
|
* @param reference : WorldObject Object referencing current action like NPC selling item or previous item in transformation
|
||||||
*/
|
*/
|
||||||
public synchronized void destroyAllItems(String process, PlayerInstance actor, WorldObject reference)
|
public void destroyAllItems(String process, PlayerInstance actor, WorldObject reference)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
@@ -530,10 +525,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -542,10 +534,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void removeItem(ItemInstance item)
|
protected void removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.remove(item);
|
||||||
{
|
|
||||||
_items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -580,17 +569,13 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void updateDatabase()
|
public void updateDatabase()
|
||||||
{
|
{
|
||||||
if (getOwner() != null)
|
if ((getOwner() != null) && (_items != null))
|
||||||
{
|
{
|
||||||
final List<ItemInstance> items = _items;
|
for (ItemInstance item : _items)
|
||||||
if (items != null)
|
|
||||||
{
|
{
|
||||||
for (ItemInstance item : items)
|
if (item != null)
|
||||||
{
|
{
|
||||||
if (item != null)
|
item.updateDatabase();
|
||||||
{
|
|
||||||
item.updateDatabase();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package org.l2jmobius.gameserver.model.itemcontainer;
|
package org.l2jmobius.gameserver.model.itemcontainer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
@@ -78,17 +79,17 @@ public class PlayerFreight extends ItemContainer
|
|||||||
* @return ItemInstance : items in inventory
|
* @return ItemInstance : items in inventory
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemInstance[] getItems()
|
public Collection<ItemInstance> getItems()
|
||||||
{
|
{
|
||||||
final List<ItemInstance> list = new ArrayList<>();
|
final List<ItemInstance> result = new ArrayList<>();
|
||||||
for (ItemInstance item : _items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
if ((item.getEquipSlot() == 0) || (item.getEquipSlot() == _activeLocationId))
|
if ((item.getEquipSlot() == 0) || (item.getEquipSlot() == _activeLocationId))
|
||||||
{
|
{
|
||||||
list.add(item);
|
result.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list.toArray(new ItemInstance[list.size()]);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
@@ -26,7 +28,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
|||||||
*/
|
*/
|
||||||
public class GMViewItemList implements IClientOutgoingPacket
|
public class GMViewItemList implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final ItemInstance[] _items;
|
private final Collection<ItemInstance> _items;
|
||||||
private final PlayerInstance _player;
|
private final PlayerInstance _player;
|
||||||
private final String _playerName;
|
private final String _playerName;
|
||||||
|
|
||||||
@@ -44,7 +46,7 @@ public class GMViewItemList implements IClientOutgoingPacket
|
|||||||
packet.writeS(_playerName);
|
packet.writeS(_playerName);
|
||||||
packet.writeD(_player.getInventoryLimit()); // inventory limit
|
packet.writeD(_player.getInventoryLimit()); // inventory limit
|
||||||
packet.writeH(0x01); // show window ??
|
packet.writeH(0x01); // show window ??
|
||||||
packet.writeH(_items.length);
|
packet.writeH(_items.size());
|
||||||
|
|
||||||
for (ItemInstance temp : _items)
|
for (ItemInstance temp : _items)
|
||||||
{
|
{
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.Item;
|
import org.l2jmobius.gameserver.model.items.Item;
|
||||||
@@ -29,7 +31,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
|||||||
*/
|
*/
|
||||||
public class GMViewWarehouseWithdrawList implements IClientOutgoingPacket
|
public class GMViewWarehouseWithdrawList implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final ItemInstance[] _items;
|
private final Collection<ItemInstance> _items;
|
||||||
private final String _playerName;
|
private final String _playerName;
|
||||||
private final PlayerInstance _player;
|
private final PlayerInstance _player;
|
||||||
private final int _money;
|
private final int _money;
|
||||||
@@ -48,7 +50,7 @@ public class GMViewWarehouseWithdrawList implements IClientOutgoingPacket
|
|||||||
OutgoingPackets.GM_VIEW_WAREHOUSE_WITHDRAW_LIST.writeId(packet);
|
OutgoingPackets.GM_VIEW_WAREHOUSE_WITHDRAW_LIST.writeId(packet);
|
||||||
packet.writeS(_playerName);
|
packet.writeS(_playerName);
|
||||||
packet.writeD(_money);
|
packet.writeD(_money);
|
||||||
packet.writeH(_items.length);
|
packet.writeH(_items.size());
|
||||||
|
|
||||||
for (ItemInstance item : _items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
@@ -29,7 +31,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
|||||||
*/
|
*/
|
||||||
public class ItemList implements IClientOutgoingPacket
|
public class ItemList implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final ItemInstance[] _items;
|
private final Collection<ItemInstance> _items;
|
||||||
private final boolean _showWindow;
|
private final boolean _showWindow;
|
||||||
|
|
||||||
public ItemList(PlayerInstance player, boolean showWindow)
|
public ItemList(PlayerInstance player, boolean showWindow)
|
||||||
@@ -38,7 +40,7 @@ public class ItemList implements IClientOutgoingPacket
|
|||||||
_showWindow = showWindow;
|
_showWindow = showWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemList(ItemInstance[] items, boolean showWindow)
|
public ItemList(Collection<ItemInstance> items, boolean showWindow)
|
||||||
{
|
{
|
||||||
_items = items;
|
_items = items;
|
||||||
_showWindow = showWindow;
|
_showWindow = showWindow;
|
||||||
@@ -49,7 +51,7 @@ public class ItemList implements IClientOutgoingPacket
|
|||||||
{
|
{
|
||||||
OutgoingPackets.ITEM_LIST.writeId(packet);
|
OutgoingPackets.ITEM_LIST.writeId(packet);
|
||||||
packet.writeH(_showWindow ? 0x01 : 0x00);
|
packet.writeH(_showWindow ? 0x01 : 0x00);
|
||||||
packet.writeH(_items.length);
|
packet.writeH(_items.size());
|
||||||
for (ItemInstance temp : _items)
|
for (ItemInstance temp : _items)
|
||||||
{
|
{
|
||||||
if ((temp == null) || (temp.getItem() == null))
|
if ((temp == null) || (temp.getItem() == null))
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
@@ -26,11 +28,11 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
|||||||
*/
|
*/
|
||||||
public class PetItemList implements IClientOutgoingPacket
|
public class PetItemList implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final PetInstance _activeChar;
|
private final Collection<ItemInstance> _items;
|
||||||
|
|
||||||
public PetItemList(PetInstance character)
|
public PetItemList(PetInstance character)
|
||||||
{
|
{
|
||||||
_activeChar = character;
|
_items = character.getInventory().getItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,11 +40,8 @@ public class PetItemList implements IClientOutgoingPacket
|
|||||||
{
|
{
|
||||||
OutgoingPackets.PET_ITEM_LIST.writeId(packet);
|
OutgoingPackets.PET_ITEM_LIST.writeId(packet);
|
||||||
|
|
||||||
final ItemInstance[] items = _activeChar.getInventory().getItems();
|
packet.writeH(_items.size());
|
||||||
final int count = items.length;
|
for (ItemInstance temp : _items)
|
||||||
packet.writeH(count);
|
|
||||||
|
|
||||||
for (ItemInstance temp : items)
|
|
||||||
{
|
{
|
||||||
packet.writeH(temp.getItem().getType1()); // item type1
|
packet.writeH(temp.getItem().getType1()); // item type1
|
||||||
packet.writeD(temp.getObjectId());
|
packet.writeD(temp.getObjectId());
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.TradeList;
|
import org.l2jmobius.gameserver.model.TradeList;
|
||||||
import org.l2jmobius.gameserver.model.TradeList.TradeItem;
|
import org.l2jmobius.gameserver.model.TradeList.TradeItem;
|
||||||
@@ -28,7 +30,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
|||||||
*/
|
*/
|
||||||
public class TradeUpdate implements IClientOutgoingPacket
|
public class TradeUpdate implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final ItemInstance[] _items;
|
private final Collection<ItemInstance> _items;
|
||||||
private final TradeItem[] _tradeItems;
|
private final TradeItem[] _tradeItems;
|
||||||
|
|
||||||
public TradeUpdate(TradeList trade, PlayerInstance player)
|
public TradeUpdate(TradeList trade, PlayerInstance player)
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.serverpackets;
|
package org.l2jmobius.gameserver.network.serverpackets;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
@@ -34,7 +36,7 @@ public class WareHouseWithdrawalList implements IClientOutgoingPacket
|
|||||||
|
|
||||||
private PlayerInstance _player;
|
private PlayerInstance _player;
|
||||||
private int _playerAdena;
|
private int _playerAdena;
|
||||||
private ItemInstance[] _items;
|
private Collection<ItemInstance> _items;
|
||||||
private int _whType;
|
private int _whType;
|
||||||
|
|
||||||
public WareHouseWithdrawalList(PlayerInstance player, int type)
|
public WareHouseWithdrawalList(PlayerInstance player, int type)
|
||||||
@@ -60,8 +62,7 @@ public class WareHouseWithdrawalList implements IClientOutgoingPacket
|
|||||||
*/
|
*/
|
||||||
packet.writeH(_whType);
|
packet.writeH(_whType);
|
||||||
packet.writeD(_playerAdena);
|
packet.writeD(_playerAdena);
|
||||||
packet.writeH(_items.length);
|
packet.writeH(_items.size());
|
||||||
|
|
||||||
for (ItemInstance item : _items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
packet.writeH(item.getItem().getType1()); // item type1 //unconfirmed, works
|
packet.writeH(item.getItem().getType1()); // item type1 //unconfirmed, works
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -483,12 +468,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,15 +495,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -531,15 +505,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -22,6 +22,7 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private final PlayerInstance _owner;
|
private final PlayerInstance _owner;
|
||||||
private ItemInstance _adena;
|
private ItemInstance _adena;
|
||||||
private ItemInstance _ancientAdena;
|
private ItemInstance _ancientAdena;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
private int[] _blockItems = null;
|
private int[] _blockItems = null;
|
||||||
|
|
||||||
@@ -674,6 +676,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -699,9 +716,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_ancientAdena = null;
|
_ancientAdena = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -483,12 +468,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,15 +495,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -531,15 +505,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -22,6 +22,7 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private final PlayerInstance _owner;
|
private final PlayerInstance _owner;
|
||||||
private ItemInstance _adena;
|
private ItemInstance _adena;
|
||||||
private ItemInstance _ancientAdena;
|
private ItemInstance _ancientAdena;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
private int[] _blockItems = null;
|
private int[] _blockItems = null;
|
||||||
|
|
||||||
@@ -674,6 +676,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -699,9 +716,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_ancientAdena = null;
|
_ancientAdena = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -683,6 +685,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -712,9 +729,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -691,6 +693,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -720,9 +737,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
@@ -22,6 +22,8 @@ import java.sql.ResultSet;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public abstract class ItemContainer
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(ItemContainer.class.getName());
|
||||||
|
|
||||||
protected final List<ItemInstance> _items = new ArrayList<>(1);
|
protected final Set<ItemInstance> _items = ConcurrentHashMap.newKeySet(1);
|
||||||
private int _questItemSize = 0;
|
|
||||||
|
|
||||||
protected ItemContainer()
|
protected ItemContainer()
|
||||||
{
|
{
|
||||||
@@ -74,22 +75,6 @@ public abstract class ItemContainer
|
|||||||
return _items.size();
|
return _items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of quest items in the inventory
|
|
||||||
*/
|
|
||||||
public int getQuestSize()
|
|
||||||
{
|
|
||||||
return _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the quantity of items in the inventory
|
|
||||||
*/
|
|
||||||
public int getNonQuestSize()
|
|
||||||
{
|
|
||||||
return _items.size() - _questItemSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the items in inventory.
|
* Gets the items in inventory.
|
||||||
* @return the items in inventory.
|
* @return the items in inventory.
|
||||||
@@ -538,12 +523,9 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
public void destroyAllItems(String process, PlayerInstance actor, Object reference)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
for (ItemInstance item : _items)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : _items)
|
destroyItem(process, item, actor, reference);
|
||||||
{
|
|
||||||
destroyItem(process, item, actor, reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,15 +562,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected void addItem(ItemInstance item)
|
protected void addItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
_items.add(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_items.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -598,15 +572,7 @@ public abstract class ItemContainer
|
|||||||
*/
|
*/
|
||||||
protected boolean removeItem(ItemInstance item)
|
protected boolean removeItem(ItemInstance item)
|
||||||
{
|
{
|
||||||
synchronized (_items)
|
return _items.remove(item);
|
||||||
{
|
|
||||||
if (item.isQuestItem())
|
|
||||||
{
|
|
||||||
_questItemSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _items.remove(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ public class PlayerInventory extends Inventory
|
|||||||
private ItemInstance _beautyTickets;
|
private ItemInstance _beautyTickets;
|
||||||
private Collection<Integer> _blockItems = null;
|
private Collection<Integer> _blockItems = null;
|
||||||
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
private InventoryBlockType _blockMode = InventoryBlockType.NONE;
|
||||||
|
private final AtomicInteger _questItemSize = new AtomicInteger();
|
||||||
|
|
||||||
public PlayerInventory(PlayerInstance owner)
|
public PlayerInventory(PlayerInstance owner)
|
||||||
{
|
{
|
||||||
@@ -691,6 +693,21 @@ public class PlayerInventory extends Inventory
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds item to inventory for further adjustments.
|
||||||
|
* @param item : ItemInstance to be added from inventory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addItem(ItemInstance item)
|
||||||
|
{
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
* <b>Overloaded</b>, when removes item from inventory, remove also owner shortcuts.
|
||||||
* @param item : ItemInstance to be removed from inventory
|
* @param item : ItemInstance to be removed from inventory
|
||||||
@@ -720,9 +737,30 @@ public class PlayerInventory extends Inventory
|
|||||||
_beautyTickets = null;
|
_beautyTickets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.isQuestItem())
|
||||||
|
{
|
||||||
|
_questItemSize.decrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
return super.removeItem(item);
|
return super.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of quest items in the inventory
|
||||||
|
*/
|
||||||
|
public int getQuestSize()
|
||||||
|
{
|
||||||
|
return _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the quantity of items in the inventory
|
||||||
|
*/
|
||||||
|
public int getNonQuestSize()
|
||||||
|
{
|
||||||
|
return _items.size() - _questItemSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the weight of equipment loaded
|
* Refresh the weight of equipment loaded
|
||||||
*/
|
*/
|
||||||
|
@@ -61,8 +61,8 @@ public class PlayerRefund extends ItemContainer
|
|||||||
{
|
{
|
||||||
if (getSize() > 12)
|
if (getSize() > 12)
|
||||||
{
|
{
|
||||||
final ItemInstance removedItem = _items.remove(0);
|
final ItemInstance removedItem = _items.stream().findFirst().get();
|
||||||
if (removedItem != null)
|
if (_items.remove(removedItem))
|
||||||
{
|
{
|
||||||
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
ItemTable.getInstance().destroyItem("ClearRefund", removedItem, getOwner(), null);
|
||||||
removedItem.updateDatabase(true);
|
removedItem.updateDatabase(true);
|
||||||
|
Reference in New Issue
Block a user