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

@@ -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
*

View File

@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class PenaltyNPCTemplate extends NPCTemplate<NPC> {
public class PenaltyNPCTemplate 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 PetManagerNPCTemplate extends NPCTemplate<NPC> {
public class PetManagerNPCTemplate 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 PriestVillageMasterNPCTemplate extends NPCTemplate<NPC> {
public class PriestVillageMasterNPCTemplate 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 RaidBossNPCTemplate extends NPCTemplate<NPC> {
public class RaidBossNPCTemplate 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 RiftInvaderNPCTemplate extends NPCTemplate<NPC> {
public class RiftInvaderNPCTemplate 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 SepulcherMonsterNPCTemplate extends NPCTemplate<NPC> {
public class SepulcherMonsterNPCTemplate 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 SiegeNPCTemplate extends NPCTemplate<NPC> {
public class SiegeNPCTemplate 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 SiegeSummonNPCTemplate extends NPCTemplate<NPC> {
public class SiegeSummonNPCTemplate 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 SignsPriestsNPCTemplate extends NPCTemplate<NPC> {
public class SignsPriestsNPCTemplate 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 SymbolMakerNPCTemplate extends NPCTemplate<NPC> {
public class SymbolMakerNPCTemplate 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 TamedBeastNPCTemplate extends NPCTemplate<NPC> {
public class TamedBeastNPCTemplate 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 TeleporterNPCTemplate extends NPCTemplate<NPC> {
public class TeleporterNPCTemplate 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