mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-09 08:52:51 +00:00
Implemented service dependencies
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -19,10 +19,10 @@ package com.l2jserver.service.game;
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service handles PVP battles.
|
||||
* This service handles PvP battles.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface PVPService extends Service {
|
||||
public interface PvPService extends Service {
|
||||
|
||||
}
|
||||
@@ -31,11 +31,17 @@ import com.l2jserver.service.game.chat.channel.PublicChatChannel;
|
||||
*/
|
||||
public interface ChatService extends Service {
|
||||
/**
|
||||
* Get the Global {@link ChatChannel}. Messages sent in this chat are
|
||||
* broadcasted to everyone online.
|
||||
*
|
||||
* @return the global {@link ChatChannel}
|
||||
*/
|
||||
PublicChatChannel getGlobalChannel();
|
||||
|
||||
/**
|
||||
* Get the Region {@link ChatChannel}. Messages sent in this chat are
|
||||
* broadcasted to everyone nearby.
|
||||
*
|
||||
* @param character
|
||||
* the character in the region
|
||||
* @return the global {@link ChatChannel}
|
||||
@@ -43,7 +49,8 @@ public interface ChatService extends Service {
|
||||
PublicChatChannel getRegionChannel(L2Character character);
|
||||
|
||||
/**
|
||||
* Get an private {@link ChatChannel} to {@link CharacterID}
|
||||
* Get an private {@link ChatChannel} to {@link CharacterID}. Messages sent
|
||||
* in this channel are sent only to <tt>character</tt>.
|
||||
*
|
||||
* @param character
|
||||
* the target character
|
||||
@@ -52,6 +59,9 @@ public interface ChatService extends Service {
|
||||
PrivateChatChannel getChannel(CharacterID character);
|
||||
|
||||
/**
|
||||
* Get the Clan {@link ChatChannel}. Messages sent in this channel are
|
||||
* broadcast to all clan members online.
|
||||
*
|
||||
* @param clan
|
||||
* the clan
|
||||
* @return the public clan {@link ChatChannel}
|
||||
|
||||
@@ -24,11 +24,15 @@ import com.l2jserver.model.id.object.ClanID;
|
||||
import com.l2jserver.model.world.Clan;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
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.game.chat.channel.ChatChannel;
|
||||
import com.l2jserver.service.game.chat.channel.ChatChannelListener;
|
||||
import com.l2jserver.service.game.chat.channel.PrivateChatChannel;
|
||||
import com.l2jserver.service.game.chat.channel.PublicChatChannel;
|
||||
import com.l2jserver.service.game.region.Region;
|
||||
import com.l2jserver.service.game.region.RegionService;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
@@ -36,7 +40,10 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@Depends(RegionService.class)
|
||||
public class SimpleChatService extends AbstractService implements ChatService {
|
||||
private final RegionService regionService;
|
||||
|
||||
/**
|
||||
* The global chat channel
|
||||
*/
|
||||
@@ -51,12 +58,27 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
* The list of clan chat channels
|
||||
*/
|
||||
private Map<ClanID, ClanChatChannelImpl> clanChannels;
|
||||
/**
|
||||
* The list of regional chat channels
|
||||
*/
|
||||
private Map<Region, RegionChatChannelImpl> regionChannels;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param regionService
|
||||
* the region service
|
||||
*/
|
||||
public SimpleChatService(RegionService regionService) {
|
||||
this.regionService = regionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws ServiceStartException {
|
||||
protected void doStart() throws ServiceStartException {
|
||||
this.global = new GlobalChatChannelImpl();
|
||||
this.privateChannels = CollectionFactory.newMap(null, null);
|
||||
this.clanChannels = CollectionFactory.newMap(null, null);
|
||||
this.regionChannels = CollectionFactory.newMap(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,8 +88,13 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
|
||||
@Override
|
||||
public PublicChatChannel getRegionChannel(L2Character character) {
|
||||
// TODO Region chat channels
|
||||
return null;
|
||||
final Region region = regionService.getRegion(character);
|
||||
RegionChatChannelImpl channel = regionChannels.get(region);
|
||||
if (channel == null) {
|
||||
channel = new RegionChatChannelImpl(region);
|
||||
regionChannels.put(region, channel);
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,6 +117,14 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws ServiceStopException {
|
||||
this.global = null;
|
||||
this.privateChannels = null;
|
||||
this.clanChannels = null;
|
||||
this.regionChannels = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ChatChannel} abstract implementation
|
||||
*
|
||||
@@ -170,4 +205,27 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
this.clanID = clanID;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link PublicChatChannel} implemenetation for {@link Region regions}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
private class RegionChatChannelImpl extends ChatChannelImpl implements
|
||||
PublicChatChannel {
|
||||
/**
|
||||
* The clan ID
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private final Region region;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param clanID
|
||||
*/
|
||||
public RegionChatChannelImpl(Region region) {
|
||||
this.region = region;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.l2jserver.service.game.region;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.capability.Actor;
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
@@ -25,5 +25,12 @@ import com.l2jserver.service.Service;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface RegionService extends Service {
|
||||
Region getRegion(L2Character character);
|
||||
/**
|
||||
* Get the region in which this actor is.
|
||||
*
|
||||
* @param actor
|
||||
* the actor
|
||||
* @return the current region
|
||||
*/
|
||||
Region getRegion(Actor actor);
|
||||
}
|
||||
|
||||
@@ -32,13 +32,21 @@ import org.slf4j.LoggerFactory;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
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.game.scripting.impl.ScriptContextImpl;
|
||||
import com.l2jserver.service.game.scripting.scriptmanager.ScriptInfo;
|
||||
import com.l2jserver.service.game.scripting.scriptmanager.ScriptList;
|
||||
import com.l2jserver.service.logging.LoggingService;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
* Default {@link ScriptingService} implementation
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@Depends(LoggingService.class)
|
||||
public class ScriptingServiceImpl extends AbstractService implements
|
||||
ScriptingService {
|
||||
/**
|
||||
@@ -60,7 +68,7 @@ public class ScriptingServiceImpl extends AbstractService implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws ServiceStartException {
|
||||
protected void doStart() throws ServiceStartException {
|
||||
for (ScriptContext context : contexts) {
|
||||
context.shutdown();
|
||||
}
|
||||
@@ -165,7 +173,7 @@ public class ScriptingServiceImpl extends AbstractService implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws ServiceStopException {
|
||||
protected void doStop() throws ServiceStopException {
|
||||
for (ScriptContext context : contexts) {
|
||||
context.shutdown();
|
||||
}
|
||||
|
||||
@@ -23,13 +23,17 @@ import com.google.inject.Injector;
|
||||
import com.l2jserver.model.id.TemplateID;
|
||||
import com.l2jserver.model.template.Template;
|
||||
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.configuration.ConfigurationService;
|
||||
import com.l2jserver.service.game.scripting.ScriptContext;
|
||||
import com.l2jserver.service.game.scripting.ScriptingService;
|
||||
import com.l2jserver.service.logging.LoggingService;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
@Depends({ LoggingService.class, ConfigurationService.class,
|
||||
ScriptingService.class })
|
||||
public class ScriptTemplateService extends AbstractService implements
|
||||
TemplateService {
|
||||
private final ScriptingService scriptingService;
|
||||
@@ -52,7 +56,7 @@ public class ScriptTemplateService extends AbstractService implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws ServiceStartException {
|
||||
protected void doStart() throws ServiceStartException {
|
||||
if (context == null) {
|
||||
try {
|
||||
context = scriptingService.load(config.getTemplateDescriptor())
|
||||
@@ -94,7 +98,7 @@ public class ScriptTemplateService extends AbstractService implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws ServiceStopException {
|
||||
protected void doStop() throws ServiceStopException {
|
||||
if (context.isInitialized())
|
||||
context.shutdown();
|
||||
context = null;
|
||||
|
||||
@@ -26,12 +26,17 @@ import org.slf4j.LoggerFactory;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.world.WorldObject;
|
||||
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.database.DatabaseService;
|
||||
import com.l2jserver.service.game.scripting.ScriptingService;
|
||||
import com.l2jserver.service.game.template.TemplateService;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
import com.l2jserver.service.game.world.filter.FilterIterator;
|
||||
import com.l2jserver.service.game.world.filter.WorldObjectFilter;
|
||||
import com.l2jserver.service.game.world.filter.impl.InstanceFilter;
|
||||
import com.l2jserver.service.logging.LoggingService;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
@@ -39,6 +44,8 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@Depends({ LoggingService.class, TemplateService.class, ScriptingService.class,
|
||||
DatabaseService.class })
|
||||
public class WorldServiceImpl extends AbstractService implements WorldService {
|
||||
/**
|
||||
* The logger
|
||||
@@ -62,7 +69,7 @@ public class WorldServiceImpl extends AbstractService implements WorldService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws ServiceStartException {
|
||||
protected void doStart() throws ServiceStartException {
|
||||
objects.clear();
|
||||
}
|
||||
|
||||
@@ -127,7 +134,7 @@ public class WorldServiceImpl extends AbstractService implements WorldService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws ServiceStopException {
|
||||
protected void doStop() throws ServiceStopException {
|
||||
objects.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user