1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-09 08:52:51 +00:00

Several improvements

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-19 01:40:53 -03:00
parent 9bb83652e4
commit 2c4af6d91d
263 changed files with 2135 additions and 663 deletions

View File

@@ -19,7 +19,7 @@ package com.l2jserver;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.l2jserver.db.dao.MySQL5DAOModule;
import com.l2jserver.model.id.factory.IDFactoryModule;
import com.l2jserver.model.id.provider.IDProviderModule;
import com.l2jserver.service.ServiceModule;
/**
@@ -31,7 +31,7 @@ public class GameServerModule extends AbstractModule {
@Override
protected void configure() {
install(new ServiceModule());
install(new IDFactoryModule());
install(new IDProviderModule());
install(new MySQL5DAOModule());
}
}

View File

@@ -16,6 +16,11 @@
*/
package com.l2jserver;
import com.google.inject.Injector;
import com.l2jserver.model.id.object.provider.NPCIDProvider;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider;
import com.l2jserver.model.world.NPC;
import com.l2jserver.service.ServiceManager;
import com.l2jserver.service.cache.CacheService;
import com.l2jserver.service.configuration.ConfigurationService;
@@ -23,8 +28,11 @@ import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.game.chat.ChatService;
import com.l2jserver.service.game.scripting.ScriptingService;
import com.l2jserver.service.game.template.TemplateService;
import com.l2jserver.service.game.world.WorldService;
import com.l2jserver.service.game.world.id.WorldIDService;
import com.l2jserver.service.network.NetworkService;
import com.l2jserver.service.network.keygen.BlowfishKeygenService;
import com.l2jserver.util.dimensional.Point;
public class L2JGameServerMain {
/**
@@ -40,6 +48,7 @@ public class L2JGameServerMain {
serviceManager.start(CacheService.class);
serviceManager.start(ConfigurationService.class);
serviceManager.start(DatabaseService.class);
serviceManager.start(WorldIDService.class);
serviceManager.start(ScriptingService.class);
serviceManager.start(TemplateService.class);
@@ -48,12 +57,33 @@ public class L2JGameServerMain {
serviceManager.start(BlowfishKeygenService.class);
serviceManager.start(NetworkService.class);
staticSpawn(server.getInjector());
} catch (Exception e) {
System.out.println("GameServer could not be started!");
e.printStackTrace();
}
Thread.sleep(60 * 60 * 1000);
// Thread.sleep(60 * 60 * 1000);
}
/**
* This method does an static spawn for an object
*/
private static void staticSpawn(Injector injector) {
final NPCTemplateIDProvider templateProvider = injector
.getInstance(NPCTemplateIDProvider.class);
final NPCIDProvider provider = injector
.getInstance(NPCIDProvider.class);
final WorldService world = injector.getInstance(WorldService.class);
final NPCTemplateID id = templateProvider.createID(12077);
final NPC npc = id.getTemplate().create();
npc.setID(provider.createID());
// close to char spawn
npc.setPoint(Point.fromXYZ(-71301, 258259, -3134));
world.add(npc);
}
}

View File

@@ -261,6 +261,8 @@ public class Lineage2Connection {
.iterable(new CharacterBroadcastFilter(characterID.getObject()))) {
final Lineage2Connection conn = networkService.discover(character
.getID());
if(conn == null)
continue;
futures.add(conn.write(packet));
}
return futures;

View File

@@ -28,8 +28,10 @@ import com.google.inject.Injector;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.ClientPacket;
import com.l2jserver.game.net.packet.client.AuthLoginPacket;
import com.l2jserver.game.net.packet.client.CharacterActionPacket;
import com.l2jserver.game.net.packet.client.CharacterChatMessagePacket;
import com.l2jserver.game.net.packet.client.CharacterCreatePacket;
import com.l2jserver.game.net.packet.client.CharacterRequestMovePacket;
import com.l2jserver.game.net.packet.client.CharacterSelectPacket;
import com.l2jserver.game.net.packet.client.CharacterValidatePositionPacket;
import com.l2jserver.game.net.packet.client.EnterWorld;
@@ -40,7 +42,6 @@ import com.l2jserver.game.net.packet.client.RequestCharacterTemplatesPacket;
import com.l2jserver.game.net.packet.client.RequestGotoLobbyPacket;
import com.l2jserver.game.net.packet.client.RequestKeyMappingPacket;
import com.l2jserver.game.net.packet.client.RequestManorListPacket;
import com.l2jserver.game.net.packet.client.CharacterRequestMovePacket;
import com.l2jserver.game.net.packet.client.RequestRestartPacket;
/**
@@ -160,6 +161,8 @@ public class Lineage2PacketReader extends OneToOneDecoder {
return CharacterValidatePositionPacket.class;
case EnterWorld.OPCODE:
return EnterWorld.class;
case CharacterActionPacket.OPCODE:
return CharacterActionPacket.class;
default:
logger.warn("Unknown opcode: 0x{}", Integer.toHexString(opcode));
break;

View File

@@ -27,7 +27,7 @@ import com.l2jserver.game.net.Lineage2Session;
import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.game.net.packet.server.CharacterSelectionListPacket;
import com.l2jserver.model.id.AccountID;
import com.l2jserver.model.id.factory.AccountIDFactory;
import com.l2jserver.model.id.provider.AccountIDProvider;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.util.BufferUtils;
@@ -51,7 +51,7 @@ public class AuthLoginPacket extends AbstractClientPacket {
/**
* The {@link AccountID} factory
*/
private final AccountIDFactory accountIdFactory;
private final AccountIDProvider accountIdFactory;
// packet
/**
@@ -65,7 +65,7 @@ public class AuthLoginPacket extends AbstractClientPacket {
@Inject
public AuthLoginPacket(CharacterDAO characterDao,
AccountIDFactory accountIdFactory) {
AccountIDProvider accountIdFactory) {
this.characterDao = characterDao;
this.accountIdFactory = accountIdFactory;
}

View File

@@ -0,0 +1,99 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.game.net.packet.client;
import org.jboss.netty.buffer.ChannelBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.id.object.NPCID;
import com.l2jserver.model.id.object.provider.ObjectIDResolver;
import com.l2jserver.model.world.NPC;
import com.l2jserver.service.game.world.WorldService;
import com.l2jserver.util.dimensional.Coordinate;
/**
* Completes the creation of an character. Creates the object, inserts into the
* database and notifies the client about the status of the operation.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterActionPacket extends AbstractClientPacket {
/**
* The packet OPCODE
*/
public static final int OPCODE = 0x1f;
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final WorldService worldService;
private final ObjectIDResolver idResolver;
private int objectId;
private Coordinate origin;
private CharacterAction action;
public enum CharacterAction {
CLICK(0),
/**
* This is the right click action.
*/
RIGHT_CLICK(1);
public final int id;
CharacterAction(int id) {
this.id = id;
}
public static CharacterAction fromID(int id) {
for (final CharacterAction action : values())
if (action.id == id)
return action;
return null;
}
}
@Inject
public CharacterActionPacket(WorldService worldService,
ObjectIDResolver idResolver) {
this.worldService = worldService;
this.idResolver = idResolver;
}
@Override
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
this.objectId = buffer.readInt();
this.origin = Coordinate.fromXYZ(buffer.readInt(), buffer.readInt(),
buffer.readInt());
this.action = CharacterAction.fromID(buffer.readByte());
}
@Override
public void process(final Lineage2Connection conn) {
// since this is an erasure type, this is safe.
final ObjectID<NPC> id = idResolver.resolve(objectId);
if (!(id instanceof NPCID))
return;
final NPC npc = id.getObject();
npc.action(conn.getCharacter(), action);
}
}

