Prevent flood from using items with skills.

This commit is contained in:
MobiusDevelopment
2022-02-03 22:05:30 +00:00
parent 9ba9ae38af
commit e0dc88e351
84 changed files with 1260 additions and 803 deletions
@@ -563,13 +563,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4646,6 +4647,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5596,16 +5614,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -662,7 +662,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -75,7 +75,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1330,12 +1330,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1347,6 +1354,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1359,14 +1367,24 @@ public abstract class Inventory extends ItemContainer
}
old.updateDatabase();
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1402,6 +1420,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1702,7 +1739,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_R_BRACELET:
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_DECO:
@@ -1718,7 +1754,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_BROOCH:
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_BROOCH_JEWEL:
@@ -1744,26 +1779,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -565,13 +565,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4648,6 +4649,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5598,16 +5616,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -664,7 +664,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -75,7 +75,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1336,12 +1336,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1353,6 +1360,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1365,14 +1373,24 @@ public abstract class Inventory extends ItemContainer
}
old.updateDatabase();
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1408,6 +1426,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1708,7 +1745,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_R_BRACELET:
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_DECO:
@@ -1724,7 +1760,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_BROOCH:
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_BROOCH_JEWEL:
@@ -1750,26 +1785,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -567,13 +567,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4650,6 +4651,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5600,16 +5618,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -664,7 +664,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -75,7 +75,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1336,12 +1336,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1353,6 +1360,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1365,14 +1373,24 @@ public abstract class Inventory extends ItemContainer
}
old.updateDatabase();
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1408,6 +1426,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1708,7 +1745,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_R_BRACELET:
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_DECO:
@@ -1724,7 +1760,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_BROOCH:
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_BROOCH_JEWEL:
@@ -1750,26 +1785,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -571,13 +571,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, Long> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4646,6 +4647,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5596,16 +5614,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -663,7 +663,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -75,7 +75,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1336,12 +1336,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1353,6 +1360,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1365,14 +1373,24 @@ public abstract class Inventory extends ItemContainer
}
old.updateDatabase();
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1408,6 +1426,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1708,7 +1745,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_R_BRACELET:
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_DECO:
@@ -1724,7 +1760,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_BROOCH:
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_BROOCH_JEWEL:
@@ -1750,26 +1785,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -567,13 +567,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, Long> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4662,6 +4663,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5612,16 +5630,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -670,7 +670,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -77,7 +77,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1379,12 +1379,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1396,6 +1403,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1433,14 +1441,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1511,6 +1529,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1792,12 +1829,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1810,7 +1845,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1837,26 +1871,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -567,13 +567,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, Long> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4662,6 +4663,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5612,16 +5630,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -679,7 +679,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -77,7 +77,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1461,12 +1461,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1478,6 +1485,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1515,14 +1523,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1593,6 +1611,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1903,12 +1940,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1921,7 +1956,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1934,7 +1968,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -1957,26 +1990,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -567,13 +567,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, Long> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4663,6 +4664,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5613,16 +5631,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -679,7 +679,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -77,7 +77,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1461,12 +1461,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1478,6 +1485,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1515,14 +1523,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1593,6 +1611,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1903,12 +1940,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1921,7 +1956,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1934,7 +1968,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -1957,26 +1990,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -581,13 +581,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, Long> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4600,6 +4601,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5578,16 +5596,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -677,7 +677,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -77,7 +77,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1455,12 +1455,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1472,6 +1479,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1509,14 +1517,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1587,6 +1605,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1893,12 +1930,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1911,7 +1946,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1924,7 +1958,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -1942,26 +1975,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -584,13 +584,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, Long> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4617,6 +4618,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5622,16 +5640,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -683,7 +683,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -76,7 +76,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1437,12 +1437,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1454,6 +1461,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1491,14 +1499,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1569,6 +1587,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1875,12 +1912,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1893,7 +1928,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1906,7 +1940,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -1924,26 +1957,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -597,13 +597,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, Long> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4634,6 +4635,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5639,16 +5657,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -683,7 +683,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -76,7 +76,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1437,12 +1437,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1454,6 +1461,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1491,14 +1499,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1569,6 +1587,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1875,12 +1912,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1893,7 +1928,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1906,7 +1940,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -1924,26 +1957,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -599,13 +599,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, Long> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4667,6 +4668,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5672,16 +5690,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -683,7 +683,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -77,7 +77,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1448,12 +1448,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1465,6 +1472,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1502,14 +1510,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1580,6 +1598,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1886,12 +1923,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1904,7 +1939,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1917,7 +1951,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -1935,26 +1968,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -565,13 +565,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4623,6 +4624,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5571,16 +5589,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -659,7 +659,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -75,7 +75,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1338,12 +1338,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1355,6 +1362,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1367,14 +1375,24 @@ public abstract class Inventory extends ItemContainer
}
old.updateDatabase();
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1410,6 +1428,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1710,7 +1747,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_R_BRACELET:
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_DECO:
@@ -1726,7 +1762,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_BROOCH:
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_BROOCH_JEWEL:
@@ -1752,26 +1787,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -565,13 +565,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4623,6 +4624,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5571,16 +5589,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -663,7 +663,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -75,7 +75,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1338,12 +1338,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1355,6 +1362,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1367,14 +1375,24 @@ public abstract class Inventory extends ItemContainer
}
old.updateDatabase();
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1410,6 +1428,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1710,7 +1747,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_R_BRACELET:
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_DECO:
@@ -1726,7 +1762,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_BROOCH:
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_BROOCH_JEWEL:
@@ -1752,26 +1787,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -563,13 +563,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4608,6 +4609,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5556,16 +5574,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -672,7 +672,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -77,7 +77,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1381,12 +1381,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1398,6 +1405,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1435,14 +1443,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1513,6 +1531,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1794,12 +1831,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1812,7 +1847,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1842,26 +1876,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -571,13 +571,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4622,6 +4623,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5570,16 +5588,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -707,7 +707,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -77,7 +77,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1463,12 +1463,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1480,6 +1487,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1517,14 +1525,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1595,6 +1613,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1905,12 +1942,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1923,7 +1958,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1936,7 +1970,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -1959,26 +1992,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -571,13 +571,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4622,6 +4623,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5570,16 +5588,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -707,7 +707,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -77,7 +77,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1463,12 +1463,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1480,6 +1487,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1517,14 +1525,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1595,6 +1613,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1905,12 +1942,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1923,7 +1958,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1936,7 +1970,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -1959,26 +1992,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -587,13 +587,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4549,6 +4550,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5525,16 +5543,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -705,7 +705,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -77,7 +77,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1457,12 +1457,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1474,6 +1481,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1511,14 +1519,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1589,6 +1607,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1895,12 +1932,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -1913,7 +1948,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -1926,7 +1960,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -1944,26 +1977,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -560,13 +560,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4604,6 +4605,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5552,16 +5570,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -663,7 +663,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -75,7 +75,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1330,12 +1330,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1347,6 +1354,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1359,14 +1367,24 @@ public abstract class Inventory extends ItemContainer
}
old.updateDatabase();
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1402,6 +1420,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -1702,7 +1739,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_R_BRACELET:
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_DECO:
@@ -1718,7 +1754,6 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_BROOCH:
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_BROOCH_JEWEL:
@@ -1744,26 +1779,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -606,13 +606,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4628,6 +4629,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5609,16 +5627,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -721,7 +721,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -76,7 +76,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1565,12 +1565,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1582,6 +1589,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1619,14 +1627,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1697,6 +1715,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -2003,12 +2040,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -2021,7 +2056,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -2034,7 +2068,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -2052,26 +2085,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -630,13 +630,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4669,6 +4670,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5650,16 +5668,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -721,7 +721,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -76,7 +76,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1574,12 +1574,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1591,6 +1598,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1628,14 +1636,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1706,6 +1724,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -2012,12 +2049,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -2030,7 +2065,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -2043,7 +2077,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -2061,26 +2094,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}
@@ -630,13 +630,14 @@ public class Player extends Playable
private PlayerRefund _refund;
private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
private TradeList _activeTradeList;
private boolean _isUsingContainerItem;
private ItemContainer _activeWarehouse;
private Map<Integer, ManufactureItem> _manufactureItems;
private String _storeName = "";
private TradeList _sellList;
private TradeList _buyList;
private boolean _isUsingSkillItem;
// Multisell
private PreparedMultisellListHolder _currentMultiSell = null;
@@ -4669,6 +4670,23 @@ public class Player extends Playable
}
}
/**
* @return if player is using an item that has skills.
*/
public boolean isUsingSkillItem()
{
return _isUsingSkillItem;
}
/**
* Set value of using an item that has skills.
* @param value : The value to set.
*/
public void setUsingSkillItem(boolean value)
{
_isUsingSkillItem = value;
}
public PreparedMultisellListHolder getMultiSell()
{
return _currentMultiSell;
@@ -5650,16 +5668,6 @@ public class Player extends Playable
return _activeWarehouse;
}
public boolean isUsingContainerItem()
{
return _isUsingContainerItem;
}
public void setUsingContainerItem(boolean value)
{
_isUsingContainerItem = value;
}
/**
* Select the TradeList to be used in next activity.
* @param tradeList
@@ -721,7 +721,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingSkillItem())
{
super.recalculateStats(broadcast);
}
@@ -76,7 +76,7 @@ public abstract class Inventory extends ItemContainer
{
protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
private ScheduledFuture<?> _containerItemTask;
private ScheduledFuture<?> _skillItemTask;
public interface PaperdollListener
{
@@ -1574,12 +1574,19 @@ public abstract class Inventory extends ItemContainer
{
if (old != null)
{
// Prevent flood from using items with skills.
if (old.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = null;
_paperdollCache.getPaperdollItems().remove(old);
// Put old item from paperdoll slot to base location
old.setItemLocation(getBaseLocation());
old.setLastChange(Item.MODIFIED);
// Get the mask for paperdoll
int mask = 0;
for (int i = 0; i < PAPERDOLL_TOTALSLOTS; i++)
@@ -1591,6 +1598,7 @@ public abstract class Inventory extends ItemContainer
}
}
_wearedMask = mask;
// Notify all paperdoll listener in order to unequip old item in slot
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1628,14 +1636,24 @@ public abstract class Inventory extends ItemContainer
}
}
// Add new item in slot of paperdoll
if (item != null)
{
// Prevent flood from using items with skills.
if (item.getItem().hasSkills())
{
checkEquipTask();
}
_paperdoll[slot] = item;
_paperdollCache.getPaperdollItems().add(item);
// Put item to equip location
item.setItemLocation(getEquipLocation(), slot);
item.setLastChange(Item.MODIFIED);
// Notify all paperdoll listener in order to equip item in slot
_wearedMask |= item.getItem().getItemMask();
for (PaperdollListener listener : _paperdollListeners)
{
@@ -1706,6 +1724,25 @@ public abstract class Inventory extends ItemContainer
return old;
}
/**
* Prevent flood from using items with skills.
*/
private void checkEquipTask()
{
if ((_skillItemTask == null) && (getOwner() != null) && getOwner().isPlayer() && (getOwner().getActingPlayer().getUptime() > 5000))
{
getOwner().getActingPlayer().setUsingSkillItem(true);
_skillItemTask = ThreadPool.schedule(() ->
{
getOwner().getActingPlayer().setUsingSkillItem(false);
getOwner().getStat().recalculateStats(true);
getOwner().updateAbnormalVisualEffects();
getOwner().getActingPlayer().sendSkillList();
_skillItemTask = null;
}, 100);
}
}
/**
* @return the mask of wore item
*/
@@ -2012,12 +2049,10 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_L_BRACELET)
{
pdollSlot = PAPERDOLL_LBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_R_BRACELET)
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_DECO)
{
@@ -2030,7 +2065,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_BROOCH)
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
{
@@ -2043,7 +2077,6 @@ public abstract class Inventory extends ItemContainer
else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
{
pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
containerItemCheck();
}
else if (slot == ItemTemplate.SLOT_ARTIFACT)
{
@@ -2061,26 +2094,6 @@ public abstract class Inventory extends ItemContainer
return null;
}
/**
* Avoid flood from container items.
*/
private void containerItemCheck()
{
final Creature owner = getOwner();
if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
{
owner.getActingPlayer().setUsingContainerItem(true);
_containerItemTask = ThreadPool.schedule(() ->
{
owner.getActingPlayer().setUsingContainerItem(false);
owner.getStat().recalculateStats(true);
owner.updateAbnormalVisualEffects();
owner.getActingPlayer().sendSkillList();
_containerItemTask = null;
}, 100);
}
}
/**
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
if (_player != null)
{
// Avoid flood from class change or container items.
if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
// Avoid flood from class change or using items with skills.
if ((_player.isChangingClass() || _player.isUsingSkillItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
{
return;
}