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

@ -123,6 +123,7 @@ import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceStatusChang
import org.l2jmobius.gameserver.model.events.impl.item.OnItemBypassEvent;
import org.l2jmobius.gameserver.model.events.impl.item.OnItemCreate;
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;
@ -178,6 +179,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),
// NPC events

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

@ -35,6 +35,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;
@ -284,6 +286,9 @@ public class UseItem implements IClientIncomingPacket
{
PacketLogger.warning("Unmanaged Item handler: " + etcItem.getHandlerName() + " for Item Id: " + _itemId + "!");
}
// Notify events.
EventDispatcher.getInstance().notifyEventAsync(new OnItemUse(player, item), item.getTemplate());
}
else if (handler.useItem(player, item, _ctrlPressed))
{