.
+ *
+ * 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.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.
+ * File is recognized as old if it's lastModified() is < JVM startup time.
+ * So we can have per-run appending.
+ *
+ * Unfortunately, UNIX systems doesn't support file creation date, so we have to
+ * use lastModified(), windows only solution is not good.
+ *
+ * @author Rogiel
+ */
+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 opens the file where the log output will go. The
+ * specified file must be writable.
+ *
+ * If there was already an opened file, then the previous file is closed
+ * first.
+ *
+ *
+ * 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.
+ *
+ *
+ * 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;
+ }
+}
diff --git a/src/main/java/com/l2jserver/service/game/character/CannotSetTargetServiceException.java b/src/main/java/com/l2jserver/service/game/character/CannotSetTargetServiceException.java
new file mode 100644
index 000000000..ddc48cd4a
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/character/CannotSetTargetServiceException.java
@@ -0,0 +1,11 @@
+package com.l2jserver.service.game.character;
+
+/**
+ * Exception thrown when the target cannot be set
+ *
+ * @author Rogiel
+ */
+public class CannotSetTargetServiceException extends
+ CharacterServiceException {
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/character/CharacterInJailServiceException.java b/src/main/java/com/l2jserver/service/game/character/CharacterInJailServiceException.java
new file mode 100644
index 000000000..577f44d74
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/character/CharacterInJailServiceException.java
@@ -0,0 +1,11 @@
+package com.l2jserver.service.game.character;
+
+/**
+ * Exception thrown when the character is in jail
+ *
+ * @author Rogiel
+ */
+public class CharacterInJailServiceException extends
+ CharacterServiceException {
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/character/CharacterNotInJailServiceException.java b/src/main/java/com/l2jserver/service/game/character/CharacterNotInJailServiceException.java
new file mode 100644
index 000000000..b5764f89e
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/character/CharacterNotInJailServiceException.java
@@ -0,0 +1,11 @@
+package com.l2jserver.service.game.character;
+
+/**
+ * Exception thrown when the character is not in jail
+ *
+ * @author Rogiel
+ */
+public class CharacterNotInJailServiceException extends
+ CharacterServiceException {
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/CharacterService.java b/src/main/java/com/l2jserver/service/game/character/CharacterService.java
similarity index 77%
rename from src/main/java/com/l2jserver/service/game/CharacterService.java
rename to src/main/java/com/l2jserver/service/game/character/CharacterService.java
index b1b409b0f..b8778574c 100644
--- a/src/main/java/com/l2jserver/service/game/CharacterService.java
+++ b/src/main/java/com/l2jserver/service/game/character/CharacterService.java
@@ -14,17 +14,16 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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 character to coordinate
@@ -152,32 +152,4 @@ public interface CharacterService extends Service {
* the character
*/
void run(L2Character character);
-
- /**
- * Exception thrown when the target cannot be set
- *
- * @author Rogiel
- */
- public class CannotSetTargetServiceException extends L2ChatServiceException {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * Exception thrown when the character is in jail
- *
- * @author Rogiel
- */
- public class CharacterInJailServiceException extends L2ChatServiceException {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * Exception thrown when the character is not in jail
- *
- * @author Rogiel
- */
- public class CharacterNotInJailServiceException extends
- L2ChatServiceException {
- private static final long serialVersionUID = 1L;
- }
}
diff --git a/src/main/java/com/l2jserver/util/exception/L2ServiceException.java b/src/main/java/com/l2jserver/service/game/character/CharacterServiceException.java
similarity index 62%
rename from src/main/java/com/l2jserver/util/exception/L2ServiceException.java
rename to src/main/java/com/l2jserver/service/game/character/CharacterServiceException.java
index 1fe6b5fe5..90c5f6068 100644
--- a/src/main/java/com/l2jserver/util/exception/L2ServiceException.java
+++ b/src/main/java/com/l2jserver/service/game/character/CharacterServiceException.java
@@ -14,44 +14,29 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-package com.l2jserver.util.exception;
+package com.l2jserver.service.game.character;
+
+import com.l2jserver.service.ServiceException;
/**
- * Base exception for Lineage 2
- *
* @author Rogiel
*/
-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);
}
}
diff --git a/src/main/java/com/l2jserver/service/game/CharacterServiceImpl.java b/src/main/java/com/l2jserver/service/game/character/CharacterServiceImpl.java
similarity index 97%
rename from src/main/java/com/l2jserver/service/game/CharacterServiceImpl.java
rename to src/main/java/com/l2jserver/service/game/character/CharacterServiceImpl.java
index f1c77f849..0f7e03985 100644
--- a/src/main/java/com/l2jserver/service/game/CharacterServiceImpl.java
+++ b/src/main/java/com/l2jserver/service/game/character/CharacterServiceImpl.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.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;
diff --git a/src/main/java/com/l2jserver/service/game/chat/CannotChatToSelfChatServiceException.java b/src/main/java/com/l2jserver/service/game/chat/CannotChatToSelfChatServiceException.java
new file mode 100644
index 000000000..b936c94c7
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/chat/CannotChatToSelfChatServiceException.java
@@ -0,0 +1,12 @@
+package com.l2jserver.service.game.chat;
+
+
+/**
+ * Exception thrown if the player is trying to chat with itself.
+ *
+ * @author Rogiel
+ */
+public class CannotChatToSelfChatServiceException extends
+ ChatServiceException {
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/chat/ChatBanActiveChatServiceException.java b/src/main/java/com/l2jserver/service/game/chat/ChatBanActiveChatServiceException.java
new file mode 100644
index 000000000..1338239d5
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/chat/ChatBanActiveChatServiceException.java
@@ -0,0 +1,13 @@
+package com.l2jserver.service.game.chat;
+
+
+/**
+ * Exception thrown if the player trying to send a message is currently
+ * banned.
+ *
+ * @author Rogiel
+ */
+public class ChatBanActiveChatServiceException extends
+ ChatServiceException {
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/chat/ChatService.java b/src/main/java/com/l2jserver/service/game/chat/ChatService.java
index 05d32af93..c26a7d449 100644
--- a/src/main/java/com/l2jserver/service/game/chat/ChatService.java
+++ b/src/main/java/com/l2jserver/service/game/chat/ChatService.java
@@ -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 Rogiel
- */
- public class TargetNotFoundChatServiceException extends
- L2ChatServiceException {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * Exception thrown if the player is trying to chat with itself.
- *
- * @author Rogiel
- */
- 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 Rogiel
- */
- public class ChatBanActiveChatServiceException extends
- L2ChatServiceException {
- private static final long serialVersionUID = 1L;
- }
}
diff --git a/src/main/java/com/l2jserver/util/exception/L2SpawnServiceException.java b/src/main/java/com/l2jserver/service/game/chat/ChatServiceException.java
similarity index 72%
rename from src/main/java/com/l2jserver/util/exception/L2SpawnServiceException.java
rename to src/main/java/com/l2jserver/service/game/chat/ChatServiceException.java
index b96a7d4ed..2311ebe1a 100644
--- a/src/main/java/com/l2jserver/util/exception/L2SpawnServiceException.java
+++ b/src/main/java/com/l2jserver/service/game/chat/ChatServiceException.java
@@ -14,27 +14,29 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-package com.l2jserver.util.exception;
+package com.l2jserver.service.game.chat;
+
+import com.l2jserver.service.ServiceException;
/**
* @author Rogiel
*/
-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);
}
}
diff --git a/src/main/java/com/l2jserver/service/game/chat/TargetNotFoundChatServiceException.java b/src/main/java/com/l2jserver/service/game/chat/TargetNotFoundChatServiceException.java
new file mode 100644
index 000000000..549c66177
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/chat/TargetNotFoundChatServiceException.java
@@ -0,0 +1,12 @@
+package com.l2jserver.service.game.chat;
+
+
+/**
+ * Exception thrown when the target of an private chat is not found
+ *
+ * @author Rogiel
+ */
+public class TargetNotFoundChatServiceException extends
+ ChatServiceException {
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/chat/channel/ChatChannel.java b/src/main/java/com/l2jserver/service/game/chat/channel/ChatChannel.java
index de46c8d1c..3b2d51ff6 100644
--- a/src/main/java/com/l2jserver/service/game/chat/channel/ChatChannel.java
+++ b/src/main/java/com/l2jserver/service/game/chat/channel/ChatChannel.java
@@ -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.
diff --git a/src/main/java/com/l2jserver/service/game/npc/ActionServiceException.java b/src/main/java/com/l2jserver/service/game/npc/ActionServiceException.java
new file mode 100644
index 000000000..8f11b4222
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/npc/ActionServiceException.java
@@ -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 cause
+ *
+ * @author Rogiel
+ */
+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);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/MonsterService.java b/src/main/java/com/l2jserver/service/game/npc/NPCService.java
similarity index 54%
rename from src/main/java/com/l2jserver/service/game/MonsterService.java
rename to src/main/java/com/l2jserver/service/game/npc/NPCService.java
index 23b23ba02..80f66c7c5 100644
--- a/src/main/java/com/l2jserver/service/game/MonsterService.java
+++ b/src/main/java/com/l2jserver/service/game/npc/NPCService.java
@@ -14,25 +14,44 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-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 Rogiel
*/
-public interface MonsterService extends Service {
+public interface NPCService extends Service {
/**
- * Interacts the given player with the given npc
+ * 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;
}
diff --git a/src/main/java/com/l2jserver/util/exception/L2ChatServiceException.java b/src/main/java/com/l2jserver/service/game/npc/NPCServiceException.java
similarity index 72%
rename from src/main/java/com/l2jserver/util/exception/L2ChatServiceException.java
rename to src/main/java/com/l2jserver/service/game/npc/NPCServiceException.java
index f08e9a9ce..9a4b9d959 100644
--- a/src/main/java/com/l2jserver/util/exception/L2ChatServiceException.java
+++ b/src/main/java/com/l2jserver/service/game/npc/NPCServiceException.java
@@ -14,27 +14,29 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-package com.l2jserver.util.exception;
+package com.l2jserver.service.game.npc;
+
+import com.l2jserver.service.ServiceException;
/**
* @author Rogiel
*/
-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);
}
}
diff --git a/src/main/java/com/l2jserver/service/game/npc/NPCServiceImpl.java b/src/main/java/com/l2jserver/service/game/npc/NPCServiceImpl.java
new file mode 100644
index 000000000..2fb5b3ed7
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/npc/NPCServiceImpl.java
@@ -0,0 +1,54 @@
+/*
+ * 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.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 Rogiel
+ */
+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");
+ }
+}
diff --git a/src/main/java/com/l2jserver/service/game/npc/NotAttackableNPCServiceException.java b/src/main/java/com/l2jserver/service/game/npc/NotAttackableNPCServiceException.java
new file mode 100644
index 000000000..93283be7a
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/npc/NotAttackableNPCServiceException.java
@@ -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 Rogiel
+ */
+public class NotAttackableNPCServiceException extends NPCServiceException {
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/pathing/MapperPathingService.java b/src/main/java/com/l2jserver/service/game/pathing/MapperPathingService.java
index 803413620..93b9aa4fc 100644
--- a/src/main/java/com/l2jserver/service/game/pathing/MapperPathingService.java
+++ b/src/main/java/com/l2jserver/service/game/pathing/MapperPathingService.java
@@ -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;
diff --git a/src/main/java/com/l2jserver/service/game/scripting/ScriptingServiceImpl.java b/src/main/java/com/l2jserver/service/game/scripting/ScriptingServiceImpl.java
index 0401edf14..957399117 100644
--- a/src/main/java/com/l2jserver/service/game/scripting/ScriptingServiceImpl.java
+++ b/src/main/java/com/l2jserver/service/game/scripting/ScriptingServiceImpl.java
@@ -118,8 +118,7 @@ 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());
context.setCompilerClassName(si.getCompilerClass());
@@ -159,8 +158,7 @@ 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) {
ctx = new ScriptContextImpl(injector, root);
diff --git a/src/main/java/com/l2jserver/service/game/spawn/AlreadySpawnedServiceException.java b/src/main/java/com/l2jserver/service/game/spawn/AlreadySpawnedServiceException.java
new file mode 100644
index 000000000..f716340ee
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/spawn/AlreadySpawnedServiceException.java
@@ -0,0 +1,12 @@
+package com.l2jserver.service.game.spawn;
+
+
+/**
+ * Exception thrown when the object is already spawned and registered in the
+ * world
+ *
+ * @author Rogiel
+ */
+public class AlreadySpawnedServiceException extends SpawnServiceException {
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/spawn/NotSpawnedServiceException.java b/src/main/java/com/l2jserver/service/game/spawn/NotSpawnedServiceException.java
new file mode 100644
index 000000000..7a869ec6e
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/spawn/NotSpawnedServiceException.java
@@ -0,0 +1,11 @@
+package com.l2jserver.service.game.spawn;
+
+
+/**
+ * Exception thrown when trying to unspawn an object that is not spawned
+ *
+ * @author Rogiel
+ */
+public class NotSpawnedServiceException extends SpawnServiceException {
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/spawn/SpawnPointNotFoundServiceException.java b/src/main/java/com/l2jserver/service/game/spawn/SpawnPointNotFoundServiceException.java
new file mode 100644
index 000000000..24b153c59
--- /dev/null
+++ b/src/main/java/com/l2jserver/service/game/spawn/SpawnPointNotFoundServiceException.java
@@ -0,0 +1,12 @@
+package com.l2jserver.service.game.spawn;
+
+
+/**
+ * Exception thrown when the target spawn point is not found
+ *
+ * @author Rogiel
+ */
+public class SpawnPointNotFoundServiceException extends
+ SpawnServiceException {
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/service/game/SpawnService.java b/src/main/java/com/l2jserver/service/game/spawn/SpawnService.java
similarity index 76%
rename from src/main/java/com/l2jserver/service/game/SpawnService.java
rename to src/main/java/com/l2jserver/service/game/spawn/SpawnService.java
index c832e7fb0..66460b7a0 100644
--- a/src/main/java/com/l2jserver/service/game/SpawnService.java
+++ b/src/main/java/com/l2jserver/service/game/spawn/SpawnService.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.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 Rogiel
- */
- public class AlreadySpawnedServiceException extends L2SpawnServiceException {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * Exception thrown when the target spawn point is not found
- *
- * @author Rogiel
- */
- public class SpawnPointNotFoundServiceException extends
- L2SpawnServiceException {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * Exception thrown when trying to unspawn an object that is not spawned
- *
- * @author Rogiel
- */
- public class NotSpawnedServiceException extends L2SpawnServiceException {
- private static final long serialVersionUID = 1L;
- }
}
diff --git a/src/main/java/com/l2jserver/util/exception/L2CharacterServiceException.java b/src/main/java/com/l2jserver/service/game/spawn/SpawnServiceException.java
similarity index 72%
rename from src/main/java/com/l2jserver/util/exception/L2CharacterServiceException.java
rename to src/main/java/com/l2jserver/service/game/spawn/SpawnServiceException.java
index 0803b44bd..95139746a 100644
--- a/src/main/java/com/l2jserver/util/exception/L2CharacterServiceException.java
+++ b/src/main/java/com/l2jserver/service/game/spawn/SpawnServiceException.java
@@ -14,27 +14,29 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see .
*/
-package com.l2jserver.util.exception;
+package com.l2jserver.service.game.spawn;
+
+import com.l2jserver.service.ServiceException;
/**
* @author Rogiel
*/
-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);
}
}
diff --git a/src/main/java/com/l2jserver/service/game/SpawnServiceImpl.java b/src/main/java/com/l2jserver/service/game/spawn/SpawnServiceImpl.java
similarity index 99%
rename from src/main/java/com/l2jserver/service/game/SpawnServiceImpl.java
rename to src/main/java/com/l2jserver/service/game/spawn/SpawnServiceImpl.java
index 2db927c44..c3277e9b9 100644
--- a/src/main/java/com/l2jserver/service/game/SpawnServiceImpl.java
+++ b/src/main/java/com/l2jserver/service/game/spawn/SpawnServiceImpl.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.service.game;
+package com.l2jserver.service.game.spawn;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/com/l2jserver/service/game/world/CachedWorldIDService.java b/src/main/java/com/l2jserver/service/game/world/CachedWorldIDService.java
index 9c5df2a19..28ce43070 100644
--- a/src/main/java/com/l2jserver/service/game/world/CachedWorldIDService.java
+++ b/src/main/java/com/l2jserver/service/game/world/CachedWorldIDService.java
@@ -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);
}