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

Completed documentation

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-14 13:27:28 -03:00
parent e9c6f1b027
commit 4b9d52e724
56 changed files with 716 additions and 26 deletions

View File

@@ -7,8 +7,8 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.l2jserver.model.id.object.allocator.BitSetIDAllocator;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.object.factory.CharacterIDFactory;
import com.l2jserver.model.id.object.factory.CharacterIDFactory.CharacterIDGuiceFactory;
import com.l2jserver.model.id.object.factory.ItemIDFactory;
import com.l2jserver.model.id.object.factory.CharacterIDFactory.CharacterIDGuiceFactory;
import com.l2jserver.model.id.object.factory.ItemIDFactory.ItemIDGuiceFactory;
import com.l2jserver.model.id.template.factory.CharacterTemplateIDFactory;
import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;

View File

@@ -1,7 +1,16 @@
package com.l2jserver.model.template.capability;
import com.l2jserver.model.template.Template;
import com.l2jserver.model.world.capability.Attacker;
/**
* Defines an {@link Template template} {@link TemplateCapability capability}
* that an {@link Attacker} can use to attack an
* {@link com.l2jserver.model.world.capability.Attackable}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public interface Attackable extends TemplateCapability {
void attack(Attacker source,
com.l2jserver.model.world.capability.Attackable target);

View File

@@ -1,7 +1,16 @@
package com.l2jserver.model.template.capability;
import com.l2jserver.model.template.Template;
import com.l2jserver.model.world.capability.Caster;
/**
* Defines an {@link Template template} {@link TemplateCapability capability}
* that an {@link Caster} can cast on an
* {@link com.l2jserver.model.world.capability.Castable}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public interface Castable extends TemplateCapability {
void cast(Caster caster,
com.l2jserver.model.world.capability.Castable... targets);

View File

@@ -1,7 +1,14 @@
package com.l2jserver.model.template.capability;
import com.l2jserver.model.template.Template;
import com.l2jserver.model.world.capability.Attacker;
/**
* Defines an {@link Template template} {@link TemplateCapability capability}
* that can be consumed.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Consumable extends TemplateCapability {
void consume(Attacker source,
com.l2jserver.model.world.capability.Attackable target);

View File

@@ -1,7 +1,15 @@
package com.l2jserver.model.template.capability;
import com.l2jserver.model.template.Template;
import com.l2jserver.model.world.capability.Attacker;
/**
* Defines an {@link Template template} {@link TemplateCapability capability}
* that an {@link com.l2jserver.model.world.capability.Attackable} can use to
* defend from an {@link Attacker}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Defendable extends TemplateCapability {
void defend(Attacker source,
com.l2jserver.model.world.capability.Attackable target);

View File

@@ -1,5 +1,13 @@
package com.l2jserver.model.template.capability;
import com.l2jserver.model.template.Template;
/**
* Defines an {@link Template template} {@link TemplateCapability capability}
* for an object that can be enchanted.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Enchantable extends TemplateCapability {
void enchant(com.l2jserver.model.world.capability.Enchantable target);
}

View File

@@ -1,7 +1,15 @@
package com.l2jserver.model.template.capability;
import com.l2jserver.model.template.Template;
import com.l2jserver.model.world.capability.Equiper;
/**
* Defines an {@link Template template} {@link TemplateCapability capability}
* for an object that acn be equipable by an {@link Equiper}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public interface Equipable extends TemplateCapability {
void equip(Equiper equiper);
}

View File

@@ -5,7 +5,7 @@ import com.l2jserver.model.world.capability.Equiper;
/**
* Indicated than an {@link AbstractTemplate} can add penalties to an given
* user.
* {@link Equiper}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/

View File

@@ -1,5 +1,12 @@
package com.l2jserver.model.template.capability;
public interface TemplateCapability {
import com.l2jserver.model.template.Template;
/**
* Defines an {@link Template template} {@link TemplateCapability capability}.
* Each capability is something that the template "knows" and "can" do.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface TemplateCapability {
}

View File

@@ -10,7 +10,15 @@ import com.l2jserver.model.world.capability.Equipable;
import com.l2jserver.model.world.capability.Equiper;
import com.l2jserver.util.Coordinate;
/**
* Abstract {@link Actor} class.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class AbstractActor extends AbstractObject implements Actor {
/**
* The actor race
*/
protected Race race;
/**
@@ -37,6 +45,9 @@ public abstract class AbstractActor extends AbstractObject implements Actor {
}
}
/**
* The actor sex
*/
protected Sex sex;
/**
@@ -63,10 +74,21 @@ public abstract class AbstractActor extends AbstractObject implements Actor {
}
}
/**
* The actor level
*/
protected int level;
/**
* The actor HP
*/
protected int hp;
/**
* The actor coordinate
*/
protected Coordinate position;
/**
* The currently effects active on the actor
*/
protected final ActorEffects effects = new ActorEffects(this);
@Override

