1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-08 08:23:11 +00:00

Event dispatcher changes and packet implementations

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-19 13:08:32 -03:00
parent 2c4af6d91d
commit 2d1181483a
77 changed files with 796 additions and 519 deletions

View File

@@ -19,13 +19,16 @@ package com.l2jserver.model.template;
import com.google.inject.Inject;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
import com.l2jserver.model.id.template.ItemTemplateID;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.model.world.AbstractActor.Race;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.NPC;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.service.game.CharacterService;
import com.l2jserver.service.network.NetworkService;
import com.l2jserver.util.calculator.Calculator;
/**
* Template for {@link NPC}
@@ -33,22 +36,52 @@ import com.l2jserver.service.network.NetworkService;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class NPCTemplate extends ActorTemplate<NPC> {
/**
* The {@link NetworkService}
*/
@Inject
protected NetworkService networkService;
/**
* The {@link CharacterService}
*/
@Inject
protected CharacterService charService;
/**
* The {@link ItemTemplateID} provider
*/
@Inject
protected ItemTemplateIDProvider itemTemplateIdProvider;
/**
* The NPC name
*/
protected String name = null;
/**
* The NPC title
*/
protected String title = null;
/**
* The attackable state of the NPC
*/
protected boolean attackable = false;
/**
* The movement speed multiplier
*/
protected double movementSpeedMultiplier = 1.0;
/**
* The attack speed multiplier
*/
protected double attackSpeedMultiplier = 1.0;
/**
* The collision radius
*/
protected double collisionRadius = 0;
protected double collisionHeigth = 0;
/**
* The collision height
*/
protected double collisionHeight = 0;
protected int maxHp;
@@ -70,10 +103,23 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> {
.getID());
if (conn == null)
return;
System.out.println(action);
charService.target(character, npc);
}
/**
* Receives an attack from an {@link Actor}
*
* @param npc
* the {@link NPC} being attacked
* @param calculator
* the calculator
* @param attacker
* the attacker actor
*/
public void receiveAttack(NPC npc, Calculator calculator, Actor attacker) {
// TODO add attributes to calculator!
}
@Override
public NPC createInstance() {
return new NPC(this.getID());
@@ -122,10 +168,10 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> {
}
/**
* @return the collisionHeigth
* @return the collisionHeight
*/
public double getCollisionHeigth() {
return collisionHeigth;
public double getCollisionHeight() {
return collisionHeight;
}
/**

View File

@@ -26,8 +26,8 @@ import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
import com.l2jserver.util.calculator.Calculator;
import com.l2jserver.util.calculator.DivisionFunction;
import com.l2jserver.util.calculator.MultiplicationFunction;
import com.l2jserver.util.calculator.Function;
import com.l2jserver.util.calculator.MultiplicationFunction;
import com.l2jserver.util.calculator.SetFunction;
import com.l2jserver.util.calculator.SubtractFunction;
import com.l2jserver.util.calculator.SumFunction;
@@ -152,7 +152,7 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
*/
public class WeaponAttribute {
private final Map<WeaponAttributeType, Map<Integer, Function<Double>>> operations = CollectionFactory
.newMap(null, null);
.newMap();
/**
* Sets the result of an calculator
@@ -248,7 +248,7 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
private Map<Integer, Function<Double>> getMap(WeaponAttributeType type) {
Map<Integer, Function<Double>> map = operations.get(type);
if (map == null) {
map = CollectionFactory.newMap(null, null);
map = CollectionFactory.newMap();
operations.put(type, map);
}
return map;

View File

@@ -22,9 +22,6 @@ import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.ClanID;
import com.l2jserver.model.id.object.iterator.WorldObjectIterator;
import com.l2jserver.model.world.capability.Joinable;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.model.world.clan.ClanEvent;
import com.l2jserver.model.world.clan.ClanListener;
import com.l2jserver.model.world.clan.ClanMembers;
/**
@@ -32,8 +29,7 @@ import com.l2jserver.model.world.clan.ClanMembers;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Clan extends AbstractObject implements
Listenable<ClanListener, ClanEvent>, Joinable<L2Character> {
public class Clan extends AbstractObject implements Joinable<L2Character> {
/**
* Clan leader
*/

View File

@@ -20,14 +20,12 @@ import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.template.ItemTemplateID;
import com.l2jserver.model.template.ItemTemplate;
import com.l2jserver.model.world.capability.Dropable;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.model.world.capability.Playable;
import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.model.world.character.CharacterInventory.InventoryLocation;
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
import com.l2jserver.model.world.item.ItemEvent;
import com.l2jserver.model.world.item.ItemListener;
import com.l2jserver.util.dimensional.Coordinate;
import com.l2jserver.util.dimensional.Point;
/**
* This class represents an {@link Item} in the Lineage II World. The item can
@@ -50,7 +48,7 @@ import com.l2jserver.util.dimensional.Coordinate;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Item extends AbstractObject implements Playable, Spawnable,
Listenable<ItemListener, ItemEvent>, Dropable {
Dropable {
/**
* The {@link ItemTemplate} ID
*/
@@ -177,4 +175,19 @@ public class Item extends AbstractObject implements Playable, Spawnable,
public void setOwnerID(CharacterID ownerID) {
this.ownerID = ownerID;
}
/*
* (non-Javadoc)
*
* @see com.l2jserver.model.world.capability.Pointable#getPoint()
*/
@Override
public Point getPoint() {
return null;
}
@Override
public void setPoint(Point point) {
}
}

View File

@@ -20,6 +20,8 @@ import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterActio
import com.l2jserver.model.id.object.NPCID;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.util.calculator.Calculator;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
@@ -47,6 +49,11 @@ public class NPC extends AbstractActor {
getTemplate().action(this, character, action);
}
public void receiveAttack(Calculator calculator, Actor attacker) {
// TODO add buffs to calculator!
getTemplate().receiveAttack(this, calculator, attacker);
}
/**
* @return the NPC template ID
*/

View File

@@ -23,9 +23,6 @@ import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.ClanID;
import com.l2jserver.model.id.object.iterator.WorldObjectIterator;
import com.l2jserver.model.world.capability.Joinable;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.model.world.party.PartyEvent;
import com.l2jserver.model.world.party.PartyListener;
import com.l2jserver.util.factory.CollectionFactory;
/**
@@ -33,13 +30,11 @@ import com.l2jserver.util.factory.CollectionFactory;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Party extends AbstractObject implements
Listenable<PartyListener, PartyEvent>, Joinable<L2Character> {
public class Party extends AbstractObject implements Joinable<L2Character> {
/**
* Active party members
*/
private final List<CharacterID> members = CollectionFactory
.newList(CharacterID.class);
private final List<CharacterID> members = CollectionFactory.newList();
@Override
public void join(L2Character member) {

View File

@@ -40,7 +40,7 @@ public class ActorSkillContainer implements Iterable<Skill> {
/**
* The learned skill list
*/
private List<Skill> skills = CollectionFactory.newList(Skill.class);
private List<Skill> skills = CollectionFactory.newList();
/**
* Creates a new instance

View File

@@ -16,14 +16,14 @@
*/
package com.l2jserver.model.world.actor.event;
import com.l2jserver.service.game.world.event.FilteredWorldListener;
import com.l2jserver.service.game.world.event.TypedWorldListener;
/**
* This listener will filter to only dispatch {@link ActorEvent} events.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class ActorListener extends FilteredWorldListener<ActorEvent> {
public abstract class ActorListener extends TypedWorldListener<ActorEvent> {
public ActorListener() {
super(ActorEvent.class);
}

View File

@@ -0,0 +1,72 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver 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.
*
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.actor.event;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.model.world.event.SpawnEvent;
import com.l2jserver.util.dimensional.Point;
/**
* Event dispatcher once an actor has spawned in the world
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ActorSpawnEvent implements ActorEvent, SpawnEvent {
/**
* The spawned player
*/
private final Actor actor;
/**
* The spawning point
*/
private final Point point;
/**
* Creates a new instance
*
* @param actor
* the spawned actor
* @param point
* the spawn point
*/
public ActorSpawnEvent(Actor actor, Point point) {
this.actor = actor;
this.point = point;
}
@Override
public Spawnable getObject() {
return actor;
}
@Override
public Actor getActor() {
return actor;
}
@Override
public Point getPoint() {
return point;
}
@Override
public ObjectID<?>[] getDispatchableObjects() {
return new ObjectID<?>[] { actor.getID() };
}
}

View File

@@ -20,8 +20,6 @@ import com.l2jserver.model.id.object.ActorID;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.model.world.actor.ActorEffects;
import com.l2jserver.model.world.actor.ActorSkillContainer;
import com.l2jserver.model.world.actor.event.ActorEvent;
import com.l2jserver.model.world.actor.event.ActorListener;
/**
* Defines an {@link AbstractObject} that defines an Actor (NPC, player, pet,
@@ -29,9 +27,8 @@ import com.l2jserver.model.world.actor.event.ActorListener;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Actor extends Listenable<ActorListener, ActorEvent>,
Spawnable, Pointable, Damagable, Attackable, Attacker, Castable,
Caster, Levelable, Killable, Equiper, Equipable {
public interface Actor extends Spawnable, Pointable, Damagable, Attackable,
Attacker, Castable, Caster, Levelable, Killable, Equiper, Equipable {
/**
* @return the actor effects
*/

View File

@@ -24,7 +24,7 @@ import com.l2jserver.util.dimensional.Coordinate;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Spawnable extends ObjectCapability, Positionable {
public interface Spawnable extends ObjectCapability, Positionable, Pointable {
void spawn(Coordinate coordinate);
boolean isSpawned();

View File

@@ -40,7 +40,7 @@ public class CharacterFriendList implements Iterable<L2Character> {
* The list of friends of this character
*/
private final Set<CharacterID> friends = CollectionFactory
.newSet(CharacterID.class);
.newSet();
/**
* Creates a new instance

View File

@@ -38,7 +38,7 @@ public class CharacterInventory implements Iterable<Item> {
/**
* The items in this character inventory
*/
private final Set<Item> items = CollectionFactory.newSet(Item.class);
private final Set<Item> items = CollectionFactory.newSet();
/**
* Creates a new instance

View File

@@ -37,8 +37,7 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
/**
* The shortcut list
*/
private List<Shortcut> shortcuts = CollectionFactory
.newList(Shortcut.class);
private List<Shortcut> shortcuts = CollectionFactory.newList();
/**
* Creates a new instance

View File

@@ -18,11 +18,11 @@ package com.l2jserver.model.world.character.event;
import java.util.Date;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
/**
* Event triggered once a character logs-in.
@@ -90,7 +90,7 @@ public class CharacterEnterWorldEvent implements CharacterEvent {
}
@Override
public Listenable<?, ?>[] getDispatchableObjects() {
return new Listenable<?, ?>[] { character };
public ObjectID<?>[] getDispatchableObjects() {
return new ObjectID<?>[] { character.getID() };
}
}

View File

@@ -18,11 +18,11 @@ package com.l2jserver.model.world.character.event;
import java.util.Date;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
/**
* Event triggered once a character logs-out.
@@ -90,7 +90,7 @@ public class CharacterLeaveWorldEvent implements CharacterEvent {
}
@Override
public Listenable<?, ?>[] getDispatchableObjects() {
return new Listenable<?, ?>[] { character };
public ObjectID<?>[] getDispatchableObjects() {
return new ObjectID<?>[] { character.getID() };
}
}

View File

@@ -16,7 +16,7 @@
*/
package com.l2jserver.model.world.character.event;
import com.l2jserver.service.game.world.event.FilteredWorldListener;
import com.l2jserver.service.game.world.event.TypedWorldListener;
/**
* This listener will filter to only dispatch {@link CharacterEvent} events.
@@ -24,7 +24,7 @@ import com.l2jserver.service.game.world.event.FilteredWorldListener;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class CharacterListener extends
FilteredWorldListener<CharacterEvent> {
TypedWorldListener<CharacterEvent> {
public CharacterListener() {
super(CharacterEvent.class);
}

View File

@@ -16,11 +16,11 @@
*/
package com.l2jserver.model.world.character.event;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.util.dimensional.Point;
/**
@@ -79,7 +79,7 @@ public class CharacterMoveEvent implements CharacterEvent {
}
@Override
public Listenable<?, ?>[] getDispatchableObjects() {
return new Listenable<?, ?>[] { character };
public ObjectID<?>[] getDispatchableObjects() {
return new ObjectID<?>[] { character.getID() };
}
}

View File

@@ -16,11 +16,11 @@
*/
package com.l2jserver.model.world.character.event;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.util.dimensional.Point;
/**
@@ -79,7 +79,7 @@ public class CharacterStopMoveEvent implements CharacterEvent {
}
@Override
public Listenable<?, ?>[] getDispatchableObjects() {
return new Listenable<?, ?>[] { character };
public ObjectID<?>[] getDispatchableObjects() {
return new ObjectID<?>[] { character.getID() };
}
}

View File

@@ -16,11 +16,11 @@
*/
package com.l2jserver.model.world.character.event;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
/**
* Event triggered once a character moves
@@ -78,7 +78,7 @@ public class CharacterTargetDeselectedEvent implements CharacterEvent {
}
@Override
public Listenable<?, ?>[] getDispatchableObjects() {
return new Listenable<?, ?>[] { character };
public ObjectID<?>[] getDispatchableObjects() {
return new ObjectID<?>[] { character.getID() };
}
}

View File

@@ -16,11 +16,11 @@
*/
package com.l2jserver.model.world.character.event;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
/**
* Event triggered once a character moves
@@ -79,7 +79,7 @@ public class CharacterTargetSelectedEvent implements CharacterEvent {
}
@Override
public Listenable<?, ?>[] getDispatchableObjects() {
return new Listenable<?, ?>[] { character };
public ObjectID<?>[] getDispatchableObjects() {
return new ObjectID<?>[] { character.getID() };
}
}

View File

@@ -16,14 +16,14 @@
*/
package com.l2jserver.model.world.clan;
import com.l2jserver.service.game.world.event.FilteredWorldListener;
import com.l2jserver.service.game.world.event.TypedWorldListener;
/**
* This listener will filter to only dispatch {@link ClanEvent} events.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class ClanListener extends FilteredWorldListener<ClanEvent> {
public abstract class ClanListener extends TypedWorldListener<ClanEvent> {
public ClanListener() {
super(ClanEvent.class);
}

View File

@@ -39,8 +39,7 @@ public class ClanMembers implements Iterable<CharacterID> {
/**
* The list of active members
*/
private final Set<CharacterID> members = CollectionFactory
.newSet(CharacterID.class);
private final Set<CharacterID> members = CollectionFactory.newSet();
/**
* Creates a new instance

View File

@@ -18,7 +18,7 @@ package com.l2jserver.model.world.event;
import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.service.game.world.event.WorldEvent;
import com.l2jserver.util.dimensional.Coordinate;
import com.l2jserver.util.dimensional.Point;
/**
* Event for objects spawning
@@ -30,7 +30,7 @@ public interface SpawnEvent extends WorldEvent {
Spawnable getObject();
/**
* @return the spawning coordinate
* @return the spawning point
*/
Coordinate getCoordinate();
Point getPoint();
}

View File

@@ -16,11 +16,11 @@
*/
package com.l2jserver.model.world.item;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.model.world.player.event.PlayerEvent;
/**
@@ -72,7 +72,7 @@ public class ItemDropEvent implements ItemEvent, PlayerEvent {
}
@Override
public Listenable<?, ?>[] getDispatchableObjects() {
return new Listenable<?, ?>[] { player, item };
public ObjectID<?>[] getDispatchableObjects() {
return new ObjectID<?>[] { item.getID() };
}
}

View File

@@ -16,14 +16,14 @@
*/
package com.l2jserver.model.world.item;
import com.l2jserver.service.game.world.event.FilteredWorldListener;
import com.l2jserver.service.game.world.event.TypedWorldListener;
/**
* This listener will filter to only dispatch {@link ItemEvent} events.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class ItemListener extends FilteredWorldListener<ItemEvent> {
public abstract class ItemListener extends TypedWorldListener<ItemEvent> {
public ItemListener() {
super(ItemEvent.class);
}

View File

@@ -14,23 +14,16 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.capability;
package com.l2jserver.model.world.npc.event;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.model.world.NPC;
import com.l2jserver.service.game.world.event.WorldEvent;
import com.l2jserver.service.game.world.event.WorldListener;
/**
* Defines an {@link AbstractObject} that can attach {@link WorldListener} that
* notifies of events on that object.
* Base event for {@link NPC} instances
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
* @param <L>
* the listener type
* @param <E>
* the event type
*/
public interface Listenable<L extends WorldListener, E extends WorldEvent>
extends ObjectCapability {
public interface NPCEvent extends WorldEvent {
NPC getNPC();
}

View File

@@ -0,0 +1,30 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver 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.
*
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.npc.event;
import com.l2jserver.service.game.world.event.TypedWorldListener;
/**
* This listener will filter to only dispatch {@link NPCEvent} events.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class NPCListener extends TypedWorldListener<NPCEvent> {
public NPCListener() {
super(NPCEvent.class);
}
}

View File

@@ -0,0 +1,43 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver 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.
*
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.npc.event;
import com.l2jserver.model.world.NPC;
import com.l2jserver.model.world.actor.event.ActorSpawnEvent;
import com.l2jserver.util.dimensional.Point;
/**
* Event dispatched once a {@link NPC} has spawned in the world.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class NPCSpawnEvent extends ActorSpawnEvent implements NPCEvent {
/**
* @param npc
* the npc
* @param point
* the spawn point
*/
public NPCSpawnEvent(NPC npc, Point point) {
super(npc, point);
}
@Override
public NPC getNPC() {
return (NPC) super.getActor();
}
}

View File

@@ -16,14 +16,14 @@
*/
package com.l2jserver.model.world.player.event;
import com.l2jserver.service.game.world.event.FilteredWorldListener;
import com.l2jserver.service.game.world.event.TypedWorldListener;
/**
* This listener will filter to only dispatch {@link PlayerEvent} events.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class PlayerListener extends FilteredWorldListener<PlayerEvent> {
public abstract class PlayerListener extends TypedWorldListener<PlayerEvent> {
public PlayerListener() {
super(PlayerEvent.class);
}

View File

@@ -17,62 +17,27 @@
package com.l2jserver.model.world.player.event;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.model.world.event.SpawnEvent;
import com.l2jserver.util.dimensional.Coordinate;
import com.l2jserver.model.world.actor.event.ActorSpawnEvent;
import com.l2jserver.util.dimensional.Point;
/**
* Event dispatcher once an player has spawned in the world
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class PlayerSpawnEvent implements PlayerEvent, SpawnEvent {
public class PlayerSpawnEvent extends ActorSpawnEvent implements PlayerEvent {
/**
* The spawned player
* @param actor
* the player
* @param point
* the spawn point
*/
private final Player player;
/**
* The spawning coordinate
*/
private final Coordinate coordinate;
/**
* Creates a new instance
*
* @param player
* the spawned player
* @param coordinate
* the spawn coordinate
*/
public PlayerSpawnEvent(Player player, Coordinate coordinate) {
this.player = player;
this.coordinate = coordinate;
}
@Override
public Spawnable getObject() {
return player;
public PlayerSpawnEvent(Player player, Point point) {
super(player, point);
}
@Override
public Player getPlayer() {
return player;
}
@Override
public Coordinate getCoordinate() {
return coordinate;
}
@Override
public Actor getActor() {
return player;
}
@Override
public Listenable<?, ?>[] getDispatchableObjects() {
return new Listenable<?, ?>[] { player };
return (Player) getActor();
}
}

View File

@@ -17,7 +17,7 @@
package com.l2jserver.model.world.player.event;
import com.l2jserver.model.world.Player;
import com.l2jserver.util.dimensional.Coordinate;
import com.l2jserver.util.dimensional.Point;
/**
* Event dispatched once an player is teleported to another location
@@ -30,10 +30,10 @@ public class PlayerTeleportEvent extends PlayerSpawnEvent {
*
* @param player
* the teleported player
* @param coordinate
* the coordinate
* @param point
* the teleport point
*/
public PlayerTeleportEvent(Player player, Coordinate coordinate) {
super(player, coordinate);
public PlayerTeleportEvent(Player player, Point point) {
super(player, point);
}
}