1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-09 17:02:53 +00:00

First commit

Change-Id: I4d273faba7286288d2b9a214c87c39a76724d787
This commit is contained in:
rogiel
2011-04-28 18:49:39 -03:00
commit 6d52f44278
112 changed files with 1746 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
package com.l2jserver.model.id;
public interface CharacterID extends ObjectID {
}

View File

@@ -0,0 +1,5 @@
package com.l2jserver.model.id;
public interface ID {
}

View File

@@ -0,0 +1,5 @@
package com.l2jserver.model.id;
public interface ObjectID extends ID {
}

View File

@@ -0,0 +1,5 @@
package com.l2jserver.model.id;
public class SimpleID implements ID {
}

View File

@@ -0,0 +1,5 @@
package com.l2jserver.model.id;
public interface TemplateID extends ID {
}

View File

@@ -0,0 +1,16 @@
package com.l2jserver.model.template;
import com.l2jserver.model.id.TemplateID;
public class AbstractTemplate {
private final TemplateID id;
public AbstractTemplate(TemplateID id) {
super();
this.id = id;
}
public TemplateID getId() {
return id;
}
}

View File

@@ -0,0 +1,11 @@
package com.l2jserver.model.template;
import com.l2jserver.model.id.TemplateID;
import com.l2jserver.model.template.capability.Consumable;
public abstract class ConsumableTemplate extends ItemTemplate implements
Consumable {
public ConsumableTemplate(TemplateID id) {
super(id);
}
}

View File

@@ -0,0 +1,9 @@
package com.l2jserver.model.template;
import com.l2jserver.model.id.TemplateID;
public abstract class ItemTemplate extends AbstractTemplate {
public ItemTemplate(TemplateID id) {
super(id);
}
}

View File

@@ -0,0 +1,9 @@
package com.l2jserver.model.template;
import com.l2jserver.model.id.TemplateID;
public abstract class PotionTemplate extends ConsumableTemplate {
public PotionTemplate(TemplateID id) {
super(id);
}
}

View File

@@ -0,0 +1,11 @@
package com.l2jserver.model.template;
import com.l2jserver.model.id.TemplateID;
import com.l2jserver.model.template.capability.Castable;
public abstract class SkillTemplate extends AbstractTemplate implements
Castable {
public SkillTemplate(TemplateID id) {
super(id);
}
}

View File

@@ -0,0 +1,12 @@
package com.l2jserver.model.template;
import com.l2jserver.model.id.TemplateID;
import com.l2jserver.model.template.capability.Attackable;
import com.l2jserver.model.template.capability.Enchantable;
public abstract class WeaponTemplate extends ItemTemplate implements
Attackable, Enchantable {
public WeaponTemplate(TemplateID id) {
super(id);
}
}

View File

@@ -0,0 +1,10 @@
package com.l2jserver.model.template.capability;
import com.l2jserver.model.world.capability.Attacker;
public interface Attackable extends TemplateCapability {
void attack(Attacker source,
com.l2jserver.model.world.capability.Attackable target);
public int getDamage();
}

View File

@@ -0,0 +1,8 @@
package com.l2jserver.model.template.capability;
import com.l2jserver.model.world.capability.Caster;
public interface Castable extends TemplateCapability {
void cast(Caster caster,
com.l2jserver.model.world.capability.Castable target);
}

View File

@@ -0,0 +1,8 @@
package com.l2jserver.model.template.capability;
import com.l2jserver.model.world.capability.Attacker;
public interface Consumable extends TemplateCapability {
void consume(Attacker source,
com.l2jserver.model.world.capability.Attackable target);
}

View File

@@ -0,0 +1,6 @@
package com.l2jserver.model.template.capability;
public interface Enchantable extends TemplateCapability {
void enchant(com.l2jserver.model.world.capability.Enchantable target);
}

View File

@@ -0,0 +1,5 @@
package com.l2jserver.model.template.capability;
public interface TemplateCapability {
}

View File

@@ -0,0 +1,19 @@
package com.l2jserver.model.world;
import com.l2jserver.model.id.ObjectID;
/**
* This is an abstract object representing all the world objects in Lineage II.
* @author Rogiel
*/
public abstract class AbstractObject implements WorldObject {
protected ObjectID id;
public ObjectID getId() {
return id;
}
public void setId(ObjectID id) {
this.id = id;
}
}