View File

@@ -27,9 +27,9 @@ import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.game.net.packet.server.CharacterCreateFailPacket;
import com.l2jserver.game.net.packet.server.CharacterCreateOkPacket;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.factory.CharacterIDFactory;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.template.CharacterTemplateID;
import com.l2jserver.model.id.template.factory.CharacterTemplateIDFactory;
import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.AbstractActor.Race;
import com.l2jserver.model.world.AbstractActor.Sex;
@@ -66,11 +66,11 @@ public class CharacterCreatePacket extends AbstractClientPacket {
/**
* The {@link CharacterID} factory
*/
private final CharacterIDFactory characterIdFactory;
private final CharacterIDProvider characterIdFactory;
/**
* The {@link CharacterTemplateID} factory
*/
private final CharacterTemplateIDFactory characterTemplateIdFactory;
private final CharacterTemplateIDProvider characterTemplateIdFactory;
// packet
/**
@@ -136,8 +136,8 @@ public class CharacterCreatePacket extends AbstractClientPacket {
@Inject
public CharacterCreatePacket(CharacterDAO characterDao,
CharacterIDFactory characterIdFactory,
CharacterTemplateIDFactory characterTemplateIdFactory) {
CharacterIDProvider characterIdFactory,
CharacterTemplateIDProvider characterTemplateIdFactory) {
this.characterDao = characterDao;
this.characterIdFactory = characterIdFactory;
this.characterTemplateIdFactory = characterTemplateIdFactory;

View File

@@ -25,7 +25,7 @@ import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.game.net.packet.server.CharacterTemplatePacket;
import com.l2jserver.model.id.template.CharacterTemplateID;
import com.l2jserver.model.id.template.factory.CharacterTemplateIDFactory;
import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.character.CharacterClass;
@@ -62,10 +62,10 @@ public class RequestCharacterTemplatesPacket extends AbstractClientPacket {
/**
* The {@link CharacterTemplateID} factory
*/
private final CharacterTemplateIDFactory idFactory;
private final CharacterTemplateIDProvider idFactory;
@Inject
public RequestCharacterTemplatesPacket(CharacterTemplateIDFactory idFactory) {
public RequestCharacterTemplatesPacket(CharacterTemplateIDProvider idFactory) {
this.idFactory = idFactory;
}

View File

@@ -57,7 +57,7 @@ import com.l2jserver.util.BufferUtils;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class UserInformationPacket extends AbstractServerPacket {
public class CharacterInformationPacket extends AbstractServerPacket {
/**
* The packet OPCODE
*/
@@ -68,7 +68,7 @@ public class UserInformationPacket extends AbstractServerPacket {
*/
private L2Character character;
public UserInformationPacket(L2Character character) {
public CharacterInformationPacket(L2Character character) {
super(OPCODE);
this.character = character;
}
@@ -95,7 +95,7 @@ public class UserInformationPacket extends AbstractServerPacket {
buffer.writeInt(character.getAttributes().getWitness());
buffer.writeInt(character.getAttributes().getMentality());
buffer.writeInt(200); // max hp
buffer.writeInt((int) 200); // cur hp
buffer.writeInt(character.getHP()); // cur hp
buffer.writeInt(200); // max mp
buffer.writeInt((int) 200); // cur mp
buffer.writeInt(0); // sp

View File

@@ -0,0 +1,61 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.game.net.packet.server;
import org.jboss.netty.buffer.ChannelBuffer;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractServerPacket;
import com.l2jserver.game.net.packet.server.CharacterCreateFailPacket.Reason;
import com.l2jserver.model.world.capability.Actor;
/**
* This packet notifies the client that the chosen character has been
* successfully selected.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
* @see Reason
*/
public class CharacterTargetSelectedPacket extends AbstractServerPacket {
/**
* The packet OPCODE
*/
public static final int OPCODE = 0xb9;
/**
* The selected character
*/
private final Actor object;
private int color;
public CharacterTargetSelectedPacket(Actor object, int color) {
super(OPCODE);
this.object = object;
this.color = color;
}
public CharacterTargetSelectedPacket(Actor object) {
this(object, 0);
}
@Override
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
buffer.writeInt(object.getID().getID());
buffer.writeShort(color);
buffer.writeInt(0x00);
}
}

View File

@@ -0,0 +1,106 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.game.net.packet.server;
import org.jboss.netty.buffer.ChannelBuffer;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractServerPacket;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.model.world.NPC;
import com.l2jserver.util.BufferUtils;
/**
* This packet sends to the client an actor information about an actor (except
* players)
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class NPCInformationPacket extends AbstractServerPacket {
/**
* The packet OPCODE
*/
public static final int OPCODE = 0x0c;
private final NPC npc;
public NPCInformationPacket(NPC npc) {
super(OPCODE);
this.npc = npc;
}
@Override
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
final NPCTemplate template = npc.getTemplate();
buffer.writeInt(npc.getID().getID());
buffer.writeInt(template.getID().getID() + 1000000); // npctype id
buffer.writeInt((template.isAttackable() ? 0x01 : 0x00));
buffer.writeInt(npc.getPoint().getX());
buffer.writeInt(npc.getPoint().getY());
buffer.writeInt(npc.getPoint().getZ());
buffer.writeInt((int) npc.getPoint().getAngle());
buffer.writeInt(0x00); // unk
buffer.writeInt(template.getCastSpeed());
buffer.writeInt(template.getAttackSpeed());
buffer.writeInt((int) template.getMoveSpeed());
buffer.writeInt((int) template.getMoveSpeed());
buffer.writeInt((int) template.getMoveSpeed()); // swim run speed
buffer.writeInt((int) template.getMoveSpeed()); // swim walk speed
buffer.writeInt((int) template.getMoveSpeed()); // swim run speed
buffer.writeInt((int) template.getMoveSpeed()); // swim walk speed
buffer.writeInt((int) template.getMoveSpeed()); // fly run speed
buffer.writeInt((int) template.getMoveSpeed()); // fly run speed
buffer.writeDouble(template.getMovementSpeedMultiplier());
buffer.writeDouble(template.getAttackSpeedMultiplier());
buffer.writeDouble(template.getCollisionRadius());
buffer.writeDouble(template.getCollisionHeigth());
buffer.writeInt(0x00); // right hand weapon
buffer.writeInt(0x00); // chest
buffer.writeInt(0x00); // left hand weapon
buffer.writeByte(1); // name above char 1=true ... ??
buffer.writeByte(0x00); // is running
buffer.writeByte(0x00); // is in combat
buffer.writeByte(0x00); // is like dead (faking)
buffer.writeByte(0x00); // 0=teleported 1=default 2=summoned
BufferUtils.writeString(buffer, template.getName());
BufferUtils.writeString(buffer, template.getTitle());
buffer.writeInt(0x00); // Title color 0=client default
buffer.writeInt(0x00); // pvp flag
buffer.writeInt(0x00); // karma
buffer.writeInt(0x00); // C2 - abnormal effect
buffer.writeInt(0x00); // clan id
buffer.writeInt(0x00); // crest id
buffer.writeInt(0x00); // ally id
buffer.writeInt(0x00); // all crest
buffer.writeByte(0x00); // C2 - is flying
buffer.writeByte(0x00); // title color 0=client
buffer.writeDouble(template.getCollisionRadius());
buffer.writeDouble(template.getCollisionHeigth());
buffer.writeInt(0x00); // C4 - enchant effect
buffer.writeInt(0x00); // C6 -- is flying
buffer.writeInt(0x00); // unk
buffer.writeInt(0x00);// CT1.5 Pet form and skills, Color effect
buffer.writeByte(0x00); // hide name
buffer.writeByte(0x00); // hide name, again
buffer.writeInt(0x00); // special effects
buffer.writeInt(0x00); // display effect
}
}

View File

@@ -0,0 +1,67 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.game.net.packet.server;
import org.jboss.netty.buffer.ChannelBuffer;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractServerPacket;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.model.world.NPC;
import com.l2jserver.util.BufferUtils;
/**
* This packet sends to the client an actor information about an actor (except
* players)
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ServerObjectPacket extends AbstractServerPacket {
/**
* The packet OPCODE
*/
public static final int OPCODE = 0x92;
private final NPC npc;
public ServerObjectPacket(NPC npc) {
super(OPCODE);
this.npc = npc;
}
@Override
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
final NPCTemplate template = npc.getTemplate();
buffer.writeInt(npc.getID().getID()); // obj id
buffer.writeInt(npc.getTemplateID().getID() + 1000000); // template id
BufferUtils.writeString(buffer, template.getName()); // name
buffer.writeInt((template.isAttackable() ? 0x01 : 0x00)); // attackable
buffer.writeInt(npc.getPoint().getX()); // x
buffer.writeInt(npc.getPoint().getY()); // y
buffer.writeInt(npc.getPoint().getZ()); // z
buffer.writeInt((int) npc.getPoint().getAngle()); // angle
buffer.writeDouble(template.getMovementSpeedMultiplier());
buffer.writeDouble(template.getAttackSpeedMultiplier());
buffer.writeDouble(template.getCollisionRadius()); // coll radius
buffer.writeDouble(template.getCollisionHeigth()); // coll height
buffer.writeInt((template.isAttackable() ? npc.getHP() : 0x00));
buffer.writeInt((template.isAttackable() ? template.getMaxHP() : 0x00));
buffer.writeInt(0x01); // object type
buffer.writeInt(0x00); // special effects
}
}

View File

@@ -71,5 +71,4 @@ public abstract class ID<T> {
return false;
return true;
}
}

View File

@@ -16,12 +16,13 @@
*/
package com.l2jserver.model.id;
import com.l2jserver.model.id.factory.IDFactory;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.model.world.WorldObject;
/**
* {@link ObjectID}s cannot be instantiated directly. This must be done through
* an {@link IDFactory}. The {@link ObjectID} provides a facility
* an {@link IDProvider}. The {@link ObjectID} provides a facility
* {@link #getObject() method} that allows easily fetch this object from
* database without the need to directly use DAOs.
*
@@ -37,7 +38,7 @@ public abstract class ObjectID<T extends WorldObject> extends ID<Integer> {
* @param id
* the raw id
*/
protected ObjectID(int id) {
protected ObjectID(@Assisted int id) {
super(id);
}
@@ -47,4 +48,33 @@ public abstract class ObjectID<T extends WorldObject> extends ID<Integer> {
* @return the {@link WorldObject} if existent, <tt>null</tt> otherwise
*/
public abstract T getObject();
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
// this way we generate an unique hash code for all ObjectID and another
// ID with same id number will still generate another hash code.
result = prime * result + id.hashCode() + ObjectID.class.hashCode();
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
// we have unique id across all objects
// accept all subclasses of ObjectID is a requirement
if (!(obj instanceof ObjectID))
return false;
@SuppressWarnings("rawtypes")
ObjectID other = (ObjectID) obj;
if (other.id != null)
return false;
if (!id.equals(other.id))
return false;
return true;
}
}

View File

@@ -1,69 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.l2jserver.model.id.object.allocator.BitSetIDAllocator;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.object.factory.CharacterIDFactory;
import com.l2jserver.model.id.object.factory.CharacterIDFactory.CharacterIDGuiceFactory;
import com.l2jserver.model.id.object.factory.ClanIDFactory;
import com.l2jserver.model.id.object.factory.ClanIDFactory.ClanIDGuiceFactory;
import com.l2jserver.model.id.object.factory.ItemIDFactory;
import com.l2jserver.model.id.object.factory.ItemIDFactory.ItemIDGuiceFactory;
import com.l2jserver.model.id.template.factory.CharacterTemplateIDFactory;
import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;
import com.l2jserver.model.id.template.factory.SkillTemplateIDFactory;
/**
* Google Guice {@link IDFactory} {@link Module}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class IDFactoryModule extends AbstractModule {
@Override
protected void configure() {
bind(IDAllocator.class).to(BitSetIDAllocator.class)
.in(Scopes.SINGLETON);
// OBJECT IDS
bind(CharacterIDFactory.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(CharacterIDGuiceFactory.class));
bind(ItemIDFactory.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(ItemIDGuiceFactory.class));
bind(ClanIDFactory.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(ClanIDGuiceFactory.class));
// bind(PetIDFactory.class).in(Scopes.SINGLETON);
// install(new FactoryModuleBuilder().build(PetIDGuiceFactory.class));
// MISC OBJECTS
install(new FactoryModuleBuilder().build(AccountIDFactory.class));
install(new FactoryModuleBuilder().build(FortIDFactory.class));
// TEMPLATE IDS
install(new FactoryModuleBuilder().build(ItemTemplateIDFactory.class));
install(new FactoryModuleBuilder().build(SkillTemplateIDFactory.class));
install(new FactoryModuleBuilder()
.build(CharacterTemplateIDFactory.class));
}
}

View File

@@ -0,0 +1,49 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.NPC;
import com.l2jserver.service.database.DataAccessObject;
import com.l2jserver.service.game.world.WorldService;
/**
* An {@link ObjectID} instance representing an {@link NPC} object. Since NPC
* instances are stores in run-time only, the search is performed in the
* {@link WorldService} instead of using a {@link DataAccessObject}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public final class NPCID extends ActorID<NPC> {
/**
* {@link WorldService} used to locate objects
*/
private final WorldService worldService;
@Inject
public NPCID(@Assisted int id, WorldService worldService) {
super(id);
this.worldService = worldService;
}
@Override
public NPC getObject() {
return worldService.find(this);
}
}

