Addition of OnItemUse event.

This commit is contained in:
MobiusDevelopment
2022-05-17 21:27:25 +00:00
parent f7c642df3f
commit 2cbec40c98
69 changed files with 1380 additions and 0 deletions

View File

@@ -127,6 +127,7 @@ import org.l2jmobius.gameserver.model.events.impl.item.OnItemCreate;
import org.l2jmobius.gameserver.model.events.impl.item.OnItemEnchantAdd;
import org.l2jmobius.gameserver.model.events.impl.item.OnItemSoulCrystalAdd;
import org.l2jmobius.gameserver.model.events.impl.item.OnItemTalk;
import org.l2jmobius.gameserver.model.events.impl.item.OnItemUse;
import org.l2jmobius.gameserver.model.events.impl.olympiad.OnOlympiadMatchResult;
import org.l2jmobius.gameserver.model.events.impl.sieges.OnCastleSiegeFinish;
import org.l2jmobius.gameserver.model.events.impl.sieges.OnCastleSiegeOwnerChange;
@@ -182,6 +183,7 @@ public enum EventType
// Item events
ON_ITEM_BYPASS_EVENT(OnItemBypassEvent.class, void.class),
ON_ITEM_CREATE(OnItemCreate.class, void.class),
ON_ITEM_USE(OnItemUse.class, void.class),
ON_ITEM_TALK(OnItemTalk.class, void.class),
ON_ITEM_ATTRIBUTE_ADD(OnItemAttributeAdd.class, void.class),
ON_ITEM_SOUL_CRYSTAL_ADD(OnItemSoulCrystalAdd.class, void.class),

View File

@@ -0,0 +1,53 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.events.impl.item;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
import org.l2jmobius.gameserver.model.item.instance.Item;
/**
* @author Mobius
*/
public class OnItemUse implements IBaseEvent
{
private final Player _player;
private final Item _item;
public OnItemUse(Player player, Item item)
{
_player = player;
_item = item;
}
public Player getPlayer()
{
return _player;
}
public Item getItem()
{
return _item;
}
@Override
public EventType getType()
{
return EventType.ON_ITEM_USE;
}
}

View File

@@ -36,6 +36,8 @@ import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.effects.EffectType;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.item.OnItemUse;
import org.l2jmobius.gameserver.model.holders.ItemSkillHolder;
import org.l2jmobius.gameserver.model.item.EtcItem;
import org.l2jmobius.gameserver.model.item.ItemTemplate;
@@ -294,6 +296,9 @@ public class UseItem implements IClientIncomingPacket
player.addTimeStampItem(item, reuseDelay);
sendSharedGroupUpdate(player, sharedReuseGroup, reuseDelay, reuseDelay);
}
// Notify events.
EventDispatcher.getInstance().notifyEventAsync(new OnItemUse(player, item), item.getTemplate());
}
// TODO: New item handler for minerals.
if (VariationData.getInstance().getVariation(_itemId) != null)