mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-06 07:32:46 +00:00
Service exceptions externalized and better logging configuration
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -25,13 +25,13 @@ import com.l2jserver.service.ServiceManager;
|
||||
import com.l2jserver.service.cache.CacheService;
|
||||
import com.l2jserver.service.configuration.ConfigurationService;
|
||||
import com.l2jserver.service.database.DatabaseService;
|
||||
import com.l2jserver.service.game.CharacterService;
|
||||
import com.l2jserver.service.game.SpawnService;
|
||||
import com.l2jserver.service.game.SpawnService.AlreadySpawnedServiceException;
|
||||
import com.l2jserver.service.game.SpawnService.SpawnPointNotFoundServiceException;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.service.game.chat.ChatService;
|
||||
import com.l2jserver.service.game.pathing.PathingService;
|
||||
import com.l2jserver.service.game.scripting.ScriptingService;
|
||||
import com.l2jserver.service.game.spawn.AlreadySpawnedServiceException;
|
||||
import com.l2jserver.service.game.spawn.SpawnPointNotFoundServiceException;
|
||||
import com.l2jserver.service.game.spawn.SpawnService;
|
||||
import com.l2jserver.service.game.template.TemplateService;
|
||||
import com.l2jserver.service.game.world.WorldIDService;
|
||||
import com.l2jserver.service.network.NetworkService;
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.l2jserver.game.net.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.channel.ExceptionEvent;
|
||||
@@ -94,13 +97,20 @@ public class Lineage2PacketHandler extends SimpleChannelHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event)
|
||||
throws Exception {
|
||||
// TODO only send exception stack trace in development mode!
|
||||
// TODO ignore netty exceptions or it could cause stack overflow
|
||||
final String exception = Throwables.getStackTraceAsString(e.getCause())
|
||||
.replaceAll("\n", "<br>").replace(" ", "");
|
||||
final Throwable e = event.getCause();
|
||||
if (e instanceof ChannelException)
|
||||
return;
|
||||
if (e instanceof IOException)
|
||||
return;
|
||||
if (!connection.isConnected())
|
||||
// no point sending error messages if the client is disconnected
|
||||
return;
|
||||
|
||||
// TODO only send exception stack trace in development mode!
|
||||
final String exception = Throwables.getStackTraceAsString(e)
|
||||
.replaceAll("\n", "<br>").replace(" ", "");
|
||||
final HtmlTemplate template = new HtmlTemplate("Java Exception") {
|
||||
@Override
|
||||
public void build(MarkupTag body) {
|
||||
@@ -108,5 +118,11 @@ public class Lineage2PacketHandler extends SimpleChannelHandler {
|
||||
}
|
||||
};
|
||||
connection.write(new NPCHtmlMessagePacket(null, template));
|
||||
connection.sendActionFailed(); // order client not to wait any packet
|
||||
|
||||
final String[] lines = Throwables.getStackTraceAsString(e).split("\n");
|
||||
for(final String line : lines) {
|
||||
connection.sendMessage(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,12 @@ import com.l2jserver.model.id.ObjectID;
|
||||
import com.l2jserver.model.id.object.NPCID;
|
||||
import com.l2jserver.model.id.object.provider.ObjectIDResolver;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.service.game.npc.ActionServiceException;
|
||||
import com.l2jserver.service.game.npc.NPCService;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Completes the creation of an character. Creates the object, inserts into the
|
||||
* database and notifies the client about the status of the operation.
|
||||
* Executes an action from an character to an NPC
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@@ -40,8 +41,10 @@ public class CharacterActionPacket extends AbstractClientPacket {
|
||||
public static final int OPCODE = 0x1f;
|
||||
|
||||
private final ObjectIDResolver idResolver;
|
||||
private final NPCService npcService;
|
||||
|
||||
private int objectId;
|
||||
@SuppressWarnings("unused")
|
||||
private Coordinate origin;
|
||||
private CharacterAction action;
|
||||
|
||||
@@ -67,8 +70,10 @@ public class CharacterActionPacket extends AbstractClientPacket {
|
||||
}
|
||||
|
||||
@Inject
|
||||
public CharacterActionPacket(ObjectIDResolver idResolver) {
|
||||
public CharacterActionPacket(ObjectIDResolver idResolver,
|
||||
NPCService npcService) {
|
||||
this.idResolver = idResolver;
|
||||
this.npcService = npcService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,11 +89,14 @@ public class CharacterActionPacket extends AbstractClientPacket {
|
||||
// since this is an erasure type, this is safe.
|
||||
final ObjectID<NPC> id = idResolver.resolve(objectId);
|
||||
if (!(id instanceof NPCID)) {
|
||||
System.out.println("Incorrect type: " + id);
|
||||
conn.sendActionFailed();
|
||||
return;
|
||||
}
|
||||
final NPC npc = id.getObject();
|
||||
npc.action(conn.getCharacter(), action);
|
||||
try {
|
||||
npcService.action(npc, conn.getCharacter(), action);
|
||||
} catch (ActionServiceException e) {
|
||||
conn.sendActionFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ import com.l2jserver.model.id.object.ActorID;
|
||||
import com.l2jserver.model.id.object.provider.ObjectIDResolver;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.capability.Actor;
|
||||
import com.l2jserver.service.game.CharacterService;
|
||||
import com.l2jserver.service.game.CharacterService.CannotSetTargetServiceException;
|
||||
import com.l2jserver.service.game.character.CannotSetTargetServiceException;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,13 +22,12 @@ import com.google.inject.Inject;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.game.net.packet.server.ActionFailedPacket;
|
||||
import com.l2jserver.service.game.chat.CannotChatToSelfChatServiceException;
|
||||
import com.l2jserver.service.game.chat.ChatBanActiveChatServiceException;
|
||||
import com.l2jserver.service.game.chat.ChatMessageDestination;
|
||||
import com.l2jserver.service.game.chat.ChatService;
|
||||
import com.l2jserver.service.game.chat.ChatService.CannotChatToSelfChatServiceException;
|
||||
import com.l2jserver.service.game.chat.ChatService.ChatBanActiveChatServiceException;
|
||||
import com.l2jserver.service.game.chat.ChatService.TargetNotFoundChatServiceException;
|
||||
import com.l2jserver.service.game.chat.TargetNotFoundChatServiceException;
|
||||
import com.l2jserver.util.BufferUtils;
|
||||
import com.l2jserver.util.exception.L2ChatServiceException;
|
||||
|
||||
/**
|
||||
* Completes the creation of an character. Creates the object, inserts into the
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.L2Character.CharacterMoveType;
|
||||
import com.l2jserver.service.game.CharacterService;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
|
||||
/**
|
||||
* This packet notifies the server which character the player has chosen to use.
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.game.net.packet.server.CharacterStopMovePacket;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.game.CharacterService;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.service.game.CharacterService;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,9 +24,9 @@ import com.google.inject.Inject;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.service.game.CharacterService;
|
||||
import com.l2jserver.service.game.SpawnService.AlreadySpawnedServiceException;
|
||||
import com.l2jserver.service.game.SpawnService.SpawnPointNotFoundServiceException;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.service.game.spawn.AlreadySpawnedServiceException;
|
||||
import com.l2jserver.service.game.spawn.SpawnPointNotFoundServiceException;
|
||||
|
||||
/**
|
||||
* The client is requesting a logout. Currently, when this packet is received
|
||||
|
||||
@@ -27,10 +27,11 @@ import com.l2jserver.model.world.AbstractActor.Race;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.capability.Actor;
|
||||
import com.l2jserver.service.game.CharacterService;
|
||||
import com.l2jserver.service.game.CharacterService.CannotSetTargetServiceException;
|
||||
import com.l2jserver.service.game.character.CannotSetTargetServiceException;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.service.network.NetworkService;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
import com.l2jserver.util.exception.L2Exception;
|
||||
import com.l2jserver.util.html.markup.HtmlTemplate;
|
||||
import com.l2jserver.util.html.markup.MarkupTag;
|
||||
|
||||
@@ -101,8 +102,11 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> {
|
||||
* the interacting character
|
||||
* @param action
|
||||
* the action performed
|
||||
* @throws L2Exception
|
||||
* any {@link L2Exception}
|
||||
*/
|
||||
public void action(NPC npc, L2Character character, CharacterAction action) {
|
||||
public void action(NPC npc, L2Character character, CharacterAction action)
|
||||
throws L2Exception {
|
||||
final Lineage2Connection conn = networkService.discover(character
|
||||
.getID());
|
||||
if (conn == null)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.l2jserver.model.template.npc;
|
||||
|
||||
import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.l2jserver.model.template.npc;
|
||||
|
||||
import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.l2jserver.model.template.npc;
|
||||
|
||||
import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
|
||||
@@ -16,14 +16,11 @@
|
||||
*/
|
||||
package com.l2jserver.model.world;
|
||||
|
||||
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
|
||||
import com.l2jserver.model.id.TemplateID;
|
||||
import com.l2jserver.model.id.object.NPCID;
|
||||
import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.capability.Actor;
|
||||
import com.l2jserver.service.game.ai.AIScript;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
|
||||
/**
|
||||
* NPC stand for "Not Playable Character" and is an character that not player
|
||||
@@ -48,23 +45,6 @@ public class NPC extends AbstractActor {
|
||||
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);
|
||||
}
|
||||
|
||||
public void receiveAttack(Calculator calculator, Actor attacker) {
|
||||
// TODO add buffs to calculator!
|
||||
getTemplate().receiveAttack(this, calculator, attacker);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the NPC template ID
|
||||
*/
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
*/
|
||||
package com.l2jserver.service;
|
||||
|
||||
import com.l2jserver.util.exception.L2Exception;
|
||||
|
||||
/**
|
||||
* Exception for an {@link Service}
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ServiceException extends Exception {
|
||||
public class ServiceException extends L2Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ServiceException() {
|
||||
|
||||
@@ -27,16 +27,18 @@ import com.l2jserver.service.core.Log4JLoggingService;
|
||||
import com.l2jserver.service.core.LoggingService;
|
||||
import com.l2jserver.service.database.DatabaseService;
|
||||
import com.l2jserver.service.database.MySQLDatabaseService;
|
||||
import com.l2jserver.service.game.CharacterService;
|
||||
import com.l2jserver.service.game.CharacterServiceImpl;
|
||||
import com.l2jserver.service.game.SpawnService;
|
||||
import com.l2jserver.service.game.SpawnServiceImpl;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.service.game.character.CharacterServiceImpl;
|
||||
import com.l2jserver.service.game.chat.ChatService;
|
||||
import com.l2jserver.service.game.chat.SimpleChatService;
|
||||
import com.l2jserver.service.game.npc.NPCService;
|
||||
import com.l2jserver.service.game.npc.NPCServiceImpl;
|
||||
import com.l2jserver.service.game.pathing.MapperPathingService;
|
||||
import com.l2jserver.service.game.pathing.PathingService;
|
||||
import com.l2jserver.service.game.scripting.ScriptingService;
|
||||
import com.l2jserver.service.game.scripting.ScriptingServiceImpl;
|
||||
import com.l2jserver.service.game.spawn.SpawnService;
|
||||
import com.l2jserver.service.game.spawn.SpawnServiceImpl;
|
||||
import com.l2jserver.service.game.template.ScriptTemplateService;
|
||||
import com.l2jserver.service.game.template.TemplateService;
|
||||
import com.l2jserver.service.game.world.CachedWorldIDService;
|
||||
@@ -87,6 +89,7 @@ public class ServiceModule extends AbstractModule {
|
||||
.in(Scopes.SINGLETON);
|
||||
bind(CharacterService.class).to(CharacterServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(NPCService.class).to(NPCServiceImpl.class).in(Scopes.SINGLETON);
|
||||
|
||||
bind(WorldService.class).to(WorldServiceImpl.class)
|
||||
.in(Scopes.SINGLETON);
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
package com.l2jserver.service.core;
|
||||
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.ConsoleAppender;
|
||||
import org.apache.log4j.Layout;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
@@ -29,9 +34,26 @@ import com.l2jserver.service.ServiceStopException;
|
||||
*/
|
||||
public class Log4JLoggingService extends AbstractService implements
|
||||
LoggingService {
|
||||
private Logger rootLogger;
|
||||
private Logger l2jLogger;
|
||||
private Logger scriptLogger;
|
||||
|
||||
@Override
|
||||
protected void doStart() throws ServiceStartException {
|
||||
final Layout layout = new PatternLayout(
|
||||
"[%p %d{yyyy-MM-dd HH-mm-ss}] %c:%L - %m%n");
|
||||
|
||||
BasicConfigurator.configure();
|
||||
rootLogger = Logger.getRootLogger();
|
||||
l2jLogger = Logger.getLogger("com.l2jserver");
|
||||
scriptLogger = Logger.getLogger("script");
|
||||
|
||||
rootLogger.removeAllAppenders();
|
||||
rootLogger.setLevel(Level.WARN);
|
||||
rootLogger.addAppender(new ConsoleAppender(layout, "System.err"));
|
||||
|
||||
l2jLogger.setLevel(Level.DEBUG);
|
||||
scriptLogger.setLevel(Level.DEBUG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.core.log4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.log4j.FileAppender;
|
||||
import org.apache.log4j.helpers.LogLog;
|
||||
|
||||
/**
|
||||
* This class is appender that zips old file instead of appending it.<br>
|
||||
* File is recognized as old if it's lastModified() is < JVM startup time.<br>
|
||||
* So we can have per-run appending. <br>
|
||||
*
|
||||
* Unfortunately, UNIX systems doesn't support file creation date, so we have to
|
||||
* use lastModified(), windows only solution is not good.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class TruncateToZipFileAppender extends FileAppender {
|
||||
|
||||
/**
|
||||
* String that points to root directory for backups
|
||||
*/
|
||||
private String backupDir = "log/backup";
|
||||
|
||||
/**
|
||||
* String that represents date format for backup files
|
||||
*/
|
||||
private String backupDateFormat = "yyyy-MM-dd HH-mm-ss";
|
||||
|
||||
/**
|
||||
* Sets and <i>opens</i> the file where the log output will go. The
|
||||
* specified file must be writable.
|
||||
* <p>
|
||||
* If there was already an opened file, then the previous file is closed
|
||||
* first.
|
||||
* <p/>
|
||||
* <p>
|
||||
* <b>Do not use this method directly. To configure a FileAppender or one of
|
||||
* its subclasses, set its properties one by one and then call
|
||||
* activateOptions.</b>
|
||||
* <p/>
|
||||
* <br>
|
||||
* Truncation is done by {@link #truncate(java.io.File)}
|
||||
*
|
||||
* @param fileName
|
||||
* The path to the log file.
|
||||
* @param append
|
||||
* If true will append to fileName. Otherwise will truncate
|
||||
* fileName.
|
||||
*/
|
||||
@Override
|
||||
public void setFile(String fileName, boolean append, boolean bufferedIO,
|
||||
int bufferSize) throws IOException {
|
||||
|
||||
if (!append) {
|
||||
truncate(new File(fileName));
|
||||
}
|
||||
|
||||
super.setFile(fileName, append, bufferedIO, bufferSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates archive with file instead of deleting it.
|
||||
*
|
||||
* @param file
|
||||
* file to truncate
|
||||
*/
|
||||
protected void truncate(File file) {
|
||||
LogLog.debug("Compression of file: " + file.getAbsolutePath()
|
||||
+ " started.");
|
||||
|
||||
// Linux systems doesn't provide file creation time, so we have to hope
|
||||
// that log files
|
||||
// were not modified manually after server starup
|
||||
// We can use here Windowns-only solution but that suck :(
|
||||
if (FileUtils.isFileOlder(file, ManagementFactory.getRuntimeMXBean()
|
||||
.getStartTime())) {
|
||||
File backupRoot = new File(getBackupDir());
|
||||
if (!backupRoot.exists() && !backupRoot.mkdirs()) {
|
||||
throw new Error("Can't create backup dir for backup storage");
|
||||
}
|
||||
|
||||
SimpleDateFormat df;
|
||||
try {
|
||||
df = new SimpleDateFormat(getBackupDateFormat());
|
||||
} catch (Exception e) {
|
||||
throw new Error("Invalid date formate for backup files: "
|
||||
+ getBackupDateFormat(), e);
|
||||
}
|
||||
String date = df.format(new Date(file.lastModified()));
|
||||
|
||||
File zipFile = new File(backupRoot, file.getName() + "." + date
|
||||
+ ".zip");
|
||||
|
||||
ZipOutputStream zos = null;
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
zos = new ZipOutputStream(new FileOutputStream(zipFile));
|
||||
ZipEntry entry = new ZipEntry(file.getName());
|
||||
entry.setMethod(ZipEntry.DEFLATED);
|
||||
entry.setCrc(FileUtils.checksumCRC32(file));
|
||||
zos.putNextEntry(entry);
|
||||
fis = FileUtils.openInputStream(file);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int readed;
|
||||
while ((readed = fis.read(buffer)) != -1) {
|
||||
zos.write(buffer, 0, readed);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new Error("Can't create zip file", e);
|
||||
} finally {
|
||||
if (zos != null) {
|
||||
try {
|
||||
zos.close();
|
||||
} catch (IOException e) {
|
||||
// not critical error
|
||||
LogLog.warn("Can't close zip file", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (fis != null) {
|
||||
try {
|
||||
// not critical error
|
||||
fis.close();
|
||||
} catch (IOException e) {
|
||||
LogLog.warn("Can't close zipped file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.delete()) {
|
||||
throw new Error("Can't delete old log file "
|
||||
+ file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns root directory for backups
|
||||
*
|
||||
* @return root directory for backups
|
||||
*/
|
||||
public String getBackupDir() {
|
||||
return backupDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets root directory for backups
|
||||
*
|
||||
* @param backupDir
|
||||
* new root directory for backups
|
||||
*/
|
||||
public void setBackupDir(String backupDir) {
|
||||
this.backupDir = backupDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns date format that should be used for backup files represented as
|
||||
* string
|
||||
*
|
||||
* @return date formate for backup files
|
||||
*/
|
||||
public String getBackupDateFormat() {
|
||||
return backupDateFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets date format for bakcup files represented as string
|
||||
*
|
||||
* @param backupDateFormat
|
||||
* date format for backup files
|
||||
*/
|
||||
public void setBackupDateFormat(String backupDateFormat) {
|
||||
this.backupDateFormat = backupDateFormat;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.l2jserver.service.game.character;
|
||||
|
||||
/**
|
||||
* Exception thrown when the target cannot be set
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CannotSetTargetServiceException extends
|
||||
CharacterServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.l2jserver.service.game.character;
|
||||
|
||||
/**
|
||||
* Exception thrown when the character is in jail
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterInJailServiceException extends
|
||||
CharacterServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.l2jserver.service.game.character;
|
||||
|
||||
/**
|
||||
* Exception thrown when the character is <b>not</b> in jail
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterNotInJailServiceException extends
|
||||
CharacterServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -14,17 +14,16 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game;
|
||||
package com.l2jserver.service.game.character;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.capability.Actor;
|
||||
import com.l2jserver.service.Service;
|
||||
import com.l2jserver.service.game.SpawnService.AlreadySpawnedServiceException;
|
||||
import com.l2jserver.service.game.SpawnService.NotSpawnedServiceException;
|
||||
import com.l2jserver.service.game.SpawnService.SpawnPointNotFoundServiceException;
|
||||
import com.l2jserver.service.game.spawn.AlreadySpawnedServiceException;
|
||||
import com.l2jserver.service.game.spawn.NotSpawnedServiceException;
|
||||
import com.l2jserver.service.game.spawn.SpawnPointNotFoundServiceException;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
import com.l2jserver.util.exception.L2ChatServiceException;
|
||||
|
||||
/**
|
||||
* This service manages {@link L2Character} instances
|
||||
@@ -105,7 +104,8 @@ public interface CharacterService extends Service {
|
||||
* @throws CharacterNotInJailServiceException
|
||||
* if character is not in jail
|
||||
*/
|
||||
void unjail(L2Character character) throws CharacterNotInJailServiceException;
|
||||
void unjail(L2Character character)
|
||||
throws CharacterNotInJailServiceException;
|
||||
|
||||
/**
|
||||
* Moves the given <tt>character</tt> to <tt>coordinate</tt>
|
||||
@@ -152,32 +152,4 @@ public interface CharacterService extends Service {
|
||||
* the character
|
||||
*/
|
||||
void run(L2Character character);
|
||||
|
||||
/**
|
||||
* Exception thrown when the target cannot be set
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CannotSetTargetServiceException extends L2ChatServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when the character is in jail
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterInJailServiceException extends L2ChatServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when the character is <b>not</b> in jail
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterNotInJailServiceException extends
|
||||
L2ChatServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
}
|
||||
@@ -14,44 +14,29 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.util.exception;
|
||||
package com.l2jserver.service.game.character;
|
||||
|
||||
import com.l2jserver.service.ServiceException;
|
||||
|
||||
/**
|
||||
* Base exception for Lineage 2
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class L2ServiceException extends Exception {
|
||||
/**
|
||||
* Default Serial Version UID
|
||||
*/
|
||||
public class CharacterServiceException extends ServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see Exception#Exception()
|
||||
*/
|
||||
public L2ServiceException() {
|
||||
public CharacterServiceException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Exception#Exception(String, Throwable)
|
||||
*/
|
||||
public L2ServiceException(String message, Throwable cause) {
|
||||
public CharacterServiceException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Exception#Exception(String)
|
||||
*/
|
||||
public L2ServiceException(String message) {
|
||||
public CharacterServiceException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Exception#Exception(Throwable)
|
||||
*/
|
||||
public L2ServiceException(Throwable cause) {
|
||||
public CharacterServiceException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game;
|
||||
package com.l2jserver.service.game.character;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
@@ -48,13 +48,14 @@ import com.l2jserver.model.world.character.event.CharacterTargetSelectedEvent;
|
||||
import com.l2jserver.model.world.npc.event.NPCSpawnEvent;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.game.SpawnService.AlreadySpawnedServiceException;
|
||||
import com.l2jserver.service.game.SpawnService.NotSpawnedServiceException;
|
||||
import com.l2jserver.service.game.SpawnService.SpawnPointNotFoundServiceException;
|
||||
import com.l2jserver.service.game.chat.ChatMessageDestination;
|
||||
import com.l2jserver.service.game.chat.ChatService;
|
||||
import com.l2jserver.service.game.chat.channel.ChatChannel;
|
||||
import com.l2jserver.service.game.chat.channel.ChatChannelListener;
|
||||
import com.l2jserver.service.game.spawn.AlreadySpawnedServiceException;
|
||||
import com.l2jserver.service.game.spawn.NotSpawnedServiceException;
|
||||
import com.l2jserver.service.game.spawn.SpawnPointNotFoundServiceException;
|
||||
import com.l2jserver.service.game.spawn.SpawnService;
|
||||
import com.l2jserver.service.game.world.WorldService;
|
||||
import com.l2jserver.service.game.world.event.FilteredWorldListener;
|
||||
import com.l2jserver.service.game.world.event.WorldEvent;
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.l2jserver.service.game.chat;
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown if the player is trying to chat with itself.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CannotChatToSelfChatServiceException extends
|
||||
ChatServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.l2jserver.service.game.chat;
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown if the player trying to send a message is currently
|
||||
* banned.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ChatBanActiveChatServiceException extends
|
||||
ChatServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import com.l2jserver.service.Service;
|
||||
import com.l2jserver.service.game.chat.channel.ChatChannel;
|
||||
import com.l2jserver.service.game.chat.channel.PrivateChatChannel;
|
||||
import com.l2jserver.service.game.chat.channel.PublicChatChannel;
|
||||
import com.l2jserver.util.exception.L2ChatServiceException;
|
||||
|
||||
/**
|
||||
* This service chatting in the server
|
||||
@@ -107,37 +106,4 @@ public interface ChatService extends Service {
|
||||
* @return the public clan {@link ChatChannel}
|
||||
*/
|
||||
PublicChatChannel getChannel(ClanID clan);
|
||||
|
||||
// TODO party chat
|
||||
|
||||
/**
|
||||
* Exception thrown when the target of an private chat is not found
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class TargetNotFoundChatServiceException extends
|
||||
L2ChatServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown if the player is trying to chat with itself.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CannotChatToSelfChatServiceException extends
|
||||
L2ChatServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown if the player trying to send a message is currently
|
||||
* banned.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ChatBanActiveChatServiceException extends
|
||||
L2ChatServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,27 +14,29 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.util.exception;
|
||||
package com.l2jserver.service.game.chat;
|
||||
|
||||
import com.l2jserver.service.ServiceException;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class L2SpawnServiceException extends L2ServiceException {
|
||||
public class ChatServiceException extends ServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public L2SpawnServiceException() {
|
||||
public ChatServiceException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public L2SpawnServiceException(String message, Throwable cause) {
|
||||
public ChatServiceException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public L2SpawnServiceException(String message) {
|
||||
public ChatServiceException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public L2SpawnServiceException(Throwable cause) {
|
||||
public ChatServiceException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.l2jserver.service.game.chat;
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown when the target of an private chat is not found
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class TargetNotFoundChatServiceException extends
|
||||
ChatServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.l2jserver.service.game.chat.channel;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.service.game.chat.ChatService.ChatBanActiveChatServiceException;
|
||||
import com.l2jserver.service.game.chat.ChatBanActiveChatServiceException;
|
||||
|
||||
/**
|
||||
* The {@link ChatChannel} object is used to send messages to a channel.
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.l2jserver.service.game.npc;
|
||||
|
||||
import com.l2jserver.util.exception.L2Exception;
|
||||
|
||||
/**
|
||||
* Exception thrown when the action implementation thrown an exception. Will
|
||||
* always contain an <tt>cause</tt>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ActionServiceException extends NPCServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param cause
|
||||
* the cause
|
||||
*/
|
||||
public ActionServiceException(L2Exception cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -14,25 +14,44 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game;
|
||||
package com.l2jserver.service.game.npc;
|
||||
|
||||
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service controls {@link NPC}s
|
||||
* This service manages {@link NPC} instances
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface MonsterService extends Service {
|
||||
public interface NPCService extends Service {
|
||||
/**
|
||||
* Interacts the given <tt>player</tt> with the given <tt>npc</tt>
|
||||
* Executes an action for an NPC. Each {@link NPCTemplate} have it's own
|
||||
* actions.
|
||||
*
|
||||
* @param npc
|
||||
* the npc
|
||||
* @param character
|
||||
* the character
|
||||
* @param action
|
||||
* the action type
|
||||
*/
|
||||
void interact(NPC npc, L2Character character);
|
||||
void action(NPC npc, L2Character character, CharacterAction action)
|
||||
throws ActionServiceException;
|
||||
|
||||
/**
|
||||
* Attacks an given NPC, if possible.
|
||||
*
|
||||
* @param npc
|
||||
* the npc
|
||||
* @param attacker
|
||||
* the character
|
||||
* @throws NotAttackableNPCServiceException
|
||||
* if {@link NPC} is not attackable
|
||||
*/
|
||||
void attack(NPC npc, L2Character attacker)
|
||||
throws NotAttackableNPCServiceException;
|
||||
}
|
||||
@@ -14,27 +14,29 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.util.exception;
|
||||
package com.l2jserver.service.game.npc;
|
||||
|
||||
import com.l2jserver.service.ServiceException;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class L2ChatServiceException extends L2ServiceException {
|
||||
public class NPCServiceException extends ServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public L2ChatServiceException() {
|
||||
public NPCServiceException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public L2ChatServiceException(String message, Throwable cause) {
|
||||
public NPCServiceException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public L2ChatServiceException(String message) {
|
||||
public NPCServiceException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public L2ChatServiceException(Throwable cause) {
|
||||
public NPCServiceException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game.npc;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.util.exception.L2Exception;
|
||||
|
||||
/**
|
||||
* Default {@link NPCService} implementation
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
@Override
|
||||
public void action(NPC npc, L2Character character, CharacterAction action)
|
||||
throws ActionServiceException {
|
||||
Preconditions.checkNotNull(npc, "npc");
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
Preconditions.checkNotNull(action, "action");
|
||||
|
||||
final NPCTemplate template = npc.getTemplate();
|
||||
try {
|
||||
template.action(npc, character, action);
|
||||
} catch (L2Exception e) {
|
||||
throw new ActionServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(NPC npc, L2Character attacker)
|
||||
throws NotAttackableNPCServiceException {
|
||||
Preconditions.checkNotNull(npc, "npc");
|
||||
Preconditions.checkNotNull(attacker, "attacker");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.l2jserver.service.game.npc;
|
||||
|
||||
import com.l2jserver.model.world.NPC;
|
||||
|
||||
/**
|
||||
* Exception thrown when the {@link NPC} is not attackable
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NotAttackableNPCServiceException extends NPCServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ 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.CharacterService;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.service.game.world.WorldService;
|
||||
import com.l2jserver.service.game.world.event.TypedWorldListener;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
|
||||
@@ -118,7 +118,6 @@ public class ScriptingServiceImpl extends AbstractService implements
|
||||
private ScriptContext createContext(ScriptInfo si, ScriptContext parent)
|
||||
throws Exception {
|
||||
Preconditions.checkNotNull(si, "si");
|
||||
Preconditions.checkNotNull(parent, "parent");
|
||||
|
||||
ScriptContext context = getScriptContext(si.getRoot(), parent);
|
||||
context.setLibraries(si.getLibraries());
|
||||
@@ -159,7 +158,6 @@ public class ScriptingServiceImpl extends AbstractService implements
|
||||
private ScriptContext getScriptContext(File root, ScriptContext parent)
|
||||
throws InstantiationException {
|
||||
Preconditions.checkNotNull(root, "root");
|
||||
Preconditions.checkNotNull(parent, "parent");
|
||||
|
||||
ScriptContextImpl ctx;
|
||||
if (parent == null) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.l2jserver.service.game.spawn;
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown when the object is already spawned and registered in the
|
||||
* world
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class AlreadySpawnedServiceException extends SpawnServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.l2jserver.service.game.spawn;
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown when trying to unspawn an object that is not spawned
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NotSpawnedServiceException extends SpawnServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.l2jserver.service.game.spawn;
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown when the target spawn point is not found
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SpawnPointNotFoundServiceException extends
|
||||
SpawnServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game;
|
||||
package com.l2jserver.service.game.spawn;
|
||||
|
||||
import com.l2jserver.model.world.Player;
|
||||
import com.l2jserver.model.world.capability.Spawnable;
|
||||
@@ -23,7 +23,6 @@ import com.l2jserver.model.world.player.event.PlayerTeleportEvent;
|
||||
import com.l2jserver.service.Service;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
import com.l2jserver.util.exception.L2SpawnServiceException;
|
||||
|
||||
/**
|
||||
* This service is responsible for spawning monsters, npcs and players.
|
||||
@@ -87,33 +86,4 @@ public interface SpawnService extends Service {
|
||||
* if the object is not spawned
|
||||
*/
|
||||
void unspawn(Spawnable spawnable) throws NotSpawnedServiceException;
|
||||
|
||||
/**
|
||||
* Exception thrown when the object is already spawned and registered in the
|
||||
* world
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class AlreadySpawnedServiceException extends L2SpawnServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when the target spawn point is not found
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SpawnPointNotFoundServiceException extends
|
||||
L2SpawnServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when trying to unspawn an object that is not spawned
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NotSpawnedServiceException extends L2SpawnServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
}
|
||||
@@ -14,27 +14,29 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.util.exception;
|
||||
package com.l2jserver.service.game.spawn;
|
||||
|
||||
import com.l2jserver.service.ServiceException;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class L2CharacterServiceException extends L2ServiceException {
|
||||
public class SpawnServiceException extends ServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public L2CharacterServiceException() {
|
||||
public SpawnServiceException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public L2CharacterServiceException(String message, Throwable cause) {
|
||||
public SpawnServiceException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public L2CharacterServiceException(String message) {
|
||||
public SpawnServiceException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public L2CharacterServiceException(Throwable cause) {
|
||||
public SpawnServiceException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game;
|
||||
package com.l2jserver.service.game.spawn;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -90,8 +90,7 @@ public class CachedWorldIDService extends AbstractService implements
|
||||
cache = new Cache(new CacheConfiguration("id-cache",
|
||||
IDAllocator.ALLOCABLE_IDS)
|
||||
.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
|
||||
.overflowToDisk(true).eternal(true).timeToLiveSeconds(60)
|
||||
.timeToIdleSeconds(30).diskPersistent(false)
|
||||
.overflowToDisk(true).eternal(true).diskPersistent(false)
|
||||
.diskExpiryThreadIntervalSeconds(0));
|
||||
cacheService.register(cache);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user