PUBLIC SECTION => Announcements => Topic started by: Tryskell on February 07, 2019, 02:10:59 AM

Title: UseItem exploit fix (duplicate items) - ALL L2J VERSIONS
Post by: Tryskell on February 07, 2019, 02:10:59 AM

The video was produced using my pack (or so state the server owner/developer), but L2J got the same issue. All non-customized L2J versions using WeaponEquipTask got this issue. Even if you patched other places to avoid to get multiple similar items with same objectId, this is the initial problem and the only fix you should apply.

For the goodness of L2J, I decided to post this fix for free.

Short version : Upon UseItem use, and if you're currently attacking, WeaponEquipTask is called to delay the time your weapon is wear.

Issue : There is no check upon task call. The item is equipped, no matter what happened between the call time, and the wear time (if you deleted, crystallized, dropped, put item elsewhere,...).

Fix : check upon task call if the item is still existing on inventory.

For L2J (consider to edit the called method - remove item parameter).

Code: [Select]
   /** Weapon Equip Task */
    private static class WeaponEquipTask implements Runnable
        private final L2PcInstance activeChar;
        protected WeaponEquipTask(L2PcInstance character)
            activeChar = character;
        public void run()
            // Check if the item is still on inventory.
            final ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
            if (item == null)
            // Equip or unEquip
            activeChar.useEquippableItem(item, false);

If you use aCis, here's the modified task found on UseItem (will be part of rev 380) :

Code: [Select]
			if (activeChar.isAttackingNow())
ThreadPool.schedule(() -> {
final ItemInstance itemToTest = activeChar.getInventory().getItemByObjectId(_objectId);
if(itemToTest == null)

activeChar.useEquippableItem(itemToTest, false);
}, activeChar.getAttackEndTime() - System.currentTimeMillis());
activeChar.useEquippableItem(item, true);

Good luck everyone !  :clap: