Proper useEquippableItem ownership checks.
This commit is contained in:
@@ -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();
|
||||
|
@@ -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
|
||||
{
|
||||
|
Reference in New Issue
Block a user