View File

@@ -0,0 +1,10 @@
package com.l2jserver.model.world;
import com.l2jserver.model.id.CharacterID;
public class Character extends Player {
@Override
public CharacterID getId() {
return (CharacterID) super.getId();
}
}

View File

@@ -0,0 +1,45 @@
package com.l2jserver.model.world;
import com.l2jserver.model.world.capability.Attackable;
import com.l2jserver.model.world.capability.Attacker;
import com.l2jserver.model.world.capability.Child;
import com.l2jserver.model.world.capability.Playable;
import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.util.Coordinate;
public class Item extends AbstractObject implements Playable, Spawnable,
Attacker, Attackable, Child<Player> {
@Override
public void spawn(Coordinate coordinate) {
}
@Override
public void receiveAttack(Attacker attacker) {
// TODO Auto-generated method stub
}
@Override
public void attack(Attackable target) {
// TODO Auto-generated method stub
}
@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
return null;
}
}

View File

@@ -0,0 +1,10 @@
package com.l2jserver.model.world;
import com.l2jserver.model.world.capability.Child;
public class Pet extends Player implements Child<Character> {
@Override
public Character getParent() {
return null;
}
}

View File

@@ -0,0 +1,90 @@
package com.l2jserver.model.world;
import java.util.List;
import com.l2jserver.model.template.SkillTemplate;
import com.l2jserver.model.world.capability.Attackable;
import com.l2jserver.model.world.capability.Attacker;
import com.l2jserver.model.world.capability.Castable;
import com.l2jserver.model.world.capability.Caster;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.model.world.capability.Parent;
import com.l2jserver.model.world.capability.Playable;
import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.model.world.player.PlayerEvent;
import com.l2jserver.model.world.player.PlayerListener;
import com.l2jserver.util.Coordinate;
/**
* {@link Player} is any object that can be controlled by the player. The most
* common implementation is {@link Character}.
*
* @author Rogiel
*/
public abstract class Player extends AbstractObject implements Playable,
Spawnable, Attacker, Attackable,
Listenable<PlayerListener, PlayerEvent>, Caster, Parent {
@Override
public void spawn(Coordinate coordinate) {
}
@Override
public void receiveAttack(Attacker attacker) {
// TODO Auto-generated method stub
}
@Override
public void attack(Attackable target) {
// TODO Auto-generated method stub
}
@Override
public void addListener(PlayerListener listener) {
// TODO Auto-generated method stub
}
@Override
public void removeListener(PlayerListener listener) {
// TODO Auto-generated method stub
}
@Override
public List<PlayerListener> getListeners() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean support(Class<? extends PlayerEvent> eventType) {
return eventType.isAssignableFrom(PlayerEvent.class);
}
@Override
public Coordinate getPosition() {
// TODO Auto-generated method stub
return null;
}
@Override
public void dispatch(PlayerEvent e) {
// TODO Auto-generated method stub
}
@Override
public void cast(SkillTemplate skill, Castable cast) {
// TODO Auto-generated method stub
}
@Override
public boolean isSpawned() {
// TODO Auto-generated method stub
return false;
}
}

View File

@@ -0,0 +1,9 @@
package com.l2jserver.model.world;
import com.l2jserver.model.id.ObjectID;
public interface WorldObject {
ObjectID getId();
void setId(ObjectID id);
}

View File

