diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index d7e1ef6419..ce5997e58a 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -243,21 +243,22 @@ public final class UseItem implements IClientIncomingPacket if (activeChar.isCastingNow()) { - // Create and Bind the next action to the AI + // Create and Bind the next action to the AI. activeChar.getAI().setNextAction(new NextAction(CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> activeChar.useEquippableItem(item, true))); } else if (activeChar.isAttackingNow()) { ThreadPool.schedule(() -> { - // Removed for preventing retail behavior. - // if (activeChar.isAttackingNow()) // If character is still engaged in strike we should not change weapon - // { - // return; - // } + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } - // Equip or unEquip - activeChar.useEquippableItem(item, false); + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index d7e1ef6419..ce5997e58a 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -243,21 +243,22 @@ public final class UseItem implements IClientIncomingPacket if (activeChar.isCastingNow()) { - // Create and Bind the next action to the AI + // Create and Bind the next action to the AI. activeChar.getAI().setNextAction(new NextAction(CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> activeChar.useEquippableItem(item, true))); } else if (activeChar.isAttackingNow()) { ThreadPool.schedule(() -> { - // Removed for preventing retail behavior. - // if (activeChar.isAttackingNow()) // If character is still engaged in strike we should not change weapon - // { - // return; - // } + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } - // Equip or unEquip - activeChar.useEquippableItem(item, false); + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index d7e1ef6419..ce5997e58a 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -243,21 +243,22 @@ public final class UseItem implements IClientIncomingPacket if (activeChar.isCastingNow()) { - // Create and Bind the next action to the AI + // Create and Bind the next action to the AI. activeChar.getAI().setNextAction(new NextAction(CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> activeChar.useEquippableItem(item, true))); } else if (activeChar.isAttackingNow()) { ThreadPool.schedule(() -> { - // Removed for preventing retail behavior. - // if (activeChar.isAttackingNow()) // If character is still engaged in strike we should not change weapon - // { - // return; - // } + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } - // Equip or unEquip - activeChar.useEquippableItem(item, false); + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index d7e1ef6419..ce5997e58a 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -243,21 +243,22 @@ public final class UseItem implements IClientIncomingPacket if (activeChar.isCastingNow()) { - // Create and Bind the next action to the AI + // Create and Bind the next action to the AI. activeChar.getAI().setNextAction(new NextAction(CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> activeChar.useEquippableItem(item, true))); } else if (activeChar.isAttackingNow()) { ThreadPool.schedule(() -> { - // Removed for preventing retail behavior. - // if (activeChar.isAttackingNow()) // If character is still engaged in strike we should not change weapon - // { - // return; - // } + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } - // Equip or unEquip - activeChar.useEquippableItem(item, false); + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index c6cf9ececd..4592972b16 100644 --- a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -240,21 +240,22 @@ public final class UseItem implements IClientIncomingPacket if (activeChar.isCastingNow()) { - // Create and Bind the next action to the AI + // Create and Bind the next action to the AI. activeChar.getAI().setNextAction(new NextAction(CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> activeChar.useEquippableItem(item, true))); } else if (activeChar.isAttackingNow()) { ThreadPool.schedule(() -> { - // Removed for preventing retail behavior. - // if (activeChar.isAttackingNow()) // If character is still engaged in strike we should not change weapon - // { - // return; - // } + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } - // Equip or unEquip - activeChar.useEquippableItem(item, false); + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index 4e1ee41aa3..4cbfff3eb0 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -256,14 +256,15 @@ public final class UseItem implements IClientIncomingPacket { ThreadPool.schedule(() -> { - // Removed for preventing retail behavior. - // if (activeChar.isAttackingNow()) // If character is still engaged in strike we should not change weapon - // { - // return; - // } + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } - // Equip or unEquip - activeChar.useEquippableItem(item, false); + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index 35d32c0ef1..16c1e0dada 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -55,26 +55,6 @@ public final class UseItem implements IClientIncomingPacket private boolean _ctrlPressed; private int _itemId; - /** Weapon Equip Task */ - private static class WeaponEquipTask implements Runnable - { - private final L2ItemInstance item; - private final L2PcInstance activeChar; - - protected WeaponEquipTask(L2ItemInstance it, L2PcInstance character) - { - item = it; - activeChar = character; - } - - @Override - public void run() - { - // Equip or unEquip - activeChar.useEquippableItem(item, false); - } - } - @Override public boolean read(L2GameClient client, PacketReader packet) { @@ -315,7 +295,18 @@ public final class UseItem implements IClientIncomingPacket } else if (activeChar.isAttackingNow()) { - ThreadPool.schedule(new WeaponEquipTask(item, activeChar), TimeUnit.MILLISECONDS.convert(activeChar.getAttackEndTime() - System.nanoTime(), TimeUnit.NANOSECONDS)); + ThreadPool.schedule(() -> + { + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } + + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); + }, TimeUnit.MILLISECONDS.convert(activeChar.getAttackEndTime() - System.nanoTime(), TimeUnit.NANOSECONDS)); } else { diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index d7e1ef6419..ce5997e58a 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -243,21 +243,22 @@ public final class UseItem implements IClientIncomingPacket if (activeChar.isCastingNow()) { - // Create and Bind the next action to the AI + // Create and Bind the next action to the AI. activeChar.getAI().setNextAction(new NextAction(CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> activeChar.useEquippableItem(item, true))); } else if (activeChar.isAttackingNow()) { ThreadPool.schedule(() -> { - // Removed for preventing retail behavior. - // if (activeChar.isAttackingNow()) // If character is still engaged in strike we should not change weapon - // { - // return; - // } + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } - // Equip or unEquip - activeChar.useEquippableItem(item, false); + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index d7e1ef6419..ce5997e58a 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -243,21 +243,22 @@ public final class UseItem implements IClientIncomingPacket if (activeChar.isCastingNow()) { - // Create and Bind the next action to the AI + // Create and Bind the next action to the AI. activeChar.getAI().setNextAction(new NextAction(CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> activeChar.useEquippableItem(item, true))); } else if (activeChar.isAttackingNow()) { ThreadPool.schedule(() -> { - // Removed for preventing retail behavior. - // if (activeChar.isAttackingNow()) // If character is still engaged in strike we should not change weapon - // { - // return; - // } + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } - // Equip or unEquip - activeChar.useEquippableItem(item, false); + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index 61dc3e3dcc..283b789c0c 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -240,21 +240,22 @@ public final class UseItem implements IClientIncomingPacket if (activeChar.isCastingNow()) { - // Create and Bind the next action to the AI + // Create and Bind the next action to the AI. activeChar.getAI().setNextAction(new NextAction(CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> activeChar.useEquippableItem(item, true))); } else if (activeChar.isAttackingNow()) { ThreadPool.schedule(() -> { - // Removed for preventing retail behavior. - // if (activeChar.isAttackingNow()) // If character is still engaged in strike we should not change weapon - // { - // return; - // } + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } - // Equip or unEquip - activeChar.useEquippableItem(item, false); + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java index 9a6d14e3f1..38c6e35e9e 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -256,14 +256,15 @@ public final class UseItem implements IClientIncomingPacket { ThreadPool.schedule(() -> { - // Removed for preventing retail behavior. - // if (activeChar.isAttackingNow()) // If character is still engaged in strike we should not change weapon - // { - // return; - // } + // Check if the item is still on inventory. + final L2ItemInstance equipItem = activeChar.getInventory().getItemByObjectId(_objectId); + if (equipItem == null) + { + return; + } - // Equip or unEquip - activeChar.useEquippableItem(item, false); + // Equip or unEquip. + activeChar.useEquippableItem(equipItem, false); }, activeChar.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else