.
+ *
+ * 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 .
+ */
+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;
+
+/**
+ * THIS PROVIDER IS READ ONLY!
+ *
+ * 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}.
+ *
+ * Another important aspect is that in {@link #createID(Integer)} if the ID is
+ * not found, it will NOT be created, instead null will be
+ * returned. You must use specific a {@link ObjectIDProvider} for that.
+ *
+ * @author Rogiel
+ */
+public class ObjectIDResolver implements ObjectIDProvider> {
+ /**
+ * 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
+ * null is returned.
+ *
+ * @param
+ * the ID type
+ * @param id
+ * the id
+ * @return the id found, null if non existent
+ */
+ @SuppressWarnings("unchecked")
+ public > T resolve(Integer id) {
+ return (T) createID(id);
+ }
+
+ @Override
+ public void destroy(ObjectID> id) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/src/main/java/com/l2jserver/model/id/object/factory/PetIDFactory.java b/src/main/java/com/l2jserver/model/id/object/provider/PetIDProvider.java
similarity index 70%
rename from src/main/java/com/l2jserver/model/id/object/factory/PetIDFactory.java
rename to src/main/java/com/l2jserver/model/id/object/provider/PetIDProvider.java
index 757edd686..48eefd14f 100644
--- a/src/main/java/com/l2jserver/model/id/object/factory/PetIDFactory.java
+++ b/src/main/java/com/l2jserver/model/id/object/provider/PetIDProvider.java
@@ -14,48 +14,63 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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 Rogiel
*/
-public class PetIDFactory implements ObjectIDFactory {
+public class PetIDProvider implements ObjectIDProvider {
/**
* 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());
}
diff --git a/src/main/java/com/l2jserver/model/id/factory/AccountIDFactory.java b/src/main/java/com/l2jserver/model/id/provider/AccountIDProvider.java
similarity index 87%
rename from src/main/java/com/l2jserver/model/id/factory/AccountIDFactory.java
rename to src/main/java/com/l2jserver/model/id/provider/AccountIDProvider.java
index 6205eec0e..e622c789d 100644
--- a/src/main/java/com/l2jserver/model/id/factory/AccountIDFactory.java
+++ b/src/main/java/com/l2jserver/model/id/provider/AccountIDProvider.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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 Rogiel
*/
-public interface AccountIDFactory extends IDFactory {
+public interface AccountIDProvider extends IDProvider {
}
diff --git a/src/main/java/com/l2jserver/model/id/factory/CastleIDFactory.java b/src/main/java/com/l2jserver/model/id/provider/CastleIDProvider.java
similarity index 87%
rename from src/main/java/com/l2jserver/model/id/factory/CastleIDFactory.java
rename to src/main/java/com/l2jserver/model/id/provider/CastleIDProvider.java
index 36576831b..8333cc88a 100644
--- a/src/main/java/com/l2jserver/model/id/factory/CastleIDFactory.java
+++ b/src/main/java/com/l2jserver/model/id/provider/CastleIDProvider.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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 Rogiel
*/
-public interface CastleIDFactory extends IDFactory {
+public interface CastleIDProvider extends IDProvider {
}
diff --git a/src/main/java/com/l2jserver/model/id/factory/FortIDFactory.java b/src/main/java/com/l2jserver/model/id/provider/FortIDProvider.java
similarity index 88%
rename from src/main/java/com/l2jserver/model/id/factory/FortIDFactory.java
rename to src/main/java/com/l2jserver/model/id/provider/FortIDProvider.java
index 6769a1ec0..699f524f8 100644
--- a/src/main/java/com/l2jserver/model/id/factory/FortIDFactory.java
+++ b/src/main/java/com/l2jserver/model/id/provider/FortIDProvider.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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 Rogiel
*/
-public interface FortIDFactory extends IDFactory {
+public interface FortIDProvider extends IDProvider {
}
diff --git a/src/main/java/com/l2jserver/model/id/factory/IDFactory.java b/src/main/java/com/l2jserver/model/id/provider/IDProvider.java
similarity index 91%
rename from src/main/java/com/l2jserver/model/id/factory/IDFactory.java
rename to src/main/java/com/l2jserver/model/id/provider/IDProvider.java
index bd6dfe6d7..c7fab6795 100644
--- a/src/main/java/com/l2jserver/model/id/factory/IDFactory.java
+++ b/src/main/java/com/l2jserver/model/id/provider/IDProvider.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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 Rogiel
*/
-public interface IDFactory> {
+public interface IDProvider> {
/**
* Creates the ID object for an EXISTING ID.
*
diff --git a/src/main/java/com/l2jserver/model/id/provider/IDProviderModule.java b/src/main/java/com/l2jserver/model/id/provider/IDProviderModule.java
new file mode 100644
index 000000000..13704b5f5
--- /dev/null
+++ b/src/main/java/com/l2jserver/model/id/provider/IDProviderModule.java
@@ -0,0 +1,79 @@
+/*
+ * This file is part of l2jserver .
+ *
+ * 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 .
+ */
+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 Rogiel
+ */
+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));
+ }
+}
diff --git a/src/main/java/com/l2jserver/model/id/template/NPCTemplateID.java b/src/main/java/com/l2jserver/model/id/template/NPCTemplateID.java
index f2402914b..7b541201b 100644
--- a/src/main/java/com/l2jserver/model/id/template/NPCTemplateID.java
+++ b/src/main/java/com/l2jserver/model/id/template/NPCTemplateID.java
@@ -27,7 +27,7 @@ import com.l2jserver.service.game.template.TemplateService;
*
* @author Rogiel
*/
-public class NPCTemplateID extends ActorTemplateID> {
+public class NPCTemplateID extends ActorTemplateID {
@Inject
protected NPCTemplateID(@Assisted int id, TemplateService templateService) {
super(id, templateService);
diff --git a/src/main/java/com/l2jserver/model/id/template/factory/CharacterTemplateIDFactory.java b/src/main/java/com/l2jserver/model/id/template/provider/CharacterTemplateIDProvider.java
similarity index 85%
rename from src/main/java/com/l2jserver/model/id/template/factory/CharacterTemplateIDFactory.java
rename to src/main/java/com/l2jserver/model/id/template/provider/CharacterTemplateIDProvider.java
index 96110330c..de82eddb0 100644
--- a/src/main/java/com/l2jserver/model/id/template/factory/CharacterTemplateIDFactory.java
+++ b/src/main/java/com/l2jserver/model/id/template/provider/CharacterTemplateIDProvider.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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 Rogiel
*/
-public interface CharacterTemplateIDFactory extends
- TemplateIDFactory {
+public interface CharacterTemplateIDProvider extends
+ TemplateIDProvider {
}
diff --git a/src/main/java/com/l2jserver/model/id/template/factory/ItemTemplateIDFactory.java b/src/main/java/com/l2jserver/model/id/template/provider/ItemTemplateIDProvider.java
similarity index 86%
rename from src/main/java/com/l2jserver/model/id/template/factory/ItemTemplateIDFactory.java
rename to src/main/java/com/l2jserver/model/id/template/provider/ItemTemplateIDProvider.java
index 26abd86b5..a68686a9b 100644
--- a/src/main/java/com/l2jserver/model/id/template/factory/ItemTemplateIDFactory.java
+++ b/src/main/java/com/l2jserver/model/id/template/provider/ItemTemplateIDProvider.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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 Rogiel
*/
-public interface ItemTemplateIDFactory extends
- TemplateIDFactory {
+public interface ItemTemplateIDProvider extends
+ TemplateIDProvider {
}
diff --git a/src/main/java/com/l2jserver/model/id/template/provider/NPCTemplateIDProvider.java b/src/main/java/com/l2jserver/model/id/template/provider/NPCTemplateIDProvider.java
new file mode 100644
index 000000000..96b3901c8
--- /dev/null
+++ b/src/main/java/com/l2jserver/model/id/template/provider/NPCTemplateIDProvider.java
@@ -0,0 +1,28 @@
+/*
+ * This file is part of l2jserver .
+ *
+ * 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 .
+ */
+package com.l2jserver.model.id.template.provider;
+
+import com.l2jserver.model.id.template.NPCTemplateID;
+
+/**
+ * Creates new {@link NPCTemplateID} instances
+ *
+ * @author Rogiel
+ */
+public interface NPCTemplateIDProvider extends
+ TemplateIDProvider {
+}
diff --git a/src/main/java/com/l2jserver/model/id/template/factory/SkillTemplateIDFactory.java b/src/main/java/com/l2jserver/model/id/template/provider/SkillTemplateIDProvider.java
similarity index 86%
rename from src/main/java/com/l2jserver/model/id/template/factory/SkillTemplateIDFactory.java
rename to src/main/java/com/l2jserver/model/id/template/provider/SkillTemplateIDProvider.java
index 95e569940..2ca9bc914 100644
--- a/src/main/java/com/l2jserver/model/id/template/factory/SkillTemplateIDFactory.java
+++ b/src/main/java/com/l2jserver/model/id/template/provider/SkillTemplateIDProvider.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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 Rogiel
*/
-public interface SkillTemplateIDFactory extends
- TemplateIDFactory {
+public interface SkillTemplateIDProvider extends
+ TemplateIDProvider {
}
diff --git a/src/main/java/com/l2jserver/model/id/template/factory/TemplateIDFactory.java b/src/main/java/com/l2jserver/model/id/template/provider/TemplateIDProvider.java
similarity index 82%
rename from src/main/java/com/l2jserver/model/id/template/factory/TemplateIDFactory.java
rename to src/main/java/com/l2jserver/model/id/template/provider/TemplateIDProvider.java
index 913abca49..896581a8c 100644
--- a/src/main/java/com/l2jserver/model/id/template/factory/TemplateIDFactory.java
+++ b/src/main/java/com/l2jserver/model/id/template/provider/TemplateIDProvider.java
@@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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
* the subclass of {@link TemplateID} that will be createdF
*/
-public interface TemplateIDFactory> extends
- IDFactory {
+public interface TemplateIDProvider> extends
+ IDProvider {
}
diff --git a/src/main/java/com/l2jserver/model/template/ActorTemplate.java b/src/main/java/com/l2jserver/model/template/ActorTemplate.java
index 8f4734f74..652e63400 100644
--- a/src/main/java/com/l2jserver/model/template/ActorTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/ActorTemplate.java
@@ -59,7 +59,7 @@ public abstract class ActorTemplate extends
return actor;
}
- public abstract T createInstance();
+ protected abstract T createInstance();
/**
* @return the race
diff --git a/src/main/java/com/l2jserver/model/template/NPCTemplate.java b/src/main/java/com/l2jserver/model/template/NPCTemplate.java
index 82944f4b8..3b6f45230 100644
--- a/src/main/java/com/l2jserver/model/template/NPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/NPCTemplate.java
@@ -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 Rogiel
*/
-public abstract class NPCTemplate extends ActorTemplate {
+public abstract class NPCTemplate extends ActorTemplate {
+ @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
+ * npc 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;
}
/**
diff --git a/src/main/java/com/l2jserver/model/template/item/WeaponTemplate.java b/src/main/java/com/l2jserver/model/template/item/WeaponTemplate.java
index 0ffc8500b..40b5a7e6c 100644
--- a/src/main/java/com/l2jserver/model/template/item/WeaponTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/item/WeaponTemplate.java
@@ -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 Rogiel
*/
public class WeaponAttribute {
- private final Map>> operations = CollectionFactory
+ private final Map>> 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> getMap(WeaponAttributeType type) {
- Map> map = operations.get(type);
+ private Map> getMap(WeaponAttributeType type) {
+ Map> 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> operations = this.operations
+ final Map> operations = this.operations
.get(type);
- for (final Entry> entry : operations
+ for (final Entry> entry : operations
.entrySet()) {
calculator.add(entry.getKey(), entry.getValue());
}
diff --git a/src/main/java/com/l2jserver/model/template/npc/AdventurerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/AdventurerNPCTemplate.java
index 14bb40b65..db6f5f243 100644
--- a/src/main/java/com/l2jserver/model/template/npc/AdventurerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/AdventurerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class AdventurerNPCTemplate extends NPCTemplate {
+public class AdventurerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/ArtefactNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/ArtefactNPCTemplate.java
index 97556440f..3f4c080ae 100644
--- a/src/main/java/com/l2jserver/model/template/npc/ArtefactNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/ArtefactNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class ArtefactNPCTemplate extends NPCTemplate {
+public class ArtefactNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/AuctioneerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/AuctioneerNPCTemplate.java
index 7d22e3423..a2f624a3f 100644
--- a/src/main/java/com/l2jserver/model/template/npc/AuctioneerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/AuctioneerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class AuctioneerNPCTemplate extends NPCTemplate {
+public class AuctioneerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/BabyPetNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/BabyPetNPCTemplate.java
index a91ae83f9..c848b6f41 100644
--- a/src/main/java/com/l2jserver/model/template/npc/BabyPetNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/BabyPetNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class BabyPetNPCTemplate extends NPCTemplate {
+public class BabyPetNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/BlockNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/BlockNPCTemplate.java
index 5d5b3677b..217a33910 100644
--- a/src/main/java/com/l2jserver/model/template/npc/BlockNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/BlockNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class BlockNPCTemplate extends NPCTemplate {
+public class BlockNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/CabaleBufferNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/CabaleBufferNPCTemplate.java
index 7c858c41b..5578e2c4e 100644
--- a/src/main/java/com/l2jserver/model/template/npc/CabaleBufferNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/CabaleBufferNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class CabaleBufferNPCTemplate extends NPCTemplate {
+public class CabaleBufferNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/CastleBlacksmithNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/CastleBlacksmithNPCTemplate.java
index d2db01c81..b1f51e34b 100644
--- a/src/main/java/com/l2jserver/model/template/npc/CastleBlacksmithNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/CastleBlacksmithNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class CastleBlacksmithNPCTemplate extends NPCTemplate {
+public class CastleBlacksmithNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/CastleChamberlainNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/CastleChamberlainNPCTemplate.java
index 5f6d5c9f9..6255364ea 100644
--- a/src/main/java/com/l2jserver/model/template/npc/CastleChamberlainNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/CastleChamberlainNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class CastleChamberlainNPCTemplate extends NPCTemplate {
+public class CastleChamberlainNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/CastleDoormenNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/CastleDoormenNPCTemplate.java
index acb52c098..121d434ad 100644
--- a/src/main/java/com/l2jserver/model/template/npc/CastleDoormenNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/CastleDoormenNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class CastleDoormenNPCTemplate extends NPCTemplate {
+public class CastleDoormenNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/CastleMagicianNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/CastleMagicianNPCTemplate.java
index 240a50609..855fbb94c 100644
--- a/src/main/java/com/l2jserver/model/template/npc/CastleMagicianNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/CastleMagicianNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class CastleMagicianNPCTemplate extends NPCTemplate {
+public class CastleMagicianNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/CastleWyvernManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/CastleWyvernManagerNPCTemplate.java
index e38e49962..1a568cab4 100644
--- a/src/main/java/com/l2jserver/model/template/npc/CastleWyvernManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/CastleWyvernManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class CastleWyvernManagerNPCTemplate extends NPCTemplate {
+public class CastleWyvernManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/ChestNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/ChestNPCTemplate.java
index aefcc7dac..32034f2ff 100644
--- a/src/main/java/com/l2jserver/model/template/npc/ChestNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/ChestNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class ChestNPCTemplate extends NPCTemplate {
+public class ChestNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/ChristmasTreeNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/ChristmasTreeNPCTemplate.java
index ba63165b2..14597a777 100644
--- a/src/main/java/com/l2jserver/model/template/npc/ChristmasTreeNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/ChristmasTreeNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class ChristmasTreeNPCTemplate extends NPCTemplate {
+public class ChristmasTreeNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/ClanTraderNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/ClanTraderNPCTemplate.java
index baf409f93..6ea6f6564 100644
--- a/src/main/java/com/l2jserver/model/template/npc/ClanTraderNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/ClanTraderNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class ClanTraderNPCTemplate extends NPCTemplate {
+public class ClanTraderNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/ClanhallDoormenNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/ClanhallDoormenNPCTemplate.java
index d77cb493c..c15c7cb97 100644
--- a/src/main/java/com/l2jserver/model/template/npc/ClanhallDoormenNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/ClanhallDoormenNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class ClanhallDoormenNPCTemplate extends NPCTemplate {
+public class ClanhallDoormenNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/ClanhallManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/ClanhallManagerNPCTemplate.java
index 2821e7d48..b75b8b15f 100644
--- a/src/main/java/com/l2jserver/model/template/npc/ClanhallManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/ClanhallManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class ClanhallManagerNPCTemplate extends NPCTemplate {
+public class ClanhallManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/ClassMasterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/ClassMasterNPCTemplate.java
index 5d8bd89f8..db907a37a 100644
--- a/src/main/java/com/l2jserver/model/template/npc/ClassMasterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/ClassMasterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class ClassMasterNPCTemplate extends NPCTemplate {
+public class ClassMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/ControlTowerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/ControlTowerNPCTemplate.java
index c2cc4557b..3a98788f1 100644
--- a/src/main/java/com/l2jserver/model/template/npc/ControlTowerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/ControlTowerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class ControlTowerNPCTemplate extends NPCTemplate {
+public class ControlTowerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/DarkElfVillageMasterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/DarkElfVillageMasterNPCTemplate.java
index 4ef834931..22f5a6faa 100644
--- a/src/main/java/com/l2jserver/model/template/npc/DarkElfVillageMasterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/DarkElfVillageMasterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class DarkElfVillageMasterNPCTemplate extends NPCTemplate {
+public class DarkElfVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/DawnPriestNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/DawnPriestNPCTemplate.java
index f8e4cd690..e2c111107 100644
--- a/src/main/java/com/l2jserver/model/template/npc/DawnPriestNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/DawnPriestNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class DawnPriestNPCTemplate extends NPCTemplate {
+public class DawnPriestNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/DecoyNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/DecoyNPCTemplate.java
index fb19c229b..cdc272879 100644
--- a/src/main/java/com/l2jserver/model/template/npc/DecoyNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/DecoyNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class DecoyNPCTemplate extends NPCTemplate {
+public class DecoyNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/DefenderNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/DefenderNPCTemplate.java
index 1679094bb..f09b04f3d 100644
--- a/src/main/java/com/l2jserver/model/template/npc/DefenderNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/DefenderNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class DefenderNPCTemplate extends NPCTemplate {
+public class DefenderNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/DoormenNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/DoormenNPCTemplate.java
index 183fde994..f2bff1b88 100644
--- a/src/main/java/com/l2jserver/model/template/npc/DoormenNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/DoormenNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class DoormenNPCTemplate extends NPCTemplate {
+public class DoormenNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/DungeonGatekeeperNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/DungeonGatekeeperNPCTemplate.java
index b6575bc41..7660cb407 100644
--- a/src/main/java/com/l2jserver/model/template/npc/DungeonGatekeeperNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/DungeonGatekeeperNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class DungeonGatekeeperNPCTemplate extends NPCTemplate {
+public class DungeonGatekeeperNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/DuskPriestNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/DuskPriestNPCTemplate.java
index f1a361682..8d18cbca2 100644
--- a/src/main/java/com/l2jserver/model/template/npc/DuskPriestNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/DuskPriestNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class DuskPriestNPCTemplate extends NPCTemplate {
+public class DuskPriestNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/DwarfVillageMasterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/DwarfVillageMasterNPCTemplate.java
index 8188e9842..d30695cc1 100644
--- a/src/main/java/com/l2jserver/model/template/npc/DwarfVillageMasterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/DwarfVillageMasterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class DwarfVillageMasterNPCTemplate extends NPCTemplate {
+public class DwarfVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/EffectPointNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/EffectPointNPCTemplate.java
index cb9e1bc50..5e0efc6b3 100644
--- a/src/main/java/com/l2jserver/model/template/npc/EffectPointNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/EffectPointNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class EffectPointNPCTemplate extends NPCTemplate {
+public class EffectPointNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/EventChestNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/EventChestNPCTemplate.java
index 4384bec97..67b536226 100644
--- a/src/main/java/com/l2jserver/model/template/npc/EventChestNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/EventChestNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class EventChestNPCTemplate extends NPCTemplate {
+public class EventChestNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FameManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FameManagerNPCTemplate.java
index 7849488d0..c40402ee7 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FameManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FameManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FameManagerNPCTemplate extends NPCTemplate {
+public class FameManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FeedableBeastNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FeedableBeastNPCTemplate.java
index c409117f9..078b55e2c 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FeedableBeastNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FeedableBeastNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FeedableBeastNPCTemplate extends NPCTemplate {
+public class FeedableBeastNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FestivalGuideNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FestivalGuideNPCTemplate.java
index 5971cc890..1e215eb4e 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FestivalGuideNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FestivalGuideNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FestivalGuideNPCTemplate extends NPCTemplate {
+public class FestivalGuideNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FestivalMonsterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FestivalMonsterNPCTemplate.java
index ed7b329c8..4abb14198 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FestivalMonsterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FestivalMonsterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FestivalMonsterNPCTemplate extends NPCTemplate {
+public class FestivalMonsterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FightherVillageMasterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FightherVillageMasterNPCTemplate.java
index 753363727..929386422 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FightherVillageMasterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FightherVillageMasterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FightherVillageMasterNPCTemplate extends NPCTemplate {
+public class FightherVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FishermanNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FishermanNPCTemplate.java
index b1dee033e..4ed02ff5c 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FishermanNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FishermanNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FishermanNPCTemplate extends NPCTemplate {
+public class FishermanNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FlameTowerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FlameTowerNPCTemplate.java
index 5461abe03..d2b633d3c 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FlameTowerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FlameTowerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FlameTowerNPCTemplate extends NPCTemplate {
+public class FlameTowerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FlyMonsterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FlyMonsterNPCTemplate.java
index 916c425e1..227552576 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FlyMonsterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FlyMonsterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FlyMonsterNPCTemplate extends NPCTemplate {
+public class FlyMonsterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FlyNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FlyNPCTemplate.java
index ec2f43b93..e5a231a29 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FlyNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FlyNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FlyNPCTemplate extends NPCTemplate {
+public class FlyNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FlyRaidBossNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FlyRaidBossNPCTemplate.java
index 3b5849d3a..4f54326bf 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FlyRaidBossNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FlyRaidBossNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FlyRaidBossNPCTemplate extends NPCTemplate {
+public class FlyRaidBossNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FlyTerrainObjectNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FlyTerrainObjectNPCTemplate.java
index 7635db4f4..021a1e193 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FlyTerrainObjectNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FlyTerrainObjectNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FlyTerrainObjectNPCTemplate extends NPCTemplate {
+public class FlyTerrainObjectNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FortBallistaNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FortBallistaNPCTemplate.java
index 78c3557ee..a02e87714 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FortBallistaNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FortBallistaNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FortBallistaNPCTemplate extends NPCTemplate {
+public class FortBallistaNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FortCommanderNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FortCommanderNPCTemplate.java
index d8fd2f55b..4a8f83988 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FortCommanderNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FortCommanderNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FortCommanderNPCTemplate extends NPCTemplate {
+public class FortCommanderNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FortDoormenNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FortDoormenNPCTemplate.java
index 836038116..fc54236ce 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FortDoormenNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FortDoormenNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FortDoormenNPCTemplate extends NPCTemplate {
+public class FortDoormenNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FortEnvoyNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FortEnvoyNPCTemplate.java
index 3a18117c0..6035f4ff3 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FortEnvoyNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FortEnvoyNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FortEnvoyNPCTemplate extends NPCTemplate {
+public class FortEnvoyNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FortLogisticsNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FortLogisticsNPCTemplate.java
index e31013187..355070ee9 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FortLogisticsNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FortLogisticsNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FortLogisticsNPCTemplate extends NPCTemplate {
+public class FortLogisticsNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FortManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FortManagerNPCTemplate.java
index 4738cdecb..0969dacd9 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FortManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FortManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FortManagerNPCTemplate extends NPCTemplate {
+public class FortManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FortSiegeNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FortSiegeNPCTemplate.java
index dd1ec0a2d..e1f8f1706 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FortSiegeNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FortSiegeNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FortSiegeNPCTemplate extends NPCTemplate {
+public class FortSiegeNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FortSupportCaptainNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FortSupportCaptainNPCTemplate.java
index 11379ebd6..56e4d87fa 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FortSupportCaptainNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FortSupportCaptainNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FortSupportCaptainNPCTemplate extends NPCTemplate {
+public class FortSupportCaptainNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FortWyvernManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FortWyvernManagerNPCTemplate.java
index 4d629470b..5308a59e1 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FortWyvernManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FortWyvernManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FortWyvernManagerNPCTemplate extends NPCTemplate {
+public class FortWyvernManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/FriendlyMonsterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/FriendlyMonsterNPCTemplate.java
index 6fdf4572b..6dcbfb135 100644
--- a/src/main/java/com/l2jserver/model/template/npc/FriendlyMonsterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/FriendlyMonsterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class FriendlyMonsterNPCTemplate extends NPCTemplate {
+public class FriendlyMonsterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/GrandeBossNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/GrandeBossNPCTemplate.java
index fc96241b0..deda403f0 100644
--- a/src/main/java/com/l2jserver/model/template/npc/GrandeBossNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/GrandeBossNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class GrandeBossNPCTemplate extends NPCTemplate {
+public class GrandeBossNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/GuardNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/GuardNPCTemplate.java
index 676e57546..8649cb4a2 100644
--- a/src/main/java/com/l2jserver/model/template/npc/GuardNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/GuardNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class GuardNPCTemplate extends NPCTemplate {
+public class GuardNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/KamaelVillageMasterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/KamaelVillageMasterNPCTemplate.java
index c3356e7aa..3d0c8515f 100644
--- a/src/main/java/com/l2jserver/model/template/npc/KamaelVillageMasterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/KamaelVillageMasterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class KamaelVillageMasterNPCTemplate extends NPCTemplate {
+public class KamaelVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/ManorManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/ManorManagerNPCTemplate.java
index b78221210..517cb73ee 100644
--- a/src/main/java/com/l2jserver/model/template/npc/ManorManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/ManorManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class ManorManagerNPCTemplate extends NPCTemplate {
+public class ManorManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/MercManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/MercManagerNPCTemplate.java
index d3b14a7a7..829961fca 100644
--- a/src/main/java/com/l2jserver/model/template/npc/MercManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/MercManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class MercManagerNPCTemplate extends NPCTemplate {
+public class MercManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/MercenaryManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/MercenaryManagerNPCTemplate.java
index 75e2b111a..54afb8f97 100644
--- a/src/main/java/com/l2jserver/model/template/npc/MercenaryManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/MercenaryManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class MercenaryManagerNPCTemplate extends NPCTemplate {
+public class MercenaryManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/MerchantNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/MerchantNPCTemplate.java
index b1e27e1ca..c89ff4115 100644
--- a/src/main/java/com/l2jserver/model/template/npc/MerchantNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/MerchantNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class MerchantNPCTemplate extends NPCTemplate {
+public class MerchantNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/MerchantSummonNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/MerchantSummonNPCTemplate.java
index 877c69429..696128ef3 100644
--- a/src/main/java/com/l2jserver/model/template/npc/MerchantSummonNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/MerchantSummonNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class MerchantSummonNPCTemplate extends NPCTemplate {
+public class MerchantSummonNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/MonsterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/MonsterNPCTemplate.java
index bb7a7f6d9..27d7029d3 100644
--- a/src/main/java/com/l2jserver/model/template/npc/MonsterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/MonsterNPCTemplate.java
@@ -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 Rogiel
*
*/
-public class MonsterNPCTemplate extends NPCTemplate {
+public class MonsterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
@@ -36,4 +38,19 @@ public class MonsterNPCTemplate extends NPCTemplate {
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) {
+
+ }
}
diff --git a/src/main/java/com/l2jserver/model/template/npc/ObservationNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/ObservationNPCTemplate.java
index a4fe7685f..ee6ee6075 100644
--- a/src/main/java/com/l2jserver/model/template/npc/ObservationNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/ObservationNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class ObservationNPCTemplate extends NPCTemplate {
+public class ObservationNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/OlympiadManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/OlympiadManagerNPCTemplate.java
index a1b0de9c1..4eb73badd 100644
--- a/src/main/java/com/l2jserver/model/template/npc/OlympiadManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/OlympiadManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class OlympiadManagerNPCTemplate extends NPCTemplate {
+public class OlympiadManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/OrcVillageMasterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/OrcVillageMasterNPCTemplate.java
index 9ed615010..f7694be5f 100644
--- a/src/main/java/com/l2jserver/model/template/npc/OrcVillageMasterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/OrcVillageMasterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class OrcVillageMasterNPCTemplate extends NPCTemplate {
+public class OrcVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/PenaltyNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/PenaltyNPCTemplate.java
index 43e9e62a0..a01666ba3 100644
--- a/src/main/java/com/l2jserver/model/template/npc/PenaltyNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/PenaltyNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class PenaltyNPCTemplate extends NPCTemplate {
+public class PenaltyNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/PetManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/PetManagerNPCTemplate.java
index fdd34291b..310675a89 100644
--- a/src/main/java/com/l2jserver/model/template/npc/PetManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/PetManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class PetManagerNPCTemplate extends NPCTemplate {
+public class PetManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/PriestVillageMasterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/PriestVillageMasterNPCTemplate.java
index ceadf4d1d..0657ff40e 100644
--- a/src/main/java/com/l2jserver/model/template/npc/PriestVillageMasterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/PriestVillageMasterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class PriestVillageMasterNPCTemplate extends NPCTemplate {
+public class PriestVillageMasterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/RaidBossNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/RaidBossNPCTemplate.java
index eb881ea07..db3ccb9cf 100644
--- a/src/main/java/com/l2jserver/model/template/npc/RaidBossNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/RaidBossNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class RaidBossNPCTemplate extends NPCTemplate {
+public class RaidBossNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/RiftInvaderNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/RiftInvaderNPCTemplate.java
index e3a44dfe9..9b8812927 100644
--- a/src/main/java/com/l2jserver/model/template/npc/RiftInvaderNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/RiftInvaderNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class RiftInvaderNPCTemplate extends NPCTemplate {
+public class RiftInvaderNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/SepulcherMonsterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/SepulcherMonsterNPCTemplate.java
index 4f773cab9..b22f1ec5d 100644
--- a/src/main/java/com/l2jserver/model/template/npc/SepulcherMonsterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/SepulcherMonsterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class SepulcherMonsterNPCTemplate extends NPCTemplate {
+public class SepulcherMonsterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/SiegeNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/SiegeNPCTemplate.java
index 86ade8841..090c9dd11 100644
--- a/src/main/java/com/l2jserver/model/template/npc/SiegeNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/SiegeNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class SiegeNPCTemplate extends NPCTemplate {
+public class SiegeNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/SiegeSummonNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/SiegeSummonNPCTemplate.java
index 0c44ca630..63529bca3 100644
--- a/src/main/java/com/l2jserver/model/template/npc/SiegeSummonNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/SiegeSummonNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class SiegeSummonNPCTemplate extends NPCTemplate {
+public class SiegeSummonNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/SignsPriestsNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/SignsPriestsNPCTemplate.java
index 53d75f8fd..2b0452b58 100644
--- a/src/main/java/com/l2jserver/model/template/npc/SignsPriestsNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/SignsPriestsNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class SignsPriestsNPCTemplate extends NPCTemplate {
+public class SignsPriestsNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/SymbolMakerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/SymbolMakerNPCTemplate.java
index b32b035ed..735a8b57e 100644
--- a/src/main/java/com/l2jserver/model/template/npc/SymbolMakerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/SymbolMakerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class SymbolMakerNPCTemplate extends NPCTemplate {
+public class SymbolMakerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/TamedBeastNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/TamedBeastNPCTemplate.java
index 0d722594a..1667db07a 100644
--- a/src/main/java/com/l2jserver/model/template/npc/TamedBeastNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/TamedBeastNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class TamedBeastNPCTemplate extends NPCTemplate {
+public class TamedBeastNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/TeleporterNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/TeleporterNPCTemplate.java
index 583522f96..6d7b53695 100644
--- a/src/main/java/com/l2jserver/model/template/npc/TeleporterNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/TeleporterNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class TeleporterNPCTemplate extends NPCTemplate {
+public class TeleporterNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/TerrainObjectNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/TerrainObjectNPCTemplate.java
index 6b413d78d..20bafbf7b 100644
--- a/src/main/java/com/l2jserver/model/template/npc/TerrainObjectNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/TerrainObjectNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class TerrainObjectNPCTemplate extends NPCTemplate {
+public class TerrainObjectNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/TerritoryWardNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/TerritoryWardNPCTemplate.java
index f73c7c652..53a28f7f7 100644
--- a/src/main/java/com/l2jserver/model/template/npc/TerritoryWardNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/TerritoryWardNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class TerritoryWardNPCTemplate extends NPCTemplate {
+public class TerritoryWardNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/TownPetNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/TownPetNPCTemplate.java
index 49ace570b..d23a4e750 100644
--- a/src/main/java/com/l2jserver/model/template/npc/TownPetNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/TownPetNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class TownPetNPCTemplate extends NPCTemplate {
+public class TownPetNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/TrainerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/TrainerNPCTemplate.java
index b8edcc84b..6edf5ab54 100644
--- a/src/main/java/com/l2jserver/model/template/npc/TrainerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/TrainerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class TrainerNPCTemplate extends NPCTemplate {
+public class TrainerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/TransformManagerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/TransformManagerNPCTemplate.java
index 0a622e8c4..2ef93d765 100644
--- a/src/main/java/com/l2jserver/model/template/npc/TransformManagerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/TransformManagerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class TransformManagerNPCTemplate extends NPCTemplate {
+public class TransformManagerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/WalkerNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/WalkerNPCTemplate.java
index 51c446c34..72f31e912 100644
--- a/src/main/java/com/l2jserver/model/template/npc/WalkerNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/WalkerNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class WalkerNPCTemplate extends NPCTemplate {
+public class WalkerNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/template/npc/WarehouseNPCTemplate.java b/src/main/java/com/l2jserver/model/template/npc/WarehouseNPCTemplate.java
index b7c0611e6..e4aa820fc 100644
--- a/src/main/java/com/l2jserver/model/template/npc/WarehouseNPCTemplate.java
+++ b/src/main/java/com/l2jserver/model/template/npc/WarehouseNPCTemplate.java
@@ -24,7 +24,7 @@ import com.l2jserver.model.world.NPC;
* @author Rogiel
*
*/
-public class WarehouseNPCTemplate extends NPCTemplate {
+public class WarehouseNPCTemplate extends NPCTemplate {
/**
* Creates a new instance of this template
*
diff --git a/src/main/java/com/l2jserver/model/world/L2Character.java b/src/main/java/com/l2jserver/model/world/L2Character.java
index 1922717b0..7d2feb0eb 100644
--- a/src/main/java/com/l2jserver/model/world/L2Character.java
+++ b/src/main/java/com/l2jserver/model/world/L2Character.java
@@ -19,11 +19,13 @@ package com.l2jserver.model.world;
import java.sql.Date;
import com.l2jserver.model.id.AccountID;
+import com.l2jserver.model.id.object.ActorID;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.ClanID;
import com.l2jserver.model.id.object.PetID;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.actor.ActorAttributes;
+import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.character.CharacterAppearance;
import com.l2jserver.model.world.character.CharacterCalculatedAttributes;
import com.l2jserver.model.world.character.CharacterClass;
@@ -92,12 +94,21 @@ public class L2Character extends Player {
* Date of character's last access
*/
private Date lastAccess;
+
+ // ////////////////////////////////////
+ // / RUNTIME
+ // ////////////////////////////////////
+
/**
* The character walk mode.
*
* This field is not persisted.
*/
private CharacterMoveType moveType = CharacterMoveType.WALK;
+ /**
+ * The character target, if any.
+ */
+ private ActorID> targetID;
/**
* The character walking mode
@@ -263,6 +274,30 @@ public class L2Character extends Player {
this.moveType = moveType;
}
+ /**
+ * @return the target ID
+ */
+ public ActorID> getTargetID() {
+ return targetID;
+ }
+
+ /**
+ * @return the target
+ */
+ public Actor getTarget() {
+ if (targetID == null)
+ return null;
+ return targetID.getObject();
+ }
+
+ /**
+ * @param target
+ * the target ID to set
+ */
+ public void setTargetID(ActorID> target) {
+ this.targetID = target;
+ }
+
/**
* @return the inventory
*/
diff --git a/src/main/java/com/l2jserver/model/world/NPC.java b/src/main/java/com/l2jserver/model/world/NPC.java
index e78a12dec..1e37e9208 100644
--- a/src/main/java/com/l2jserver/model/world/NPC.java
+++ b/src/main/java/com/l2jserver/model/world/NPC.java
@@ -16,10 +16,53 @@
*/
package com.l2jserver.model.world;
+import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
+import com.l2jserver.model.id.object.NPCID;
+import com.l2jserver.model.id.template.NPCTemplateID;
+import com.l2jserver.model.template.NPCTemplate;
+
/**
* @author Rogiel
*
*/
public class NPC extends AbstractActor {
+ /**
+ * The NPC template ID
+ */
+ private final NPCTemplateID templateID;
+ public NPC(NPCTemplateID templateID) {
+ this.templateID = templateID;
+ }
+
+ /**
+ * Executes an action on this NPC
+ *
+ * @param character
+ * the interacting character
+ * @param action
+ * the action
+ */
+ public void action(L2Character character, CharacterAction action) {
+ getTemplate().action(this, character, action);
+ }
+
+ /**
+ * @return the NPC template ID
+ */
+ public NPCTemplateID getTemplateID() {
+ return templateID;
+ }
+
+ /**
+ * @return the NPC template
+ */
+ public NPCTemplate getTemplate() {
+ return templateID.getTemplate();
+ }
+
+ @Override
+ public NPCID getID() {
+ return (NPCID) super.getID();
+ }
}
diff --git a/src/main/java/com/l2jserver/model/world/character/event/CharacterTargetDeselectedEvent.java b/src/main/java/com/l2jserver/model/world/character/event/CharacterTargetDeselectedEvent.java
new file mode 100644
index 000000000..e60bf085f
--- /dev/null
+++ b/src/main/java/com/l2jserver/model/world/character/event/CharacterTargetDeselectedEvent.java
@@ -0,0 +1,84 @@
+/*
+ * This file is part of l2jserver .
+ *
+ * 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 .
+ */
+package com.l2jserver.model.world.character.event;
+
+import com.l2jserver.model.world.L2Character;
+import com.l2jserver.model.world.Player;
+import com.l2jserver.model.world.WorldObject;
+import com.l2jserver.model.world.capability.Actor;
+import com.l2jserver.model.world.capability.Listenable;
+
+/**
+ * Event triggered once a character moves
+ *
+ * @author Rogiel
+ */
+public class CharacterTargetDeselectedEvent implements CharacterEvent {
+ /**
+ * The character that is logging in
+ */
+ private final L2Character character;
+ /**
+ * The object target
+ */
+ private final Actor oldTarget;
+
+ /**
+ * Creates a new instance
+ *
+ * @param character
+ * the character
+ * @param target
+ * the character target
+ */
+ public CharacterTargetDeselectedEvent(L2Character character, Actor oldTarget) {
+ this.character = character;
+ this.oldTarget = oldTarget;
+ }
+
+ /**
+ * @return the old target
+ */
+ public Actor getOldTarget() {
+ return oldTarget;
+ }
+
+ @Override
+ public Player getPlayer() {
+ return character;
+ }
+
+ @Override
+ public Actor getActor() {
+ return character;
+ }
+
+ @Override
+ public WorldObject getObject() {
+ return character;
+ }
+
+ @Override
+ public L2Character getCharacter() {
+ return character;
+ }
+
+ @Override
+ public Listenable, ?>[] getDispatchableObjects() {
+ return new Listenable, ?>[] { character };
+ }
+}
diff --git a/src/main/java/com/l2jserver/model/world/character/event/CharacterTargetSelectedEvent.java b/src/main/java/com/l2jserver/model/world/character/event/CharacterTargetSelectedEvent.java
new file mode 100644
index 000000000..cb7f8f813
--- /dev/null
+++ b/src/main/java/com/l2jserver/model/world/character/event/CharacterTargetSelectedEvent.java
@@ -0,0 +1,85 @@
+/*
+ * This file is part of l2jserver .
+ *
+ * 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 .
+ */
+package com.l2jserver.model.world.character.event;
+
+import com.l2jserver.model.world.L2Character;
+import com.l2jserver.model.world.Player;
+import com.l2jserver.model.world.WorldObject;
+import com.l2jserver.model.world.capability.Actor;
+import com.l2jserver.model.world.capability.Listenable;
+
+/**
+ * Event triggered once a character moves
+ *
+ * @author Rogiel
+ */
+public class CharacterTargetSelectedEvent implements CharacterEvent {
+ /**
+ * The character that is logging in
+ */
+ private final L2Character character;
+ /**
+ * The object target
+ */
+ private final Actor target;
+
+ /**
+ * Creates a new instance
+ *
+ * @param character
+ * the character
+ * @param target
+ * the character target
+ */
+ public CharacterTargetSelectedEvent(L2Character character,
+ Actor target) {
+ this.character = character;
+ this.target = target;
+ }
+
+ /**
+ * @return the target
+ */
+ public Actor getTarget() {
+ return target;
+ }
+
+ @Override
+ public Player getPlayer() {
+ return character;
+ }
+
+ @Override
+ public Actor getActor() {
+ return character;
+ }
+
+ @Override
+ public WorldObject getObject() {
+ return character;
+ }
+
+ @Override
+ public L2Character getCharacter() {
+ return character;
+ }
+
+ @Override
+ public Listenable, ?>[] getDispatchableObjects() {
+ return new Listenable, ?>[] { character };
+ }
+}
diff --git a/src/main/java/com/l2jserver/service/ServiceModule.java b/src/main/java/com/l2jserver/service/ServiceModule.java
index aba759b20..851a76417 100644
--- a/src/main/java/com/l2jserver/service/ServiceModule.java
+++ b/src/main/java/com/l2jserver/service/ServiceModule.java
@@ -39,6 +39,8 @@ import com.l2jserver.service.game.world.WorldService;
import com.l2jserver.service.game.world.WorldServiceImpl;
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
import com.l2jserver.service.game.world.event.WorldEventDispatcherImpl;
+import com.l2jserver.service.game.world.id.CachedWorldIDService;
+import com.l2jserver.service.game.world.id.WorldIDService;
import com.l2jserver.service.logging.Log4JLoggingService;
import com.l2jserver.service.logging.LoggingService;
import com.l2jserver.service.network.NettyNetworkService;
@@ -62,6 +64,8 @@ public class ServiceModule extends AbstractModule {
bind(CacheService.class).to(EhCacheService.class).in(Scopes.SINGLETON);
bind(DatabaseService.class).to(MySQLDatabaseService.class).in(
Scopes.SINGLETON);
+ bind(WorldIDService.class).to(CachedWorldIDService.class).in(
+ Scopes.SINGLETON);
bind(BlowfishKeygenService.class).to(SecureBlowfishKeygenService.class)
.in(Scopes.SINGLETON);
diff --git a/src/main/java/com/l2jserver/service/database/MySQLDatabaseService.java b/src/main/java/com/l2jserver/service/database/MySQLDatabaseService.java
index 98440f3e6..a8e244bd4 100644
--- a/src/main/java/com/l2jserver/service/database/MySQLDatabaseService.java
+++ b/src/main/java/com/l2jserver/service/database/MySQLDatabaseService.java
@@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.l2jserver.model.id.ObjectID;
+import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.AbstractService.Depends;
@@ -116,8 +117,10 @@ public class MySQLDatabaseService extends AbstractService implements
connectionFactory, connectionPool, null, null, false, true);
dataSource = new PoolingDataSource(connectionPool);
+ // cache must be large enough for all world objects, to avoid
+ // duplication... this would endanger non-persistent states
objectCache = new Cache(new CacheConfiguration("database-service",
- 10 * 1000)
+ IDAllocator.ALLOCABLE_IDS)
.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
.overflowToDisk(true).eternal(false).timeToLiveSeconds(60)
.timeToIdleSeconds(30).diskPersistent(false)
diff --git a/src/main/java/com/l2jserver/service/game/CharacterService.java b/src/main/java/com/l2jserver/service/game/CharacterService.java
index 15c150dbd..dd73b5e38 100644
--- a/src/main/java/com/l2jserver/service/game/CharacterService.java
+++ b/src/main/java/com/l2jserver/service/game/CharacterService.java
@@ -17,6 +17,7 @@
package com.l2jserver.service.game;
import com.l2jserver.model.world.L2Character;
+import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.service.Service;
import com.l2jserver.util.dimensional.Coordinate;
@@ -42,6 +43,16 @@ public interface CharacterService extends Service {
*/
void leaveWorld(L2Character character);
+ /**
+ * Set the target of this character
+ *
+ * @param character
+ * the character
+ * @param actor
+ * the targeted actor
+ */
+ void target(L2Character character, Actor actor);
+
/**
* Moves the given character to coordinate
*
diff --git a/src/main/java/com/l2jserver/service/game/CharacterServiceImpl.java b/src/main/java/com/l2jserver/service/game/CharacterServiceImpl.java
index f9922531f..e9638400f 100644
--- a/src/main/java/com/l2jserver/service/game/CharacterServiceImpl.java
+++ b/src/main/java/com/l2jserver/service/game/CharacterServiceImpl.java
@@ -21,17 +21,24 @@ import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.client.CharacterChatMessagePacket.MessageDestination;
import com.l2jserver.game.net.packet.server.ActorChatMessagePacket;
import com.l2jserver.game.net.packet.server.ActorMovementPacket;
+import com.l2jserver.game.net.packet.server.CharacterInformationPacket;
import com.l2jserver.game.net.packet.server.CharacterMovementTypePacket;
+import com.l2jserver.game.net.packet.server.CharacterTargetSelectedPacket;
import com.l2jserver.game.net.packet.server.GameGuardQueryPacket;
import com.l2jserver.game.net.packet.server.InventoryPacket;
-import com.l2jserver.game.net.packet.server.UserInformationPacket;
+import com.l2jserver.game.net.packet.server.NPCInformationPacket;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.L2Character.CharacterMoveType;
+import com.l2jserver.model.world.NPC;
+import com.l2jserver.model.world.WorldObject;
+import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.character.event.CharacterEnterWorldEvent;
import com.l2jserver.model.world.character.event.CharacterEvent;
import com.l2jserver.model.world.character.event.CharacterLeaveWorldEvent;
import com.l2jserver.model.world.character.event.CharacterListener;
+import com.l2jserver.model.world.character.event.CharacterTargetDeselectedEvent;
+import com.l2jserver.model.world.character.event.CharacterTargetSelectedEvent;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.AbstractService.Depends;
import com.l2jserver.service.game.ai.AIService;
@@ -40,6 +47,7 @@ import com.l2jserver.service.game.chat.channel.ChatChannel;
import com.l2jserver.service.game.chat.channel.ChatChannelListener;
import com.l2jserver.service.game.world.WorldService;
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
+import com.l2jserver.service.game.world.filter.impl.KnownListFilter;
import com.l2jserver.service.network.NetworkService;
import com.l2jserver.util.dimensional.Coordinate;
@@ -81,17 +89,12 @@ public class CharacterServiceImpl extends AbstractService implements
@Inject
public CharacterServiceImpl(WorldService worldService,
WorldEventDispatcher eventDispatcher, ChatService chatService,
- NetworkService networkService, SpawnService spawnService/*
- * ,
- * AIService
- * aiService
- */) {
+ NetworkService networkService, SpawnService spawnService) {
this.worldService = worldService;
this.eventDispatcher = eventDispatcher;
this.chatService = chatService;
this.networkService = networkService;
this.spawnService = spawnService;
- // this.aiService = aiService;
}
@Override
@@ -134,13 +137,24 @@ public class CharacterServiceImpl extends AbstractService implements
globalChatListener);
// send this user information
- conn.write(new UserInformationPacket(character));
+ conn.write(new CharacterInformationPacket(character));
// TODO game guard enforcing
conn.write(new GameGuardQueryPacket());
conn.write(new InventoryPacket(character.getInventory()));
+ // characters start in run mode
run(character);
+ // broadcast knownlist -- trashy implementation
+ // TODO should be moved to world service
+ for (final WorldObject o : worldService.iterable(new KnownListFilter(
+ character))) {
+ if (o instanceof NPC) {
+ conn.write(new NPCInformationPacket((NPC) o));
+ // conn.write(new ServerObjectPacket((NPC) o));
+ }
+ }
+
// dispatch enter world event
eventDispatcher.dispatch(new CharacterEnterWorldEvent(character));
@@ -169,6 +183,28 @@ public class CharacterServiceImpl extends AbstractService implements
eventDispatcher.dispatch(new CharacterLeaveWorldEvent(character));
}
+ @Override
+ public void target(L2Character character, Actor target) {
+ final CharacterID id = character.getID();
+ final Lineage2Connection conn = networkService.discover(id);
+
+ if (target == null && character.getTargetID() != null) {
+ final Actor oldTarget = character.getTarget();
+ character.setTargetID(null);
+ eventDispatcher.dispatch(new CharacterTargetDeselectedEvent(
+ character, oldTarget));
+ } else if (target != null && !target.getID().equals(character.getID())) {
+ if (character.getTargetID() != null) {
+ eventDispatcher.dispatch(new CharacterTargetDeselectedEvent(
+ character, character.getTarget()));
+ }
+ character.setTargetID(null);
+ eventDispatcher.dispatch(new CharacterTargetSelectedEvent(
+ character, target));
+ conn.write(new CharacterTargetSelectedPacket(target));
+ }
+ }
+
@Override
public void walk(L2Character character) {
final CharacterID id = character.getID();
diff --git a/src/main/java/com/l2jserver/service/game/world/id/CachedWorldIDService.java b/src/main/java/com/l2jserver/service/game/world/id/CachedWorldIDService.java
new file mode 100644
index 000000000..7aa15cce0
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/world/id/CachedWorldIDService.java
@@ -0,0 +1,128 @@
+/*
+ * This file is part of l2jserver .
+ *
+ * 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 .
+ */
+package com.l2jserver.service.game.world.id;
+
+import java.util.Collection;
+
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.Element;
+import net.sf.ehcache.config.CacheConfiguration;
+import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
+
+import com.google.inject.Inject;
+import com.l2jserver.db.dao.CharacterDAO;
+import com.l2jserver.model.id.ID;
+import com.l2jserver.model.id.ObjectID;
+import com.l2jserver.model.id.object.allocator.IDAllocator;
+import com.l2jserver.service.AbstractService;
+import com.l2jserver.service.AbstractService.Depends;
+import com.l2jserver.service.ServiceStartException;
+import com.l2jserver.service.ServiceStopException;
+import com.l2jserver.service.cache.CacheService;
+import com.l2jserver.service.database.DatabaseService;
+
+/**
+ * Implementation for {@link IDService} that caches all {@link ID} objects in
+ * memory.
+ *
+ * @author Rogiel
+ */
+@Depends({ DatabaseService.class, CacheService.class })
+public class CachedWorldIDService extends AbstractService implements
+ WorldIDService {
+ /**
+ * The cache service
+ */
+ private final CacheService cacheService;
+ /**
+ * The {@link IDAllocator}
+ */
+ private final IDAllocator allocator;
+
+ // DAOS
+ /**
+ * The {@link CharacterDAO}
+ */
+ private final CharacterDAO characterDao;
+
+ /**
+ * The ID cache
+ */
+ private Cache cache;
+
+ @Inject
+ public CachedWorldIDService(CacheService cacheService,
+ IDAllocator allocator, CharacterDAO characterDao) {
+ this.cacheService = cacheService;
+ this.allocator = allocator;
+ this.characterDao = characterDao;
+ }
+
+ @Override
+ protected void doStart() throws ServiceStartException {
+ // we allocate an cache which can fit all ids
+ cache = new Cache(new CacheConfiguration("id-cache",
+ IDAllocator.ALLOCABLE_IDS)
+ .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
+ .overflowToDisk(true).eternal(false).timeToLiveSeconds(60)
+ .timeToIdleSeconds(30).diskPersistent(false)
+ .diskExpiryThreadIntervalSeconds(0));
+ cacheService.register(cache);
+
+ // load all ids
+ load(characterDao.listIDs());
+ }
+
+ /**
+ * Load the pre-existing ids
+ *
+ * @param ids
+ * an collection of ids
+ */
+ private void load(Collection extends ObjectID>> ids) {
+ for (final ObjectID> id : ids) {
+ allocator.allocate(id.getID());
+ add(id);
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public > I resolve(int id) {
+ final Element element = cache.get(id);
+ if (element == null)
+ return null;
+ return (I) element.getObjectValue();
+ }
+
+ @Override
+ public > void add(I id) {
+ cache.put(new Element(id.getID(), id));
+ }
+
+ @Override
+ public > void remove(I id) {
+ cache.remove(id.getID());
+ }
+
+ @Override
+ protected void doStop() throws ServiceStopException {
+ cacheService.unregister(cache);
+ cache = null;
+ allocator.clear();
+ }
+}
diff --git a/src/main/java/com/l2jserver/service/game/world/id/WorldIDService.java b/src/main/java/com/l2jserver/service/game/world/id/WorldIDService.java
new file mode 100644
index 000000000..ea75116c6
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/world/id/WorldIDService.java
@@ -0,0 +1,49 @@
+/*
+ * This file is part of l2jserver .
+ *
+ * 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 .
+ */
+package com.l2jserver.service.game.world.id;
+
+import com.l2jserver.model.id.ObjectID;
+import com.l2jserver.model.id.object.allocator.IDAllocator;
+import com.l2jserver.service.Service;
+import com.l2jserver.service.database.DatabaseService;
+
+/**
+ * This service manages all {@link ObjectID} related tasks. Please note that
+ * this service must be started right after the {@link DatabaseService} has
+ * started, since the database depends on {@link ObjectID} but the
+ * {@link IDAllocator} depends on database data.
+ *
+ * @author Rogiel
+ */
+public interface WorldIDService extends Service {
+ /**
+ * Tries to resolve an ID based on its raw value
+ *
+ * @param
+ * the raw ID type
+ * @param
+ * the ID type
+ * @param id
+ * the id raw value
+ * @return the id located
+ */
+ > I resolve(int id);
+
+ > void add(I id);
+
+ > void remove(I id);
+}
diff --git a/src/main/java/com/l2jserver/util/RGBColor.java b/src/main/java/com/l2jserver/util/RGBColor.java
index 969ef255e..ecce26ae8 100644
--- a/src/main/java/com/l2jserver/util/RGBColor.java
+++ b/src/main/java/com/l2jserver/util/RGBColor.java
@@ -77,7 +77,7 @@ public class RGBColor {
* @return the color integer
*/
public int toInteger() {
- return red >> 24 + green >> 16 + blue >> 8;
+ return (red >> 24) + (green >> 16) + (blue >> 8);
}
public static RGBColor fromByteArray(byte[] rgb) {
diff --git a/src/main/java/com/l2jserver/util/calculator/Calculator.java b/src/main/java/com/l2jserver/util/calculator/Calculator.java
index c63ee3b03..900fdf92c 100644
--- a/src/main/java/com/l2jserver/util/calculator/Calculator.java
+++ b/src/main/java/com/l2jserver/util/calculator/Calculator.java
@@ -16,50 +16,166 @@
*/
package com.l2jserver.util.calculator;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import com.l2jserver.util.factory.CollectionFactory;
/**
* An calculator is used to compute data and outputs its result. Note also, that
- * an calculator is also an operation, that way you can nest calculators.
+ * an calculator is also an function, that way you can nest calculators.
*
* @author Rogiel
*/
-public class Calculator implements Operation {
+public class Calculator implements Function {
/**
* List of operations in this calculator
*/
- private final List> operations = CollectionFactory
+ private final List functions = CollectionFactory
.newList(null);
/**
- * Adds a new operation to this calculator. Operations with the same order
- * are replaced.
- *
- * @param order
- * the operation order, starting at 0.
- * @param operation
- * the operation
+ * Creates a new empty calculator. Functions can be add using
+ * {@link #add(int, Function)}.
*/
- public void add(int order, Operation operation) {
- operations.add(order, operation);
+ public Calculator() {
}
/**
- * Computes the result and output it
+ * Creates a new calculator with functions in the declaration
+ * order.
+ *
+ * @param functions
+ * the calculator functions
+ */
+ public Calculator(Function... functions) {
+ for (int i = 0; i < functions.length; i++) {
+ this.functions.add(new FunctionContainer(i, functions[i]));
+ }
+ }
+
+ /**
+ * Adds a new function to this calculator. Executing order for functions
+ * with the same order is undefined.
+ *
+ * Once a new function is added, sorting will be performed automatically.
+ *
+ * @param order
+ * the operation order, starting at 0.
+ * @param function
+ * the operation
+ */
+ public void add(int order, Function function) {
+ functions.add(new FunctionContainer(order, function));
+ Collections.sort(functions);
+ }
+
+ /**
+ * Imports all functions in the given calculator. This is useful to
+ * preserve right calculation ordering but changes to original
+ * calculator will no reflect in this one.
+ *
+ * This method will heuristically search for nested calculators.
+ *
+ * @param calculator
+ * the calculator
+ */
+ public void importFunctions(Calculator calculator) {
+ for (final FunctionContainer container : calculator.functions) {
+ if (container.function instanceof Calculator) {
+ importFunctions((Calculator) container.function);
+ } else {
+ functions.add(container);
+ }
+ }
+ }
+
+ /**
+ * Computes the result and output it. Input value is 0.
*
* @return the computed value
+ * @see #calculate(Double)
*/
- public double compute() {
- return perform(0.00);
+ public double calculate() {
+ return calculate(0.00);
}
@Override
- public Double perform(Double result) {
- for (final Operation operation : operations) {
- result = operation.perform(result);
+ public Double calculate(Double input) {
+ double result = input;
+ for (final FunctionContainer container : functions) {
+ result = container.function.calculate(result);
}
return result;
}
+
+ /**
+ * -- Internal use only --
Container used to sort calculator
+ * functions. This class implements {@link Comparable} and can be used to
+ * sort lists using {@link Collections#sort(List)} or
+ * {@link Arrays#sort(Object[])}.
+ *
+ * @author Rogiel
+ */
+ private static class FunctionContainer implements
+ Comparable {
+ /**
+ * The execution order
+ */
+ protected final int order;
+ /**
+ * The function object
+ */
+ protected final Function function;
+
+ /**
+ * Creates a new instance
+ *
+ * @param order
+ * the execution order
+ * @param function
+ * the function
+ */
+ public FunctionContainer(int order, Function function) {
+ this.order = order;
+ this.function = function;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((function == null) ? 0 : function.hashCode());
+ result = prime * result + order;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ FunctionContainer other = (FunctionContainer) obj;
+ if (function == null) {
+ if (other.function != null)
+ return false;
+ } else if (!function.equals(other.function))
+ return false;
+ if (order != other.order)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int compareTo(FunctionContainer o) {
+ if (this.equals(o))
+ return 0;
+ return this.order - o.order;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/util/calculator/DivisionOperation.java b/src/main/java/com/l2jserver/util/calculator/DivisionFunction.java
similarity index 81%
rename from src/main/java/com/l2jserver/util/calculator/DivisionOperation.java
rename to src/main/java/com/l2jserver/util/calculator/DivisionFunction.java
index 68748374e..cf0ebea85 100644
--- a/src/main/java/com/l2jserver/util/calculator/DivisionOperation.java
+++ b/src/main/java/com/l2jserver/util/calculator/DivisionFunction.java
@@ -17,23 +17,23 @@
package com.l2jserver.util.calculator;
/**
- * This operation performs a division: chain value /
+ * This function performs a division: chain value /
* value
*
* @author Rogiel
*/
-public class DivisionOperation implements Operation {
+public class DivisionFunction implements Function {
/**
* The value
*/
private final double value;
- public DivisionOperation(double value) {
+ public DivisionFunction(double value) {
this.value = value;
}
@Override
- public Double perform(Double value) {
+ public Double calculate(Double value) {
return value / this.value;
}
}
diff --git a/src/main/java/com/l2jserver/util/calculator/Operation.java b/src/main/java/com/l2jserver/util/calculator/Function.java
similarity index 68%
rename from src/main/java/com/l2jserver/util/calculator/Operation.java
rename to src/main/java/com/l2jserver/util/calculator/Function.java
index cff949b32..e0ed0fce5 100644
--- a/src/main/java/com/l2jserver/util/calculator/Operation.java
+++ b/src/main/java/com/l2jserver/util/calculator/Function.java
@@ -17,15 +17,21 @@
package com.l2jserver.util.calculator;
/**
+ * An function is nothing more than a mathematical operation.
+ *
* @author Rogiel
*/
-public interface Operation {
+public interface Function {
/**
- * Performs the operation in the calculation process
+ * Performs the operation in the calculation process.
+ *
+ * The value in the argument is normally used for calculation, but
+ * an {@link Function} can ignore the value if required to (i.e.
+ * {@link SetFunction})
*
* @param value
- * the chain input value
+ * the input value
* @return the output value
*/
- T perform(T value);
+ T calculate(T value);
}
diff --git a/src/main/java/com/l2jserver/util/calculator/ModulusOperation.java b/src/main/java/com/l2jserver/util/calculator/ModulusFunction.java
similarity index 83%
rename from src/main/java/com/l2jserver/util/calculator/ModulusOperation.java
rename to src/main/java/com/l2jserver/util/calculator/ModulusFunction.java
index 2a11fbc81..3908b0a93 100644
--- a/src/main/java/com/l2jserver/util/calculator/ModulusOperation.java
+++ b/src/main/java/com/l2jserver/util/calculator/ModulusFunction.java
@@ -17,14 +17,14 @@
package com.l2jserver.util.calculator;
/**
- * This operation performs an modulus:
|chain value|
+ * This function performs an modulus: |chain value|
*
*
* @author Rogiel
*/
-public class ModulusOperation implements Operation {
+public class ModulusFunction implements Function {
@Override
- public Double perform(Double value) {
+ public Double calculate(Double value) {
if (value < 0)
return value * -1;
return value;
diff --git a/src/main/java/com/l2jserver/util/calculator/MultiplicationOperation.java b/src/main/java/com/l2jserver/util/calculator/MultiplicationFunction.java
similarity index 80%
rename from src/main/java/com/l2jserver/util/calculator/MultiplicationOperation.java
rename to src/main/java/com/l2jserver/util/calculator/MultiplicationFunction.java
index fa747dab7..99b8a26e5 100644
--- a/src/main/java/com/l2jserver/util/calculator/MultiplicationOperation.java
+++ b/src/main/java/com/l2jserver/util/calculator/MultiplicationFunction.java
@@ -17,23 +17,23 @@
package com.l2jserver.util.calculator;
/**
- * This operation performs an multiplication: chain value *
+ * This function performs an multiplication: chain value *
* value
*
* @author Rogiel
*/
-public class MultiplicationOperation implements Operation {
+public class MultiplicationFunction implements Function {
/**
* The value
*/
private final double value;
- public MultiplicationOperation(double value) {
+ public MultiplicationFunction(double value) {
this.value = value;
}
@Override
- public Double perform(Double value) {
+ public Double calculate(Double value) {
return value * this.value;
}
}
diff --git a/src/main/java/com/l2jserver/util/calculator/NegateOperation.java b/src/main/java/com/l2jserver/util/calculator/NegateFunction.java
similarity index 82%
rename from src/main/java/com/l2jserver/util/calculator/NegateOperation.java
rename to src/main/java/com/l2jserver/util/calculator/NegateFunction.java
index bcfbec3ff..6edb4c3ff 100644
--- a/src/main/java/com/l2jserver/util/calculator/NegateOperation.java
+++ b/src/main/java/com/l2jserver/util/calculator/NegateFunction.java
@@ -17,14 +17,14 @@
package com.l2jserver.util.calculator;
/**
- * This operation performs an negate: -chain value
+ * This function performs an negate: -chain value
*
*
* @author Rogiel
*/
-public class NegateOperation implements Operation {
+public class NegateFunction implements Function {
@Override
- public Double perform(Double value) {
+ public Double calculate(Double value) {
return -value;
}
}
diff --git a/src/main/java/com/l2jserver/util/calculator/PercentOperation.java b/src/main/java/com/l2jserver/util/calculator/PercentFunction.java
similarity index 83%
rename from src/main/java/com/l2jserver/util/calculator/PercentOperation.java
rename to src/main/java/com/l2jserver/util/calculator/PercentFunction.java
index af1e434e0..8cca8aee0 100644
--- a/src/main/java/com/l2jserver/util/calculator/PercentOperation.java
+++ b/src/main/java/com/l2jserver/util/calculator/PercentFunction.java
@@ -17,16 +17,16 @@
package com.l2jserver.util.calculator;
/**
- * This operation performs a multiplication: chain value *
+ * This function performs a multiplication: chain value *
* (value / 100)
*
* @author Rogiel
*/
-public class PercentOperation extends MultiplicationOperation {
+public class PercentFunction extends MultiplicationFunction {
/**
* The value
*/
- public PercentOperation(double value) {
+ public PercentFunction(double value) {
super(value / 100);
}
}
diff --git a/src/main/java/com/l2jserver/util/calculator/RoundOperation.java b/src/main/java/com/l2jserver/util/calculator/RoundFunction.java
similarity index 84%
rename from src/main/java/com/l2jserver/util/calculator/RoundOperation.java
rename to src/main/java/com/l2jserver/util/calculator/RoundFunction.java
index bd0477dff..f3d4d48c0 100644
--- a/src/main/java/com/l2jserver/util/calculator/RoundOperation.java
+++ b/src/main/java/com/l2jserver/util/calculator/RoundFunction.java
@@ -17,13 +17,13 @@
package com.l2jserver.util.calculator;
/**
- * This operation performs an rounding in the number.
+ * This function performs an rounding in the number.
*
* @author Rogiel
*/
-public class RoundOperation implements Operation {
+public class RoundFunction implements Function {
@Override
- public Double perform(Double value) {
+ public Double calculate(Double value) {
return (double) Math.round(value);
}
}
diff --git a/src/main/java/com/l2jserver/util/calculator/SetOperation.java b/src/main/java/com/l2jserver/util/calculator/SetFunction.java
similarity index 81%
rename from src/main/java/com/l2jserver/util/calculator/SetOperation.java
rename to src/main/java/com/l2jserver/util/calculator/SetFunction.java
index 2493cd8ba..9f89e0f6c 100644
--- a/src/main/java/com/l2jserver/util/calculator/SetOperation.java
+++ b/src/main/java/com/l2jserver/util/calculator/SetFunction.java
@@ -17,23 +17,23 @@
package com.l2jserver.util.calculator;
/**
- * This operation performs an set. It ignores the input value and return its
+ * This function performs an set. It ignores the input value and return its
* own.
*
* @author Rogiel
*/
-public class SetOperation implements Operation {
+public class SetFunction implements Function {
/**
* The value
*/
private final double value;
- public SetOperation(double value) {
+ public SetFunction(double value) {
this.value = value;
}
@Override
- public Double perform(Double value) {
+ public Double calculate(Double value) {
return this.value;
}
}
diff --git a/src/main/java/com/l2jserver/util/calculator/SubtractOperation.java b/src/main/java/com/l2jserver/util/calculator/SubtractFunction.java
similarity index 81%
rename from src/main/java/com/l2jserver/util/calculator/SubtractOperation.java
rename to src/main/java/com/l2jserver/util/calculator/SubtractFunction.java
index d3aa9010b..929601365 100644
--- a/src/main/java/com/l2jserver/util/calculator/SubtractOperation.java
+++ b/src/main/java/com/l2jserver/util/calculator/SubtractFunction.java
@@ -17,23 +17,23 @@
package com.l2jserver.util.calculator;
/**
- * This operation performs an subtraction: chain value -
+ * This function performs an subtraction: chain value -
* value
*
* @author Rogiel
*/
-public class SubtractOperation implements Operation {
+public class SubtractFunction implements Function {
/**
* The value
*/
private final double value;
- public SubtractOperation(double value) {
+ public SubtractFunction(double value) {
this.value = value;
}
@Override
- public Double perform(Double value) {
+ public Double calculate(Double value) {
return value - this.value;
}
}
diff --git a/src/main/java/com/l2jserver/util/calculator/SumOperation.java b/src/main/java/com/l2jserver/util/calculator/SumFunction.java
similarity index 82%
rename from src/main/java/com/l2jserver/util/calculator/SumOperation.java
rename to src/main/java/com/l2jserver/util/calculator/SumFunction.java
index 768e6b1b8..7b5c2166d 100644
--- a/src/main/java/com/l2jserver/util/calculator/SumOperation.java
+++ b/src/main/java/com/l2jserver/util/calculator/SumFunction.java
@@ -17,23 +17,23 @@
package com.l2jserver.util.calculator;
/**
- * This operation performs a sum: chain value +
+ * This function performs a sum: chain value +
* value
*
* @author Rogiel
*/
-public class SumOperation implements Operation {
+public class SumFunction implements Function {
/**
* The value
*/
private final double value;
- public SumOperation(double value) {
+ public SumFunction(double value) {
this.value = value;
}
@Override
- public Double perform(Double value) {
+ public Double calculate(Double value) {
return value + this.value;
}
}
diff --git a/src/test/java/com/l2jserver/db/dao/mysql5/MySQL5CharacterDAOTest.java b/src/test/java/com/l2jserver/db/dao/mysql5/MySQL5CharacterDAOTest.java
index c050e4964..aa06c6881 100644
--- a/src/test/java/com/l2jserver/db/dao/mysql5/MySQL5CharacterDAOTest.java
+++ b/src/test/java/com/l2jserver/db/dao/mysql5/MySQL5CharacterDAOTest.java
@@ -24,7 +24,7 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import com.l2jserver.GameServerModule;
import com.l2jserver.db.dao.CharacterDAO;
-import com.l2jserver.model.id.object.factory.CharacterIDFactory;
+import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.ServiceManager;
import com.l2jserver.service.ServiceStartException;
@@ -42,9 +42,9 @@ public class MySQL5CharacterDAOTest {
final CharacterDAO dao = injector.getInstance(CharacterDAO.class);
final L2Character char1 = dao.load(injector.getInstance(
- CharacterIDFactory.class).createID(268437456));
+ CharacterIDProvider.class).createID(268437456));
final L2Character char2 = dao.load(injector.getInstance(
- CharacterIDFactory.class).createID(268437456));
+ CharacterIDProvider.class).createID(268437456));
Assert.assertSame(char1, char2);
}
diff --git a/src/test/java/com/l2jserver/model/id/factory/IDFactoryTest.java b/src/test/java/com/l2jserver/model/id/factory/IDFactoryTest.java
index 8e69aaad6..4c29aaa16 100644
--- a/src/test/java/com/l2jserver/model/id/factory/IDFactoryTest.java
+++ b/src/test/java/com/l2jserver/model/id/factory/IDFactoryTest.java
@@ -26,7 +26,8 @@ import com.google.inject.Injector;
import com.l2jserver.db.dao.MySQL5DAOModule;
import com.l2jserver.model.id.ID;
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.provider.IDProviderModule;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.ServiceModule;
import com.l2jserver.service.ServiceStartException;
@@ -36,9 +37,9 @@ import com.l2jserver.service.game.template.TemplateService;
public class IDFactoryTest {
private final Injector injector = Guice.createInjector(new ServiceModule(),
- new MySQL5DAOModule(), new IDFactoryModule());
- private final CharacterIDFactory charIdFactory = injector
- .getInstance(CharacterIDFactory.class);
+ new MySQL5DAOModule(), new IDProviderModule());
+ private final CharacterIDProvider charIdFactory = injector
+ .getInstance(CharacterIDProvider.class);
@Test
public void testCreateID() {
diff --git a/src/test/java/com/l2jserver/model/world/character/CharacterFriendListTest.java b/src/test/java/com/l2jserver/model/world/character/CharacterFriendListTest.java
index 67ade3c59..4c98f02b8 100644
--- a/src/test/java/com/l2jserver/model/world/character/CharacterFriendListTest.java
+++ b/src/test/java/com/l2jserver/model/world/character/CharacterFriendListTest.java
@@ -25,9 +25,9 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import com.l2jserver.db.dao.CharacterFriendDAO;
import com.l2jserver.db.dao.MySQL5DAOModule;
-import com.l2jserver.model.id.factory.IDFactoryModule;
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.provider.IDProviderModule;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.ServiceModule;
import com.l2jserver.service.ServiceStartException;
@@ -37,9 +37,9 @@ import com.l2jserver.service.game.template.TemplateService;
public class CharacterFriendListTest {
private final Injector injector = Guice.createInjector(new ServiceModule(),
- new MySQL5DAOModule(), new IDFactoryModule());
- private final CharacterIDFactory charIdFactory = injector
- .getInstance(CharacterIDFactory.class);
+ new MySQL5DAOModule(), new IDProviderModule());
+ private final CharacterIDProvider charIdFactory = injector
+ .getInstance(CharacterIDProvider.class);
@Test
public void testIterator() throws ServiceStartException {
diff --git a/src/test/java/com/l2jserver/service/game/template/StaticTemplateServiceTest.java b/src/test/java/com/l2jserver/service/game/template/StaticTemplateServiceTest.java
index 27d92d419..3b2ffa831 100644
--- a/src/test/java/com/l2jserver/service/game/template/StaticTemplateServiceTest.java
+++ b/src/test/java/com/l2jserver/service/game/template/StaticTemplateServiceTest.java
@@ -23,18 +23,18 @@ import script.template.item.AdenaItemTemplate;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.l2jserver.db.dao.MySQL5DAOModule;
-import com.l2jserver.model.id.factory.IDFactoryModule;
-import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;
+import com.l2jserver.model.id.provider.IDProviderModule;
+import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.service.ServiceModule;
import com.l2jserver.service.ServiceStartException;
public class StaticTemplateServiceTest {
private final Injector injector = Guice.createInjector(new ServiceModule(),
- new IDFactoryModule(), new MySQL5DAOModule());
+ new IDProviderModule(), new MySQL5DAOModule());
private final TemplateService service = injector
.getInstance(TemplateService.class);
- private final ItemTemplateIDFactory factory = injector
- .getInstance(ItemTemplateIDFactory.class);
+ private final ItemTemplateIDProvider factory = injector
+ .getInstance(ItemTemplateIDProvider.class);
@Test
public void testAdena() throws ServiceStartException {
diff --git a/src/test/java/com/l2jserver/service/world/WorldEventDispatcherImplTest.java b/src/test/java/com/l2jserver/service/world/WorldEventDispatcherImplTest.java
index cd99e52b3..b62c13a93 100644
--- a/src/test/java/com/l2jserver/service/world/WorldEventDispatcherImplTest.java
+++ b/src/test/java/com/l2jserver/service/world/WorldEventDispatcherImplTest.java
@@ -23,14 +23,11 @@ import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
-import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
-import com.google.inject.Scopes;
-import com.l2jserver.db.dao.MySQL5DAOModule;
-import com.l2jserver.model.id.factory.IDFactoryModule;
-import com.l2jserver.model.id.object.factory.CharacterIDFactory;
-import com.l2jserver.model.id.object.factory.ItemIDFactory;
+import com.l2jserver.GameServerModule;
+import com.l2jserver.model.id.object.provider.CharacterIDProvider;
+import com.l2jserver.model.id.object.provider.ItemIDProvider;
import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.item.ItemDropEvent;
@@ -39,37 +36,23 @@ import com.l2jserver.model.world.item.ItemListener;
import com.l2jserver.model.world.player.event.PlayerEvent;
import com.l2jserver.model.world.player.event.PlayerListener;
import com.l2jserver.model.world.player.event.PlayerSpawnEvent;
-import com.l2jserver.service.ServiceModule;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.game.world.WorldService;
-import com.l2jserver.service.game.world.WorldServiceImpl;
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
-import com.l2jserver.service.game.world.event.WorldEventDispatcherImpl;
public class WorldEventDispatcherImplTest {
private WorldService world;
private WorldEventDispatcher dispatcher;
- private CharacterIDFactory cidFactory;
- private ItemIDFactory iidFactory;
+ private CharacterIDProvider cidFactory;
+ private ItemIDProvider iidFactory;
@Before
public void tearUp() throws ServiceStartException {
- Injector injector = Guice.createInjector(new ServiceModule(),
- new MySQL5DAOModule(), new IDFactoryModule(),
- new AbstractModule() {
- @Override
- protected void configure() {
- bind(WorldService.class).to(WorldServiceImpl.class).in(
- Scopes.SINGLETON);
- bind(WorldEventDispatcher.class).to(
- WorldEventDispatcherImpl.class).in(
- Scopes.SINGLETON);
- }
- });
+ Injector injector = Guice.createInjector(new GameServerModule());
- cidFactory = injector.getInstance(CharacterIDFactory.class);
- iidFactory = injector.getInstance(ItemIDFactory.class);
+ cidFactory = injector.getInstance(CharacterIDProvider.class);
+ iidFactory = injector.getInstance(ItemIDProvider.class);
world = injector.getInstance(WorldService.class);
dispatcher = injector.getInstance(WorldEventDispatcher.class);
diff --git a/src/test/java/com/l2jserver/util/calculator/CalculatorTest.java b/src/test/java/com/l2jserver/util/calculator/CalculatorTest.java
index c13ddfb5c..10f53477c 100644
--- a/src/test/java/com/l2jserver/util/calculator/CalculatorTest.java
+++ b/src/test/java/com/l2jserver/util/calculator/CalculatorTest.java
@@ -29,76 +29,110 @@ public class CalculatorTest {
public void testSimple() {
final Calculator calc = new Calculator();
- calc.add(0, new SetOperation(10));
- calc.add(1, new MultiplicationOperation(2));
- calc.add(2, new SetOperation(30));
+ calc.add(0, new SetFunction(10));
+ calc.add(1, new MultiplicationFunction(2));
+ calc.add(2, new SetFunction(30));
- Assert.assertEquals(30.0, calc.compute());
+ Assert.assertEquals(30.0, calc.calculate());
}
@Test
public void testPercent() {
final Calculator calc = new Calculator();
- calc.add(0, new SetOperation(10));
- calc.add(1, new MultiplicationOperation(2));
- calc.add(2, new PercentOperation(75));
+ calc.add(0, new SetFunction(10));
+ calc.add(1, new MultiplicationFunction(2));
+ calc.add(2, new PercentFunction(75));
- Assert.assertEquals(15.0, calc.compute());
+ Assert.assertEquals(15.0, calc.calculate());
}
@Test
public void testComplex() {
final Calculator calc = new Calculator();
- calc.add(0, new SetOperation(10));
- calc.add(1, new MultiplicationOperation(2));
- calc.add(2, new PercentOperation(75));
- calc.add(3, new SumOperation(3));
- calc.add(4, new SubtractOperation(8));
- calc.add(5, new DivisionOperation(2));
+ calc.add(0, new SetFunction(10));
+ calc.add(1, new MultiplicationFunction(2));
+ calc.add(2, new PercentFunction(75));
+ calc.add(3, new SumFunction(3));
+ calc.add(4, new SubtractFunction(8));
+ calc.add(5, new DivisionFunction(2));
- Assert.assertEquals(5.0, calc.compute());
+ Assert.assertEquals(5.0, calc.calculate());
}
@Test
public void testNesting() {
final Calculator calc1 = new Calculator();
- calc1.add(0, new SetOperation(10));
- calc1.add(1, new MultiplicationOperation(2));
- calc1.add(2, new PercentOperation(75));
- calc1.add(3, new SumOperation(3));
- calc1.add(4, new SubtractOperation(8));
- calc1.add(5, new DivisionOperation(2));
- Assert.assertEquals(5.0, calc1.compute());
+ calc1.add(0, new SetFunction(10));
+ calc1.add(1, new MultiplicationFunction(2));
+ calc1.add(2, new PercentFunction(75));
+ calc1.add(3, new SumFunction(3));
+ calc1.add(4, new SubtractFunction(8));
+ calc1.add(5, new DivisionFunction(2));
+ Assert.assertEquals(5.0, calc1.calculate());
final Calculator calc2 = new Calculator();
- calc2.add(0, new MultiplicationOperation(2));
- calc2.add(1, new PercentOperation(75));
- calc2.add(2, new SumOperation(3));
- calc2.add(3, new SubtractOperation(8));
- calc2.add(4, new DivisionOperation(2));
- Assert.assertEquals(-2.5, calc2.compute());
+ calc2.add(0, new MultiplicationFunction(2));
+ calc2.add(1, new PercentFunction(75));
+ calc2.add(2, new SumFunction(3));
+ calc2.add(3, new SubtractFunction(8));
+ calc2.add(4, new DivisionFunction(2));
+ Assert.assertEquals(-2.5, calc2.calculate());
final Calculator calc3 = new Calculator();
calc3.add(0, calc1);
calc3.add(1, calc2);
- Assert.assertEquals(1.25, calc3.compute());
+ // this should be executed
+ calc2.add(5, new SumFunction(1));
+
+ Assert.assertEquals(2.25, calc3.calculate());
+ }
+
+ @Test
+ public void testImporting() {
+ final Calculator calc1 = new Calculator();
+
+ calc1.add(0, new SetFunction(10));
+ calc1.add(2, new MultiplicationFunction(2));
+ calc1.add(4, new PercentFunction(75));
+ calc1.add(6, new SumFunction(3));
+ calc1.add(8, new SubtractFunction(8));
+ calc1.add(10, new DivisionFunction(2));
+ Assert.assertEquals(5.0, calc1.calculate());
+
+ final Calculator calc2 = new Calculator();
+
+ calc2.add(1, new MultiplicationFunction(2));
+ calc2.add(3, new PercentFunction(75));
+ calc2.add(5, new SumFunction(3));
+ calc2.add(7, new SubtractFunction(8));
+ calc2.add(9, new DivisionFunction(2));
+ Assert.assertEquals(-2.5, calc2.calculate());
+
+ final Calculator calc3 = new Calculator();
+ calc3.importFunctions(calc1);
+ calc3.importFunctions(calc2);
+
+ // this should not be executed
+ calc2.add(5, new SumFunction(50));
+
+ Assert.assertEquals(1.25, calc3.calculate());
}
@Test
public void testRounding() {
final Calculator calc1 = new Calculator();
- calc1.add(0, new MultiplicationOperation(2));
- calc1.add(1, new PercentOperation(75));
- calc1.add(2, new SumOperation(3));
- calc1.add(3, new SubtractOperation(8.1));
- calc1.add(4, new DivisionOperation(2));
- calc1.add(5, new RoundOperation());
- Assert.assertEquals(-3.0, calc1.compute());
+ calc1.add(0, new MultiplicationFunction(2));
+ calc1.add(1, new PercentFunction(75));
+ calc1.add(2, new SumFunction(3));
+ calc1.add(3, new SubtractFunction(8.1));
+ calc1.add(4, new DivisionFunction(2));
+ calc1.add(5, new RoundFunction());
+ Assert.assertEquals(-3.0, calc1.calculate());
}
}