Support for item equip and unequip listeners.
This commit is contained in:
@@ -192,10 +192,10 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import org.l2jmobius.gameserver.model.events.EventType;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayableExpChanged;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerAbilityPointsChanged;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerEquipItem;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerFameChanged;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerHennaAdd;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerHennaRemove;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerItemEquip;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerLogin;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerLogout;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerMenteeStatus;
|
||||
@@ -2292,6 +2292,9 @@ public class PlayerInstance extends Playable
|
||||
{
|
||||
rechargeShots(true, true, false);
|
||||
}
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemEquip(this, item), item.getItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2316,9 +2319,6 @@ public class PlayerInstance extends Playable
|
||||
{
|
||||
sendPacket(new ExStorageMaxCount(this));
|
||||
}
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerEquipItem(this, item), this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -76,7 +76,7 @@ import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanWH
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerCreate;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerDelete;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerDlgAnswer;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerEquipItem;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerItemEquip;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerFameChanged;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerFishing;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerHennaAdd;
|
||||
@@ -114,6 +114,7 @@ import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerSummon
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerSummonTalk;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerTakeHero;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerTransform;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerItemUnequip;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerUnsummonAgathion;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnTrapAction;
|
||||
import org.l2jmobius.gameserver.model.events.impl.instance.OnInstanceCreated;
|
||||
@@ -238,7 +239,6 @@ public enum EventType
|
||||
ON_PLAYER_CREATE(OnPlayerCreate.class, void.class),
|
||||
ON_PLAYER_DELETE(OnPlayerDelete.class, void.class),
|
||||
ON_PLAYER_DLG_ANSWER(OnPlayerDlgAnswer.class, void.class, TerminateReturn.class),
|
||||
ON_PLAYER_EQUIP_ITEM(OnPlayerEquipItem.class, void.class),
|
||||
ON_PLAYER_FAME_CHANGED(OnPlayerFameChanged.class, void.class),
|
||||
ON_PLAYER_FISHING(OnPlayerFishing.class, void.class),
|
||||
// Henna events
|
||||
@@ -250,6 +250,8 @@ public enum EventType
|
||||
ON_PLAYER_ITEM_DROP(OnPlayerItemDrop.class, void.class),
|
||||
ON_PLAYER_ITEM_PICKUP(OnPlayerItemPickup.class, void.class),
|
||||
ON_PLAYER_ITEM_TRANSFER(OnPlayerItemTransfer.class, void.class),
|
||||
ON_PLAYER_ITEM_EQUIP(OnPlayerItemEquip.class, void.class),
|
||||
ON_PLAYER_ITEM_UNEQUIP(OnPlayerItemUnequip.class, void.class),
|
||||
// Mentoring events
|
||||
ON_PLAYER_MENTEE_ADD(OnPlayerMenteeAdd.class, void.class),
|
||||
ON_PLAYER_MENTEE_LEFT(OnPlayerMenteeLeft.class, void.class),
|
||||
|
@@ -24,12 +24,12 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class OnPlayerEquipItem implements IBaseEvent
|
||||
public class OnPlayerItemEquip implements IBaseEvent
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
private final ItemInstance _item;
|
||||
|
||||
public OnPlayerEquipItem(PlayerInstance player, ItemInstance item)
|
||||
public OnPlayerItemEquip(PlayerInstance player, ItemInstance item)
|
||||
{
|
||||
_player = player;
|
||||
_item = item;
|
||||
@@ -48,6 +48,6 @@ public class OnPlayerEquipItem implements IBaseEvent
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
return EventType.ON_PLAYER_EQUIP_ITEM;
|
||||
return EventType.ON_PLAYER_ITEM_EQUIP;
|
||||
}
|
||||
}
|
@@ -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.creature.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.events.EventType;
|
||||
import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class OnPlayerItemUnequip implements IBaseEvent
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
private final ItemInstance _item;
|
||||
|
||||
public OnPlayerItemUnequip(PlayerInstance player, ItemInstance item)
|
||||
{
|
||||
_player = player;
|
||||
_item = item;
|
||||
}
|
||||
|
||||
public PlayerInstance getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public ItemInstance getItem()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
return EventType.ON_PLAYER_ITEM_UNEQUIP;
|
||||
}
|
||||
}
|
@@ -44,7 +44,10 @@ import org.l2jmobius.gameserver.model.ArmorSet;
|
||||
import org.l2jmobius.gameserver.model.PlayerCondOverride;
|
||||
import org.l2jmobius.gameserver.model.VariationInstance;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerItemUnequip;
|
||||
import org.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemSkillHolder;
|
||||
import org.l2jmobius.gameserver.model.items.EtcItem;
|
||||
@@ -1378,6 +1381,17 @@ public abstract class Inventory extends ItemContainer
|
||||
getOwner().sendPacket(new ExUserInfoEquipSlot(getOwner().getActingPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
// Notify to scripts
|
||||
if (old != null)
|
||||
{
|
||||
final Creature owner = getOwner();
|
||||
if ((owner != null) && owner.isPlayer())
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemUnequip(owner.getActingPlayer(), old), old.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user