View File

@@ -8,6 +8,9 @@ import com.l2jserver.model.id.ObjectID;
* @author Rogiel
*/
public abstract class AbstractObject implements WorldObject {
/**
* The {@link ObjectID}
*/
protected ObjectID<?> id;
public ObjectID<?> getID() {

View File

@@ -11,6 +11,11 @@ import com.l2jserver.model.world.clan.ClanEvent;
import com.l2jserver.model.world.clan.ClanListener;
import com.l2jserver.model.world.clan.ClanMembers;
/**
* This class represents an clan in the Lineage II world
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Clan extends AbstractObject implements
Listenable<ClanListener, ClanEvent>, Joinable<L2Character> {
/**
@@ -23,9 +28,6 @@ public class Clan extends AbstractObject implements
*/
private final ClanMembers members = new ClanMembers(this);
/**
* Remember to save your clan!
*/
@Override
public void join(L2Character member) {
members.add(member);

View File

@@ -12,6 +12,26 @@ import com.l2jserver.model.world.item.ItemEvent;
import com.l2jserver.model.world.item.ItemListener;
import com.l2jserver.util.Coordinate;
/**
* This class represents an {@link Item} in the Lineage II World. The item can
* be:
* <ul>
* <li><b>In the {@link L2Character character} inventory</b>: <tt>location</tt>
* is {@link InventoryLocation#INVENTORY}, <tt>coordinate</tt> and
* <tt>paperdoll</tt> are null.</li>
* <li><b>In the {@link L2Character character} warehouse</b>: <tt>location</tt>
* is {@link InventoryLocation#WAREHOUSE}, <tt>coordinate</tt> and
* <tt>paperdoll</tt> are null.</li>
* <li><b>Equipped by the {@link L2Character character}</b>: <tt>location</tt>
* is {@link InventoryLocation#PAPERDOLL}, <tt>paperdoll</tt> is not null and
* <tt>coordinate</tt> is null.</li>
* <li><b>Dropped on the ground</b>: <tt>location</li> and <tt>paperdoll</tt>
* are null, <tt>coordinate</tt> is not null and represents the dropping
* location.
* </ul>
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Item extends AbstractObject implements Playable, Spawnable,
Listenable<ItemListener, ItemEvent>, Dropable {
private final ItemTemplateID templateID;

View File

@@ -12,8 +12,16 @@ import com.l2jserver.model.world.party.PartyEvent;
import com.l2jserver.model.world.party.PartyListener;
import com.l2jserver.util.factory.CollectionFactory;
/**
* This class represents an Party in Lineage II world
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Party extends AbstractObject implements
Listenable<PartyListener, PartyEvent>, Joinable<L2Character> {
/**
* Active party members
*/
private final List<CharacterID> members = CollectionFactory
.newList(CharacterID.class);
@@ -29,7 +37,6 @@ public class Party extends AbstractObject implements
@Override
public void leave(L2Character member) {
// TODO Auto-generated method stub
}

View File

@@ -1,11 +1,24 @@
package com.l2jserver.model.world;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.ItemID;
import com.l2jserver.model.world.capability.Summonable;
import com.l2jserver.util.Coordinate;
/**
* This class represents an Pet in the Lineage II World
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Pet extends Player implements Summonable {
/**
* The {@link CharacterID} pet's owner
*/
private CharacterID ownerID;
/**
* {@link ItemID} used to summon this pet
*/
private ItemID itemID;
@Override
public void teleport(Coordinate coordinate) {
@@ -26,7 +39,7 @@ public class Pet extends Player implements Summonable {
}
/**
* @return the ownerID
* @return the owner ID
*/
public CharacterID getOwnerID() {
return ownerID;
@@ -41,9 +54,31 @@ public class Pet extends Player implements Summonable {
/**
* @param ownerID
* the ownerID to set
* the owner ID to set
*/
public void setOwnerID(CharacterID ownerID) {
this.ownerID = ownerID;
}
/**
* @return the item ID
*/
public ItemID getItemID() {
return itemID;
}
/**
* @return the item
*/
public Item getItem() {
return itemID.getObject();
}
/**
* @param itemID
* the item ID to set
*/
public void setItemID(ItemID itemID) {
this.itemID = itemID;
}
}

View File

@@ -2,6 +2,13 @@ package com.l2jserver.model.world;
import com.l2jserver.model.id.ObjectID;
/**
* This is an base interface that every object in the Lineage II World need to
* implement. The only methods defines by this class are getters and setters for
* {@link ObjectID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface WorldObject {
/**
* Get the object's ID

View File

@@ -2,9 +2,23 @@ package com.l2jserver.model.world.actor;
import com.l2jserver.model.world.capability.Actor;
/**
* Class controlling active effects on an {@link Actor}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ActorEffects {
/**
* The actor being affected by the effects
*/
private final Actor actor;
/**
* Creates a new instance
*
* @param actor
* the actor
*/
public ActorEffects(Actor actor) {
this.actor = actor;
}

View File

@@ -3,6 +3,11 @@ package com.l2jserver.model.world.actor;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.event.WorldEvent;
/**
* Base event for {@link Actor} instances
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface ActorEvent extends WorldEvent {
Actor getActor();
}

View File

@@ -1,5 +1,12 @@
package com.l2jserver.model.world.actor;
import com.l2jserver.model.world.capability.Actor;
/**
* This enumeration maps for each level the minimum experience required.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum ActorExperience {
/**
* This is an unreachable level!
@@ -60,6 +67,13 @@ public enum ActorExperience {
this.level = this.ordinal();
}
/**
* Look for level of the {@link Actor} given it's <tt>experience</tt>
*
* @param experience
* the experience value
* @return the {@link ActorExperience}
*/
public static ActorExperience getLevel(long experience) {
ActorExperience last = ActorExperience.LEVEL_0;
for (ActorExperience exp : values()) {

View File

@@ -1,6 +1,12 @@
package com.l2jserver.model.world.actor;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.event.WorldListener;
/**
* Base listener for {@link Actor} instances
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface ActorListener extends WorldListener<ActorEvent> {
}

View File

@@ -1,5 +1,15 @@
package com.l2jserver.model.world.character;
import com.l2jserver.model.template.CharacterTemplate;
/**
* Defines attributes of the character. Implementations can use an static value
* (i.e. from {@link CharacterTemplate}) or can use an calculator to define
* values, composed from many attributes objects.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public interface CharacterAttributes {
/**
* @return the intelligence

View File

@@ -1,9 +1,23 @@
package com.l2jserver.model.world.character;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.L2Character;
/**
* This {@link CharacterAttributes} implementation calculates the <b>real</b>
* character attributes based on it's {@link CharacterTemplate} and active
* buffs.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterCalculatedAttributes implements CharacterAttributes {
/**
* The character
*/
private final L2Character character;
/**
* The base attributes (from {@link CharacterTemplate})
*/
private final CharacterAttributes baseAttributes;
public CharacterCalculatedAttributes(L2Character character) {

View File

@@ -143,12 +143,41 @@ public enum CharacterClass {
null, null), DUMMY_ENTRY_33(0x79, null, false, null, null), DUMMY_ENTRY_34(
0x7a, null, false, null, null);
/**
* The Class ID
*/
public final int id;
/**
* The class type
*/
public final ClassType type;
/**
* Is this class summoner?
*/
public final boolean summoner;
/**
* The class race
*/
public final Race race;
/**
* The parent class
*/
public final CharacterClass parent;
/**
* Creates a new class
*
* @param id
* the id
* @param type
* the type
* @param summoner
* is summoner
* @param race
* the race
* @param parent
* the parent
*/
private CharacterClass(int id, ClassType type, boolean summoner, Race race,
CharacterClass parent) {
this.id = id;
@@ -158,31 +187,104 @@ public enum CharacterClass {
this.parent = parent;
}
/**
* Creates a new instance, will inherit <tt>type</tt>, <tt>summoner</tt> and
* <tt>race</tt> from <tt>parent</tt>
*
* @param id
* the id
* @param parent
* the parent
*/
private CharacterClass(int id, CharacterClass parent) {
this(id, parent.type, parent.summoner, parent.race, parent);
}
/**
* Creates a new instance, will inherit <tt>type</tt> and <tt>race</tt> from
* <tt>parent</tt>
*
* @param id
* the class id
* @param summoner
* is summoner
* @param parent
* the parent
*/
private CharacterClass(int id, boolean summoner, CharacterClass parent) {
this(id, parent.type, summoner, parent.race, parent);
}
/**
* Creates a new instance, will inherit <tt>type</tt> and <tt>summoner</tt>
* from <tt>parent</tt>
*
* @param id
* the class id
* @param race
* the race
* @param parent
* the parent class
*/
private CharacterClass(int id, Race race, CharacterClass parent) {
this(id, parent.type, parent.summoner, race, parent);
}
/**
* Creates a new instance, will inherit <tt>summoner</tt> will be false and
* <tt>parent</tt> null.
*
* @param id
* the id
* @param type
* the class type
* @param race
* the class race
*/
private CharacterClass(int id, ClassType type, Race race) {
this(id, type, false, race, null);
}
/**
* Creates a new instance will inherit <tt>race</tt> from <tt/>parent</tt>.
* <tt>summoner</tt> will be false
*
* @param id
* the class id
* @param type
* the class type
* @param parent
* the parent class
*/
private CharacterClass(int id, ClassType type, CharacterClass parent) {
this(id, type, false, parent.race, parent);
}
/**
* Creates a new instance will inherit <tt>race</tt> from <tt/>parent</tt>
*
* @param id
* the class id
* @param type
* the class type
* @param summoner
* is class summoner
* @param parent
* the parent class
*/
private CharacterClass(int id, ClassType type, boolean summoner,
CharacterClass parent) {
this(id, type, summoner, parent.race, parent);
}
/**
* Tries to locate the class based on its ID. If not found, <tt>null</tt> is
* returned.
*
* @param id
* the class id
* @return the {@link CharacterClass} instance found
*/
public CharacterClass fromID(int id) {
for (final CharacterClass c : values()) {
if (c.id == id)
@@ -202,6 +304,11 @@ public enum CharacterClass {
return 1 + parent.level();
}
/**
* The class type
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum ClassType {
FIGHTER, MYSTIC, PRIEST;
}

View File

@@ -10,16 +10,28 @@ import com.l2jserver.model.world.L2Character;
import com.l2jserver.util.factory.CollectionFactory;
/**
* Defines how an character looks in-game.
* Controls the friend list of an {@link L2Character}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterFriendList implements Iterable<L2Character> {
/**
* The character
*/
private final L2Character character;
/**
* The list of friends of this character
*/
private final Set<CharacterID> friends = CollectionFactory
.newSet(CharacterID.class);
/**
* Creates a new instance
*
* @param character
* the parent character
*/
public CharacterFriendList(L2Character character) {
this.character = character;
}
@@ -45,6 +57,14 @@ public class CharacterFriendList implements Iterable<L2Character> {
return new WorldObjectIterator<L2Character>(friends.iterator());
}
/**
* Load an {@link Collection} of {@link CharacterID} to this object.
* <p>
* Note that this is normally used by DAOs do load data.
*
* @param list
* the id list
*/
public void load(Collection<CharacterID> list) {
friends.addAll(list);
}

View File

@@ -8,7 +8,15 @@ import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.util.factory.CollectionFactory;
/**
* This class controls an {@link L2Character} inventory
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterInventory implements Iterable<Item> {
/**
* The character
*/
private final L2Character character;
/**
@@ -16,6 +24,12 @@ public class CharacterInventory implements Iterable<Item> {
*/
private final Set<Item> items = CollectionFactory.newSet(Item.class);
/**
* Creates a new instance
*
* @param character
* the character
*/
public CharacterInventory(L2Character character) {
this.character = character;
}
@@ -43,10 +57,31 @@ public class CharacterInventory implements Iterable<Item> {
return items.iterator();
}
/**
* Location of an item
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum InventoryLocation {
PAPERDOLL, INVENTORY;
/**
* The item is equipped
*/
PAPERDOLL,
/**
* The item is stored in the inventory
*/
INVENTORY,
/**
* The item is in the warehouse
*/
WAREHOUSE;
}
/**
* {@link InventoryLocation#PAPERDOLL Paperdoll} slots for items
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum InventoryPaperdoll {
UNDERWEAR, HEAD, HAIR1, HAIR2, NECK, RIGHT_HAND, LEFT_HAND, RIGHT_EAR, LEFT_EAR, GLOVES, LEGS, LEFT_FEET, RIGHT_FEET, RIGHT_FINGER, LEFT_FINGER, LEFT_BRACELET, RIGHT_BRACELET, DECORATION_1, DECOREATION_2, DECORATION_3, DECORATION_4, DECORATION_5, DECORATION_6, CLOAK, BELT;
}

View File

@@ -3,6 +3,14 @@ package com.l2jserver.model.world.clan;
import com.l2jserver.model.world.Clan;
import com.l2jserver.model.world.event.WorldEvent;
/**
* Base event for {@link Clan} objects
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface ClanEvent extends WorldEvent {
/**
* @return the clan
*/
Clan getClan();
}

View File

@@ -2,5 +2,10 @@ package com.l2jserver.model.world.clan;
import com.l2jserver.model.world.event.WorldListener;
/**
* Base listener for {@link ClanEvent}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface ClanListener extends WorldListener<ClanEvent> {
}

View File

@@ -26,6 +26,12 @@ public class ClanMembers implements Iterable<CharacterID> {
private final Set<CharacterID> members = CollectionFactory
.newSet(CharacterID.class);
/**
* Creates a new instance
*
* @param clan
* the clan
*/
public ClanMembers(Clan clan) {
this.clan = clan;
}

View File

@@ -3,7 +3,13 @@ package com.l2jserver.model.world.event;
import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.util.Coordinate;
/**
* Event for objects spawning
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface SpawnEvent extends WorldEvent {
@Override
Spawnable getObject();
Coordinate getCoordinate();

View File

@@ -4,7 +4,13 @@ import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.capability.Listenable;
public interface WorldEvent {
/**
* @return the object that issued this event
*/
WorldObject getObject();
/**
* @return the list of objects that will be notified of this event
*/
Listenable<?, ?>[] getDispatchableObjects();
}

View File

@@ -2,9 +2,27 @@ package com.l2jserver.model.world.filter;
import com.l2jserver.model.world.WorldObject;
/**
* <tt>AND</tt> filter that accepts all values in which all other
* <tt>filters</tt> return true.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
* @param <O>
* the item type
*/
public class AndFilter<O extends WorldObject> implements WorldObjectFilter<O> {
/**
* The filters
*/
private WorldObjectFilter<O>[] filters;
/**
* Creates a new instance
*
* @param filters
* filters to be used with <tt>AND</tt> operator
*/
public AndFilter(WorldObjectFilter<O>... filters) {
this.filters = filters;
}

View File

@@ -2,9 +2,27 @@ package com.l2jserver.model.world.filter;
import com.l2jserver.model.world.WorldObject;
/**
* And filter that accepts all values in which the other <tt>filter</tt> return
* false.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
* @param <O>
* the item type
*/
public class NotFilter<O extends WorldObject> implements WorldObjectFilter<O> {
/**
* The filter
*/
private WorldObjectFilter<O> filter;
/**
* Creates a new instance
*
* @param filter
* the filter
*/
public NotFilter(WorldObjectFilter<O> filter) {
this.filter = filter;
}

View File

@@ -2,9 +2,27 @@ package com.l2jserver.model.world.filter;
import com.l2jserver.model.world.WorldObject;
/**
* <tt>OR</tt> filter that accepts all values in which at least one of the
* <tt>filters</tt> return true.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
* @param <O>
* the item type
*/
public class OrFilter<O extends WorldObject> implements WorldObjectFilter<O> {
/**
* The filters
*/
private WorldObjectFilter<O>[] filters;
/**
* Creates a new instance
*
* @param filters
* filters to be used with <tt>OR</tt> operator
*/
public OrFilter(WorldObjectFilter<O>... filters) {
this.filters = filters;
}

View File

@@ -2,18 +2,50 @@ package com.l2jserver.model.world.filter;
import com.l2jserver.model.world.WorldObject;
/**
* Utility class for common filter types
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public final class WorldFilters {
/**
* Performs an <tt>AND</tt> operation
*
* @param <O>
* the object type
* @param filters
* the filters
* @return the {@link AndFilter}
*/
public static final <O extends WorldObject> WorldObjectFilter<O> and(
WorldObjectFilter<O>... filters) {
return new AndFilter<O>(filters);
}
/**
* Performs an <tt>OR</tt> operation
*
* @param <O>
* the object type
* @param filters
* the filters
* @return the {@link OrFilter}
*/
public static final <O extends WorldObject> WorldObjectFilter<O> or(
WorldObjectFilter<O>... filters) {
return new OrFilter<O>(filters);
}
public static final <O extends WorldObject> WorldObjectFilter<O> notf(
/**
* Performs an <tt>NOTA</tt> operation
*
* @param <O>
* the object type
* @param filters
* the filters
* @return the {@link NotFilter}
*/
public static final <O extends WorldObject> WorldObjectFilter<O> not(
WorldObjectFilter<O> filter) {
return new NotFilter<O>(filter);
}

View File

@@ -4,9 +4,23 @@ import com.l2jserver.model.id.ID;
import com.l2jserver.model.world.capability.Positionable;
import com.l2jserver.model.world.filter.WorldObjectFilter;
/**
* Filter objects based on its ID.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class IDFilter implements WorldObjectFilter<Positionable> {
/**
* The object id
*/
private final ID id;
/**
* Creates a new instance
*
* @param id
* the desired object ID
*/
public IDFilter(final ID id) {
this.id = id;
}

View File

@@ -3,10 +3,26 @@ package com.l2jserver.model.world.filter.impl;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.filter.WorldObjectFilter;
/**
* Filter object based on their types
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
* @param <T>
* the instance type
*/
public class InstanceFilter<T extends WorldObject> implements
WorldObjectFilter<T> {
/**
* The object's type
*/
private final Class<?> type;
/**
* Creates a new instance
*
* @param instance
* the instance type
*/
public InstanceFilter(Class<?> instance) {
this.type = instance;
}

View File

@@ -4,15 +4,42 @@ import com.l2jserver.model.world.capability.Positionable;
import com.l2jserver.model.world.filter.WorldObjectFilter;
import com.l2jserver.util.Coordinate;
/**
* Filter objects that are in the <tt>range</tt> of <tt>coordinate</tt>
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class RangeFilter implements WorldObjectFilter<Positionable> {
/**
* The coordinate point
*/
private final Coordinate coordinate;
/**
* The desired maximum distance of the object
*/
private final int range;
/**
* Creates a new instance
*
* @param coordinate
* the coordinate as base for range search
* @param range
* the desired maximum distance of the object
*/
public RangeFilter(final Coordinate coordinate, final int range) {
this.coordinate = coordinate;
this.range = range;
}
/**
* Creates a new instance
*
* @param positionable
* the base object
* @param range
* the desired maximum distance of the object
*/
public RangeFilter(final Positionable positionable, final int range) {
this(positionable.getPosition(), range);
}

View File

@@ -7,10 +7,29 @@ import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.model.world.player.PlayerEvent;
/**
* Event dispatched once an {@link Item} has been dropped on the ground.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ItemDropEvent implements ItemEvent, PlayerEvent {
/**
* The dropping player
*/
private final Player player;
/**
* The item dropped
*/
private final Item item;
/**
* Creates a new instance of this event
*
* @param player
* the dropping player
* @param item
* the dropped item
*/
public ItemDropEvent(Player player, Item item) {
this.player = player;
this.item = item;

View File

@@ -3,6 +3,15 @@ package com.l2jserver.model.world.item;
import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.event.WorldEvent;
/**
* Base event for items
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public interface ItemEvent extends WorldEvent {
/**
* @return the item
*/
Item getItem();
}

View File

@@ -2,5 +2,10 @@ package com.l2jserver.model.world.item;
import com.l2jserver.model.world.event.WorldListener;
/**
* Listener for {@link ItemEvent}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface ItemListener extends WorldListener<ItemEvent> {
}

View File

@@ -5,12 +5,38 @@ import java.util.Iterator;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.filter.WorldObjectFilter;
/**
* The {@link FilterIterator} takes an {@link WorldObject} and a
* {@link WorldObjectFilter} and dynamically iterates over the items and find
* the next matching object.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
* @param <O>
* the object type
*/
public class FilterIterator<O extends WorldObject> implements Iterator<O> {
/**
* The unfiltered object iterator
*/
private final Iterator<WorldObject> objects;
/**
* The filter
*/
private final WorldObjectFilter<O> filter;
/**
* The next object found
*/
private O selected;
/**
* Creates a new instance
*
* @param filter
* the filter
* @param objects
* the unfiltered object iterator
*/
public FilterIterator(final WorldObjectFilter<O> filter,
Iterator<WorldObject> objects) {
this.filter = filter;
@@ -36,7 +62,12 @@ public class FilterIterator<O extends WorldObject> implements Iterator<O> {
public void remove() {
}
public O findNext() {
/**
* Locates the next matching object
*
* @return the next matching object
*/
private O findNext() {
if (selected != null)
return selected;
while (objects.hasNext()) {

View File

@@ -1,8 +1,14 @@
package com.l2jserver.model.world.party;
import com.l2jserver.model.world.Clan;
import com.l2jserver.model.world.Party;
import com.l2jserver.model.world.event.WorldEvent;
/**
* Base event for {@link Party} objects
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface PartyEvent extends WorldEvent {
Clan getClan();
}

View File

@@ -2,5 +2,10 @@ package com.l2jserver.model.world.party;
import com.l2jserver.model.world.event.WorldListener;
/**
* Listener for {@link PartyEvent}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface PartyListener extends WorldListener<PartyEvent> {
}

View File

@@ -3,6 +3,14 @@ package com.l2jserver.model.world.player;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.actor.ActorEvent;
/**
* Base event for {@link Player} objects
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface PlayerEvent extends ActorEvent {
/**
* @return the player
*/
Player getPlayer();
}

View File

@@ -5,6 +5,11 @@ import com.l2jserver.model.world.actor.ActorListener;
import com.l2jserver.model.world.event.WorldEvent;
import com.l2jserver.model.world.event.WorldListener;
/**
* Listener for {@link PlayerEvent}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class PlayerListener implements ActorListener {
@Override
public boolean dispatch(ActorEvent e) {

View File

@@ -7,10 +7,29 @@ import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.model.world.event.SpawnEvent;
import com.l2jserver.util.Coordinate;
/**
* 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 {
/**
* The spawned player
*/
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;

View File

@@ -3,7 +3,20 @@ package com.l2jserver.model.world.player;
import com.l2jserver.model.world.Player;
import com.l2jserver.util.Coordinate;
/**
* Event dispatched once an player is teleported.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class PlayerTeleportEvent extends PlayerSpawnEvent {
/**
* Creates a new instance
*
* @param player
* the teleported player
* @param coordinate
* the coordinate
*/
public PlayerTeleportEvent(Player player, Coordinate coordinate) {
super(player, coordinate);
}

View File

@@ -1,6 +0,0 @@
package com.l2jserver.model.world.player;
import com.l2jserver.model.world.event.WorldEvent;
public interface TestEvent extends WorldEvent {
}