@@ -0,0 +1,13 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
/**
* Defines an {@link AbstractObject} that can receive attacks from an
* {@link Attacker}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Attackable extends WorldCapability {
void receiveAttack(Attacker attacker);
}

View File

@@ -0,0 +1,12 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
/**
* Defines an {@link AbstractObject} that can attack an {@link Attackable}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Attacker extends WorldCapability {
void attack(Attackable target);
}

View File

@@ -0,0 +1,12 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
/**
* Defines an {@link AbstractObject} that can receive skill castings.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Castable extends WorldCapability {
void cast();
}

View File

@@ -0,0 +1,13 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.template.SkillTemplate;
import com.l2jserver.model.world.AbstractObject;
/**
* Defines an {@link AbstractObject} that can cast skills.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Caster extends WorldCapability {
void cast(SkillTemplate skill, Castable cast);
}

View File

@@ -0,0 +1,13 @@
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 WorldCapability {
public P getParent();
}

View File

@@ -0,0 +1,12 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
/**
* Defines an {@link AbstractObject} that an player can talk to.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Conversable extends WorldCapability {
}

View File

@@ -0,0 +1,12 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
/**
* Defines an {@link AbstractObject} that can be dropped on the ground.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Dropable extends WorldCapability {
void drop();
}

View File

@@ -0,0 +1,14 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
/**
* Defines an {@link AbstractObject} that can be enchanted.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Enchantable extends WorldCapability {
public int getEnchantLevel();
public int setEnchantLevel();
}

View File

@@ -0,0 +1,13 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
/**
* Defines an {@link AbstractObject} that can be equipped into an
* {@link Equiper}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Equipable extends WorldCapability {
void equip(Equiper equiper);
}

View File

@@ -0,0 +1,17 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
/**
* Defines an {@link AbstractObject} that can be equipped with {@link Equipable}
* instances.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Equiper extends WorldCapability {
void equip(Equipable equipable);
void setEquipment(Object slot, Equipable equipment);
void getEquipment(Object slot);
}

View File

@@ -0,0 +1,31 @@
package com.l2jserver.model.world.capability;
import java.util.List;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.model.world.event.WorldEvent;
import com.l2jserver.model.world.event.WorldListener;
/**
* Defines an {@link AbstractObject} that can attach {@link WorldListener} that
* notifies of events on that object.
*
* @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>, E extends WorldEvent>
extends WorldCapability {
void addListener(L listener);
void removeListener(L listener);
List<L> getListeners();
boolean support(Class<? extends E> eventType);
void dispatch(E e);
}

View File

@@ -0,0 +1,12 @@
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 WorldCapability {
}

View File

@@ -0,0 +1,13 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
/**
* Defines an {@link AbstractObject} that can be played (i.e. controlled by the
* player)
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Playable extends WorldCapability {
}

View File

@@ -0,0 +1,13 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.util.Coordinate;
/**
* Defines an {@link AbstractObject} that can be positioned in the world.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Positionable extends WorldCapability {
Coordinate getPosition();
}

View File

@@ -0,0 +1,27 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.service.game.script.Script;
/**
* Defines an {@link AbstractObject} that can be controller by an {@link Script}
* implementation.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Scriptable extends WorldCapability {
/**
* The the current script attached to this object
*
* @return the attached script
*/
Script<Scriptable> getScript();
/**
* Set the attached script to this object
*
* @param script
* the script
*/
void setScript(Script<Scriptable> script);
}

View File

@@ -0,0 +1,15 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.util.Coordinate;
/**
* Represents an {@link AbstractObject} that can be spawned.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Spawnable extends WorldCapability, Positionable {
void spawn(Coordinate coordinate);
boolean isSpawned();
}

View File

@@ -0,0 +1,15 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.util.Coordinate;
/**
* Represents an {@link AbstractObject} that can be summoned.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface Summunable extends Spawnable {
void summon(Coordinate coordinate);
boolean isSummoned();
}

View File

@@ -0,0 +1,13 @@
package com.l2jserver.model.world.capability;
import com.l2jserver.model.world.AbstractObject;
import com.l2jserver.model.world.WorldObject;
/**
* Defines an base interface for all capabilities for {@link AbstractObject}
* instances. No implementing class need to implement this interface.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface WorldCapability extends WorldObject {
}

View File

@@ -0,0 +1,7 @@
package com.l2jserver.model.world.event;
import com.l2jserver.model.world.capability.Spawnable;
public interface SpawnEvent extends WorldEvent {
Spawnable getObject();
}

View File

@@ -0,0 +1,5 @@
package com.l2jserver.model.world.event;
public interface WorldEvent {
}

View File

@@ -0,0 +1,5 @@
package com.l2jserver.model.world.event;
public interface WorldListener<E extends WorldEvent> {
void onAction(E e);
}

View File

@@ -0,0 +1,20 @@
package com.l2jserver.model.world.filter;
import com.l2jserver.model.world.WorldObject;
public class AndFilter<O extends WorldObject> implements WorldFilter<O> {
private WorldFilter<O>[] filters;
public AndFilter(WorldFilter<O>... filters) {
this.filters = filters;
}
@Override
public boolean accept(O object) {
for(final WorldFilter<O> filter : filters) {
if(!filter.accept(object))
return false;
}
return true;
}
}

View File

@@ -0,0 +1,16 @@
package com.l2jserver.model.world.filter;
import com.l2jserver.model.world.WorldObject;
public class NotFilter<O extends WorldObject> implements WorldFilter<O> {
private WorldFilter<O> filter;
public NotFilter(WorldFilter<O> filter) {
this.filter = filter;
}
@Override
public boolean accept(O object) {
return !filter.accept(object);
}
}

View File

@@ -0,0 +1,20 @@
package com.l2jserver.model.world.filter;
import com.l2jserver.model.world.WorldObject;
public class OrFilter<O extends WorldObject> implements WorldFilter<O> {
private WorldFilter<O>[] filters;
public OrFilter(WorldFilter<O>... filters) {
this.filters = filters;
}
@Override
public boolean accept(O object) {
for(final WorldFilter<O> filter : filters) {
if(filter.accept(object))
return true;
}
return false;
}
}

View File

@@ -0,0 +1,19 @@
package com.l2jserver.model.world.filter;
import com.l2jserver.model.world.WorldObject;
/**
* Filter an object in a world
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface WorldFilter<O extends WorldObject> {
/**
* Test if <tt>object</tt> matches the filter requirements
*
* @param object
* the object
* @return true if object match requirements
*/
boolean accept(O object);
}

