Jelajahi Sumber

Adding Maven build and Zip

Fixed HTML loading issue.
Zoey76 6 tahun lalu
induk
melakukan
3479827c55
24 mengubah file dengan 216 tambahan dan 192 penghapusan
  1. 44 2
      pom.xml
  2. 43 0
      src/main/assembly/zip.xml
  3. 14 7
      src/main/java/com/l2jserver/gameserver/GameServer.java
  4. 8 8
      src/main/java/com/l2jserver/gameserver/SevenSignsFestival.java
  5. 21 47
      src/main/java/com/l2jserver/gameserver/cache/HtmCache.java
  6. 12 4
      src/main/java/com/l2jserver/gameserver/config/Config.java
  7. 13 13
      src/main/java/com/l2jserver/gameserver/data/sql/impl/CharNameTable.java
  8. 1 1
      src/main/java/com/l2jserver/gameserver/data/xml/impl/SiegeScheduleData.java
  9. 28 28
      src/main/java/com/l2jserver/gameserver/model/olympiad/Olympiad.java
  10. 2 12
      src/main/java/com/l2jserver/gameserver/model/quest/Quest.java
  11. 5 3
      src/main/java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java
  12. 6 13
      src/main/java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java
  13. 7 8
      src/main/java/com/l2jserver/gameserver/scripting/ScriptEngineManager.java
  14. 2 1
      src/main/java/com/l2jserver/gameserver/taskmanager/tasks/TaskScript.java
  15. 0 4
      src/main/java/com/l2jserver/gameserver/util/Util.java
  16. 1 1
      src/main/resources/config/SecondaryAuth.xml
  17. 0 0
      src/main/resources/config/SecondaryAuth.xsd
  18. 7 4
      src/main/resources/config/Server.properties
  19. 1 1
      src/main/resources/config/SiegeSchedule.xml
  20. 0 0
      src/main/resources/config/SiegeSchedule.xsd
  21. 1 1
      src/main/resources/config/botreport_punishments.xml
  22. 0 0
      src/main/resources/config/botreport_punishments.xsd
  23. 0 34
      src/main/resources/data/xsd/ipconfig.xsd
  24. TEMPAT SAMPAH
      src/main/resources/libs/L2J_GeoDriver.jar

+ 44 - 2
pom.xml

@@ -9,17 +9,20 @@
 		<maven.compiler.source>11</maven.compiler.source>
 		<maven.compiler.target>11</maven.compiler.target>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<slf4j.version>1.7.25</slf4j.version>
+		<slf4j.version>1.7.26</slf4j.version>
 		<log4j.version>2.11.1</log4j.version>
 		<InMemoryJavaCompiler.version>1.3.0</InMemoryJavaCompiler.version>
 		<gson.version>2.8.5</gson.version>
 		<weupnp.version>0.1.4</weupnp.version>
 		<l2j-server-mmocore.version>2.6.1.0</l2j-server-mmocore.version>
-		<l2j-server-commons.version>2.6.1.0</l2j-server-commons.version>
+		<l2j-server-commons.version>2.6.1.1</l2j-server-commons.version>
 		<l2j-server-geo-driver.version>2.6.1.0</l2j-server-geo-driver.version>
 		<!-- Test -->
 		<testng.version>6.14.3</testng.version>
 		<mockito-core.version>2.24.5</mockito-core.version>
+		<!-- Plugins -->
+		<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
+		<maven-assembly-plugin.version>3.1.1</maven-assembly-plugin.version>
 	</properties>
 	<repositories>
 		<repository>
@@ -27,6 +30,45 @@
 			<url>https://jitpack.io</url>
 		</repository>
 	</repositories>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<version>${maven-jar-plugin.version}</version>
+				<configuration>
+					<finalName>l2jserver</finalName>
+					<archive>
+						<manifest>
+							<addClasspath>true</addClasspath>
+							<classpathPrefix>libs/</classpathPrefix>
+							<mainClass>com.l2jserver.gameserver.GameServer</mainClass>
+						</manifest>
+					</archive>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<version>${maven-assembly-plugin.version}</version>
+				<executions>
+					<execution>
+						<phase>package</phase>
+						<goals>
+							<goal>single</goal>
+						</goals>
+						<configuration>
+							<finalName>${project.artifactId}-${project.version}</finalName>
+							<appendAssemblyId>false</appendAssemblyId>
+							<descriptors>
+								<descriptor>src/main/assembly/zip.xml</descriptor>
+							</descriptors>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
 	<dependencies>
 		<dependency>
 			<groupId>org.slf4j</groupId>

+ 43 - 0
src/main/assembly/zip.xml

