commit 6d52f442785223af7561f256e5f9e276c777e5cf Author: rogiel Date: Thu Apr 28 18:49:39 2011 -0300 First commit Change-Id: I4d273faba7286288d2b9a214c87c39a76724d787 diff --git a/.classpath b/.classpath new file mode 100644 index 000000000..a85f9973a --- /dev/null +++ b/.classpath @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 000000000..8c4533f0c --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + l2jserver2-gameserver + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..1855e5851 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,3 @@ +#Thu Apr 28 15:32:21 BRT 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning diff --git a/.settings/org.maven.ide.eclipse.prefs b/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..4479fc27b --- /dev/null +++ b/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,8 @@ +#Thu Apr 28 15:16:57 BRT 2011 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/data/scripts/com/l2jserver/script/DummyScript.java b/data/scripts/com/l2jserver/script/DummyScript.java new file mode 100644 index 000000000..4d3ba44b7 --- /dev/null +++ b/data/scripts/com/l2jserver/script/DummyScript.java @@ -0,0 +1,24 @@ +package com.l2jserver.script; + +import com.l2jserver.model.world.capability.Scriptable; +import com.l2jserver.service.game.script.Script; + +public class DummyScript implements Script { + @Override + public void load(Scriptable object) { + } + + @Override + public void run() { + + } + + @Override + public void unload() { + } + + @Override + public Scriptable getObject() { + return null; + } +} diff --git a/data/template/com/l2jserver/model/template/TestPotionTemplate.java b/data/template/com/l2jserver/model/template/TestPotionTemplate.java new file mode 100644 index 000000000..54429a488 --- /dev/null +++ b/data/template/com/l2jserver/model/template/TestPotionTemplate.java @@ -0,0 +1,15 @@ +package com.l2jserver.model.template; + +import com.l2jserver.model.world.capability.Attackable; +import com.l2jserver.model.world.capability.Attacker; + +public class TestPotionTemplate extends PotionTemplate { + public TestPotionTemplate() { + super(null); + } + + @Override + public void consume(Attacker source, Attackable target) { + //TODO consume item + } +} diff --git a/data/template/com/l2jserver/model/template/TestSkillTemplate.java b/data/template/com/l2jserver/model/template/TestSkillTemplate.java new file mode 100644 index 000000000..ec96e0377 --- /dev/null +++ b/data/template/com/l2jserver/model/template/TestSkillTemplate.java @@ -0,0 +1,15 @@ +package com.l2jserver.model.template; + +import com.l2jserver.model.world.capability.Castable; +import com.l2jserver.model.world.capability.Caster; + +public class TestSkillTemplate extends SkillTemplate { + public TestSkillTemplate() { + super(null); + } + + @Override + public void cast(Caster caster, Castable target) { + // TODO do casting + } +} diff --git a/data/template/com/l2jserver/model/template/TestWeaponTemplate.java b/data/template/com/l2jserver/model/template/TestWeaponTemplate.java new file mode 100644 index 000000000..fdf191d9b --- /dev/null +++ b/data/template/com/l2jserver/model/template/TestWeaponTemplate.java @@ -0,0 +1,31 @@ +package com.l2jserver.model.template; + +import com.l2jserver.model.world.capability.Attackable; +import com.l2jserver.model.world.capability.Attacker; +import com.l2jserver.model.world.capability.Enchantable; + +public class TestWeaponTemplate extends WeaponTemplate { + private static final int DAMAGE = 10; + private static final int MAX_ENCHANT_LEVEL = 10; + + public TestWeaponTemplate() { + super(null); + } + + @Override + public void attack(Attacker source, Attackable target) { + // TODO deal damage! + } + + @Override + public void enchant(Enchantable target) { + if (target.getEnchantLevel() == MAX_ENCHANT_LEVEL) + return; + // TODO do enchant + } + + @Override + public int getDamage() { + return DAMAGE; + } +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000..3e0a4f100 --- /dev/null +++ b/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + com.l2jserver + l2jserver2-gameserver + 2.0.0-DEVEL + L2JServer - Game Server Module + Lineage II server emulator + + + + org.jboss.netty + netty + 3.2.4.Final + compile + + + junit + junit + 4.8.2 + jar + compile + + + com.google.inject + guice + 3.0 + jar + compile + + + + + + repository.jboss.org + https://repository.jboss.org/nexus/content/repositories/releases/ + + false + + + + \ No newline at end of file diff --git a/src/dao/com/l2jserver/db/dao/PlayerDAO.java b/src/dao/com/l2jserver/db/dao/PlayerDAO.java new file mode 100644 index 000000000..2603a5be5 --- /dev/null +++ b/src/dao/com/l2jserver/db/dao/PlayerDAO.java @@ -0,0 +1,13 @@ +package com.l2jserver.db.dao; + +import com.l2jserver.model.world.Player; +import com.l2jserver.service.database.DataAccessObject; + +/** + * The {@link PlayerDAO} is can load and save {@link Player player instances}. + * + * @author Rogiel + */ +public interface PlayerDAO extends DataAccessObject { + void load(Player player); +} diff --git a/src/dao/db4o/com/l2jserver/db/dao/db4o/AbstractDB4ODAO.java b/src/dao/db4o/com/l2jserver/db/dao/db4o/AbstractDB4ODAO.java new file mode 100644 index 000000000..3000916fe --- /dev/null +++ b/src/dao/db4o/com/l2jserver/db/dao/db4o/AbstractDB4ODAO.java @@ -0,0 +1,15 @@ +package com.l2jserver.db.dao.db4o; + +import com.google.inject.Inject; +import com.l2jserver.service.database.AbstractDAO; +import com.l2jserver.service.database.DB4ODatabaseService; + +public class AbstractDB4ODAO extends AbstractDAO implements BD4ODAO { + protected final DB4ODatabaseService database; + + @Inject + protected AbstractDB4ODAO(DB4ODatabaseService database) { + super(database); + this.database = database; + } +} diff --git a/src/dao/db4o/com/l2jserver/db/dao/db4o/BD4ODAO.java b/src/dao/db4o/com/l2jserver/db/dao/db4o/BD4ODAO.java new file mode 100644 index 000000000..8967570ef --- /dev/null +++ b/src/dao/db4o/com/l2jserver/db/dao/db4o/BD4ODAO.java @@ -0,0 +1,5 @@ +package com.l2jserver.db.dao.db4o; + +public interface BD4ODAO { + +} diff --git a/src/dao/db4o/com/l2jserver/db/dao/db4o/DB4OPlayerDAO.java b/src/dao/db4o/com/l2jserver/db/dao/db4o/DB4OPlayerDAO.java new file mode 100644 index 000000000..fd6d1bb9c --- /dev/null +++ b/src/dao/db4o/com/l2jserver/db/dao/db4o/DB4OPlayerDAO.java @@ -0,0 +1,18 @@ +package com.l2jserver.db.dao.db4o; + +import com.google.inject.Inject; +import com.l2jserver.db.dao.PlayerDAO; +import com.l2jserver.model.world.Player; +import com.l2jserver.service.database.DB4ODatabaseService; + +public class DB4OPlayerDAO extends AbstractDB4ODAO implements PlayerDAO { + @Inject + protected DB4OPlayerDAO(DB4ODatabaseService database) { + super(database); + } + + @Override + public void load(Player player) { + + } +} diff --git a/src/main/java/com/l2jserver/game/net/codec/Lineage2Decoder.java b/src/main/java/com/l2jserver/game/net/codec/Lineage2Decoder.java new file mode 100644 index 000000000..629a57b24 --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/codec/Lineage2Decoder.java @@ -0,0 +1,14 @@ +package com.l2jserver.game.net.codec; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.handler.codec.frame.FrameDecoder; + +public class Lineage2Decoder extends FrameDecoder { + @Override + protected Object decode(ChannelHandlerContext ctx, Channel channel, + ChannelBuffer buffer) throws Exception { + return null; + } +} diff --git a/src/main/java/com/l2jserver/game/net/codec/Lineage2Encoder.java b/src/main/java/com/l2jserver/game/net/codec/Lineage2Encoder.java new file mode 100644 index 000000000..f708d19a1 --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/codec/Lineage2Encoder.java @@ -0,0 +1,5 @@ +package com.l2jserver.game.net.codec; + +public class Lineage2Encoder { + +} diff --git a/src/main/java/com/l2jserver/game/net/packet/AbstractClientPacket.java b/src/main/java/com/l2jserver/game/net/packet/AbstractClientPacket.java new file mode 100644 index 000000000..cd9090819 --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/packet/AbstractClientPacket.java @@ -0,0 +1,4 @@ +package com.l2jserver.game.net.packet; + +public abstract class AbstractClientPacket implements ClientPacket { +} diff --git a/src/main/java/com/l2jserver/game/net/packet/AbstractServerPacket.java b/src/main/java/com/l2jserver/game/net/packet/AbstractServerPacket.java new file mode 100644 index 000000000..8dc2e8d63 --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/packet/AbstractServerPacket.java @@ -0,0 +1,14 @@ +package com.l2jserver.game.net.packet; + +public abstract class AbstractServerPacket implements ServerPacket { + private final int opcode; + + public AbstractServerPacket(int opcode) { + this.opcode = opcode; + } + + @Override + public int getOpcode() { + return opcode; + } +} diff --git a/src/main/java/com/l2jserver/game/net/packet/ClientPacket.java b/src/main/java/com/l2jserver/game/net/packet/ClientPacket.java new file mode 100644 index 000000000..a0f784da9 --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/packet/ClientPacket.java @@ -0,0 +1,7 @@ +package com.l2jserver.game.net.packet; + +import org.jboss.netty.buffer.ChannelBuffer; + +public interface ClientPacket extends Packet { + void read(ChannelBuffer buffer); +} diff --git a/src/main/java/com/l2jserver/game/net/packet/Packet.java b/src/main/java/com/l2jserver/game/net/packet/Packet.java new file mode 100644 index 000000000..f895d6988 --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/packet/Packet.java @@ -0,0 +1,5 @@ +package com.l2jserver.game.net.packet; + + +public interface Packet { +} diff --git a/src/main/java/com/l2jserver/game/net/packet/PacketManager.java b/src/main/java/com/l2jserver/game/net/packet/PacketManager.java new file mode 100644 index 000000000..205e41250 --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/packet/PacketManager.java @@ -0,0 +1,5 @@ +package com.l2jserver.game.net.packet; + +public class PacketManager { + +} diff --git a/src/main/java/com/l2jserver/game/net/packet/PacketModule.java b/src/main/java/com/l2jserver/game/net/packet/PacketModule.java new file mode 100644 index 000000000..f437bc58f --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/packet/PacketModule.java @@ -0,0 +1,10 @@ +package com.l2jserver.game.net.packet; + +import com.google.inject.AbstractModule; + +public class PacketModule extends AbstractModule { + @Override + protected void configure() { + + } +} diff --git a/src/main/java/com/l2jserver/game/net/packet/ServerPacket.java b/src/main/java/com/l2jserver/game/net/packet/ServerPacket.java new file mode 100644 index 000000000..ae07e15bb --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/packet/ServerPacket.java @@ -0,0 +1,8 @@ +package com.l2jserver.game.net.packet; + +import org.jboss.netty.buffer.ChannelBuffer; + +public interface ServerPacket extends Packet { + void write(ChannelBuffer buffer); + int getOpcode(); +} diff --git a/src/main/java/com/l2jserver/game/net/packet/client/TestPacket.java b/src/main/java/com/l2jserver/game/net/packet/client/TestPacket.java new file mode 100644 index 000000000..1b0f1dffe --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/packet/client/TestPacket.java @@ -0,0 +1,15 @@ +package com.l2jserver.game.net.packet.client; + +import org.jboss.netty.buffer.ChannelBuffer; + +import com.l2jserver.game.net.packet.AbstractClientPacket; + +public class TestPacket extends AbstractClientPacket { + public static final int OPCODE = 0x00; + + @Override + public void read(ChannelBuffer buffer) { + // TODO Auto-generated method stub + + } +} diff --git a/src/main/java/com/l2jserver/game/net/packet/server/TestPacket.java b/src/main/java/com/l2jserver/game/net/packet/server/TestPacket.java new file mode 100644 index 000000000..3783ff4af --- /dev/null +++ b/src/main/java/com/l2jserver/game/net/packet/server/TestPacket.java @@ -0,0 +1,18 @@ +package com.l2jserver.game.net.packet.server; + +import org.jboss.netty.buffer.ChannelBuffer; + +import com.l2jserver.game.net.packet.AbstractServerPacket; + +public class TestPacket extends AbstractServerPacket { + public static final int OPCODE = 0x00; + + @Override + public void write(ChannelBuffer buffer) { + + } + + public TestPacket() { + super(OPCODE); + } +} diff --git a/src/main/java/com/l2jserver/model/id/CharacterID.java b/src/main/java/com/l2jserver/model/id/CharacterID.java new file mode 100644 index 000000000..5f9a20d5e --- /dev/null +++ b/src/main/java/com/l2jserver/model/id/CharacterID.java @@ -0,0 +1,5 @@ +package com.l2jserver.model.id; + +public interface CharacterID extends ObjectID { + +} diff --git a/src/main/java/com/l2jserver/model/id/ID.java b/src/main/java/com/l2jserver/model/id/ID.java new file mode 100644 index 000000000..9deba53f9 --- /dev/null +++ b/src/main/java/com/l2jserver/model/id/ID.java @@ -0,0 +1,5 @@ +package com.l2jserver.model.id; + +public interface ID { + +} diff --git a/src/main/java/com/l2jserver/model/id/ObjectID.java b/src/main/java/com/l2jserver/model/id/ObjectID.java new file mode 100644 index 000000000..9b04b7dca --- /dev/null +++ b/src/main/java/com/l2jserver/model/id/ObjectID.java @@ -0,0 +1,5 @@ +package com.l2jserver.model.id; + +public interface ObjectID extends ID { + +} diff --git a/src/main/java/com/l2jserver/model/id/SimpleID.java b/src/main/java/com/l2jserver/model/id/SimpleID.java new file mode 100644 index 000000000..84f13c087 --- /dev/null +++ b/src/main/java/com/l2jserver/model/id/SimpleID.java @@ -0,0 +1,5 @@ +package com.l2jserver.model.id; + +public class SimpleID implements ID { + +} diff --git a/src/main/java/com/l2jserver/model/id/TemplateID.java b/src/main/java/com/l2jserver/model/id/TemplateID.java new file mode 100644 index 000000000..49cd4a865 --- /dev/null +++ b/src/main/java/com/l2jserver/model/id/TemplateID.java @@ -0,0 +1,5 @@ +package com.l2jserver.model.id; + +public interface TemplateID extends ID { + +} diff --git a/src/main/java/com/l2jserver/model/template/AbstractTemplate.java b/src/main/java/com/l2jserver/model/template/AbstractTemplate.java new file mode 100644 index 000000000..d065b8acf --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/AbstractTemplate.java @@ -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; + } +} diff --git a/src/main/java/com/l2jserver/model/template/ConsumableTemplate.java b/src/main/java/com/l2jserver/model/template/ConsumableTemplate.java new file mode 100644 index 000000000..0b3c9a6a9 --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/ConsumableTemplate.java @@ -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); + } +} diff --git a/src/main/java/com/l2jserver/model/template/ItemTemplate.java b/src/main/java/com/l2jserver/model/template/ItemTemplate.java new file mode 100644 index 000000000..6074cca37 --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/ItemTemplate.java @@ -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); + } +} diff --git a/src/main/java/com/l2jserver/model/template/PotionTemplate.java b/src/main/java/com/l2jserver/model/template/PotionTemplate.java new file mode 100644 index 000000000..d3155425f --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/PotionTemplate.java @@ -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); + } +} diff --git a/src/main/java/com/l2jserver/model/template/SkillTemplate.java b/src/main/java/com/l2jserver/model/template/SkillTemplate.java new file mode 100644 index 000000000..a65926887 --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/SkillTemplate.java @@ -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); + } +} diff --git a/src/main/java/com/l2jserver/model/template/WeaponTemplate.java b/src/main/java/com/l2jserver/model/template/WeaponTemplate.java new file mode 100644 index 000000000..f1ff61097 --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/WeaponTemplate.java @@ -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); + } +} diff --git a/src/main/java/com/l2jserver/model/template/capability/Attackable.java b/src/main/java/com/l2jserver/model/template/capability/Attackable.java new file mode 100644 index 000000000..43725bc2a --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/capability/Attackable.java @@ -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(); +} diff --git a/src/main/java/com/l2jserver/model/template/capability/Castable.java b/src/main/java/com/l2jserver/model/template/capability/Castable.java new file mode 100644 index 000000000..ec8bb1a2f --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/capability/Castable.java @@ -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); +} diff --git a/src/main/java/com/l2jserver/model/template/capability/Consumable.java b/src/main/java/com/l2jserver/model/template/capability/Consumable.java new file mode 100644 index 000000000..6baab8210 --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/capability/Consumable.java @@ -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); +} diff --git a/src/main/java/com/l2jserver/model/template/capability/Enchantable.java b/src/main/java/com/l2jserver/model/template/capability/Enchantable.java new file mode 100644 index 000000000..7b24993a8 --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/capability/Enchantable.java @@ -0,0 +1,6 @@ +package com.l2jserver.model.template.capability; + + +public interface Enchantable extends TemplateCapability { + void enchant(com.l2jserver.model.world.capability.Enchantable target); +} diff --git a/src/main/java/com/l2jserver/model/template/capability/TemplateCapability.java b/src/main/java/com/l2jserver/model/template/capability/TemplateCapability.java new file mode 100644 index 000000000..ef01ac556 --- /dev/null +++ b/src/main/java/com/l2jserver/model/template/capability/TemplateCapability.java @@ -0,0 +1,5 @@ +package com.l2jserver.model.template.capability; + +public interface TemplateCapability { + +} diff --git a/src/main/java/com/l2jserver/model/world/AbstractObject.java b/src/main/java/com/l2jserver/model/world/AbstractObject.java new file mode 100644 index 000000000..05d76d4f7 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/AbstractObject.java @@ -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; + } +} diff --git a/src/main/java/com/l2jserver/model/world/Character.java b/src/main/java/com/l2jserver/model/world/Character.java new file mode 100644 index 000000000..690f75187 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/Character.java @@ -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(); + } +} diff --git a/src/main/java/com/l2jserver/model/world/Item.java b/src/main/java/com/l2jserver/model/world/Item.java new file mode 100644 index 000000000..a389e8a02 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/Item.java @@ -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 { + @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; + } +} diff --git a/src/main/java/com/l2jserver/model/world/Pet.java b/src/main/java/com/l2jserver/model/world/Pet.java new file mode 100644 index 000000000..d30b231ea --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/Pet.java @@ -0,0 +1,10 @@ +package com.l2jserver.model.world; + +import com.l2jserver.model.world.capability.Child; + +public class Pet extends Player implements Child { + @Override + public Character getParent() { + return null; + } +} diff --git a/src/main/java/com/l2jserver/model/world/Player.java b/src/main/java/com/l2jserver/model/world/Player.java new file mode 100644 index 000000000..2d3f87f43 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/Player.java @@ -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, 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 getListeners() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean support(Class 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; + } +} diff --git a/src/main/java/com/l2jserver/model/world/WorldObject.java b/src/main/java/com/l2jserver/model/world/WorldObject.java new file mode 100644 index 000000000..274eb5b2e --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/WorldObject.java @@ -0,0 +1,9 @@ +package com.l2jserver.model.world; + +import com.l2jserver.model.id.ObjectID; + +public interface WorldObject { + ObjectID getId(); + + void setId(ObjectID id); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Attackable.java b/src/main/java/com/l2jserver/model/world/capability/Attackable.java new file mode 100644 index 000000000..d341f9a9c --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Attackable.java @@ -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 Rogiel + */ +public interface Attackable extends WorldCapability { + void receiveAttack(Attacker attacker); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Attacker.java b/src/main/java/com/l2jserver/model/world/capability/Attacker.java new file mode 100644 index 000000000..619b7a734 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Attacker.java @@ -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 Rogiel + */ +public interface Attacker extends WorldCapability { + void attack(Attackable target); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Castable.java b/src/main/java/com/l2jserver/model/world/capability/Castable.java new file mode 100644 index 000000000..1893b2c76 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Castable.java @@ -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 Rogiel + */ +public interface Castable extends WorldCapability { + void cast(); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Caster.java b/src/main/java/com/l2jserver/model/world/capability/Caster.java new file mode 100644 index 000000000..97c13ec8d --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Caster.java @@ -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 Rogiel + */ +public interface Caster extends WorldCapability { + void cast(SkillTemplate skill, Castable cast); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Child.java b/src/main/java/com/l2jserver/model/world/capability/Child.java new file mode 100644 index 000000000..33b62511e --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Child.java @@ -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 Rogiel + */ +public interface Child

