mirror of
https://github.com/Rogiel/l2jserver2
synced 2026-01-30 14:32:48 +00:00
Change-Id: I0cca627373c68d94025647f802a7fa6b419e0aad
This commit is contained in:
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
|
||||
import com.l2jserver.model.template.SkillTemplate;
|
||||
import com.l2jserver.model.template.capability.Attackable;
|
||||
import com.l2jserver.model.world.actor.ActorEvent;
|
||||
import com.l2jserver.model.world.actor.ActorListener;
|
||||
import com.l2jserver.model.world.capability.Actor;
|
||||
import com.l2jserver.model.world.capability.Attacker;
|
||||
@@ -124,21 +123,4 @@ public abstract class AbstractActor extends AbstractObject implements Actor {
|
||||
public void equip(Equiper equiper) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(ActorListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(ActorListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatch(ActorEvent e) {
|
||||
for (final ActorListener listener : listeners) {
|
||||
listener.dispatch(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,15 @@ import com.l2jserver.model.id.ObjectID;
|
||||
* @author Rogiel
|
||||
*/
|
||||
public abstract class AbstractObject implements WorldObject {
|
||||
protected ObjectID id;
|
||||
protected ObjectID<?> id;
|
||||
|
||||
public ObjectID getId() {
|
||||
public ObjectID<?> getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(ObjectID id) {
|
||||
public void setID(ObjectID<?> id) {
|
||||
if (this.id != null)
|
||||
throw new IllegalStateException("ID is already set!");
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
71
src/main/java/com/l2jserver/model/world/Clan.java
Normal file
71
src/main/java/com/l2jserver/model/world/Clan.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.l2jserver.model.world;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.model.id.CharacterID;
|
||||
import com.l2jserver.model.id.ClanID;
|
||||
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;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
public class Clan extends AbstractObject implements
|
||||
Listenable<ClanListener, ClanEvent>, Joinable<L2Character> {
|
||||
/**
|
||||
* This clan listeners
|
||||
*/
|
||||
private final List<ClanListener> listeners = CollectionFactory
|
||||
.newList(ClanListener.class);
|
||||
|
||||
/**
|
||||
* Clan leader
|
||||
*/
|
||||
private CharacterID leaderID;
|
||||
|
||||
/**
|
||||
* Members in the clan
|
||||
*/
|
||||
private final ClanMembers members = new ClanMembers(this);
|
||||
|
||||
/**
|
||||
* Remember to save your clan!
|
||||
*/
|
||||
@Override
|
||||
public void join(L2Character member) {
|
||||
members.add(member);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leave(L2Character member) {
|
||||
members.remove(member);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the leaderID
|
||||
*/
|
||||
public CharacterID getLeaderID() {
|
||||
return leaderID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the leader
|
||||
*/
|
||||
public L2Character getLeader() {
|
||||
return leaderID.getObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param leaderID
|
||||
* the leaderID to set
|
||||
*/
|
||||
public void setLeaderID(CharacterID leaderID) {
|
||||
this.leaderID = leaderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClanID getID() {
|
||||
return (ClanID) super.getID();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.l2jserver.model.world;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.model.world.capability.Child;
|
||||
import com.l2jserver.model.id.CharacterID;
|
||||
import com.l2jserver.model.world.capability.Listenable;
|
||||
import com.l2jserver.model.world.capability.Playable;
|
||||
import com.l2jserver.model.world.capability.Spawnable;
|
||||
@@ -12,43 +12,23 @@ import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
public class Item extends AbstractObject implements Playable, Spawnable,
|
||||
Child<Player>, Listenable<ItemListener, ItemEvent> {
|
||||
Listenable<ItemListener, ItemEvent> {
|
||||
private final List<ItemListener> listeners = CollectionFactory
|
||||
.newList(ItemListener.class);
|
||||
|
||||
private CharacterID ownerID;
|
||||
|
||||
@Override
|
||||
public void spawn(Coordinate coordinate) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(ItemListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(ItemListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatch(ItemEvent e) {
|
||||
for (final ItemListener listener : listeners) {
|
||||
listener.dispatch(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpawned() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coordinate getPosition() {
|
||||
// TODO Auto-generated method stub
|
||||
@@ -57,6 +37,21 @@ public class Item extends AbstractObject implements Playable, Spawnable,
|
||||
|
||||
@Override
|
||||
public void setPosition(Coordinate coord) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ownerID
|
||||
*/
|
||||
public CharacterID getOwnerID() {
|
||||
return ownerID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ownerID
|
||||
* the ownerID to set
|
||||
*/
|
||||
public void setOwnerID(CharacterID ownerID) {
|
||||
this.ownerID = ownerID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,137 @@
|
||||
package com.l2jserver.model.world;
|
||||
|
||||
import com.l2jserver.model.id.CharacterID;
|
||||
import com.l2jserver.model.id.ClanID;
|
||||
import com.l2jserver.model.id.PetID;
|
||||
import com.l2jserver.model.world.character.CharacterAppearance;
|
||||
import com.l2jserver.model.world.character.CharacterInventory;
|
||||
|
||||
/**
|
||||
* This class represents a playable character in Lineage II world.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class L2Character extends Player {
|
||||
/**
|
||||
* The clan id
|
||||
*/
|
||||
private ClanID clanID;
|
||||
/**
|
||||
* The pet id
|
||||
*/
|
||||
private PetID petID;
|
||||
/**
|
||||
* The character name
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* The character's status
|
||||
*/
|
||||
private boolean online;
|
||||
|
||||
/**
|
||||
* This character's inventory
|
||||
*/
|
||||
private final CharacterInventory inventory = new CharacterInventory(this);
|
||||
/**
|
||||
* The appearance of this character
|
||||
*/
|
||||
private final CharacterAppearance appearance = new CharacterAppearance(this);
|
||||
|
||||
@Override
|
||||
public CharacterID getId() {
|
||||
return (CharacterID) super.getId();
|
||||
public CharacterID getID() {
|
||||
return (CharacterID) super.getID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clanID
|
||||
*/
|
||||
public ClanID getClanID() {
|
||||
return clanID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clan
|
||||
*/
|
||||
public Clan getClan() {
|
||||
if (clanID == null)
|
||||
return null;
|
||||
return clanID.getObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clanID
|
||||
* the clanID to set
|
||||
*/
|
||||
public void setClanID(ClanID clanID) {
|
||||
this.clanID = clanID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the petID
|
||||
*/
|
||||
public PetID getPetID() {
|
||||
return petID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pet
|
||||
*/
|
||||
public Pet getPet() {
|
||||
if (petID == null)
|
||||
return null;
|
||||
return petID.getObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param petID
|
||||
* the petID to set
|
||||
*/
|
||||
public void setPetID(PetID petID) {
|
||||
this.petID = petID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the online
|
||||
*/
|
||||
public boolean isOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param online
|
||||
* the online to set
|
||||
*/
|
||||
public void setOnline(boolean online) {
|
||||
this.online = online;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the inventory
|
||||
*/
|
||||
public CharacterInventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the appearance
|
||||
*/
|
||||
public CharacterAppearance getAppearance() {
|
||||
return appearance;
|
||||
}
|
||||
}
|
||||
|
||||
36
src/main/java/com/l2jserver/model/world/Party.java
Normal file
36
src/main/java/com/l2jserver/model/world/Party.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.l2jserver.model.world;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.model.id.CharacterID;
|
||||
import com.l2jserver.model.id.ClanID;
|
||||
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;
|
||||
|
||||
public class Party extends AbstractObject implements
|
||||
Listenable<PartyListener, PartyEvent>, Joinable<L2Character> {
|
||||
private final List<PartyListener> listeners = CollectionFactory
|
||||
.newList(PartyListener.class);
|
||||
|
||||
private final List<CharacterID> members = CollectionFactory
|
||||
.newList(CharacterID.class);
|
||||
|
||||
@Override
|
||||
public void join(L2Character member) {
|
||||
members.add(member.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClanID getID() {
|
||||
return (ClanID) super.getID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leave(L2Character member) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,22 @@
|
||||
package com.l2jserver.model.world;
|
||||
|
||||
import com.l2jserver.model.world.capability.Child;
|
||||
import com.l2jserver.model.id.CharacterID;
|
||||
import com.l2jserver.model.world.capability.Summonable;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
|
||||
public class Pet extends Player implements Child<L2Character>, Summonable {
|
||||
@Override
|
||||
public L2Character getParent() {
|
||||
return null;
|
||||
}
|
||||
public class Pet extends Player implements Summonable {
|
||||
private CharacterID ownerID;
|
||||
|
||||
@Override
|
||||
public void teleport(Coordinate coordinate) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void summon(Coordinate coordinate) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,4 +24,26 @@ public class Pet extends Player implements Child<L2Character>, Summonable {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ownerID
|
||||
*/
|
||||
public CharacterID getOwnerID() {
|
||||
return ownerID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the owner
|
||||
*/
|
||||
public L2Character getOwner() {
|
||||
return ownerID.getObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ownerID
|
||||
* the ownerID to set
|
||||
*/
|
||||
public void setOwnerID(CharacterID ownerID) {
|
||||
this.ownerID = ownerID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.l2jserver.model.world;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.model.world.capability.Actor;
|
||||
import com.l2jserver.model.world.capability.Parent;
|
||||
import com.l2jserver.model.world.capability.Playable;
|
||||
import com.l2jserver.model.world.capability.Teleportable;
|
||||
import com.l2jserver.model.world.player.PlayerTeleportEvent;
|
||||
@@ -15,28 +13,12 @@ import com.l2jserver.util.Coordinate;
|
||||
* @author Rogiel
|
||||
*/
|
||||
public abstract class Player extends AbstractActor implements Playable, Actor,
|
||||
Teleportable, Parent {
|
||||
protected Lineage2Connection connection;
|
||||
|
||||
Teleportable {
|
||||
@Override
|
||||
public void teleport(Coordinate coordinate) {
|
||||
final PlayerTeleportEvent event = new PlayerTeleportEvent(this, coordinate);
|
||||
final PlayerTeleportEvent event = new PlayerTeleportEvent(this,
|
||||
coordinate);
|
||||
this.setPosition(coordinate);
|
||||
event.dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the connection
|
||||
*/
|
||||
public Lineage2Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param connection
|
||||
* the connection to set
|
||||
*/
|
||||
public void setConnection(Lineage2Connection connection) {
|
||||
this.connection = connection;
|
||||
// event.dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,21 @@ package com.l2jserver.model.world;
|
||||
import com.l2jserver.model.id.ObjectID;
|
||||
|
||||
public interface WorldObject {
|
||||
ObjectID getId();
|
||||
/**
|
||||
* Get the object's ID
|
||||
*
|
||||
* @return the object id
|
||||
*/
|
||||
ObjectID<?> getID();
|
||||
|
||||
void setId(ObjectID id);
|
||||
/**
|
||||
* Set this object ID. Note that the ID can only be set once. Truing to
|
||||
* change an ID will thrown an {@link IllegalStateException}.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @throws IllegalStateException
|
||||
* if ID is already set
|
||||
*/
|
||||
void setID(ObjectID<?> id) throws IllegalStateException;
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.l2jserver.model.world.capability;
|
||||
|
||||
import com.l2jserver.model.world.AbstractObject;
|
||||
|
||||
/**
|
||||
* Defines an {@link AbstractObject} that is a child of another
|
||||
* {@link AbstractObject}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Child<P extends Parent> extends ObjectCapability {
|
||||
public P getParent();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.l2jserver.model.world.capability;
|
||||
|
||||
import com.l2jserver.model.world.AbstractObject;
|
||||
|
||||
/**
|
||||
* Defines an {@link AbstractObject} that other objects can join to.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Joinable<T> extends ObjectCapability {
|
||||
/**
|
||||
* Join an <tt>member</tt> to this object.
|
||||
*
|
||||
* @param member
|
||||
* the entering member
|
||||
*/
|
||||
void join(T member);
|
||||
|
||||
/**
|
||||
* Removes the joined <tt>member</tt> from this object
|
||||
*
|
||||
* @param member
|
||||
* the exiting member
|
||||
*/
|
||||
void leave(T member);
|
||||
}
|
||||
@@ -17,27 +17,4 @@ import com.l2jserver.model.world.event.WorldListener;
|
||||
*/
|
||||
public interface Listenable<L extends WorldListener<E>, E extends WorldEvent>
|
||||
extends ObjectCapability {
|
||||
/**
|
||||
* Adds a new listener
|
||||
*
|
||||
* @param listener
|
||||
* the listener
|
||||
*/
|
||||
void addListener(L listener);
|
||||
|
||||
/**
|
||||
* Removes an listener
|
||||
*
|
||||
* @param listener
|
||||
* the listener
|
||||
*/
|
||||
void removeListener(L listener);
|
||||
|
||||
/**
|
||||
* Don't use this method directly. It is called by the event dispatcher.
|
||||
*
|
||||
* @param e
|
||||
* the event
|
||||
*/
|
||||
void dispatch(E e);
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.l2jserver.model.world.capability;
|
||||
|
||||
import com.l2jserver.model.world.AbstractObject;
|
||||
|
||||
/**
|
||||
* Defines an {@link AbstractObject} that is the parent of another
|
||||
* {@link AbstractObject}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Parent extends ObjectCapability {
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
package com.l2jserver.model.world.character;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.RGBColor;
|
||||
|
||||
/**
|
||||
* Defines how an character looks in-game.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterAppearance {
|
||||
/**
|
||||
* The parent character
|
||||
*/
|
||||
private final L2Character character;
|
||||
|
||||
/**
|
||||
* The character face
|
||||
*/
|
||||
private CharacterFace face;
|
||||
|
||||
/**
|
||||
* Character possible faces
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public enum CharacterFace {
|
||||
FACE1((byte) 0x00),
|
||||
|
||||
FACE2((byte) 0x01),
|
||||
|
||||
FACE3((byte) 0x02),
|
||||
|
||||
FACE4((byte) 0x03);
|
||||
|
||||
public final byte option;
|
||||
|
||||
CharacterFace(byte option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
public static CharacterFace fromOption(byte option) {
|
||||
for (CharacterFace face : values()) {
|
||||
if (face.option == option)
|
||||
return face;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The character hair color
|
||||
*/
|
||||
private CharacterHairColor hairColor;
|
||||
|
||||
/**
|
||||
* Character possible hair colors
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public enum CharacterHairColor {
|
||||
COLOR1((byte) 0x00),
|
||||
|
||||
COLOR2((byte) 0x01),
|
||||
|
||||
COLOR3((byte) 0x02),
|
||||
|
||||
COLOR4((byte) 0x03);
|
||||
|
||||
public final byte option;
|
||||
|
||||
CharacterHairColor(byte option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
public static CharacterHairColor fromOption(byte option) {
|
||||
for (CharacterHairColor color : values()) {
|
||||
if (color.option == option)
|
||||
return color;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The character hair style
|
||||
*/
|
||||
private CharacterHairStyle hairStyle;
|
||||
|
||||
/**
|
||||
* Character possible hair styles
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public enum CharacterHairStyle {
|
||||
STYLE1((byte) 0x00),
|
||||
|
||||
STYLE2((byte) 0x01),
|
||||
|
||||
STYLE3((byte) 0x02),
|
||||
|
||||
STYLE4((byte) 0x03);
|
||||
|
||||
public final byte option;
|
||||
|
||||
CharacterHairStyle(byte option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
public static CharacterHairStyle fromOption(byte option) {
|
||||
for (CharacterHairStyle style : values()) {
|
||||
if (style.option == option)
|
||||
return style;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The character sex
|
||||
*/
|
||||
private CharacterSex sex;
|
||||
|
||||
/**
|
||||
* Represent the sex of an character.
|
||||
* <p>
|
||||
* TODO this will be moved soon: not only characters have sex, NPC can
|
||||
* have'em too.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public enum CharacterSex {
|
||||
MALE, FEMALE;
|
||||
}
|
||||
|
||||
/**
|
||||
* An alternative name. It will be displayed in-game.
|
||||
* <p>
|
||||
* <b>This is not persisted!</b>
|
||||
*/
|
||||
private String alternativeName;
|
||||
/**
|
||||
* An alternative title. It will be displayed in-game.
|
||||
* <p>
|
||||
* <b>This is not persisted!</b>
|
||||
*/
|
||||
private String alternativeTitle;
|
||||
|
||||
/**
|
||||
* The name color
|
||||
*/
|
||||
private RGBColor nameColor = new RGBColor((byte) 0xFF, (byte) 0xFF,
|
||||
(byte) 0xFF);
|
||||
/**
|
||||
* The title color
|
||||
*/
|
||||
private RGBColor titleColor = new RGBColor((byte) 0xFF, (byte) 0xFF,
|
||||
(byte) 0x77);
|
||||
|
||||
public CharacterAppearance(L2Character character) {
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the character face
|
||||
*/
|
||||
public CharacterFace getFace() {
|
||||
return face;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param face
|
||||
* the character face to set
|
||||
*/
|
||||
public void setFace(CharacterFace face) {
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hair color
|
||||
*/
|
||||
public CharacterHairColor getHairColor() {
|
||||
return hairColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hairColor
|
||||
* the hair color to set
|
||||
*/
|
||||
public void setHairColor(CharacterHairColor hairColor) {
|
||||
this.hairColor = hairColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hair style
|
||||
*/
|
||||
public CharacterHairStyle getHairStyle() {
|
||||
return hairStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hairStyle
|
||||
* the hair style to set
|
||||
*/
|
||||
public void setHairStyle(CharacterHairStyle hairStyle) {
|
||||
this.hairStyle = hairStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the character sex
|
||||
*/
|
||||
public CharacterSex getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sex
|
||||
* the character sex to set
|
||||
*/
|
||||
public void setSex(CharacterSex sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the alternative name
|
||||
*/
|
||||
public String getAlternativeName() {
|
||||
return alternativeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param alternativeName
|
||||
* the alternative name to set
|
||||
*/
|
||||
public void setAlternativeName(String alternativeName) {
|
||||
this.alternativeName = alternativeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the alternative title
|
||||
*/
|
||||
public String getAlternativeTitle() {
|
||||
return alternativeTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param alternativeTitle
|
||||
* the alternative title to set
|
||||
*/
|
||||
public void setAlternativeTitle(String alternativeTitle) {
|
||||
this.alternativeTitle = alternativeTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name color
|
||||
*/
|
||||
public RGBColor getNameColor() {
|
||||
return nameColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nameColor
|
||||
* the name color to set
|
||||
*/
|
||||
public void setNameColor(RGBColor nameColor) {
|
||||
this.nameColor = nameColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the title color
|
||||
*/
|
||||
public RGBColor getTitleColor() {
|
||||
return titleColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param titleColor
|
||||
* the title color to set
|
||||
*/
|
||||
public void setTitleColor(RGBColor titleColor) {
|
||||
this.titleColor = titleColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the character
|
||||
*/
|
||||
public L2Character getCharacter() {
|
||||
return character;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.l2jserver.model.world.character;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jserver.model.id.CharacterID;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
* Defines how an character looks in-game.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterFriendList implements Iterable<L2Character> {
|
||||
private final L2Character character;
|
||||
|
||||
private final Set<CharacterID> friends = CollectionFactory
|
||||
.newSet(CharacterID.class);
|
||||
|
||||
public CharacterFriendList(L2Character character) {
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the character
|
||||
*/
|
||||
public L2Character getCharacter() {
|
||||
return character;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<L2Character> iterator() {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.l2jserver.model.world.character;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
public class CharacterInventory implements Iterable<Item> {
|
||||
private final L2Character character;
|
||||
|
||||
/**
|
||||
* The items in this character inventory
|
||||
*/
|
||||
private final Set<Item> items = CollectionFactory.newSet(Item.class);
|
||||
|
||||
public CharacterInventory(L2Character character) {
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
public void load(List<Item> items) {
|
||||
items.addAll(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the character
|
||||
*/
|
||||
public L2Character getCharacter() {
|
||||
return character;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Item> iterator() {
|
||||
return items.iterator();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.l2jserver.model.world.clan;
|
||||
|
||||
import com.l2jserver.model.world.Clan;
|
||||
import com.l2jserver.model.world.event.WorldEvent;
|
||||
|
||||
public interface ClanEvent extends WorldEvent {
|
||||
Clan getClan();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.l2jserver.model.world.clan;
|
||||
|
||||
import com.l2jserver.model.world.event.WorldListener;
|
||||
|
||||
public interface ClanListener extends WorldListener<ClanEvent> {
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.l2jserver.model.world.clan;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jserver.model.id.CharacterID;
|
||||
import com.l2jserver.model.world.Clan;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
* This class handles members inside an clan
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ClanMembers implements Iterable<CharacterID> {
|
||||
/**
|
||||
* The parent {@link Clan}
|
||||
*/
|
||||
private final Clan clan;
|
||||
|
||||
/**
|
||||
* The list of active members
|
||||
*/
|
||||
private final Set<CharacterID> members = CollectionFactory
|
||||
.newSet(CharacterID.class);
|
||||
|
||||
public ClanMembers(Clan clan) {
|
||||
this.clan = clan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Effectively add this character as a clan member
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @return true if add, false otherwise
|
||||
*/
|
||||
public boolean add(L2Character character) {
|
||||
return members.add(character.getID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Effectively add this character as a clan member
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @return true if add, false otherwise
|
||||
*/
|
||||
public boolean remove(L2Character character) {
|
||||
return members.remove(character.getID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an list of members to this clan
|
||||
*
|
||||
* @param members
|
||||
* the list of members ids
|
||||
*/
|
||||
public void load(List<CharacterID> members) {
|
||||
this.members.addAll(members);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clan
|
||||
*/
|
||||
public Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<CharacterID> iterator() {
|
||||
return members.iterator();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.l2jserver.model.world.event;
|
||||
|
||||
import com.l2jserver.model.world.WorldObject;
|
||||
import com.l2jserver.model.world.capability.Listenable;
|
||||
|
||||
public interface WorldEvent {
|
||||
WorldObject getObject();
|
||||
|
||||
/**
|
||||
* Dispatch this event to all the objects
|
||||
*/
|
||||
void dispatch();
|
||||
Listenable<?, ?>[] getDispatchableObjects();
|
||||
}
|
||||
|
||||
@@ -10,11 +10,13 @@ package com.l2jserver.model.world.event;
|
||||
*/
|
||||
public interface WorldListener<E extends WorldEvent> {
|
||||
/**
|
||||
* Once the event call is dispatched, the listener <b>WILL NOT</b> be
|
||||
* removed. You must manually remove it from the <tt>event</tt> object.
|
||||
* Once the event call is dispatched the listener <b>WILL</b> be removed if
|
||||
* false is returned. If you wish to keep this listener, you must return
|
||||
* true.
|
||||
*
|
||||
* @param e
|
||||
* the event
|
||||
* @return true to keep listener alive
|
||||
*/
|
||||
void dispatch(E e);
|
||||
boolean dispatch(E e);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ public class IDFilter implements WorldObjectFilter<Positionable> {
|
||||
public boolean accept(Positionable other) {
|
||||
if (other == null)
|
||||
return false;
|
||||
return other.getId().equals(id);
|
||||
return other.getID().equals(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ 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.PlayerEvent;
|
||||
|
||||
public class ItemDropEvent implements ItemEvent, PlayerEvent {
|
||||
@@ -30,15 +31,13 @@ public class ItemDropEvent implements ItemEvent, PlayerEvent {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatch() {
|
||||
item.dispatch(this);
|
||||
if (player != null)
|
||||
player.dispatch(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Actor getActor() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listenable<?, ?>[] getDispatchableObjects() {
|
||||
return new Listenable<?, ?>[] { player, item };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.l2jserver.model.world.party;
|
||||
|
||||
import com.l2jserver.model.world.Clan;
|
||||
import com.l2jserver.model.world.event.WorldEvent;
|
||||
|
||||
public interface PartyEvent extends WorldEvent {
|
||||
Clan getClan();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.l2jserver.model.world.party;
|
||||
|
||||
import com.l2jserver.model.world.event.WorldListener;
|
||||
|
||||
public interface PartyListener extends WorldListener<PartyEvent> {
|
||||
}
|
||||
@@ -5,10 +5,10 @@ import com.l2jserver.model.world.actor.ActorListener;
|
||||
|
||||
public abstract class PlayerListener implements ActorListener {
|
||||
@Override
|
||||
public void dispatch(ActorEvent e) {
|
||||
public boolean dispatch(ActorEvent e) {
|
||||
if (!(e instanceof PlayerEvent))
|
||||
return;
|
||||
dispatch((PlayerEvent) e);
|
||||
return false;
|
||||
return dispatch((PlayerEvent) e);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,5 +18,5 @@ public abstract class PlayerListener implements ActorListener {
|
||||
* @param e
|
||||
* the event
|
||||
*/
|
||||
protected abstract void dispatch(PlayerEvent e);
|
||||
protected abstract boolean dispatch(PlayerEvent e);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.l2jserver.model.world.player;
|
||||
|
||||
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.Coordinate;
|
||||
@@ -14,12 +15,6 @@ public class PlayerSpawnEvent implements PlayerEvent, SpawnEvent {
|
||||
this.player = player;
|
||||
this.coordinate = coordinate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatch() {
|
||||
if (player != null)
|
||||
player.dispatch(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spawnable getObject() {
|
||||
@@ -40,4 +35,9 @@ public class PlayerSpawnEvent implements PlayerEvent, SpawnEvent {
|
||||
public Actor getActor() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listenable<?, ?>[] getDispatchableObjects() {
|
||||
return new Listenable<?, ?>[] { player };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user