@@ -0,0 +1,43 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+	<id>zip</id>
+	<includeBaseDirectory>false</includeBaseDirectory>
+	<formats>
+		<format>zip</format>
+	</formats>
+	<files>
+		<file>
+			<source>${project.build.directory}/l2jserver.jar</source>
+			<outputDirectory>.</outputDirectory>
+		</file>
+		<file>
+			<source>src/main/resources/GameServer_loop.sh</source>
+			<outputDirectory>.</outputDirectory>
+		</file>
+		<file>
+			<source>src/main/resources/startGameServer.bat</source>
+			<outputDirectory>.</outputDirectory>
+		</file>
+		<file>
+			<source>src/main/resources/startGameServer.sh</source>
+			<outputDirectory>.</outputDirectory>
+		</file>
+	</files>
+	<fileSets>
+		<fileSet>
+			<directory>src/main/resources/</directory>
+			<includes>
+				<include>config/*</include>
+			</includes>
+			<outputDirectory>.</outputDirectory>
+		</fileSet>
+	</fileSets>
+	<dependencySets>
+		<dependencySet>
+			<outputDirectory>libs</outputDirectory>
+			<excludes>
+				<exclude>${project.groupId}:${project.artifactId}:jar:*</exclude>
+			</excludes>
+		</dependencySet>
+	</dependencySets>
+</assembly>

+ 14 - 7
src/main/java/com/l2jserver/gameserver/GameServer.java

@@ -153,6 +153,8 @@ public final class GameServer {
 	
 	private static final String DATAPACK = "-dp";
 	
+	private static final String SCRIPT = "-s";
+	
 	private static final String GEODATA = "-gd";
 	
 	private final SelectorThread<L2GameClient> _selectorThread;
@@ -354,7 +356,7 @@ public final class GameServer {
 		
 		Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
 		
-		LOG.info("IdFactory: Free ObjectID's remaining: {}", IdFactory.getInstance().size());
+		LOG.info("Free Object Ids remaining {}.", IdFactory.getInstance().size());
 		
 		TvTManager.getInstance();
 		KnownListUpdateTaskManager.getInstance();
@@ -425,14 +427,19 @@ public final class GameServer {
 	public static void main(String[] args) throws Exception {
 		Config.load();
 		
-		final String dp = Util.parseArg(args, DATAPACK, true);
-		if (dp != null) {
-			Config.DATAPACK_ROOT = new File(dp);
+		final String dataPack = Util.parseArg(args, DATAPACK, true);
+		if (dataPack != null) {
+			Config.DATAPACK_ROOT = new File(dataPack);
+		}
+		
+		final String scriptRoot = Util.parseArg(args, SCRIPT, true);
+		if (scriptRoot != null) {
+			Config.SCRIPT_ROOT = new File(scriptRoot);
 		}
 		
-		final String gd = Util.parseArg(args, GEODATA, true);
-		if (gd != null) {
-			Config.GEODATA_PATH = Paths.get(gd);
+		final String geodata = Util.parseArg(args, GEODATA, true);
+		if (geodata != null) {
+			Config.GEODATA_PATH = Paths.get(geodata);
 		}
 		
 		gameServer = new GameServer();

+ 8 - 8
src/main/java/com/l2jserver/gameserver/SevenSignsFestival.java

@@ -786,7 +786,7 @@ public class SevenSignsFestival implements SpawnListener {
 		restoreFestivalData();
 		
 		if (SevenSigns.getInstance().isSealValidationPeriod()) {
-			LOG.info("SevenSignsFestival: Initialization bypassed due to Seal Validation in effect.");
+			LOG.info("Initialization bypassed due to Seal Validation in effect.");
 			return;
 		}
 		
@@ -901,7 +901,7 @@ public class SevenSignsFestival implements SpawnListener {
 		setNextFestivalStart(Config.ALT_FESTIVAL_MANAGER_START + FESTIVAL_SIGNUP_TIME);
 		_managerScheduledTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(_managerInstance, Config.ALT_FESTIVAL_MANAGER_START, Config.ALT_FESTIVAL_CYCLE_LENGTH);
 		
-		LOG.info("SevenSignsFestival: The first Festival of Darkness cycle begins in {} minute(s).", TimeUnit.MILLISECONDS.toMinutes(Config.ALT_FESTIVAL_MANAGER_START));
+		LOG.info("The first Festival of Darkness cycle begins in {} minute(s).", TimeUnit.MILLISECONDS.toMinutes(Config.ALT_FESTIVAL_MANAGER_START));
 	}
 	
 	/**
@@ -933,7 +933,7 @@ public class SevenSignsFestival implements SpawnListener {
 				_festivalData.put(festivalCycle, tempData);
 			}
 		} catch (SQLException e) {
-			LOG.error("SevenSignsFestival: Failed to load configuration!", e);
+			LOG.error("Failed to load configuration!", e);
 		}
 		
 		StringBuilder query = new StringBuilder();
@@ -961,7 +961,7 @@ public class SevenSignsFestival implements SpawnListener {
 				}
 			}
 		} catch (SQLException e) {
-			LOG.error("SevenSignsFestival: Failed to load configuration!", e);
+			LOG.error("Failed to load configuration!", e);
 		}
 	}
 	
@@ -985,7 +985,7 @@ public class SevenSignsFestival implements SpawnListener {
 			}
 			psInsert.executeBatch();
 		} catch (SQLException e) {
-			LOG.error("SevenSignsFestival: Failed to save configuration!", e);
+			LOG.error("Failed to save configuration!", e);
 		}
 		
 		// Updates Seven Signs DB data also, so call only if really necessary.
@@ -1137,7 +1137,7 @@ public class SevenSignsFestival implements SpawnListener {
 			}
 		}
 		
-		LOG.info("SevenSignsFestival: Reinitialized engine for next competition period.");
+		LOG.info("Reinitialized engine for next competition period.");
 	}
 	
 	public final int getCurrentFestivalCycle() {
@@ -1905,7 +1905,7 @@ public class SevenSignsFestival implements SpawnListener {
 				SpawnTable.getInstance().addNewSpawn(npcSpawn, false);
 				_witchInst = npcSpawn.doSpawn();
 			} catch (Exception e) {
-				LOG.warn("SevenSignsFestival: Error while spawning Festival Witch ID {}!", _witchSpawn._npcId, e);
+				LOG.warn("Error while spawning Festival Witch ID {}!", _witchSpawn._npcId, e);
 			}
 			
 			// Make it appear as though the Witch has appeared there.
@@ -2022,7 +2022,7 @@ public class SevenSignsFestival implements SpawnListener {
 					
 					_npcInsts.add(festivalMob);
 				} catch (Exception e) {
-					LOG.warn("SevenSignsFestival: Error while spawning NPC ID {}!", currSpawn._npcId, e);
+					LOG.warn("Error while spawning NPC ID {}!", currSpawn._npcId, e);
 				}
 			}
 		}

+ 21 - 47
src/main/java/com/l2jserver/gameserver/cache/HtmCache.java

@@ -28,22 +28,25 @@ import java.util.concurrent.ConcurrentHashMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Objects;
 import com.l2jserver.gameserver.config.Config;
-import com.l2jserver.gameserver.util.Util;
 import com.l2jserver.gameserver.util.file.filter.HTMLFilter;
 
 /**
  * HTML Cache.
  * @author Layane
+ * @author Zoey76
  */
 public class HtmCache {
+	
 	private static final Logger LOG = LoggerFactory.getLogger(HtmCache.class);
 	
 	private static final HTMLFilter HTML_FILTER = new HTMLFilter();
 	
-	private static final Map<String, String> _cache = Config.LAZY_CACHE ? new ConcurrentHashMap<>() : new HashMap<>();
+	private static final Map<String, String> HTML_CACHE = Config.LAZY_CACHE ? new ConcurrentHashMap<>() : new HashMap<>();
 	
 	private int _loadedFiles;
+	
 	private long _bytesBuffLen;
 	
 	protected HtmCache() {
@@ -58,18 +61,18 @@ public class HtmCache {
 		if (!Config.LAZY_CACHE) {
 			LOG.info("Html cache start...");
 			parseDir(f);
-			LOG.info("Cache[HTML]: " + String.format("%.3f", getMemoryUsage()) + " megabytes on " + getLoadedFiles() + " files loaded");
+			LOG.info(String.format("%.3f", getMemoryUsage()) + " megabytes on " + getLoadedFiles() + " files loaded");
 		} else {
-			_cache.clear();
+			HTML_CACHE.clear();
 			_loadedFiles = 0;
 			_bytesBuffLen = 0;
-			LOG.info("Cache[HTML]: Running lazy cache");
+			LOG.info("Running lazy cache.");
 		}
 	}
 	
 	public void reloadPath(File f) {
 		parseDir(f);
-		LOG.info("Cache[HTML]: Reloaded specified path.");
+		LOG.info("Reloaded specified path.");
 	}
 	
 	public double getMemoryUsage() {
@@ -98,10 +101,9 @@ public class HtmCache {
 			return null;
 		}
 		
-		final String relpath = Util.getRelativePath(Config.DATAPACK_ROOT, file);
 		String content = null;
-		try (FileInputStream fis = new FileInputStream(file);
-			BufferedInputStream bis = new BufferedInputStream(fis)) {
+		try (var fis = new FileInputStream(file);
+			var bis = new BufferedInputStream(fis)) {
 			final int bytes = bis.available();
 			byte[] raw = new byte[bytes];
 			
@@ -109,7 +111,7 @@ public class HtmCache {
 			content = new String(raw, "UTF-8");
 			content = content.replaceAll("(?s)<!--.*?-->", ""); // Remove html comments
 			
-			String oldContent = _cache.put(relpath, content);
+			String oldContent = HTML_CACHE.put(file.getCanonicalPath(), content);
 			if (oldContent == null) {
 				_bytesBuffLen += bytes;
 				_loadedFiles++;
@@ -122,48 +124,20 @@ public class HtmCache {
 		return content;
 	}
 	
-	public String getHtmForce(String prefix, String path) {
-		String content = getHtm(prefix, path);
-		if (content == null) {
-			content = "<html><body>My text is missing:<br>" + path + "</body></html>";
-			LOG.warn("Cache[HTML]: Missing HTML page: " + path);
-		}
-		return content;
-	}
-	
 	public String getHtm(String prefix, String path) {
-		String newPath = null;
-		String content;
-		if ((prefix != null) && !prefix.isEmpty()) {
-			newPath = prefix + path;
-			content = getHtm(newPath);
-			if (content != null) {
-				return content;
-			}
-		}
-		
-		content = getHtm(path);
-		if ((content != null) && (newPath != null)) {
-			_cache.put(newPath, content);
-		}
-		
-		return content;
-	}
-	
-	private String getHtm(String path) {
-		if ((path == null) || path.isEmpty()) {
-			return ""; // avoid possible NPE
-		}
-		
-		String content = _cache.get(path);
+		final var newPath = Objects.firstNonNull(prefix, "") + path;
+		var content = HTML_CACHE.get(newPath);
 		if (Config.LAZY_CACHE && (content == null)) {
-			content = loadFile(new File(Config.DATAPACK_ROOT, path));
+			content = loadFile(new File(Config.DATAPACK_ROOT, newPath));
+			if (content == null) {
+				content = loadFile(new File(Config.SCRIPT_ROOT, newPath));
+			}
 		}
 		return content;
 	}
 	
 	public boolean contains(String path) {
-		return _cache.containsKey(path);
+		return HTML_CACHE.containsKey(path);
 	}
 	
 	/**
@@ -175,10 +149,10 @@ public class HtmCache {
 	}
 	
 	public static HtmCache getInstance() {
-		return SingletonHolder._instance;
+		return SingletonHolder.INSTANCE;
 	}
 	
 	private static class SingletonHolder {
-		protected static final HtmCache _instance = new HtmCache();
+		protected static final HtmCache INSTANCE = new HtmCache();
 	}
 }

+ 12 - 4
src/main/java/com/l2jserver/gameserver/config/Config.java

@@ -948,6 +948,7 @@ public final class Config {
 	public static Pattern CLAN_NAME_TEMPLATE;
 	public static int MAX_CHARACTERS_NUMBER_PER_ACCOUNT;
 	public static File DATAPACK_ROOT;
+	public static File SCRIPT_ROOT;
 	public static boolean ACCEPT_ALTERNATE_ID;
 	public static int REQUEST_ID;
 	public static boolean RESERVE_HOST_ON_LOGIN = false;
@@ -1154,8 +1155,8 @@ public final class Config {
 		ACCEPT_ALTERNATE_ID = serverSettings.getBoolean("AcceptAlternateID", true);
 		
 		DATABASE_ENGINE = serverSettings.getString("Database", "MySQL");
-		DATABASE_DRIVER = serverSettings.getString("Driver", "com.mysql.jdbc.Driver");
-		DATABASE_URL = serverSettings.getString("URL", "jdbc:mysql://localhost/l2jgs?useSSL=false&serverTimezone=UTC");
+		DATABASE_DRIVER = serverSettings.getString("Driver", "com.mysql.cj.jdbc.Driver");
+		DATABASE_URL = serverSettings.getString("URL", "jdbc:mysql://localhost/l2jgs?serverTimezone=UTC");
 		DATABASE_LOGIN = serverSettings.getString("Login", "root");
 		DATABASE_PASSWORD = serverSettings.getString("Password", "toor");
 		DATABASE_CONNECTION_POOL = serverSettings.getString("ConnectionPool", "HikariCP");
@@ -1164,11 +1165,18 @@ public final class Config {
 		
 		try {
 			DATAPACK_ROOT = new File(serverSettings.getString("DatapackRoot", ".").replaceAll("\\\\", "/")).getCanonicalFile();
-		} catch (IOException e) {
-			LOG.warn("Error setting datapack root!", e);
+		} catch (Exception ex) {
+			LOG.warn("Error setting datapack root!", ex);
 			DATAPACK_ROOT = new File(".");
 		}
 		
+		try {
+			SCRIPT_ROOT = new File(serverSettings.getString("ScriptRoot", "script").replaceAll("\\\\", "/")).getCanonicalFile();
+		} catch (Exception ex) {
+			LOG.warn("Error setting script root!", ex);
+			SCRIPT_ROOT = new File(".");
+		}
+		
 		PLAYER_NAME_TEMPLATE = Pattern.compile(serverSettings.getString("PlayerNameTemplate", "[a-zA-Z0-9]*"));
 		PET_NAME_TEMPLATE = Pattern.compile(serverSettings.getString("PetNameTemplate", "[a-zA-Z0-9]*"));
 		CLAN_NAME_TEMPLATE = Pattern.compile(serverSettings.getString("ClanNameTemplate", "[a-zA-Z0-9]*"));

+ 13 - 13
src/main/java/com/l2jserver/gameserver/data/sql/impl/CharNameTable.java

@@ -94,8 +94,8 @@ public class CharNameTable {
 					accessLevel = rs.getInt(2);
 				}
 			}
-		} catch (Exception e) {
-			LOG.warn("Could not check existing char name!", e);
+		} catch (Exception ex) {
+			LOG.warn("Could not check existing char name!", ex);
 		}
 		
 		if (id > 0) {
@@ -132,8 +132,8 @@ public class CharNameTable {
 					return name;
 				}
 			}
-		} catch (Exception e) {
-			LOG.warn("Could not check existing char id!", e);
+		} catch (Exception ex) {
+			LOG.warn("Could not check existing char id!", ex);
 		}
 		
 		return null; // not found
@@ -154,8 +154,8 @@ public class CharNameTable {
 			try (var rs = ps.executeQuery()) {
 				return rs.next();
 			}
-		} catch (Exception e) {
-			LOG.warn("Could not check existing charname!", e);
+		} catch (Exception ex) {
+			LOG.warn("Could not check existing charname!", ex);
 		}
 		return false;
 	}
@@ -169,8 +169,8 @@ public class CharNameTable {
 					return rset.getInt(1);
 				}
 			}
-		} catch (Exception e) {
-			LOG.warn("Could not check existing char count!", e);
+		} catch (Exception ex) {
+			LOG.warn("Could not check existing char count!", ex);
 		}
 		return 0;
 	}
@@ -184,17 +184,17 @@ public class CharNameTable {
 				_chars.put(id, rs.getString(2));
 				_accessLevels.put(id, rs.getInt(3));
 			}
-		} catch (Exception e) {
-			LOG.warn("Could not load char name!", e);
+		} catch (Exception ex) {
+			LOG.warn("Could not load char name!", ex);
 		}
-		LOG.info(getClass().getSimpleName() + ": Loaded " + _chars.size() + " char names.");
+		LOG.info("Loaded {} char names.", _chars.size());
 	}
 	
 	public static CharNameTable getInstance() {
-		return SingletonHolder._instance;
+		return SingletonHolder.INSTANCE;
 	}
 	
 	private static class SingletonHolder {
-		protected static final CharNameTable _instance = new CharNameTable();
+		protected static final CharNameTable INSTANCE = new CharNameTable();
 	}
 }

+ 1 - 1
src/main/java/com/l2jserver/gameserver/data/xml/impl/SiegeScheduleData.java

@@ -52,7 +52,7 @@ public class SiegeScheduleData implements IXmlReader {
 	public synchronized void load() {
 		_scheduleData.clear();
 		parseFile(new File("config/SiegeSchedule.xml"));
-		LOG.info("Loaded: {} siege schedulers.", _scheduleData.size());
+		LOG.info("Loaded {} siege schedulers.", _scheduleData.size());
 		
 		if (_scheduleData.isEmpty()) {
 			_scheduleData.add(new SiegeScheduleDate(new StatsSet()));

+ 28 - 28
src/main/java/com/l2jserver/gameserver/model/olympiad/Olympiad.java

@@ -196,18 +196,18 @@ public class Olympiad extends ListenersContainer {
 				loaded = true;
 			}
 		} catch (Exception e) {
-			_log.log(Level.WARNING, "Olympiad System: Error loading olympiad data from database: ", e);
+			_log.log(Level.WARNING, "Error loading olympiad data from database: ", e);
 		}
 		
 		if (!loaded) {
-			_log.log(Level.INFO, "Olympiad System: failed to load data from database, trying to load from file.");
+			_log.log(Level.INFO, "Failed to load data from database, trying to load from file.");
 			
 			Properties OlympiadProperties = new Properties();
 			try (InputStream is = new FileInputStream(Config.OLYMPIAD_CONFIG_FILE)) {
 				
 				OlympiadProperties.load(is);
 			} catch (Exception e) {
-				_log.log(Level.SEVERE, "Olympiad System: Error loading olympiad properties: ", e);
+				_log.log(Level.SEVERE, "Error loading olympiad properties: ", e);
 				return;
 			}
 			
@@ -238,7 +238,7 @@ public class Olympiad extends ListenersContainer {
 				}
 				break;
 			default:
-				_log.warning("Olympiad System: Omg something went wrong in loading!! Period = " + _period);
+				_log.warning("Omg something went wrong in loading!! Period = " + _period);
 				return;
 		}
 		
@@ -264,15 +264,15 @@ public class Olympiad extends ListenersContainer {
 				addNobleStats(rset.getInt(CHAR_ID), statData);
 			}
 		} catch (Exception e) {
-			_log.log(Level.WARNING, "Olympiad System: Error loading noblesse data from database: ", e);
+			_log.log(Level.WARNING, "Error loading noblesse data from database: ", e);
 		}
 		
 		synchronized (this) {
-			_log.info("Olympiad System: Loading Olympiad System....");
+			_log.info("Loading Olympiad System....");
 			if (_period == 0) {
-				_log.info("Olympiad System: Currently in Olympiad Period");
+				_log.info("Currently in Olympiad Period");
 			} else {
-				_log.info("Olympiad System: Currently in Validation Period");
+				_log.info("Currently in Validation Period");
 			}
 			
 			long milliToEnd;
@@ -282,16 +282,16 @@ public class Olympiad extends ListenersContainer {
 				milliToEnd = getMillisToValidationEnd();
 			}
 			
-			_log.info("Olympiad System: " + (milliToEnd / 60000) + " minutes until period ends");
+			_log.info("" + (milliToEnd / 60000) + " minutes until period ends");
 			
 			if (_period == 0) {
 				milliToEnd = getMillisToWeekChange();
 				
-				_log.info("Olympiad System: Next weekly change is in " + (milliToEnd / 60000) + " minutes");
+				_log.info("Next weekly change is in " + (milliToEnd / 60000) + " minutes");
 			}
 		}
 		
-		_log.info("Olympiad System: Loaded " + NOBLES.size() + " Nobles");
+		_log.info("Loaded " + NOBLES.size() + " Nobles");
 		
 	}
 	
@@ -306,7 +306,7 @@ public class Olympiad extends ListenersContainer {
 				tmpPlace.put(rs.getInt(CHAR_ID), place++);
 			}
 		} catch (Exception e) {
-			_log.log(Level.WARNING, "Olympiad System: Error loading noblesse data from database for Ranking: ", e);
+			_log.log(Level.WARNING, "Error loading noblesse data from database for Ranking: ", e);
 		}
 		
 		int rank1 = (int) Math.round(tmpPlace.size() * 0.01);
@@ -423,9 +423,9 @@ public class Olympiad extends ListenersContainer {
 			int numHours = (int) Math.floor(countDown % 24);
 			int numDays = (int) Math.floor((countDown - numHours) / 24);
 			
-			_log.info("Olympiad System: Competition Period Starts in " + numDays + " days, " + numHours + " hours and " + numMins + " mins.");
+			_log.info("Competition Period Starts in " + numDays + " days, " + numHours + " hours and " + numMins + " mins.");
 			
-			_log.info("Olympiad System: Event starts/started : " + _compStart.getTime());
+			_log.info("Event starts/started : " + _compStart.getTime());
 		}
 		
 		_scheduledCompStart = ThreadPoolManager.getInstance().scheduleGeneral(() -> {
@@ -436,7 +436,7 @@ public class Olympiad extends ListenersContainer {
 			_inCompPeriod = true;
 			
 			Broadcast.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.THE_OLYMPIAD_GAME_HAS_STARTED));
-			_log.info("Olympiad System: Olympiad Game Started");
+			_log.info("Olympiad Game Started");
 			
 			LOG_OLYMPIAD.info("Result,Player1,Player2,Player1 HP,Player2 HP,Player1 Damage,Player2 Damage,Points,Classed");
 			
@@ -456,7 +456,7 @@ public class Olympiad extends ListenersContainer {
 				}
 				_inCompPeriod = false;
 				Broadcast.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.THE_OLYMPIAD_GAME_HAS_ENDED));
-				_log.info("Olympiad System: Olympiad Game Ended");
+				_log.info("Olympiad Game Ended");
 				
 				while (OlympiadGameManager.getInstance().isBattleStarted()) // cleared in game manager
 				{
@@ -552,7 +552,7 @@ public class Olympiad extends ListenersContainer {
 		_compStart.add(Calendar.HOUR_OF_DAY, 24);
 		_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
 		
-		_log.info("Olympiad System: New Schedule @ " + _compStart.getTime());
+		_log.info("New Schedule @ " + _compStart.getTime());
 		
 		return (_compStart.getTimeInMillis() - Calendar.getInstance().getTimeInMillis());
 	}
@@ -573,9 +573,9 @@ public class Olympiad extends ListenersContainer {
 	private void scheduleWeeklyChange() {
 		_scheduledWeeklyTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() -> {
 			addWeeklyPoints();
-			_log.info("Olympiad System: Added weekly points to nobles");
+			_log.info("Added weekly points to nobles");
 			resetWeeklyMatches();
-			_log.info("Olympiad System: Reset weekly matches to nobles");
+			_log.info("Reset weekly matches to nobles");
 			
 			Calendar nextChange = Calendar.getInstance();
 			_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
@@ -683,7 +683,7 @@ public class Olympiad extends ListenersContainer {
 				}
 			}
 		} catch (Exception e) {
-			_log.log(Level.SEVERE, "Olympiad System: Failed to save noblesse data to database: ", e);
+			_log.log(Level.SEVERE, "Failed to save noblesse data to database: ", e);
 		}
 	}
 	
@@ -707,7 +707,7 @@ public class Olympiad extends ListenersContainer {
 			ps.setLong(10, _nextWeeklyChange);
 			ps.execute();
 		} catch (Exception e) {
-			_log.log(Level.SEVERE, "Olympiad System: Failed to save olympiad data to database: ", e);
+			_log.log(Level.SEVERE, "Failed to save olympiad data to database: ", e);
 		}
 		
 		//@formatter:off
@@ -724,7 +724,7 @@ public class Olympiad extends ListenersContainer {
 		}
 		catch (Exception e)
 		{
-			_log.log(Level.WARNING, "Olympiad System: Unable to save olympiad properties to file: ", e);
+			_log.log(Level.WARNING, "Unable to save olympiad properties to file: ", e);
 		}
 		*/
 		//@formatter:on
@@ -737,7 +737,7 @@ public class Olympiad extends ListenersContainer {
 			s1.executeUpdate(OLYMPIAD_MONTH_CLEAR);
 			s2.executeUpdate(OLYMPIAD_MONTH_CREATE);
 		} catch (Exception e) {
-			_log.log(Level.SEVERE, "Olympiad System: Failed to update monthly noblese data: ", e);
+			_log.log(Level.SEVERE, "Failed to update monthly noblese data: ", e);
 		}
 	}
 	
@@ -840,7 +840,7 @@ public class Olympiad extends ListenersContainer {
 				}
 			}
 		} catch (Exception e) {
-			_log.warning("Olympiad System: Couldnt load heros from DB");
+			_log.warning("Couldnt load heros from DB");
 		}
 	}
 	
@@ -856,7 +856,7 @@ public class Olympiad extends ListenersContainer {
 				}
 			}
 		} catch (Exception e) {
-			_log.warning("Olympiad System: Couldn't load olympiad leaders from DB!");
+			_log.warning("Couldn't load olympiad leaders from DB!");
 		}
 		return names;
 	}