extends WorldCapability { + public P getParent(); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Conversable.java b/src/main/java/com/l2jserver/model/world/capability/Conversable.java new file mode 100644 index 000000000..f0df4cb34 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Conversable.java @@ -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 Rogiel + */ +public interface Conversable extends WorldCapability { + +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Dropable.java b/src/main/java/com/l2jserver/model/world/capability/Dropable.java new file mode 100644 index 000000000..6661f2cd4 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Dropable.java @@ -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 Rogiel + */ +public interface Dropable extends WorldCapability { + void drop(); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Enchantable.java b/src/main/java/com/l2jserver/model/world/capability/Enchantable.java new file mode 100644 index 000000000..d0087a097 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Enchantable.java @@ -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 Rogiel + */ +public interface Enchantable extends WorldCapability { + public int getEnchantLevel(); + + public int setEnchantLevel(); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Equipable.java b/src/main/java/com/l2jserver/model/world/capability/Equipable.java new file mode 100644 index 000000000..2639597e0 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Equipable.java @@ -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 Rogiel + */ +public interface Equipable extends WorldCapability { + void equip(Equiper equiper); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Equiper.java b/src/main/java/com/l2jserver/model/world/capability/Equiper.java new file mode 100644 index 000000000..2e7e6f977 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Equiper.java @@ -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 Rogiel + */ +public interface Equiper extends WorldCapability { + void equip(Equipable equipable); + + void setEquipment(Object slot, Equipable equipment); + + void getEquipment(Object slot); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Listenable.java b/src/main/java/com/l2jserver/model/world/capability/Listenable.java new file mode 100644 index 000000000..fdce1ea61 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Listenable.java @@ -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 Rogiel + * + * @param + * the listener type + * @param + * the event type + */ +public interface Listenable, E extends WorldEvent> + extends WorldCapability { + void addListener(L listener); + + void removeListener(L listener); + + List getListeners(); + + boolean support(Class eventType); + + void dispatch(E e); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Parent.java b/src/main/java/com/l2jserver/model/world/capability/Parent.java new file mode 100644 index 000000000..563db9acc --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Parent.java @@ -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 Rogiel + */ +public interface Parent extends WorldCapability { +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Playable.java b/src/main/java/com/l2jserver/model/world/capability/Playable.java new file mode 100644 index 000000000..54966189f --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Playable.java @@ -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 Rogiel + */ +public interface Playable extends WorldCapability { + +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Positionable.java b/src/main/java/com/l2jserver/model/world/capability/Positionable.java new file mode 100644 index 000000000..5893590c4 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Positionable.java @@ -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 Rogiel + */ +public interface Positionable extends WorldCapability { + Coordinate getPosition(); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Scriptable.java b/src/main/java/com/l2jserver/model/world/capability/Scriptable.java new file mode 100644 index 000000000..cd6b98872 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Scriptable.java @@ -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 Rogiel + */ +public interface Scriptable extends WorldCapability { + /** + * The the current script attached to this object + * + * @return the attached script + */ + Script getScript(); + + /** + * Set the attached script to this object + * + * @param script + * the script + */ + void setScript(Script script); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Spawnable.java b/src/main/java/com/l2jserver/model/world/capability/Spawnable.java new file mode 100644 index 000000000..c1e2f4a42 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Spawnable.java @@ -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 Rogiel + */ +public interface Spawnable extends WorldCapability, Positionable { + void spawn(Coordinate coordinate); + + boolean isSpawned(); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/Summunable.java b/src/main/java/com/l2jserver/model/world/capability/Summunable.java new file mode 100644 index 000000000..325b549c9 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/Summunable.java @@ -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 Rogiel + */ +public interface Summunable extends Spawnable { + void summon(Coordinate coordinate); + + boolean isSummoned(); +} diff --git a/src/main/java/com/l2jserver/model/world/capability/WorldCapability.java b/src/main/java/com/l2jserver/model/world/capability/WorldCapability.java new file mode 100644 index 000000000..bec846233 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/capability/WorldCapability.java @@ -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 Rogiel + */ +public interface WorldCapability extends WorldObject { +} diff --git a/src/main/java/com/l2jserver/model/world/event/SpawnEvent.java b/src/main/java/com/l2jserver/model/world/event/SpawnEvent.java new file mode 100644 index 000000000..a7ecfb698 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/event/SpawnEvent.java @@ -0,0 +1,7 @@ +package com.l2jserver.model.world.event; + +import com.l2jserver.model.world.capability.Spawnable; + +public interface SpawnEvent extends WorldEvent { + Spawnable getObject(); +} \ No newline at end of file diff --git a/src/main/java/com/l2jserver/model/world/event/WorldEvent.java b/src/main/java/com/l2jserver/model/world/event/WorldEvent.java new file mode 100644 index 000000000..e7c2c4713 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/event/WorldEvent.java @@ -0,0 +1,5 @@ +package com.l2jserver.model.world.event; + +public interface WorldEvent { + +} diff --git a/src/main/java/com/l2jserver/model/world/event/WorldListener.java b/src/main/java/com/l2jserver/model/world/event/WorldListener.java new file mode 100644 index 000000000..95f533a3d --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/event/WorldListener.java @@ -0,0 +1,5 @@ +package com.l2jserver.model.world.event; + +public interface WorldListener { + void onAction(E e); +} diff --git a/src/main/java/com/l2jserver/model/world/filter/AndFilter.java b/src/main/java/com/l2jserver/model/world/filter/AndFilter.java new file mode 100644 index 000000000..1f7907217 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/filter/AndFilter.java @@ -0,0 +1,20 @@ +package com.l2jserver.model.world.filter; + +import com.l2jserver.model.world.WorldObject; + +public class AndFilter implements WorldFilter { + private WorldFilter[] filters; + + public AndFilter(WorldFilter... filters) { + this.filters = filters; + } + + @Override + public boolean accept(O object) { + for(final WorldFilter filter : filters) { + if(!filter.accept(object)) + return false; + } + return true; + } +} diff --git a/src/main/java/com/l2jserver/model/world/filter/NotFilter.java b/src/main/java/com/l2jserver/model/world/filter/NotFilter.java new file mode 100644 index 000000000..b5fcec9b4 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/filter/NotFilter.java @@ -0,0 +1,16 @@ +package com.l2jserver.model.world.filter; + +import com.l2jserver.model.world.WorldObject; + +public class NotFilter implements WorldFilter { + private WorldFilter filter; + + public NotFilter(WorldFilter filter) { + this.filter = filter; + } + + @Override + public boolean accept(O object) { + return !filter.accept(object); + } +} diff --git a/src/main/java/com/l2jserver/model/world/filter/OrFilter.java b/src/main/java/com/l2jserver/model/world/filter/OrFilter.java new file mode 100644 index 000000000..6ca2459bb --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/filter/OrFilter.java @@ -0,0 +1,20 @@ +package com.l2jserver.model.world.filter; + +import com.l2jserver.model.world.WorldObject; + +public class OrFilter implements WorldFilter { + private WorldFilter[] filters; + + public OrFilter(WorldFilter... filters) { + this.filters = filters; + } + + @Override + public boolean accept(O object) { + for(final WorldFilter filter : filters) { + if(filter.accept(object)) + return true; + } + return false; + } +} diff --git a/src/main/java/com/l2jserver/model/world/filter/WorldFilter.java b/src/main/java/com/l2jserver/model/world/filter/WorldFilter.java new file mode 100644 index 000000000..04710a610 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/filter/WorldFilter.java @@ -0,0 +1,19 @@ +package com.l2jserver.model.world.filter; + +import com.l2jserver.model.world.WorldObject; + +/** + * Filter an object in a world + * + * @author Rogiel + */ +public interface WorldFilter { + /** + * Test if object matches the filter requirements + * + * @param object + * the object + * @return true if object match requirements + */ + boolean accept(O object); +} diff --git a/src/main/java/com/l2jserver/model/world/filter/WorldFilters.java b/src/main/java/com/l2jserver/model/world/filter/WorldFilters.java new file mode 100644 index 000000000..db9cd3302 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/filter/WorldFilters.java @@ -0,0 +1,20 @@ +package com.l2jserver.model.world.filter; + +import com.l2jserver.model.world.WorldObject; + +public final class WorldFilters { + public static final WorldFilter and( + WorldFilter... filters) { + return new AndFilter(filters); + } + + public static final WorldFilter or( + WorldFilter... filters) { + return new OrFilter(filters); + } + + public static final WorldFilter notf( + WorldFilter filter) { + return new NotFilter(filter); + } +} diff --git a/src/main/java/com/l2jserver/model/world/filter/impl/IDFilter.java b/src/main/java/com/l2jserver/model/world/filter/impl/IDFilter.java new file mode 100644 index 000000000..90b0d5132 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/filter/impl/IDFilter.java @@ -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 { + 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); + } +} diff --git a/src/main/java/com/l2jserver/model/world/filter/impl/RangeFilter.java b/src/main/java/com/l2jserver/model/world/filter/impl/RangeFilter.java new file mode 100644 index 000000000..b240fa84d --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/filter/impl/RangeFilter.java @@ -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 { + 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; + } +} diff --git a/src/main/java/com/l2jserver/model/world/item/ItemEvent.java b/src/main/java/com/l2jserver/model/world/item/ItemEvent.java new file mode 100644 index 000000000..109d8d39e --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/item/ItemEvent.java @@ -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(); +} diff --git a/src/main/java/com/l2jserver/model/world/item/ItemListener.java b/src/main/java/com/l2jserver/model/world/item/ItemListener.java new file mode 100644 index 000000000..55d54d115 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/item/ItemListener.java @@ -0,0 +1,6 @@ +package com.l2jserver.model.world.item; + +import com.l2jserver.model.world.event.WorldListener; + +public interface ItemListener extends WorldListener { +} diff --git a/src/main/java/com/l2jserver/model/world/player/PlayerEvent.java b/src/main/java/com/l2jserver/model/world/player/PlayerEvent.java new file mode 100644 index 000000000..be73a7554 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/player/PlayerEvent.java @@ -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(); +} diff --git a/src/main/java/com/l2jserver/model/world/player/PlayerListener.java b/src/main/java/com/l2jserver/model/world/player/PlayerListener.java new file mode 100644 index 000000000..1c926a041 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/player/PlayerListener.java @@ -0,0 +1,6 @@ +package com.l2jserver.model.world.player; + +import com.l2jserver.model.world.event.WorldListener; + +public interface PlayerListener extends WorldListener { +} diff --git a/src/main/java/com/l2jserver/model/world/player/PlayerSpawnEvent.java b/src/main/java/com/l2jserver/model/world/player/PlayerSpawnEvent.java new file mode 100644 index 000000000..9c7532c07 --- /dev/null +++ b/src/main/java/com/l2jserver/model/world/player/PlayerSpawnEvent.java @@ -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; + } +} diff --git a/src/main/java/com/l2jserver/service/Service.java b/src/main/java/com/l2jserver/service/Service.java new file mode 100644 index 000000000..0ac0f13dd --- /dev/null +++ b/src/main/java/com/l2jserver/service/Service.java @@ -0,0 +1,19 @@ +package com.l2jserver.service; + +public interface Service { + /** + * Start this service + * + * @throws ServiceStartException + * if an error occurred + */ + void start() throws ServiceStartException; + + /** + * Stop this service + * + * @throws ServiceStartException + * if an error occurred + */ + void stop() throws ServiceStopException; +} diff --git a/src/main/java/com/l2jserver/service/ServiceException.java b/src/main/java/com/l2jserver/service/ServiceException.java new file mode 100644 index 000000000..cd4ca7c39 --- /dev/null +++ b/src/main/java/com/l2jserver/service/ServiceException.java @@ -0,0 +1,21 @@ +package com.l2jserver.service; + +public class ServiceException extends Exception { + private static final long serialVersionUID = 1L; + + public ServiceException() { + super(); + } + + public ServiceException(String message, Throwable cause) { + super(message, cause); + } + + public ServiceException(String message) { + super(message); + } + + public ServiceException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/com/l2jserver/service/ServiceModule.java b/src/main/java/com/l2jserver/service/ServiceModule.java new file mode 100644 index 000000000..aeb38c6f3 --- /dev/null +++ b/src/main/java/com/l2jserver/service/ServiceModule.java @@ -0,0 +1,23 @@ +package com.l2jserver.service; + +import com.google.inject.AbstractModule; +import com.google.inject.Scopes; +import com.l2jserver.service.configuration.ConfigurationService; +import com.l2jserver.service.configuration.ProxyConfigurationService; +import com.l2jserver.service.database.DB4ODatabaseService; +import com.l2jserver.service.database.DatabaseService; +import com.l2jserver.service.network.NettyNetworkService; +import com.l2jserver.service.network.NetworkService; + +public class ServiceModule extends AbstractModule { + @Override + protected void configure() { + bind(ConfigurationService.class).to(ProxyConfigurationService.class) + .in(Scopes.SINGLETON); + bind(DatabaseService.class).to(DB4ODatabaseService.class).in( + Scopes.SINGLETON); + + bind(NetworkService.class).to(NettyNetworkService.class).in( + Scopes.SINGLETON); + } +} diff --git a/src/main/java/com/l2jserver/service/ServiceStartException.java b/src/main/java/com/l2jserver/service/ServiceStartException.java new file mode 100644 index 000000000..9ff9cd53a --- /dev/null +++ b/src/main/java/com/l2jserver/service/ServiceStartException.java @@ -0,0 +1,21 @@ +package com.l2jserver.service; + +public class ServiceStartException extends ServiceException { + private static final long serialVersionUID = 1L; + + public ServiceStartException() { + super(); + } + + public ServiceStartException(String message, Throwable cause) { + super(message, cause); + } + + public ServiceStartException(String message) { + super(message); + } + + public ServiceStartException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/com/l2jserver/service/ServiceStopException.java b/src/main/java/com/l2jserver/service/ServiceStopException.java new file mode 100644 index 000000000..df856da15 --- /dev/null +++ b/src/main/java/com/l2jserver/service/ServiceStopException.java @@ -0,0 +1,21 @@ +package com.l2jserver.service; + +public class ServiceStopException extends ServiceException { + private static final long serialVersionUID = 1L; + + public ServiceStopException() { + super(); + } + + public ServiceStopException(String message, Throwable cause) { + super(message, cause); + } + + public ServiceStopException(String message) { + super(message); + } + + public ServiceStopException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/com/l2jserver/service/compiler/CompilerService.java b/src/main/java/com/l2jserver/service/compiler/CompilerService.java new file mode 100644 index 000000000..905aa949b --- /dev/null +++ b/src/main/java/com/l2jserver/service/compiler/CompilerService.java @@ -0,0 +1,8 @@ +package com.l2jserver.service.compiler; + +import com.l2jserver.service.Service; + +public interface CompilerService extends Service { + Class compile(byte[] clazz); + ClassLoader getClassLoader(); +} diff --git a/src/main/java/com/l2jserver/service/compiler/DynamicClassLoader.java b/src/main/java/com/l2jserver/service/compiler/DynamicClassLoader.java new file mode 100644 index 000000000..f71266d00 --- /dev/null +++ b/src/main/java/com/l2jserver/service/compiler/DynamicClassLoader.java @@ -0,0 +1,11 @@ +package com.l2jserver.service.compiler; + +public class DynamicClassLoader extends ClassLoader { + public DynamicClassLoader() { + super(); + } + + public DynamicClassLoader(ClassLoader parent) { + super(parent); + } +} diff --git a/src/main/java/com/l2jserver/service/compiler/JavacCompilerService.java b/src/main/java/com/l2jserver/service/compiler/JavacCompilerService.java new file mode 100644 index 000000000..88f1e62cf --- /dev/null +++ b/src/main/java/com/l2jserver/service/compiler/JavacCompilerService.java @@ -0,0 +1,29 @@ +package com.l2jserver.service.compiler; + +import com.l2jserver.service.ServiceStartException; +import com.l2jserver.service.ServiceStopException; + +public class JavacCompilerService implements CompilerService { + @Override + public void start() throws ServiceStartException { + // TODO Auto-generated method stub + + } + + @Override + public Class compile(byte[] clazz) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ClassLoader getClassLoader() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void stop() throws ServiceStopException { + + } +} diff --git a/src/main/java/com/l2jserver/service/configuration/Configuration.java b/src/main/java/com/l2jserver/service/configuration/Configuration.java new file mode 100644 index 000000000..1ac44a733 --- /dev/null +++ b/src/main/java/com/l2jserver/service/configuration/Configuration.java @@ -0,0 +1,24 @@ +package com.l2jserver.service.configuration; + +import com.l2jserver.service.configuration.Configuration.ConfigurationName; + +@ConfigurationName("l2j") +public interface Configuration { + + public @interface ConfigurationName { + String value(); + } + + public @interface ConfigurationPrefix { + String value(); + } + + public @interface ConfigurationPropertyGetter { + String name(); + String defaultValue() default ""; + } + + public @interface ConfigurationPropertySetter { + String name(); + } +} diff --git a/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java b/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java new file mode 100644 index 000000000..20aa423f7 --- /dev/null +++ b/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java @@ -0,0 +1,5 @@ +package com.l2jserver.service.configuration; + +public interface ConfigurationService { + C get(Class config); +} diff --git a/src/main/java/com/l2jserver/service/configuration/ProxyConfigurationService.java b/src/main/java/com/l2jserver/service/configuration/ProxyConfigurationService.java new file mode 100644 index 000000000..7d735f525 --- /dev/null +++ b/src/main/java/com/l2jserver/service/configuration/ProxyConfigurationService.java @@ -0,0 +1,12 @@ +package com.l2jserver.service.configuration; + +import java.util.Properties; + +public class ProxyConfigurationService implements ConfigurationService { + private Properties properties; + + @Override + public C get(Class config) { + return null; + } +} diff --git a/src/main/java/com/l2jserver/service/database/AbstractDAO.java b/src/main/java/com/l2jserver/service/database/AbstractDAO.java new file mode 100644 index 000000000..c27327610 --- /dev/null +++ b/src/main/java/com/l2jserver/service/database/AbstractDAO.java @@ -0,0 +1,16 @@ +package com.l2jserver.service.database; + +import com.google.inject.Inject; + +public abstract class AbstractDAO implements DataAccessObject { + protected final DatabaseService database; + + @Inject + protected AbstractDAO(DatabaseService database) { + this.database = database; + } + + public DatabaseService getDatabase() { + return database; + } +} diff --git a/src/main/java/com/l2jserver/service/database/DB4ODatabaseService.java b/src/main/java/com/l2jserver/service/database/DB4ODatabaseService.java new file mode 100644 index 000000000..50be31d9a --- /dev/null +++ b/src/main/java/com/l2jserver/service/database/DB4ODatabaseService.java @@ -0,0 +1,15 @@ +package com.l2jserver.service.database; + +public class DB4ODatabaseService implements DatabaseService { + @Override + public void start() { + // TODO Auto-generated method stub + + } + + @Override + public void stop() { + // TODO Auto-generated method stub + + } +} diff --git a/src/main/java/com/l2jserver/service/database/DataAccessObject.java b/src/main/java/com/l2jserver/service/database/DataAccessObject.java new file mode 100644 index 000000000..fde32187a --- /dev/null +++ b/src/main/java/com/l2jserver/service/database/DataAccessObject.java @@ -0,0 +1,10 @@ +package com.l2jserver.service.database; + +/** + * The DAO interface + * + * @author Rogiel + */ +public interface DataAccessObject { + +} diff --git a/src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java b/src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java new file mode 100644 index 000000000..b886a64e5 --- /dev/null +++ b/src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java @@ -0,0 +1,11 @@ +package com.l2jserver.service.database; + +import com.l2jserver.service.configuration.Configuration; +import com.l2jserver.service.configuration.Configuration.ConfigurationName; +import com.l2jserver.service.configuration.Configuration.ConfigurationPrefix; + +@ConfigurationName("database") +@ConfigurationPrefix("database") +public interface DatabaseConfiguration extends Configuration { + +} diff --git a/src/main/java/com/l2jserver/service/database/DatabaseService.java b/src/main/java/com/l2jserver/service/database/DatabaseService.java new file mode 100644 index 000000000..b38f85a4c --- /dev/null +++ b/src/main/java/com/l2jserver/service/database/DatabaseService.java @@ -0,0 +1,7 @@ +package com.l2jserver.service.database; + +import com.l2jserver.service.Service; + +public interface DatabaseService extends Service { + +} diff --git a/src/main/java/com/l2jserver/service/database/MySQL5DatabaseService.java b/src/main/java/com/l2jserver/service/database/MySQL5DatabaseService.java new file mode 100644 index 000000000..aa2158dc7 --- /dev/null +++ b/src/main/java/com/l2jserver/service/database/MySQL5DatabaseService.java @@ -0,0 +1,25 @@ +package com.l2jserver.service.database; + +import com.google.inject.Inject; +import com.l2jserver.service.configuration.ConfigurationService; + +public class MySQL5DatabaseService implements DatabaseService { + private final MySQLDatabaseConfiguration config; + + @Inject + public MySQL5DatabaseService(ConfigurationService configService) { + config = configService.get(MySQLDatabaseConfiguration.class); + } + + @Override + public void start() { + // TODO Auto-generated method stub + + } + + @Override + public void stop() { + // TODO Auto-generated method stub + + } +} diff --git a/src/main/java/com/l2jserver/service/database/MySQLDatabaseConfiguration.java b/src/main/java/com/l2jserver/service/database/MySQLDatabaseConfiguration.java new file mode 100644 index 000000000..b9bcb8ae5 --- /dev/null +++ b/src/main/java/com/l2jserver/service/database/MySQLDatabaseConfiguration.java @@ -0,0 +1,31 @@ +package com.l2jserver.service.database; + +import com.l2jserver.service.configuration.Configuration.ConfigurationPrefix; + +@ConfigurationPrefix("mysql") +public interface MySQLDatabaseConfiguration extends DatabaseConfiguration { + /** + * @return the jdbc url + */ + @ConfigurationPropertyGetter(name = "jdbc.url", defaultValue = "jdbc:mysql://localhost/l2jserver-gs") + String getJdbcUrl(); + + /** + * @param jdbcUrl + * the new jdbc url + */ + @ConfigurationPropertySetter(name = "jdbc.url") + void setJdbcUrl(String jdbcUrl); + + @ConfigurationPropertyGetter(name = "jdbc.username", defaultValue = "root") + String getUsername(); + + @ConfigurationPropertySetter(name = "jdbc.username") + void setUsername(String username); + + @ConfigurationPropertyGetter(name = "jdbc.password") + String getPassword(); + + @ConfigurationPropertySetter(name = "jdbc.password") + void setPassword(String password); +} diff --git a/src/main/java/com/l2jserver/service/game/script/Script.java b/src/main/java/com/l2jserver/service/game/script/Script.java new file mode 100644 index 000000000..34cde54fc --- /dev/null +++ b/src/main/java/com/l2jserver/service/game/script/Script.java @@ -0,0 +1,16 @@ +package com.l2jserver.service.game.script; + +import com.l2jserver.model.world.capability.Scriptable; + +public interface Script extends Runnable { + /** + * Load this script for object + * + * @param object + */ + void load(O object); + + void unload(); + + O getObject(); +} diff --git a/src/main/java/com/l2jserver/service/game/script/ScriptingService.java b/src/main/java/com/l2jserver/service/game/script/ScriptingService.java new file mode 100644 index 000000000..b0b8ee957 --- /dev/null +++ b/src/main/java/com/l2jserver/service/game/script/ScriptingService.java @@ -0,0 +1,7 @@ +package com.l2jserver.service.game.script; + +import com.l2jserver.service.Service; + +public interface ScriptingService extends Service { + +} diff --git a/src/main/java/com/l2jserver/service/game/template/TemplateService.java b/src/main/java/com/l2jserver/service/game/template/TemplateService.java new file mode 100644 index 000000000..d04b2f31f --- /dev/null +++ b/src/main/java/com/l2jserver/service/game/template/TemplateService.java @@ -0,0 +1,25 @@ +package com.l2jserver.service.game.template; + +import com.l2jserver.model.id.TemplateID; +import com.l2jserver.model.template.AbstractTemplate; +import com.l2jserver.service.Service; + +public interface TemplateService extends Service { + /** + * Get the template assigned with id + * + * @param id + * the template id + * @return the template matching the id + */ + AbstractTemplate getTemplate(TemplateID id); + + /** + * Recompile the template with id id. This can be used to reload + * the template. + * + * @param id + * the template id + */ + void recompile(TemplateID id); +} diff --git a/src/main/java/com/l2jserver/service/game/world/WorldEventDispatcher.java b/src/main/java/com/l2jserver/service/game/world/WorldEventDispatcher.java new file mode 100644 index 000000000..32f62674f --- /dev/null +++ b/src/main/java/com/l2jserver/service/game/world/WorldEventDispatcher.java @@ -0,0 +1,8 @@ +package com.l2jserver.service.game.world; + +import com.l2jserver.model.world.AbstractObject; +import com.l2jserver.model.world.event.WorldEvent; + +public interface WorldEventDispatcher { + void dispatch(AbstractObject object, WorldEvent event); +} diff --git a/src/main/java/com/l2jserver/service/game/world/WorldService.java b/src/main/java/com/l2jserver/service/game/world/WorldService.java new file mode 100644 index 000000000..80c20d263 --- /dev/null +++ b/src/main/java/com/l2jserver/service/game/world/WorldService.java @@ -0,0 +1,22 @@ +package com.l2jserver.service.game.world; + +import com.l2jserver.model.world.WorldObject; +import com.l2jserver.service.Service; + +public interface WorldService extends Service, Iterable { + /** + * Register a new {@link WorldObject} to the service. + * + * @param object + * the object + */ + void register(WorldObject object); + + /** + * Removes an registered {@link WorldObject} from the service. + * + * @param object + * the object + */ + void unregister(WorldObject object); +} diff --git a/src/main/java/com/l2jserver/service/game/world/WorldServiceImpl.java b/src/main/java/com/l2jserver/service/game/world/WorldServiceImpl.java new file mode 100644 index 000000000..534ca424f --- /dev/null +++ b/src/main/java/com/l2jserver/service/game/world/WorldServiceImpl.java @@ -0,0 +1,47 @@ +package com.l2jserver.service.game.world; + +import java.util.Iterator; +import java.util.Set; + +import com.l2jserver.model.world.WorldObject; +import com.l2jserver.model.world.filter.WorldFilter; +import com.l2jserver.service.ServiceStartException; +import com.l2jserver.service.ServiceStopException; + +public class WorldServiceImpl implements WorldService { + private Set objects; + + @Override + public void start() throws ServiceStartException { + // TODO Auto-generated method stub + + } + + @Override + public void register(WorldObject object) { + // TODO Auto-generated method stub + + } + + @Override + public void unregister(WorldObject object) { + // TODO Auto-generated method stub + + } + + @Override + public Iterator iterator() { + return objects.iterator(); + } + + public Iterator iterator(WorldFilter filter) { + //return objects.iterator(); + return null; + } + + @Override + public void stop() throws ServiceStopException { + // TODO Auto-generated method stub + + } +} diff --git a/src/main/java/com/l2jserver/service/logging/JdkLogger.java b/src/main/java/com/l2jserver/service/logging/JdkLogger.java new file mode 100644 index 000000000..eeb107c11 --- /dev/null +++ b/src/main/java/com/l2jserver/service/logging/JdkLogger.java @@ -0,0 +1,19 @@ +package com.l2jserver.service.logging; + +public class JdkLogger implements Logger { + private final java.util.logging.Logger logger; + + public JdkLogger(java.util.logging.Logger logger) { + this.logger = logger; + } + + @Override + public void info(String message) { + logger.info(message); + } + + @Override + public void info(String message, Exception e) { + logger.info(message); + } +} diff --git a/src/main/java/com/l2jserver/service/logging/JdkLoggingService.java b/src/main/java/com/l2jserver/service/logging/JdkLoggingService.java new file mode 100644 index 000000000..2a0eb773e --- /dev/null +++ b/src/main/java/com/l2jserver/service/logging/JdkLoggingService.java @@ -0,0 +1,26 @@ +package com.l2jserver.service.logging; + +import java.util.logging.LogManager; + +import com.l2jserver.service.ServiceStartException; +import com.l2jserver.service.ServiceStopException; + +public class JdkLoggingService implements LoggingService { + @Override + public void start() throws ServiceStartException { + // TODO Auto-generated method stub + + } + + @Override + public Logger getLogger(Class clazz) { + return new JdkLogger(LogManager.getLogManager().getLogger( + clazz.getName())); + } + + @Override + public void stop() throws ServiceStopException { + // TODO Auto-generated method stub + + } +} diff --git a/src/main/java/com/l2jserver/service/logging/Logger.java b/src/main/java/com/l2jserver/service/logging/Logger.java new file mode 100644 index 000000000..922c3794c --- /dev/null +++ b/src/main/java/com/l2jserver/service/logging/Logger.java @@ -0,0 +1,7 @@ +package com.l2jserver.service.logging; + +public interface Logger { + void info(String message); + + void info(String message, Exception e); +} diff --git a/src/main/java/com/l2jserver/service/logging/LoggingService.java b/src/main/java/com/l2jserver/service/logging/LoggingService.java new file mode 100644 index 000000000..48dff91e5 --- /dev/null +++ b/src/main/java/com/l2jserver/service/logging/LoggingService.java @@ -0,0 +1,7 @@ +package com.l2jserver.service.logging; + +import com.l2jserver.service.Service; + +public interface LoggingService extends Service { + Logger getLogger(Class clazz); +} diff --git a/src/main/java/com/l2jserver/service/network/NettyNetworkService.java b/src/main/java/com/l2jserver/service/network/NettyNetworkService.java new file mode 100644 index 000000000..536341772 --- /dev/null +++ b/src/main/java/com/l2jserver/service/network/NettyNetworkService.java @@ -0,0 +1,23 @@ +package com.l2jserver.service.network; + +import com.google.inject.Inject; +import com.l2jserver.service.configuration.ConfigurationService; + +public class NettyNetworkService implements NetworkService { + private final NetworkConfiguration config; + + @Inject + public NettyNetworkService(ConfigurationService configService) { + this.config = configService.get(NetworkConfiguration.class); + } + + @Override + public void start() { + + } + + @Override + public void stop() { + + } +} diff --git a/src/main/java/com/l2jserver/service/network/NetworkConfiguration.java b/src/main/java/com/l2jserver/service/network/NetworkConfiguration.java new file mode 100644 index 000000000..921a5f7dd --- /dev/null +++ b/src/main/java/com/l2jserver/service/network/NetworkConfiguration.java @@ -0,0 +1,29 @@ +package com.l2jserver.service.network; + +import java.net.InetSocketAddress; + +import com.l2jserver.service.configuration.Configuration; +import com.l2jserver.service.configuration.Configuration.ConfigurationName; +import com.l2jserver.service.configuration.Configuration.ConfigurationPrefix; + +@ConfigurationName("network") +@ConfigurationPrefix("net") +public interface NetworkConfiguration extends Configuration { + // TODO set default value + /** + * Get the server listen address + * + * @return the listen address + */ + @ConfigurationPropertyGetter(name = "listen", defaultValue = "0.0.0.0:54") + InetSocketAddress getListenAddress(); + + /** + * Set the server listen address + * + * @param addr + * the listen address + */ + @ConfigurationPropertySetter(name = "listen") + void setListenAddress(InetSocketAddress addr); +} diff --git a/src/main/java/com/l2jserver/service/network/NetworkService.java b/src/main/java/com/l2jserver/service/network/NetworkService.java new file mode 100644 index 000000000..3154e718f --- /dev/null +++ b/src/main/java/com/l2jserver/service/network/NetworkService.java @@ -0,0 +1,7 @@ +package com.l2jserver.service.network; + +import com.l2jserver.service.Service; + +public interface NetworkService extends Service { + +} diff --git a/src/main/java/com/l2jserver/util/Coordinate.java b/src/main/java/com/l2jserver/util/Coordinate.java new file mode 100644 index 000000000..ac3ae3a4e --- /dev/null +++ b/src/main/java/com/l2jserver/util/Coordinate.java @@ -0,0 +1,30 @@ +package com.l2jserver.util; + +public class Coordinate { + private final int x; + private final int y; + private final int z; + + public Coordinate(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + + public int getZ() { + return z; + } + + public int getDistance(Coordinate other) { + //TODO calculation + return x + y + z; + } +} diff --git a/src/main/java/com/l2jserver/util/factory/CollectionFactory.java b/src/main/java/com/l2jserver/util/factory/CollectionFactory.java new file mode 100644 index 000000000..c8b825408 --- /dev/null +++ b/src/main/java/com/l2jserver/util/factory/CollectionFactory.java @@ -0,0 +1,40 @@ +package com.l2jserver.util.factory; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Factory class to create {@link Collection} instances. + * + * @author Rogiel + */ +public class CollectionFactory { + /** + * Creates a new list of type T + * + * @param + * the type + * @param type + * the type + * @return the created list + */ + public static final List newList(Class type) { + return new ArrayList(); + } + + /** + * Creates a new set of type T + * + * @param + * the type + * @param type + * the type + * @return the created set + */ + public static final Set newSet(Class type) { + return new HashSet(); + } +}