Dropped OnNpcCreatureSee in favor of OnCreatureSee event.

This commit is contained in:
MobiusDevelopment
2021-06-23 02:05:25 +00:00
parent f6bc846256
commit fee7b294bb
581 changed files with 2730 additions and 6055 deletions

View File

@ -37,8 +37,6 @@ import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcCreatureSee;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
@ -357,16 +355,6 @@ public class World
}
}
}
if (wo.isNpc() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((Npc) wo, (Creature) object, object.isSummon()), (Npc) wo);
}
if (object.isNpc() && wo.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((Npc) object, (Creature) wo, wo.isSummon()), (Npc) object);
}
});
}
@ -580,16 +568,6 @@ public class World
}
}
}
if (wo.isNpc() && object.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((Npc) wo, (Creature) object, object.isSummon()), (Npc) wo);
}
if (object.isNpc() && wo.isCreature())
{
EventDispatcher.getInstance().notifyEventAsync(new OnNpcCreatureSee((Npc) object, (Creature) wo, wo.isSummon()), (Npc) object);
}
}
}
}

View File

@ -86,7 +86,6 @@ import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableFacti
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableHate;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableKill;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcCanBeSeen;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcCreatureSee;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcDespawn;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcEventReceived;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcFirstTalk;
@ -952,28 +951,6 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
// ---------------------------------------------------------------------------------------------------------------------------
/**
* Provides instant callback operation when {@link Npc} sees another creature.
* @param callback
* @param npcIds
* @return
*/
protected final List<AbstractEventListener> setNpcCreatureSeeId(Consumer<OnNpcCreatureSee> callback, int... npcIds)
{
return registerConsumer(callback, EventType.ON_NPC_CREATURE_SEE, ListenerRegisterType.NPC, npcIds);
}
/**
* Provides instant callback operation when {@link Npc} sees another creature.
* @param callback
* @param npcIds
* @return
*/
protected final List<AbstractEventListener> setNpcCreatureSeeId(Consumer<OnNpcCreatureSee> callback, Collection<Integer> npcIds)
{
return registerConsumer(callback, EventType.ON_NPC_CREATURE_SEE, ListenerRegisterType.NPC, npcIds);
}
/**
* Provides instant callback operation when {@link Creature} sees another creature.
* @param callback

View File

@ -43,7 +43,6 @@ import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableFacti
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableHate;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableKill;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcCanBeSeen;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcCreatureSee;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcDespawn;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcEventReceived;
import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnNpcFirstTalk;
@ -186,7 +185,6 @@ public enum EventType
// NPC events
ON_NPC_CAN_BE_SEEN(OnNpcCanBeSeen.class, void.class, TerminateReturn.class),
ON_NPC_CREATURE_SEE(OnNpcCreatureSee.class, void.class),
ON_NPC_EVENT_RECEIVED(OnNpcEventReceived.class, void.class),
ON_NPC_FIRST_TALK(OnNpcFirstTalk.class, void.class),
ON_NPC_HATE(OnAttackableHate.class, void.class, TerminateReturn.class),

View File

@ -1,61 +0,0 @@
/*
* 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.npc;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
/**
* An instantly executed event when Creature is killed by Creature.
* @author UnAfraid
*/
public class OnNpcCreatureSee implements IBaseEvent
{
private final Npc _npc;
private final Creature _creature;
private final boolean _isSummon;
public OnNpcCreatureSee(Npc npc, Creature creature, boolean isSummon)
{
_npc = npc;
_creature = creature;
_isSummon = isSummon;
}
public Npc getNpc()
{
return _npc;
}
public Creature getCreature()
{
return _creature;
}
public boolean isSummon()
{
return _isSummon;
}
@Override
public EventType getType()
{
return EventType.ON_NPC_CREATURE_SEE;
}
}

View File

@ -818,37 +818,6 @@ public class Quest extends AbstractScript implements IIdentifiable
showResult(player, res);
}
/**
* @param npc the NPC that sees the creature
* @param creature the creature seen by the NPC
* @param isSummon
*/
public void notifySeeCreature(Npc npc, Creature creature, boolean isSummon)
{
PlayerInstance player = null;
if (isSummon || creature.isPlayer())
{
player = creature.getActingPlayer();
}
String res = null;
try
{
res = onSeeCreature(npc, creature, isSummon);
}
catch (Exception e)
{
if (player != null)
{
showError(player, e);
}
return;
}
if (player != null)
{
showResult(player, res);
}
}
/**
* @param eventName - name of event
* @param sender - NPC, who sent event
@ -1313,18 +1282,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return null;
}
/**
* This function is called whenever a NPC "sees" a creature.
* @param npc the NPC who sees the creature
* @param creature the creature seen by the NPC
* @param isSummon this parameter if it's {@code false} it denotes that the character seen by the NPC was indeed the player, else it specifies that the character was the player's summon
* @return
*/
public String onSeeCreature(Npc npc, Creature creature, boolean isSummon)
{
return null;
}
/**
* This function is called whenever a player enters the game.
* @param player this parameter contains a reference to the exact instance of the player who is entering to the world.
@ -2102,22 +2059,6 @@ public class Quest extends AbstractScript implements IIdentifiable
setAttackableAggroRangeEnterId(event -> notifyAggroRangeEnter(event.getNpc(), event.getActiveChar(), event.isSummon()), npcIds);
}
/**
* @param npcIds the IDs of the NPCs to register
*/
public void addSeeCreatureId(int... npcIds)
{
setNpcCreatureSeeId(event -> notifySeeCreature(event.getNpc(), event.getCreature(), event.isSummon()), npcIds);
}
/**
* @param npcIds the IDs of the NPCs to register
*/
public void addSeeCreatureId(Collection<Integer> npcIds)
{
setNpcCreatureSeeId(event -> notifySeeCreature(event.getNpc(), event.getCreature(), event.isSummon()), npcIds);
}
/**
* Register onEnterZone trigger for zone
* @param zoneId the ID of the zone to register