From 414cbb7773a01657daf0cf234b186c6537002e17 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Tue, 28 Apr 2020 23:31:54 +0000 Subject: [PATCH] Proper useEquippableItem ownership checks. --- .../model/actor/instance/PlayerInstance.java | 21 +++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 21 +++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 21 +++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 20 +++++++++++++++++ .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 20 +++++++++++++++++ .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 20 +++++++++++++++++ .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 20 +++++++++++++++++ .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 20 +++++++++++++++++ .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 22 ++++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 22 ++++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 21 +++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 21 +++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 21 +++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 21 +++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 21 +++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 20 +++++++++++++++++ .../network/clientpackets/UseItem.java | 14 ++---------- .../model/actor/instance/PlayerInstance.java | 21 +++++++++++++++++- .../network/clientpackets/UseItem.java | 14 ++---------- 34 files changed, 376 insertions(+), 215 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 03da421726..a06e91c104 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -86,6 +86,7 @@ import org.l2jmobius.gameserver.enums.GroupType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2190,6 +2191,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2254,7 +2274,6 @@ public class PlayerInstance extends Playable } refreshExpertisePenalty(); - broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index c2650bf6a0..9298de80ed 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -250,18 +250,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 6ed9a3b374..5ee99b46ea 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -87,6 +87,7 @@ import org.l2jmobius.gameserver.enums.GroupType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2196,6 +2197,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2260,7 +2280,6 @@ public class PlayerInstance extends Playable } refreshExpertisePenalty(); - broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index c2650bf6a0..9298de80ed 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -250,18 +250,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 16b6e917f6..c9601936ee 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -88,6 +88,7 @@ import org.l2jmobius.gameserver.enums.GroupType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2198,6 +2199,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2262,7 +2282,6 @@ public class PlayerInstance extends Playable } refreshExpertisePenalty(); - broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index c2650bf6a0..9298de80ed 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -250,18 +250,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index ef050c30ed..de6ca84222 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -89,6 +89,7 @@ import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; import org.l2jmobius.gameserver.enums.ItemGrade; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2205,6 +2206,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index c2650bf6a0..9298de80ed 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -250,18 +250,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index cabe32ba8b..43bcf594ea 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -89,6 +89,7 @@ import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; import org.l2jmobius.gameserver.enums.ItemGrade; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2198,6 +2199,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 8219ca006d..8e3201dd64 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -247,18 +247,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index a1dda79f22..1915f9adeb 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -89,6 +89,7 @@ import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; import org.l2jmobius.gameserver.enums.ItemGrade; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2198,6 +2199,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 0cde588f5a..f7ec91f0bc 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -256,18 +256,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 413fc65f9f..d40e9b291a 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -89,6 +89,7 @@ import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; import org.l2jmobius.gameserver.enums.ItemGrade; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2198,6 +2199,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 0cde588f5a..f7ec91f0bc 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -256,18 +256,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 4f34791c06..9a4342aec4 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -90,6 +90,7 @@ import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; import org.l2jmobius.gameserver.enums.ItemGrade; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2131,6 +2132,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 0cde588f5a..f7ec91f0bc 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -256,18 +256,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 68e05cd062..35e08100c8 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -85,6 +85,7 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.enums.PlayerAction; @@ -2223,6 +2224,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2283,8 +2303,8 @@ public class PlayerInstance extends Playable sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM); } } - refreshExpertisePenalty(); + refreshExpertisePenalty(); broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 058ac45e85..f516180bf3 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -297,18 +297,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, TimeUnit.MILLISECONDS.convert(player.getAttackEndTime() - System.nanoTime(), TimeUnit.NANOSECONDS)); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), TimeUnit.MILLISECONDS.convert(player.getAttackEndTime() - System.nanoTime(), TimeUnit.NANOSECONDS)); } else { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 21373d8a91..0f22c245d0 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -85,6 +85,7 @@ import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.PartyDistributionType; import org.l2jmobius.gameserver.enums.PlayerAction; @@ -2134,6 +2135,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2194,8 +2214,8 @@ public class PlayerInstance extends Playable sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM); } } - refreshExpertisePenalty(); + refreshExpertisePenalty(); broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 058ac45e85..f516180bf3 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -297,18 +297,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, TimeUnit.MILLISECONDS.convert(player.getAttackEndTime() - System.nanoTime(), TimeUnit.NANOSECONDS)); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), TimeUnit.MILLISECONDS.convert(player.getAttackEndTime() - System.nanoTime(), TimeUnit.NANOSECONDS)); } else { diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index adff9b1d22..7349ad377e 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -87,6 +87,7 @@ import org.l2jmobius.gameserver.enums.GroupType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2169,6 +2170,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2233,7 +2253,6 @@ public class PlayerInstance extends Playable } refreshExpertisePenalty(); - broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index c2650bf6a0..9298de80ed 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -250,18 +250,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 1ec44a7254..e5e410d0ea 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -87,6 +87,7 @@ import org.l2jmobius.gameserver.enums.GroupType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2169,6 +2170,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2233,7 +2253,6 @@ public class PlayerInstance extends Playable } refreshExpertisePenalty(); - broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index c2650bf6a0..9298de80ed 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -250,18 +250,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 95bd780c0a..2cefe3b173 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -87,6 +87,7 @@ import org.l2jmobius.gameserver.enums.GroupType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2167,6 +2168,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2231,7 +2251,6 @@ public class PlayerInstance extends Playable } refreshExpertisePenalty(); - broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 3ad8990649..787d1bdb8b 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -247,18 +247,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 2fbdf7b385..08d65acb62 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -89,6 +89,7 @@ import org.l2jmobius.gameserver.enums.GroupType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2177,6 +2178,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2241,7 +2261,6 @@ public class PlayerInstance extends Playable } refreshExpertisePenalty(); - broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 7c3fc1f3e2..9f131ab54a 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -256,18 +256,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 4f27a59536..0f1b889eb5 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -89,6 +89,7 @@ import org.l2jmobius.gameserver.enums.GroupType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2177,6 +2178,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2241,7 +2261,6 @@ public class PlayerInstance extends Playable } refreshExpertisePenalty(); - broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 7c3fc1f3e2..9f131ab54a 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -256,18 +256,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index f863731a39..059a7cb917 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -90,6 +90,7 @@ import org.l2jmobius.gameserver.enums.GroupType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2098,6 +2099,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 7c3fc1f3e2..9f131ab54a 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -256,18 +256,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else { diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index fbfa3df915..23c59b0496 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -87,6 +87,7 @@ import org.l2jmobius.gameserver.enums.GroupType; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import org.l2jmobius.gameserver.enums.InstanceType; +import org.l2jmobius.gameserver.enums.ItemLocation; import org.l2jmobius.gameserver.enums.MountType; import org.l2jmobius.gameserver.enums.NextActionType; import org.l2jmobius.gameserver.enums.PartyDistributionType; @@ -2171,6 +2172,25 @@ public class PlayerInstance extends Playable public void useEquippableItem(ItemInstance item, boolean abortAttack) { + // Check if the item is null. + if (item == null) + { + return; + } + + // Check if the item is owned by this player. + if (item.getOwnerId() != getObjectId()) + { + return; + } + + // Check if the item is in the inventory. + final ItemLocation itemLocation = item.getItemLocation(); + if ((itemLocation != ItemLocation.INVENTORY) && (itemLocation != ItemLocation.PAPERDOLL)) + { + return; + } + // Equip or unEquip ItemInstance[] items = null; final boolean isEquiped = item.isEquipped(); @@ -2235,7 +2255,6 @@ public class PlayerInstance extends Playable } refreshExpertisePenalty(); - broadcastUserInfo(); final InventoryUpdate iu = new InventoryUpdate(); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java index 8802516511..a617f82004 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/UseItem.java @@ -258,18 +258,8 @@ public class UseItem implements IClientIncomingPacket } else if (player.isAttackingNow()) { - ThreadPool.schedule(() -> - { - // Check if the item is still on inventory. - final ItemInstance equipItem = player.getInventory().getItemByObjectId(_objectId); - if (equipItem == null) - { - return; - } - - // Equip or unEquip. - player.useEquippableItem(equipItem, false); - }, player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); + // Equip or unEquip. + ThreadPool.schedule(() -> player.useEquippableItem(item, false), player.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())); } else {