@@ -1035,7 +1035,7 @@ public class Olympiad extends ListenersContainer {
 			var s = con.createStatement()) {
 			s.executeUpdate(OLYMPIAD_DELETE_ALL);
 		} catch (Exception e) {
-			_log.warning("Olympiad System: Couldn't delete nobles from DB!");
+			_log.warning("Couldn't delete nobles from DB!");
 		}
 		NOBLES.clear();
 	}
@@ -1050,10 +1050,10 @@ public class Olympiad extends ListenersContainer {
 	}
 	
 	public static Olympiad getInstance() {
-		return SingletonHolder._instance;
+		return SingletonHolder.INSTANCE;
 	}
 	
 	private static class SingletonHolder {
-		protected static final Olympiad _instance = new Olympiad();
+		protected static final Olympiad INSTANCE = new Olympiad();
 	}
 }

+ 2 - 12
src/main/java/com/l2jserver/gameserver/model/quest/Quest.java

@@ -2340,20 +2340,10 @@ public class Quest extends AbstractScript implements IIdentifiable {
 	 * @return the HTML file contents
 	 */
 	public String getHtm(String prefix, String fileName) {
-		final HtmCache hc = HtmCache.getInstance();
-		String content = hc.getHtm(prefix, fileName.startsWith("data/") ? fileName : "../java/com/l2jserver/datapack/" + getDescr().toLowerCase() + "/" + getName() + "/" + fileName);
-		if (content == null) {
-			content = hc.getHtm(prefix, "../java/com/l2jserver/datapack/" + getDescr() + "/" + getName() + "/" + fileName);
-			if (content == null) {
-				content = hc.getHtmForce(prefix, "../java/com/l2jserver/datapack/quests/" + getName() + "/" + fileName);
-			}
-		}
-		return content;
+		final var path = fileName.startsWith("data/") ? fileName : getClass().getPackageName().replace('.', '/') + "/" + fileName;
+		return HtmCache.getInstance().getHtm(prefix, path);
 	}
 	
-	/**
-	 * @return the registered quest items IDs.
-	 */
 	public int[] getRegisteredItemIds() {
 		return _questItemIds;
 	}

+ 5 - 3
src/main/java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java

@@ -50,10 +50,12 @@ import com.l2jserver.gameserver.network.serverpackets.CharSelectionInfo;
 
 @SuppressWarnings("unused")
 public final class CharacterCreate extends L2GameClientPacket {
+	
+	private static final Logger LOG_ACCOUNTING = LoggerFactory.getLogger("accounting");
+	
 	private static final String _C__0C_CHARACTERCREATE = "[C] 0C CharacterCreate";
-	private static final int PLAYER_NAME_MAX_LENGHT = 16;
 	
-	private static final Logger LOG = LoggerFactory.getLogger("accounting");
+	private static final int PLAYER_NAME_MAX_LENGHT = 16;
 	
 	// cSdddddddddddd
 	private String _name;
@@ -175,7 +177,7 @@ public final class CharacterCreate extends L2GameClientPacket {
 		
 		initNewChar(getClient(), newChar);
 		
-		LOG.info("Created new character {} {}.", newChar, getClient());
+		LOG_ACCOUNTING.info("Created new character {} {}.", newChar, getClient());
 	}
 	
 	private boolean isValidName(String text) {

+ 6 - 13
src/main/java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java

@@ -18,9 +18,8 @@
  */
 package com.l2jserver.gameserver.network.clientpackets;
 
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.l2jserver.gameserver.SevenSignsFestival;
 import com.l2jserver.gameserver.config.Config;
@@ -35,13 +34,11 @@ import com.l2jserver.gameserver.network.serverpackets.CharSelectionInfo;
 import com.l2jserver.gameserver.network.serverpackets.RestartResponse;
 import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
 
-/**
- * This class ...
- * @version $Revision: 1.11.2.1.2.4 $ $Date: 2005/03/27 15:29:30 $
- */
 public final class RequestRestart extends L2GameClientPacket {
+	
+	private static final Logger LOG_ACCOUNTING = LoggerFactory.getLogger("accounting");
+	
 	private static final String _C__57_REQUESTRESTART = "[C] 57 RequestRestart";
-	protected static final Logger _logAccounting = Logger.getLogger("accounting");
 	
 	@Override
 	protected void readImpl() {
@@ -110,11 +107,7 @@ public final class RequestRestart extends L2GameClientPacket {
 		
 		final L2GameClient client = getClient();
 		
-		LogRecord record = new LogRecord(Level.INFO, "Logged out");
-		record.setParameters(new Object[] {
-			client
-		});
-		_logAccounting.log(record);
+		LOG_ACCOUNTING.info("{} logged out.", client);
 		
 		// detach the client from the char so that the connection isnt closed in the deleteMe
 		player.setClient(null);

+ 7 - 8
src/main/java/com/l2jserver/gameserver/scripting/ScriptEngineManager.java

@@ -18,6 +18,8 @@
  */
 package com.l2jserver.gameserver.scripting;
 
+import static com.l2jserver.gameserver.config.Config.SCRIPT_ROOT;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -46,10 +48,7 @@ import com.l2jserver.gameserver.config.Config;
 public final class ScriptEngineManager {
 	private static final Logger LOG = LoggerFactory.getLogger(ScriptEngineManager.class);
 	
-	// TODO(Zoey76): Implement this correctly.
-	public static final File SCRIPT_FOLDER = new File(Config.DATAPACK_ROOT.getParentFile(), "java");
-	
-	private static final String CLASS_PATH = SCRIPT_FOLDER.getAbsolutePath() + System.getProperty("path.separator") + System.getProperty("java.class.path");
+	private static final String CLASS_PATH = SCRIPT_ROOT.getAbsolutePath() + System.getProperty("path.separator") + System.getProperty("java.class.path");
 	
 	private static final String MAIN = "main";
 	
@@ -66,7 +65,7 @@ public final class ScriptEngineManager {
 	public void executeScriptList(File list) throws Exception {
 		if (Config.NO_QUESTS) {
 			if (!Config.NO_HANDLERS) {
-				addSource(new File(SCRIPT_FOLDER, "com/l2jserver/datapack/handlers/MasterHandler.java"));
+				addSource(new File(SCRIPT_ROOT, "com/l2jserver/datapack/handlers/MasterHandler.java"));
 				LOG.info("Handlers loaded, all other scripts skipped!");
 			}
 			return;
@@ -93,7 +92,7 @@ public final class ScriptEngineManager {
 							line = line.substring(0, line.length() - 2);
 						}
 						
-						final File file = new File(SCRIPT_FOLDER, line);
+						final File file = new File(SCRIPT_ROOT, line);
 						if (file.isDirectory() && parts[0].endsWith("/**")) {
 							executeAllScriptsInDirectory(file, true);
 						} else if (file.isDirectory() && parts[0].endsWith("/*")) {
@@ -156,7 +155,7 @@ public final class ScriptEngineManager {
 	}
 	
 	public void executeScript(String file) throws Exception {
-		executeScript(new File(SCRIPT_FOLDER, file));
+		executeScript(new File(SCRIPT_ROOT, file));
 	}
 	
 	public void addSource(File file) {
@@ -175,7 +174,7 @@ public final class ScriptEngineManager {
 	
 	private static String getClassForFile(File script) {
 		final String path = script.getAbsolutePath();
-		final String scpPath = SCRIPT_FOLDER.getAbsolutePath();
+		final String scpPath = SCRIPT_ROOT.getAbsolutePath();
 		if (path.startsWith(scpPath)) {
 			final int idx = path.lastIndexOf('.');
 			return path.substring(scpPath.length() + 1, idx).replace('/', '.').replace('\\', '.');

+ 2 - 1
src/main/java/com/l2jserver/gameserver/taskmanager/tasks/TaskScript.java

@@ -23,6 +23,7 @@ import java.io.File;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.l2jserver.gameserver.config.Config;
 import com.l2jserver.gameserver.scripting.ScriptEngineManager;
 import com.l2jserver.gameserver.taskmanager.Task;
 import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
@@ -43,7 +44,7 @@ public class TaskScript extends Task {
 	
 	@Override
 	public void onTimeElapsed(ExecutedTask task) {
-		final File file = new File(ScriptEngineManager.SCRIPT_FOLDER, "cron/" + task.getParams()[2]);
+		final File file = new File(Config.SCRIPT_ROOT, "com/l2jserver/datapack/cron/" + task.getParams()[2]);
 		if (!file.isFile()) {
 			LOG.warn("File not found {}!", task.getParams()[2]);
 			return;

+ 0 - 4
src/main/java/com/l2jserver/gameserver/util/Util.java

@@ -57,10 +57,6 @@ public final class Util {
 		ThreadPoolManager.getInstance().scheduleGeneral(new IllegalPlayerActionTask(actor, message, punishment), 5000);
 	}
 	
-	public static String getRelativePath(File base, File file) {
-		return file.toURI().getPath().substring(base.toURI().getPath().length());
-	}
-	
 	/**
 	 * @param from
 	 * @param to

+ 1 - 1
src/main/resources/config/SecondaryAuth.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../data/xsd/SecondaryAuth.xsd">
+<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SecondaryAuth.xsd">
 	<enabled>false</enabled> <!-- Enable Secondary Authentication on Character Select -->
 	<maxAttempts>5</maxAttempts> <!-- Max Attempts for Second Auth Password (0 to disable) -->
 	<banTime>480</banTime> <!-- Ban time if user reach maxAttempts (in minutes) -->

+ 0 - 0
src/main/resources/data/xsd/SecondaryAuth.xsd → src/main/resources/config/SecondaryAuth.xsd


+ 7 - 4
src/main/resources/config/Server.properties

@@ -47,19 +47,19 @@ Database = MySQL
 
 # Specify the appropriate driver and url for the database you're using.
 # Examples:
-# Driver = com.mysql.jdbc.Driver
+# Driver = com.mysql.cj.jdbc.Driver
 # Driver = org.hsqldb.jdbcDriver
 # Driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
 # Driver = org.mariadb.jdbc.Driver
 # Default: com.mysql.cj.jdbc.Driver
 Driver = com.mysql.cj.jdbc.Driver
 # Database URL
-# URL = jdbc:mysql://localhost/l2jgs?useSSL=false&serverTimezone=UTC
+# URL = jdbc:mysql://localhost/l2jgs?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC
 # URL = jdbc:hsqldb:hsql://localhost/l2jgs
 # URL = jdbc:sqlserver://localhost/database = l2jgs/user = sa/password = 
 # URL = jdbc:mariadb://localhost/l2jgs
-# Default: jdbc:mysql://localhost/l2jgs?useSSL=false&serverTimezone=UTC
-URL = jdbc:mysql://localhost/l2jgs?useSSL=false&serverTimezone=UTC
+# Default: jdbc:mysql://localhost/l2jgs?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC
+URL = jdbc:mysql://localhost/l2jgs?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC
 # Database user info (default is "root" but it's not recommended)
 Login = root
 # Database connection password
@@ -95,6 +95,9 @@ AcceptAlternateID = True
 #Default: .
 DatapackRoot = .
 
+# Scripts root directory.
+ScriptRoot = script
+
 # Define how many players are allowed to play simultaneously on your server.
 # Default: 500
 MaximumOnlineUsers = 500

+ 1 - 1
src/main/resources/config/SiegeSchedule.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../data/xsd/SiegeSchedule.xsd">
+<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SiegeSchedule.xsd">
 	<schedule day="SUNDAY" hour="16" maxConcurrent="5" />
 	<schedule day="SUNDAY" hour="20" maxConcurrent="5" />
 </list>

+ 0 - 0
src/main/resources/data/xsd/SiegeSchedule.xsd → src/main/resources/config/SiegeSchedule.xsd


+ 1 - 1
src/main/resources/config/botreport_punishments.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../data/xsd/botreport_punishments.xsd">
+<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="botreport_punishments.xsd">
 	<!-- To add a range punishments (E.G., a debuff which apply if you have 150 reports or more, use negative neededReportCount -->
 	<punishment neededReportCount="25" skillId="6038" skillLevel="1" sysMessageId="2473" />
 	<punishment neededReportCount="75" skillId="6039" skillLevel="1" sysMessageId="2474" />

+ 0 - 0
src/main/resources/data/xsd/botreport_punishments.xsd → src/main/resources/config/botreport_punishments.xsd


+ 0 - 34
src/main/resources/data/xsd/ipconfig.xsd

@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-	<xs:element name="gameserver">
-		<xs:complexType>
-			<xs:sequence minOccurs="1" maxOccurs="1">
-				<xs:element name="define" minOccurs="1" maxOccurs="unbounded">
-					<xs:complexType>
-						<xs:attribute name="address" use="required">
-							<xs:simpleType>
-								<xs:restriction base="xs:token">
-									<xs:pattern value="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|[.]?.*[.x][a-z]{2,3}" />
-								</xs:restriction>
-							</xs:simpleType>
-						</xs:attribute>
-						<xs:attribute name="subnet" use="required">
-							<xs:simpleType>
-								<xs:restriction base="xs:token">
-									<xs:pattern value="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?/\d+)|(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|[.]?.*[.x][a-z]{2,3}" />
-								</xs:restriction>
-							</xs:simpleType>
-						</xs:attribute>
-					</xs:complexType>
-				</xs:element>
-			</xs:sequence>
-			<xs:attribute name="address" use="required">
-				<xs:simpleType>
-					<xs:restriction base="xs:token">
-						<xs:pattern value="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|[.]?.*[.x][a-z]{2,3}" />
-					</xs:restriction>
-				</xs:simpleType>
-			</xs:attribute>
-		</xs:complexType>
-	</xs:element>
-</xs:schema>

TEMPAT SAMPAH
src/main/resources/libs/L2J_GeoDriver.jar