1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-10 09:22:49 +00:00

Java side template changes

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-06-03 15:57:08 -03:00
parent 4d6289b12c
commit 5990a97dfd
27 changed files with 500 additions and 484 deletions

View File

@@ -16,8 +16,6 @@
*/
package com.l2jserver.service.game.npc;
import java.util.Collection;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.client.CM_CHAR_ACTION.CharacterAction;
import com.l2jserver.model.template.NPCTemplate;
@@ -27,8 +25,6 @@ import com.l2jserver.model.world.NPC;
import com.l2jserver.service.Service;
import com.l2jserver.service.core.threading.AsyncFuture;
import com.l2jserver.service.game.character.CannotSetTargetServiceException;
import com.l2jserver.service.game.spawn.AlreadySpawnedServiceException;
import com.l2jserver.service.game.spawn.SpawnPointNotFoundServiceException;
import com.l2jserver.util.geometry.Point3D;
/**
@@ -91,17 +87,6 @@ public interface NPCService extends Service {
*/
AsyncFuture<Boolean> move(NPC npc, Point3D point);
/**
* Load from database and spawn all {@link NPC NPCs} instances
*
* @throws AlreadySpawnedServiceException
* if one of the NPCs is already spawned
* @throws SpawnPointNotFoundServiceException
* if one of the NPCs does not have an spawn point defined
*/
Collection<NPC> spawnAll() throws SpawnPointNotFoundServiceException,
AlreadySpawnedServiceException;
/**
* Attacks an given NPC, if possible.
*

View File

@@ -36,6 +36,7 @@ import com.l2jserver.model.world.npc.controller.NPCController;
import com.l2jserver.model.world.npc.event.NPCDieEvent;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.AbstractService.Depends;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.core.threading.AsyncFuture;
import com.l2jserver.service.core.threading.ThreadService;
import com.l2jserver.service.database.DatabaseService;
@@ -101,6 +102,7 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
*/
private Map<Class<? extends NPCController>, NPCController> controllers = CollectionFactory
.newMap();
private Collection<NPC> npcs;
@Inject
public NPCServiceImpl(SpawnService spawnService,
@@ -118,6 +120,20 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
this.injector = injector;
}
@Override
protected void doStart() throws ServiceStartException {
npcs = npcDao.loadAll();
try {
for (final NPC npc : npcs) {
spawnService.spawn(npc, null);
}
} catch (SpawnPointNotFoundServiceException e) {
throw new ServiceStartException(e);
} catch (AlreadySpawnedServiceException e) {
throw new ServiceStartException(e);
}
}
@Override
public void action(NPC npc, L2Character character, CharacterAction action)
throws ActionServiceException, CannotSetTargetServiceException {
@@ -197,17 +213,6 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
});
}
@Override
public Collection<NPC> spawnAll()
throws SpawnPointNotFoundServiceException,
AlreadySpawnedServiceException {
final Collection<NPC> npcs = npcDao.loadAll();
for (final NPC npc : npcs) {
spawnService.spawn(npc, null);
}
return npcs;
}
@Override
public void attack(NPC npc, Lineage2Connection conn, L2Character attacker)
throws NotAttackableNPCServiceException {