From e0dc88e3510661fc26076b959587d23e1f9f21a0 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Thu, 3 Feb 2022 22:05:30 +0000 Subject: [PATCH] Prevent flood from using items with skills. --- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 61 +++++++++++------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 61 +++++++++++------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 61 +++++++++++------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 61 +++++++++++------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 62 +++++++++++------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 61 +++++++++++------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 61 +++++++++++------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 62 +++++++++++------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 61 +++++++++++------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- .../gameserver/model/actor/Player.java | 30 +++++---- .../model/actor/stat/PlayerStat.java | 2 +- .../model/itemcontainer/Inventory.java | 63 +++++++++++-------- .../gameserver/network/GameClient.java | 4 +- 84 files changed, 1260 insertions(+), 803 deletions(-) diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Player.java index 3a92218d90..22a1cf5830 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index efe81046d6..602a9433ef 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index aa158b2fd5..2b45073c3e 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Player.java index 8a2d3fe693..1a36ee4915 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 3376739a79..abc5dd244b 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index cedc85b818..fd6d67d8b3 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Player.java index 81b1096575..aa241ab61d 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 3376739a79..abc5dd244b 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index cedc85b818..fd6d67d8b3 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Player.java index 1d837df4d0..05ead15f79 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index a979cc985f..f723923af0 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 6c7bee800e..a8fac05671 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Player.java index 697a26af55..7dade8025e 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 5d8882e0dd..9542e0688a 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 241af03a25..260164e122 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java index 1784a8a6ec..d147a706a0 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 09661b7a80..a64f2bdd25 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 199d65b3cf..8d6ed0cf22 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java index 0f501f7a7f..dca4376900 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 09661b7a80..a64f2bdd25 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 199d65b3cf..8d6ed0cf22 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java index eec45bcfcd..d11ab93fa2 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 3680035f37..ee3f9d77d4 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 058f488155..ac35e0d15b 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java index a411df200f..728206e3ce 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index f77cb7a248..b49f625fb6 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index a4d53cef1c..65d9cc5c07 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java index 3c204ea774..34578b97a3 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index f77cb7a248..b49f625fb6 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index a4d53cef1c..65d9cc5c07 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java index 001dced412..f7338a5cf2 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 46c87cfcc5..6a5c33538c 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 27491c5041..b251f9e450 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_10.0_MasterClass/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java index d4ff832bc2..00c9cad7fc 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index d5b698321b..38bb39cbd2 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 37089fea16..6032548f61 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Player.java index eb56dbf119..1bfe237fa2 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index a979cc985f..f723923af0 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 37089fea16..6032548f61 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Player.java index 2509adaca5..e83186dae0 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index e37cfa48a2..cf31498bd6 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index c14b825dc6..ab69b447d8 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java index 0fa00ceba9..e4a6ec46bf 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 58a230d9f9..996e29368e 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 5dc9fe98c0..2bdfa04e2d 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java index fff11c4c13..3000c4e52d 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 58a230d9f9..996e29368e 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 5dc9fe98c0..2bdfa04e2d 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java index 95abca4110..fab4b1189f 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 814de69045..4e6a62826d 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 79f21541da..e8d95ce601 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java index 52093c69a2..4375f92e35 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index a979cc985f..f723923af0 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 74be7b9633..7d2858f967 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/GameClient.java index 186451bb1c..ae9b8070b3 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java index 53725c5d6c..61295a9cfd 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 3856c9c7d8..99ddf8dcc4 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 7772205329..0a436d151e 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java index 828334a783..1a299d2607 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 3856c9c7d8..99ddf8dcc4 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 1a9a2249e7..6f40531177 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java index 5f82dbaa08..aa8c205c53 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -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 _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 diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java index 3856c9c7d8..99ddf8dcc4 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java @@ -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); } diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 1a9a2249e7..6f40531177 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -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
* If you don't need return value use {@link Inventory#equipItem(Item)} instead diff --git a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/GameClient.java index ee8c65ae92..ef0a42d21d 100644 --- a/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/GameClient.java +++ b/L2J_Mobius_Essence_6.0_BattleChronicle/java/org/l2jmobius/gameserver/network/GameClient.java @@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler 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; }