View File

@@ -0,0 +1,20 @@
package com.l2jserver.model.world.filter;
import com.l2jserver.model.world.WorldObject;
public final class WorldFilters {
public static final <O extends WorldObject> WorldFilter<O> and(
WorldFilter<O>... filters) {
return new AndFilter<O>(filters);
}
public static final <O extends WorldObject> WorldFilter<O> or(
WorldFilter<O>... filters) {
return new OrFilter<O>(filters);
}
public static final <O extends WorldObject> WorldFilter<O> notf(
WorldFilter<O> filter) {
return new NotFilter<O>(filter);
}
}

View File

@@ -0,0 +1,20 @@
package com.l2jserver.model.world.filter.impl;
import com.l2jserver.model.id.ID;
import com.l2jserver.model.world.capability.Positionable;
import com.l2jserver.model.world.filter.WorldFilter;
public class IDFilter implements WorldFilter<Positionable> {
private final ID id;
public IDFilter(final ID id) {
this.id = id;
}
@Override
public boolean accept(Positionable other) {
if (other == null)
return false;
return other.getId().equals(id);
}
}

View File

@@ -0,0 +1,26 @@
package com.l2jserver.model.world.filter.impl;
import com.l2jserver.model.world.capability.Positionable;
import com.l2jserver.model.world.filter.WorldFilter;
import com.l2jserver.util.Coordinate;
public class RangeFilter implements WorldFilter<Positionable> {
private final Coordinate coordinate;
private final int range;
public RangeFilter(final Coordinate coordinate, final int range) {
this.coordinate = coordinate;
this.range = range;
}
public RangeFilter(final Positionable positionable, final int range) {
this(positionable.getPosition(), range);
}
@Override
public boolean accept(Positionable other) {
if (other == null)
return false;
return other.getPosition().getDistance(coordinate) <= range;
}
}

View File

@@ -0,0 +1,8 @@
package com.l2jserver.model.world.item;
import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.event.WorldEvent;
public interface ItemEvent extends WorldEvent {
Item getItem();
}

View File

@@ -0,0 +1,6 @@
package com.l2jserver.model.world.item;
import com.l2jserver.model.world.event.WorldListener;
public interface ItemListener extends WorldListener<ItemEvent> {
}

View File

@@ -0,0 +1,8 @@
package com.l2jserver.model.world.player;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.event.WorldEvent;
public interface PlayerEvent extends WorldEvent {
Player getPlayer();
}

View File

@@ -0,0 +1,6 @@
package com.l2jserver.model.world.player;
import com.l2jserver.model.world.event.WorldListener;
public interface PlayerListener extends WorldListener<PlayerEvent> {
}

View File

@@ -0,0 +1,23 @@
package com.l2jserver.model.world.player;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.capability.Spawnable;
import com.l2jserver.model.world.event.SpawnEvent;
public class PlayerSpawnEvent implements PlayerEvent, SpawnEvent {
private final Player player;
public PlayerSpawnEvent(Player player) {
this.player = player;
}
@Override
public Spawnable getObject() {
return player;
}
@Override
public Player getPlayer() {
return player;
}
}