mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-05 23:22:47 +00:00
Fixes network services start order
This commit is contained in:
@@ -32,6 +32,7 @@ import com.l2jserver.service.game.scripting.ScriptingService;
|
||||
import com.l2jserver.service.game.template.TemplateService;
|
||||
import com.l2jserver.service.game.world.WorldIDService;
|
||||
import com.l2jserver.service.network.NetworkService;
|
||||
import com.l2jserver.service.network.gameguard.GameGuardService;
|
||||
import com.l2jserver.service.network.keygen.BlowfishKeygenService;
|
||||
|
||||
/**
|
||||
@@ -40,13 +41,18 @@ import com.l2jserver.service.network.keygen.BlowfishKeygenService;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class L2JGameServerMain {
|
||||
public static final Class<?>[] SERVICES = { CacheService.class,
|
||||
ConfigurationService.class, DatabaseService.class,
|
||||
WorldIDService.class, ScriptingService.class,
|
||||
TemplateService.class, ChatService.class, NPCService.class,
|
||||
ItemService.class, CharacterService.class, ShortcutService.class,
|
||||
PathingService.class, BlowfishKeygenService.class,
|
||||
NetworkService.class };
|
||||
public static final Class<?>[][] SERVICES = {
|
||||
// core services
|
||||
{ CacheService.class, ConfigurationService.class,
|
||||
DatabaseService.class, WorldIDService.class,
|
||||
ScriptingService.class, TemplateService.class },
|
||||
// game services
|
||||
{ ChatService.class, NPCService.class, ItemService.class,
|
||||
CharacterService.class, ShortcutService.class,
|
||||
PathingService.class },
|
||||
// network services - should be started at last!
|
||||
{ BlowfishKeygenService.class, GameGuardService.class,
|
||||
NetworkService.class } };
|
||||
|
||||
/**
|
||||
* Main method
|
||||
@@ -61,18 +67,22 @@ public class L2JGameServerMain {
|
||||
final ServiceManager serviceManager = server.getInjector()
|
||||
.getInstance(ServiceManager.class);
|
||||
|
||||
for (final Class<?> service : SERVICES) {
|
||||
serviceManager.start((Class<? extends Service>) service);
|
||||
for (final Class<?>[] category : SERVICES) {
|
||||
for (final Class<?> service : category) {
|
||||
serviceManager.start((Class<? extends Service>) service);
|
||||
}
|
||||
}
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (final Class<?> service : SERVICES) {
|
||||
try {
|
||||
serviceManager
|
||||
.stop((Class<? extends Service>) service);
|
||||
} catch (ServiceStopException e) {
|
||||
for (final Class<?>[] category : SERVICES) {
|
||||
for (final Class<?> service : category) {
|
||||
try {
|
||||
serviceManager
|
||||
.stop((Class<? extends Service>) service);
|
||||
} catch (ServiceStopException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,44 +94,4 @@ public class L2JGameServerMain {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * This method does an static spawn for an object
|
||||
// *
|
||||
// * @throws AlreadySpawnedServiceException
|
||||
// * @throws SpawnPointNotFoundServiceException
|
||||
// */
|
||||
// private static void staticSpawn(Injector injector)
|
||||
// throws SpawnPointNotFoundServiceException,
|
||||
// AlreadySpawnedServiceException {
|
||||
// final NPCTemplateIDProvider templateProvider = injector
|
||||
// .getInstance(NPCTemplateIDProvider.class);
|
||||
// final NPCIDProvider provider = injector
|
||||
// .getInstance(NPCIDProvider.class);
|
||||
// final SpawnService spawnService = injector
|
||||
// .getInstance(SpawnService.class);
|
||||
//
|
||||
// final NPCTemplateID id = templateProvider.createID(12077);
|
||||
// final NPC npc = id.getTemplate().create();
|
||||
//
|
||||
// npc.setID(provider.createID());
|
||||
// // close to char spawn
|
||||
// npc.setPoint(Point.fromXYZ(-71301, 258259, -3134));
|
||||
//
|
||||
// spawnService.spawn(npc, null);
|
||||
//
|
||||
// // close spawn gatekepper
|
||||
// final NPCTemplateID gid = templateProvider.createID(30006);
|
||||
// final NPC gatekeeper = gid.getTemplate().create();
|
||||
// gatekeeper.setID(provider.createID());
|
||||
// gatekeeper.setPoint(Point.fromXYZ(-71301, 258559, -3134));
|
||||
// spawnService.spawn(gatekeeper, null);
|
||||
//
|
||||
// // spawn tamil - orc village
|
||||
// final NPCTemplateID tamilId = templateProvider.createID(30576);
|
||||
// final NPC tamil = tamilId.getTemplate().create();
|
||||
// tamil.setID(provider.createID());
|
||||
// tamil.setPoint(Point.fromXYZ(-45264, -112512, -240));
|
||||
// spawnService.spawn(tamil, null);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -94,10 +94,6 @@ public class L2Character extends Player {
|
||||
*/
|
||||
private double CP;
|
||||
|
||||
/**
|
||||
* The character's status
|
||||
*/
|
||||
private boolean online;
|
||||
/**
|
||||
* Date of character's last access
|
||||
*/
|
||||
@@ -326,22 +322,6 @@ public class L2Character extends Player {
|
||||
this.CP = CP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the online
|
||||
*/
|
||||
public boolean isOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param online
|
||||
* the online to set
|
||||
*/
|
||||
public void setOnline(boolean online) {
|
||||
desireUpdate();
|
||||
this.online = online;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lastAccess
|
||||
*/
|
||||
|
||||
@@ -102,6 +102,24 @@ public interface CharacterService extends Service {
|
||||
*/
|
||||
void leaveWorld(L2Character character) throws NotSpawnedServiceException;
|
||||
|
||||
/**
|
||||
* Checks whether the character is currently online or not
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @return <code>true</code> if the character is online right now
|
||||
*/
|
||||
boolean isOnline(L2Character character);
|
||||
|
||||
/**
|
||||
* Checks if this account has an character that is currently online
|
||||
*
|
||||
* @param accountID
|
||||
* the account id
|
||||
* @return <code>true</code> if the account is online right now
|
||||
*/
|
||||
boolean isOnline(AccountID accountID);
|
||||
|
||||
/**
|
||||
* Set the target of this <tt>character</tt>
|
||||
*
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package com.l2jserver.service.game.character;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -61,6 +63,7 @@ import com.l2jserver.service.game.world.WorldService;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
import com.l2jserver.service.network.broadcast.BroadcastService;
|
||||
import com.l2jserver.service.network.gameguard.GameGuardService;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
import com.l2jserver.util.geometry.Coordinate;
|
||||
import com.l2jserver.util.geometry.Point3D;
|
||||
|
||||
@@ -69,8 +72,7 @@ import com.l2jserver.util.geometry.Point3D;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@Depends({ WorldService.class, SpawnService.class, AttackService.class,
|
||||
GameGuardService.class, BroadcastService.class })
|
||||
@Depends({ WorldService.class, SpawnService.class, AttackService.class })
|
||||
public class CharacterServiceImpl extends AbstractService implements
|
||||
CharacterService {
|
||||
/**
|
||||
@@ -122,6 +124,12 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
*/
|
||||
private final CharacterTemplateIDProvider charTemplateIdProvider;
|
||||
|
||||
/**
|
||||
* An map containing all currently online characters
|
||||
*/
|
||||
private final Map<CharacterID, L2Character> onlineCharacters = CollectionFactory
|
||||
.newMap();
|
||||
|
||||
// /**
|
||||
// * The {@link AIService}
|
||||
// */
|
||||
@@ -239,7 +247,7 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
character.getInventory().load(itemDao.selectByCharacter(character));
|
||||
character.getShortcuts().load(shortcutDao.selectByCharacter(character));
|
||||
|
||||
character.setOnline(true);
|
||||
onlineCharacters.put(character.getID(), character);
|
||||
// inventory interfere on calculators
|
||||
character.getStats().updateCalculator();
|
||||
|
||||
@@ -276,11 +284,25 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
|
||||
spawnService.unspawn(character);
|
||||
eventDispatcher.dispatch(new CharacterLeaveWorldEvent(character));
|
||||
character.setOnline(false);
|
||||
onlineCharacters.remove(character.getID());
|
||||
|
||||
characterDao.saveObjectsAsync(character);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline(L2Character character) {
|
||||
return onlineCharacters.containsKey(character.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline(AccountID accountID) {
|
||||
for (final L2Character character : onlineCharacters.values()) {
|
||||
if (character.getAccountID().equals(accountID))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void target(L2Character character, Actor target)
|
||||
throws CannotSetTargetServiceException {
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.l2jserver.service.core.threading.AsyncFuture;
|
||||
import com.l2jserver.service.core.threading.ThreadService;
|
||||
import com.l2jserver.service.game.world.WorldService;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
import com.l2jserver.service.network.NetworkService;
|
||||
import com.l2jserver.util.geometry.Coordinate;
|
||||
import com.l2jserver.util.geometry.Point3D;
|
||||
|
||||
@@ -50,7 +49,7 @@ import com.l2jserver.util.geometry.Point3D;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@Depends({ WorldService.class, NetworkService.class, ThreadService.class })
|
||||
@Depends({ WorldService.class, ThreadService.class })
|
||||
public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
/**
|
||||
* The logger
|
||||
|
||||
Reference in New Issue
Block a user