View File

@@ -134,6 +134,11 @@ public class BitSetIDAllocator implements IDAllocator {
lock.unlock();
}
}
@Override
public void clear() {
ids.clear();
}
/**
* Increases the {@link BitSet} capacity

View File

@@ -59,6 +59,11 @@ public interface IDAllocator {
*/
void release(int id);
/**
* Release all allocated IDs
*/
void clear();
/**
* Get the amount of already allocated IDs
*

View File

@@ -14,49 +14,62 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.factory;
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* {@link IDFactory} for {@link CharacterID}.
* {@link IDProvider} for {@link CharacterID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterIDFactory implements ObjectIDFactory<CharacterID> {
public class CharacterIDProvider implements ObjectIDProvider<CharacterID> {
/**
* The ID allocator
*/
private final IDAllocator allocator;
/**
* The {@link WorldIDService} instance. Used to locate existing IDs.
*/
private final WorldIDService idService;
/**
* The Guice Factory
*/
private final CharacterIDGuiceFactory factory;
@Inject
public CharacterIDFactory(IDAllocator allocator,
public CharacterIDProvider(IDAllocator allocator, WorldIDService idService,
CharacterIDGuiceFactory factory) {
super();
this.allocator = allocator;
this.idService = idService;
this.factory = factory;
}
@Override
public CharacterID createID() {
return createID(allocator.allocate());
final CharacterID id = factory.create(allocator.allocate());
idService.add(id);
return id;
}
@Override
public CharacterID createID(Integer id) {
return factory.create(id);
CharacterID idObject = idService.resolve(id);
if (idObject == null) {
idObject = factory.create(id);
idService.add(idObject);
}
return idObject;
}
@Override
public void destroy(CharacterID id) {
idService.remove(id);
allocator.release(id.getID());
}

View File

@@ -14,48 +14,63 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.factory;
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.object.ClanID;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* {@link IDFactory} for {@link ClanID}.
* {@link IDProvider} for {@link ClanID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ClanIDFactory implements ObjectIDFactory<ClanID> {
public class ClanIDProvider implements ObjectIDProvider<ClanID> {
/**
* The ID allocator
*/
private final IDAllocator allocator;
/**
* The {@link WorldIDService}
*/
private final WorldIDService idService;
/**
* The Guice factory
*/
private final ClanIDGuiceFactory factory;
@Inject
public ClanIDFactory(IDAllocator allocator, ClanIDGuiceFactory factory) {
public ClanIDProvider(IDAllocator allocator, WorldIDService idService,
ClanIDGuiceFactory factory) {
super();
this.allocator = allocator;
this.idService = idService;
this.factory = factory;
}
@Override
public ClanID createID() {
return createID(allocator.allocate());
final ClanID id = factory.create(allocator.allocate());
idService.add(id);
return id;
}
@Override
public ClanID createID(Integer id) {
return factory.create(id);
ClanID idObject = idService.resolve(id);
if (idObject == null) {
idObject = factory.create(id);
idService.add(idObject);
}
return idObject;
}
@Override
public void destroy(ClanID id) {
idService.remove(id);
allocator.release(id.getID());
}

View File

@@ -14,48 +14,63 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.factory;
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.object.ItemID;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* {@link IDFactory} for {@link ItemID}.
* {@link IDProvider} for {@link ItemID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ItemIDFactory implements ObjectIDFactory<ItemID> {
public class ItemIDProvider implements ObjectIDProvider<ItemID> {
/**
* The ID allocator
*/
private final IDAllocator allocator;
/**
* The {@link WorldIDService}
*/
private final WorldIDService idService;
/**
* The Guice factory
*/
private final ItemIDGuiceFactory factory;
@Inject
public ItemIDFactory(IDAllocator allocator, ItemIDGuiceFactory factory) {
public ItemIDProvider(IDAllocator allocator, WorldIDService idService,
ItemIDGuiceFactory factory) {
super();
this.allocator = allocator;
this.idService = idService;
this.factory = factory;
}
@Override
public ItemID createID() {
return createID(allocator.allocate());
final ItemID id = factory.create(allocator.allocate());
idService.add(id);
return id;
}
@Override
public ItemID createID(Integer id) {
return factory.create(id);
ItemID idObject = idService.resolve(id);
if (idObject == null) {
idObject = factory.create(id);
idService.add(idObject);
}
return idObject;
}
@Override
public void destroy(ItemID id) {
idService.remove(id);
allocator.release(id.getID());
}

View File

@@ -0,0 +1,92 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.object.NPCID;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* {@link IDProvider} for {@link NPCID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class NPCIDProvider implements ObjectIDProvider<NPCID> {
/**
* The ID allocator
*/
private final IDAllocator allocator;
/**
* The {@link WorldIDService} instance. Used to locate existing IDs.
*/
private final WorldIDService idService;
/**
* The Guice Factory
*/
private final NPCIDGuiceFactory factory;
@Inject
public NPCIDProvider(IDAllocator allocator, WorldIDService idService,
NPCIDGuiceFactory factory) {
this.allocator = allocator;
this.idService = idService;
this.factory = factory;
}
@Override
public NPCID createID() {
final NPCID id = factory.create(allocator.allocate());
idService.add(id);
return id;
}
@Override
public NPCID createID(Integer id) {
NPCID idObject = idService.resolve(id);
if (idObject == null) {
idObject = factory.create(id);
idService.add(idObject);
}
return idObject;
}
@Override
public void destroy(NPCID id) {
idService.remove(id);
allocator.release(id.getID());
}
/**
* This is an Google Guice factory. Assistect Inject extension will
* automatically implement it and create the injected instances.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface NPCIDGuiceFactory {
/**
* Creates a new ID instance
*
* @param id
* the numeric ID
* @return the new ID created by injection
*/
NPCID create(@Assisted int id);
}
}

View File

@@ -14,13 +14,13 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.factory;
package com.l2jserver.model.id.object.provider;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.provider.IDProvider;
public interface ObjectIDFactory<T extends ObjectID<?>> extends
IDFactory<Integer, T> {
public interface ObjectIDProvider<T extends ObjectID<?>> extends
IDProvider<Integer, T> {
/**
* Generates a new ID
*

View File

@@ -0,0 +1,77 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* <h1>THIS PROVIDER IS READ ONLY!</h1>
* <p>
* This is an ID resolver that will lookup for IDs in {@link WorldIDService}.
* Since this is only a resolver, only read operations can be performed and
* {@link #createID()} and {@link #destroy(ObjectID)} will throw
* {@link UnsupportedOperationException}.
* <p>
* Another important aspect is that in {@link #createID(Integer)} if the ID is
* not found, it will <b>NOT</b> be created, instead <tt>null</tt> will be
* returned. You must use specific a {@link ObjectIDProvider} for that.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ObjectIDResolver implements ObjectIDProvider<ObjectID<?>> {
/**
* The {@link WorldIDService}
*/
private final WorldIDService idService;
@Inject
public ObjectIDResolver(WorldIDService idService) {
this.idService = idService;
}
@Override
public ObjectID<?> createID() {
throw new UnsupportedOperationException();
}
@Override
public ObjectID<?> createID(Integer id) {
return idService.resolve(id);
}
/**
* Resolves an integer ID to an {@link ObjectID}. If the ID does not exists
* <tt>null</tt> is returned.
*
* @param <T>
* the ID type
* @param id
* the id
* @return the id found, null if non existent
*/
@SuppressWarnings("unchecked")
public <T extends ObjectID<?>> T resolve(Integer id) {
return (T) createID(id);
}
@Override
public void destroy(ObjectID<?> id) {
throw new UnsupportedOperationException();
}
}

View File

@@ -14,48 +14,63 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.factory;
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.object.PetID;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* {@link IDFactory} for {@link PetID}.
* {@link IDProvider} for {@link PetID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class PetIDFactory implements ObjectIDFactory<PetID> {
public class PetIDProvider implements ObjectIDProvider<PetID> {
/**
* The ID allocator
*/
private final IDAllocator allocator;
/**
* The {@link WorldIDService}
*/
private final WorldIDService idService;
/**
* The Guice factory
*/
private final PetIDGuiceFactory factory;
@Inject
public PetIDFactory(IDAllocator allocator, PetIDGuiceFactory factory) {
public PetIDProvider(IDAllocator allocator, WorldIDService idService,
PetIDGuiceFactory factory) {
super();
this.allocator = allocator;
this.idService = idService;
this.factory = factory;
}
@Override
public PetID createID() {
return createID(allocator.allocate());
final PetID id = factory.create(allocator.allocate());
idService.add(id);
return id;
}
@Override
public PetID createID(Integer id) {
return factory.create(id);
PetID idObject = idService.resolve(id);
if (idObject == null) {
idObject = factory.create(id);
idService.add(idObject);
}
return idObject;
}
@Override
public void destroy(PetID id) {
idService.remove(id);
allocator.release(id.getID());
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
package com.l2jserver.model.id.provider;
import com.l2jserver.model.id.AccountID;
@@ -23,5 +23,5 @@ import com.l2jserver.model.id.AccountID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface AccountIDFactory extends IDFactory<String, AccountID> {
public interface AccountIDProvider extends IDProvider<String, AccountID> {
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
package com.l2jserver.model.id.provider;
import com.l2jserver.model.id.CastleID;
@@ -23,5 +23,5 @@ import com.l2jserver.model.id.CastleID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface CastleIDFactory extends IDFactory<Integer, CastleID> {
public interface CastleIDProvider extends IDProvider<Integer, CastleID> {
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
package com.l2jserver.model.id.provider;
import com.l2jserver.model.id.FortID;
@@ -23,5 +23,5 @@ import com.l2jserver.model.id.FortID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface FortIDFactory extends IDFactory<Integer, FortID> {
public interface FortIDProvider extends IDProvider<Integer, FortID> {
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
package com.l2jserver.model.id.provider;
import com.l2jserver.model.id.ID;
@@ -24,7 +24,7 @@ import com.l2jserver.model.id.ID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface IDFactory<I, T extends ID<?>> {
public interface IDProvider<I, T extends ID<?>> {
/**
* Creates the ID object for an <b>EXISTING</b> ID.
*

View File

@@ -0,0 +1,79 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.provider;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.l2jserver.model.id.object.allocator.BitSetIDAllocator;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.CharacterIDProvider.CharacterIDGuiceFactory;
import com.l2jserver.model.id.object.provider.ClanIDProvider;
import com.l2jserver.model.id.object.provider.ClanIDProvider.ClanIDGuiceFactory;
import com.l2jserver.model.id.object.provider.ItemIDProvider;
import com.l2jserver.model.id.object.provider.ItemIDProvider.ItemIDGuiceFactory;
import com.l2jserver.model.id.object.provider.NPCIDProvider;
import com.l2jserver.model.id.object.provider.NPCIDProvider.NPCIDGuiceFactory;
import com.l2jserver.model.id.object.provider.ObjectIDResolver;
import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider;
import com.l2jserver.model.id.template.provider.SkillTemplateIDProvider;
/**
* Google Guice {@link IDProvider} {@link Module}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class IDProviderModule extends AbstractModule {
@Override
protected void configure() {
bind(IDAllocator.class).to(BitSetIDAllocator.class)
.in(Scopes.SINGLETON);
// OBJECT IDS
bind(ObjectIDResolver.class).in(Scopes.SINGLETON); // read-only!
bind(CharacterIDProvider.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(CharacterIDGuiceFactory.class));
bind(NPCIDProvider.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(NPCIDGuiceFactory.class));
bind(ItemIDProvider.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(ItemIDGuiceFactory.class));
bind(ClanIDProvider.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(ClanIDGuiceFactory.class));
// bind(PetIDFactory.class).in(Scopes.SINGLETON);
// install(new FactoryModuleBuilder().build(PetIDGuiceFactory.class));
// MISC OBJECTS
install(new FactoryModuleBuilder().build(AccountIDProvider.class));
install(new FactoryModuleBuilder().build(FortIDProvider.class));
// TEMPLATE IDS
install(new FactoryModuleBuilder().build(ItemTemplateIDProvider.class));
install(new FactoryModuleBuilder().build(SkillTemplateIDProvider.class));
install(new FactoryModuleBuilder()
.build(CharacterTemplateIDProvider.class));
install(new FactoryModuleBuilder().build(NPCTemplateIDProvider.class));
}
}

View File

@@ -27,7 +27,7 @@ import com.l2jserver.service.game.template.TemplateService;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class NPCTemplateID extends ActorTemplateID<NPCTemplate<?>> {
public class NPCTemplateID extends ActorTemplateID<NPCTemplate> {
@Inject
protected NPCTemplateID(@Assisted int id, TemplateService templateService) {
super(id, templateService);

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.template.factory;
package com.l2jserver.model.id.template.provider;
import com.l2jserver.model.id.template.CharacterTemplateID;
@@ -23,6 +23,6 @@ import com.l2jserver.model.id.template.CharacterTemplateID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface CharacterTemplateIDFactory extends
TemplateIDFactory<CharacterTemplateID> {
public interface CharacterTemplateIDProvider extends
TemplateIDProvider<CharacterTemplateID> {
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.template.factory;
package com.l2jserver.model.id.template.provider;
import com.l2jserver.model.id.template.ItemTemplateID;
@@ -23,6 +23,6 @@ import com.l2jserver.model.id.template.ItemTemplateID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface ItemTemplateIDFactory extends
TemplateIDFactory<ItemTemplateID> {
public interface ItemTemplateIDProvider extends
TemplateIDProvider<ItemTemplateID> {
}

View File

@@ -0,0 +1,28 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.template.provider;
import com.l2jserver.model.id.template.NPCTemplateID;
/**
* Creates new {@link NPCTemplateID} instances
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface NPCTemplateIDProvider extends
TemplateIDProvider<NPCTemplateID> {
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.template.factory;
package com.l2jserver.model.id.template.provider;
import com.l2jserver.model.id.template.SkillTemplateID;
@@ -23,6 +23,6 @@ import com.l2jserver.model.id.template.SkillTemplateID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface SkillTemplateIDFactory extends
TemplateIDFactory<SkillTemplateID> {
public interface SkillTemplateIDProvider extends
TemplateIDProvider<SkillTemplateID> {
}

View File

@@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.template.factory;
package com.l2jserver.model.id.template.provider;
import com.l2jserver.model.id.TemplateID;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.provider.IDProvider;
/**
* Creates a new {@link TemplateID}
@@ -27,6 +27,6 @@ import com.l2jserver.model.id.factory.IDFactory;
* @param <T>
* the subclass of {@link TemplateID} that will be createdF
*/
public interface TemplateIDFactory<T extends TemplateID<?>> extends
IDFactory<Integer, T> {
public interface TemplateIDProvider<T extends TemplateID<?>> extends
IDProvider<Integer, T> {
}

View File

@@ -59,7 +59,7 @@ public abstract class ActorTemplate<T extends Actor> extends
return actor;
}
public abstract T createInstance();
protected abstract T createInstance();
/**
* @return the race

View File

@@ -16,23 +16,123 @@
*/
package com.l2jserver.model.template;
import com.google.inject.Inject;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.model.world.AbstractActor.Race;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.NPC;
import com.l2jserver.service.game.CharacterService;
import com.l2jserver.service.network.NetworkService;
/**
* Template for {@link NPC}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class NPCTemplate<T extends NPC> extends ActorTemplate<T> {
public abstract class NPCTemplate extends ActorTemplate<NPC> {
@Inject
protected NetworkService networkService;
@Inject
protected CharacterService charService;
@Inject
protected ItemTemplateIDProvider itemTemplateIdProvider;
protected String name = null;
protected String title = null;
protected boolean attackable = false;
protected double movementSpeedMultiplier = 1.0;
protected double attackSpeedMultiplier = 1.0;
protected double collisionRadius = 0;
protected double collisionHeigth = 0;
protected int maxHp;
protected NPCTemplate(NPCTemplateID id) {
super(id, null);
}
/**
* Performs an interaction with this NPC. This is normally invoked from
* <tt>npc</tt> instance.
*
* @param character
* the interacting character
* @param action
* the action performed
*/
public void action(NPC npc, L2Character character, CharacterAction action) {
final Lineage2Connection conn = networkService.discover(character
.getID());
if (conn == null)
return;
System.out.println(action);
charService.target(character, npc);
}
@Override
public T createInstance() {
return null;
public NPC createInstance() {
return new NPC(this.getID());
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @return the attackable
*/
public boolean isAttackable() {
return attackable;
}
/**
* @return the movementSpeedMultiplier
*/
public double getMovementSpeedMultiplier() {
return movementSpeedMultiplier;
}
/**
* @return the attackSpeedMultiplier
*/
public double getAttackSpeedMultiplier() {
return attackSpeedMultiplier;
}
/**
* @return the collisionRadius
*/
public double getCollisionRadius() {
return collisionRadius;
}
/**
* @return the collisionHeigth
*/
public double getCollisionHeigth() {
return collisionHeigth;
}
/**
* @return the maxHp
*/
public int getMaxHP() {
return maxHp;
}
/**

View File

@@ -25,12 +25,12 @@ import com.l2jserver.model.template.capability.Attackable;
import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
import com.l2jserver.util.calculator.Calculator;
import com.l2jserver.util.calculator.DivisionOperation;
import com.l2jserver.util.calculator.MultiplicationOperation;
import com.l2jserver.util.calculator.Operation;
import com.l2jserver.util.calculator.SetOperation;
import com.l2jserver.util.calculator.SubtractOperation;
import com.l2jserver.util.calculator.SumOperation;
import com.l2jserver.util.calculator.DivisionFunction;
import com.l2jserver.util.calculator.MultiplicationFunction;
import com.l2jserver.util.calculator.Function;
import com.l2jserver.util.calculator.SetFunction;
import com.l2jserver.util.calculator.SubtractFunction;
import com.l2jserver.util.calculator.SumFunction;
import com.l2jserver.util.factory.CollectionFactory;
/**
@@ -151,7 +151,7 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class WeaponAttribute {
private final Map<WeaponAttributeType, Map<Integer, Operation<Double>>> operations = CollectionFactory
private final Map<WeaponAttributeType, Map<Integer, Function<Double>>> operations = CollectionFactory
.newMap(null, null);
/**
@@ -165,7 +165,7 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
* the value to set
*/
public void set(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SetOperation(value));
getMap(type).put(order, new SetFunction(value));
}
/**
@@ -179,7 +179,7 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
* the value to be summed
*/
public void add(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SumOperation(value));
getMap(type).put(order, new SumFunction(value));
}
/**
@@ -193,7 +193,7 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
* the value to be subtracted
*/
public void sub(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SubtractOperation(value));
getMap(type).put(order, new SubtractFunction(value));
}
/**
@@ -207,7 +207,7 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
* the value to be multiplied
*/
public void mult(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new MultiplicationOperation(value));
getMap(type).put(order, new MultiplicationFunction(value));
}
/**
@@ -221,7 +221,7 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
* the value to be divided by
*/
public void div(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new DivisionOperation(value));
getMap(type).put(order, new DivisionFunction(value));
}
/**
@@ -245,8 +245,8 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
* the type
* @return the order-operation map
*/
private Map<Integer, Operation<Double>> getMap(WeaponAttributeType type) {
Map<Integer, Operation<Double>> map = operations.get(type);
private Map<Integer, Function<Double>> getMap(WeaponAttributeType type) {
Map<Integer, Function<Double>> map = operations.get(type);
if (map == null) {
map = CollectionFactory.newMap(null, null);
operations.put(type, map);
@@ -263,9 +263,9 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
* the calculator
*/
private void calculator(WeaponAttributeType type, Calculator calculator) {
final Map<Integer, Operation<Double>> operations = this.operations
final Map<Integer, Function<Double>> operations = this.operations
.get(type);
for (final Entry<Integer, Operation<Double>> entry : operations
for (final Entry<Integer, Function<Double>> entry : operations
.entrySet()) {
calculator.add(entry.getKey(), entry.getValue());
}

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class AdventurerNPCTemplate extends NPCTemplate<NPC> {
public class AdventurerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ArtefactNPCTemplate extends NPCTemplate<NPC> {
public class ArtefactNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class AuctioneerNPCTemplate extends NPCTemplate<NPC> {
public class AuctioneerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BabyPetNPCTemplate extends NPCTemplate<NPC> {
public class BabyPetNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BlockNPCTemplate extends NPCTemplate<NPC> {
public class BlockNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class CabaleBufferNPCTemplate extends NPCTemplate<NPC> {
public class CabaleBufferNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class CastleBlacksmithNPCTemplate extends NPCTemplate<NPC> {
public class CastleBlacksmithNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class CastleChamberlainNPCTemplate extends NPCTemplate<NPC> {
public class CastleChamberlainNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class CastleDoormenNPCTemplate extends NPCTemplate<NPC> {
public class CastleDoormenNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class CastleMagicianNPCTemplate extends NPCTemplate<NPC> {
public class CastleMagicianNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class CastleWyvernManagerNPCTemplate extends NPCTemplate<NPC> {
public class CastleWyvernManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ChestNPCTemplate extends NPCTemplate<NPC> {
public class ChestNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ChristmasTreeNPCTemplate extends NPCTemplate<NPC> {
public class ChristmasTreeNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ClanTraderNPCTemplate extends NPCTemplate<NPC> {
public class ClanTraderNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ClanhallDoormenNPCTemplate extends NPCTemplate<NPC> {
public class ClanhallDoormenNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ClanhallManagerNPCTemplate extends NPCTemplate<NPC> {
public class ClanhallManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ClassMasterNPCTemplate extends NPCTemplate<NPC> {
public class ClassMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ControlTowerNPCTemplate extends NPCTemplate<NPC> {
public class ControlTowerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class DarkElfVillageMasterNPCTemplate extends NPCTemplate<NPC> {
public class DarkElfVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class DawnPriestNPCTemplate extends NPCTemplate<NPC> {
public class DawnPriestNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class DecoyNPCTemplate extends NPCTemplate<NPC> {
public class DecoyNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class DefenderNPCTemplate extends NPCTemplate<NPC> {
public class DefenderNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class DoormenNPCTemplate extends NPCTemplate<NPC> {
public class DoormenNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class DungeonGatekeeperNPCTemplate extends NPCTemplate<NPC> {
public class DungeonGatekeeperNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class DuskPriestNPCTemplate extends NPCTemplate<NPC> {
public class DuskPriestNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class DwarfVillageMasterNPCTemplate extends NPCTemplate<NPC> {
public class DwarfVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class EffectPointNPCTemplate extends NPCTemplate<NPC> {
public class EffectPointNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class EventChestNPCTemplate extends NPCTemplate<NPC> {
public class EventChestNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FameManagerNPCTemplate extends NPCTemplate<NPC> {
public class FameManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FeedableBeastNPCTemplate extends NPCTemplate<NPC> {
public class FeedableBeastNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FestivalGuideNPCTemplate extends NPCTemplate<NPC> {
public class FestivalGuideNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FestivalMonsterNPCTemplate extends NPCTemplate<NPC> {
public class FestivalMonsterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FightherVillageMasterNPCTemplate extends NPCTemplate<NPC> {
public class FightherVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FishermanNPCTemplate extends NPCTemplate<NPC> {
public class FishermanNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FlameTowerNPCTemplate extends NPCTemplate<NPC> {
public class FlameTowerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FlyMonsterNPCTemplate extends NPCTemplate<NPC> {
public class FlyMonsterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FlyNPCTemplate extends NPCTemplate<NPC> {
public class FlyNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FlyRaidBossNPCTemplate extends NPCTemplate<NPC> {
public class FlyRaidBossNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FlyTerrainObjectNPCTemplate extends NPCTemplate<NPC> {
public class FlyTerrainObjectNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FortBallistaNPCTemplate extends NPCTemplate<NPC> {
public class FortBallistaNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FortCommanderNPCTemplate extends NPCTemplate<NPC> {
public class FortCommanderNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FortDoormenNPCTemplate extends NPCTemplate<NPC> {
public class FortDoormenNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FortEnvoyNPCTemplate extends NPCTemplate<NPC> {
public class FortEnvoyNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FortLogisticsNPCTemplate extends NPCTemplate<NPC> {
public class FortLogisticsNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FortManagerNPCTemplate extends NPCTemplate<NPC> {
public class FortManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FortSiegeNPCTemplate extends NPCTemplate<NPC> {
public class FortSiegeNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FortSupportCaptainNPCTemplate extends NPCTemplate<NPC> {
public class FortSupportCaptainNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FortWyvernManagerNPCTemplate extends NPCTemplate<NPC> {
public class FortWyvernManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class FriendlyMonsterNPCTemplate extends NPCTemplate<NPC> {
public class FriendlyMonsterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class GrandeBossNPCTemplate extends NPCTemplate<NPC> {
public class GrandeBossNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class GuardNPCTemplate extends NPCTemplate<NPC> {
public class GuardNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class KamaelVillageMasterNPCTemplate extends NPCTemplate<NPC> {
public class KamaelVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ManorManagerNPCTemplate extends NPCTemplate<NPC> {
public class ManorManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class MercManagerNPCTemplate extends NPCTemplate<NPC> {
public class MercManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class MercenaryManagerNPCTemplate extends NPCTemplate<NPC> {
public class MercenaryManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class MerchantNPCTemplate extends NPCTemplate<NPC> {
public class MerchantNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class MerchantSummonNPCTemplate extends NPCTemplate<NPC> {
public class MerchantSummonNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -16,15 +16,17 @@
*/
package com.l2jserver.model.template.npc;
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.NPC;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class MonsterNPCTemplate extends NPCTemplate<NPC> {
public class MonsterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
@@ -36,4 +38,19 @@ public class MonsterNPCTemplate extends NPCTemplate<NPC> {
protected MonsterNPCTemplate(NPCTemplateID id) {
super(id);
}
@Override
public void action(NPC npc, L2Character character, CharacterAction action) {
super.action(npc, character, action);
}
/**
* Called when an character is executing an attack action
*
* @param attacker
* the attacking character
*/
public void attack(L2Character attacker) {
}
}

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ObservationNPCTemplate extends NPCTemplate<NPC> {
public class ObservationNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class OlympiadManagerNPCTemplate extends NPCTemplate<NPC> {
public class OlympiadManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class OrcVillageMasterNPCTemplate extends NPCTemplate<NPC> {
public class OrcVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*

Some files were not shown because too many files have changed in this diff Show More