Bladeren bron

Removing tools from L2J Server

The idea is to clean L2J Server, in order to dockerize it, as well as
empowering the L2J Server CLI for common tasks such as server setup.

Removed Database Installer.
Removed Account Manager.
Removed Game Server Register.

Use https://bitbucket.org/l2jserver/l2j-server-cli/
Zoey76 6 jaren geleden
bovenliggende
commit
a1979bac09
33 gewijzigde bestanden met toevoegingen van 3 en 4002 verwijderingen
  1. 2 1
      .settings/org.eclipse.jdt.core.prefs
  2. 1 40
      build.gradle
  3. BIN
      dist/images/add.png
  4. BIN
      dist/images/cross.png
  5. 0 80
      dist/languages/gsregister/GSRegister.properties
  6. 0 5
      dist/login/RegisterGameServer.bat
  7. BIN
      dist/login/RegisterGameServer.exe
  8. 0 2
      dist/login/RegisterGameServer.sh
  9. 0 22
      dist/login/startSQLAccountManager.bat
  10. 0 2
      dist/login/startSQLAccountManager.sh
  11. 0 266
      src/main/java/com/l2jserver/tools/accountmanager/SQLAccountManager.java
  12. 0 108
      src/main/java/com/l2jserver/tools/dbinstaller/DatabaseInstaller.java
  13. 0 31
      src/main/java/com/l2jserver/tools/dbinstaller/LauncherGS.java
  14. 0 31
      src/main/java/com/l2jserver/tools/dbinstaller/LauncherLS.java
  15. 0 183
      src/main/java/com/l2jserver/tools/dbinstaller/RunTasks.java
  16. 0 249
      src/main/java/com/l2jserver/tools/dbinstaller/frontend/stdio/DBInstallerStdio.java
  17. 0 114
      src/main/java/com/l2jserver/tools/dbinstaller/frontend/swing/AbstractGUI.java
  18. 0 214
      src/main/java/com/l2jserver/tools/dbinstaller/frontend/swing/DBConfigGUI.java
  19. 0 91
      src/main/java/com/l2jserver/tools/dbinstaller/frontend/swing/DBInstallerGUI.java
  20. 0 605
      src/main/java/com/l2jserver/tools/gsregistering/BaseGameServerRegister.java
  21. 0 389
      src/main/java/com/l2jserver/tools/gsregistering/GUserInterface.java
  22. 0 343
      src/main/java/com/l2jserver/tools/gsregistering/GameServerRegister.java
  23. 0 199
      src/main/java/com/l2jserver/tools/gsregistering/RegisterDialog.java
  24. 0 37
      src/main/java/com/l2jserver/tools/util/ResourceUtil.java
  25. 0 286
      src/main/java/com/l2jserver/tools/util/SQLUtil.java
  26. 0 52
      src/main/java/com/l2jserver/tools/util/SwingUtil.java
  27. 0 45
      src/main/java/com/l2jserver/tools/util/app/IApplicationFrontend.java
  28. 0 148
      src/main/java/com/l2jserver/tools/util/io/CloseShieldedInputStream.java
  29. 0 49
      src/main/java/com/l2jserver/tools/util/io/FileWriterStdout.java
  30. 0 28
      src/main/java/com/l2jserver/tools/util/swing/BackgroundTask.java
  31. 0 116
      src/main/java/com/l2jserver/tools/util/swing/BackgroundTaskRunner.java
  32. 0 226
      src/main/java/com/l2jserver/tools/util/swing/SpringUtilities.java
  33. 0 40
      src/main/java/com/l2jserver/util/file/filter/SQLFilter.java

+ 2 - 1
.settings/org.eclipse.jdt.core.prefs

@@ -113,6 +113,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
 org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
 org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.release=disabled
 org.eclipse.jdt.core.compiler.source=11
 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
 org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
@@ -220,7 +221,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_label=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
 org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
 org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=insert
 org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
 org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert

+ 1 - 40
build.gradle

@@ -46,9 +46,7 @@ def generalManifest = manifest {
 
 jar {
 	archiveName = 'l2jserver.jar'
-	exclude('**/dbinstaller/**')
 	exclude('**/loginserver/**')
-	exclude('**/accountmanager/**')
 	exclude('**/gsregistering/**')
 	manifest {
 		from(generalManifest)
@@ -59,7 +57,6 @@ jar {
 task loginJar(type: Jar, dependsOn: classes) {
 	from(sourceSets.main.output)
 	archiveName = 'l2jlogin.jar'
-	exclude('**/dbinstaller/**')
 	exclude('**/gameserver/**')
 	manifest {
 		from(generalManifest)
@@ -73,8 +70,6 @@ task configuratorJar(type: Jar, dependsOn: classes) {
 	include('**/configurator/**')
 	include('**/i18n/**')
 	include('**/images/**')
-	exclude('**/accountmanager/**')
-	exclude('**/dbinstaller/**')
 	exclude('**/gameserver/**')
 	exclude('**/gsregistering/**')
 	exclude('**/log/**')
@@ -90,38 +85,8 @@ task configuratorJar(type: Jar, dependsOn: classes) {
 	}
 }
 
-task dbInstLsJar(type: Jar, dependsOn: classes) {
-	from(sourceSets.main.output)
-	archiveName = 'dbinst_ls.jar'
-	include '**/tools/*'
-	include '**/dbinstaller/**'
-	include '**/images/**'
-	include '**/util/**'
-	include '**/SQLFilter**'
-	exclude '**/LauncherGS*'
-	manifest {
-		from(generalManifest)
-		attributes('Main-Class': 'com.l2jserver.tools.dbinstaller.LauncherLS')
-	}
-}
-
-task dbInstGsJar(type: Jar, dependsOn: classes) {
-	from(sourceSets.main.output)
-	archiveName = 'dbinst_gs.jar'
-	include '**/tools/*'
-	include('**/dbinstaller/**')
-	include('**/images/**')
-	include('**/util/**')
-	include('**/SQLFilter**')
-	exclude('**/LauncherLS*')
-	manifest {
-		from(generalManifest)
-		attributes 'Main-Class': 'com.l2jserver.tools.dbinstaller.LauncherGS'
-	}
-}
-
 artifacts {
-	archives loginJar, configuratorJar, dbInstLsJar, dbInstGsJar
+	archives loginJar, configuratorJar
 }
 
 task zip(type: Zip, dependsOn: build) {
@@ -138,10 +103,6 @@ task zip(type: Zip, dependsOn: build) {
 	into('login') {
 		from(loginJar)
 	}
-	into('tools') {
-		from(dbInstLsJar)
-		from(dbInstGsJar)
-	}
 	
 	baseName = 'L2J_Server_' + new Date().format("yyyy-MM-dd")
 	println 'Build in build/distributions/' + baseName + '.zip'

BIN
dist/images/add.png


BIN
dist/images/cross.png


+ 0 - 80
dist/languages/gsregister/GSRegister.properties

@@ -1,80 +0,0 @@
-language = English
-toolName = GS Registering Tool
-
-error = Error
-reason = Reason:
-yes = Yes
-no = No
-
-fileMenu = File
-exitItem = Exit
-helpMenu = Help
-aboutItem = About
-
-btnRemove = Remove
-btnRemoveAll = Remove All
-btnRegister = Register GameServer
-confirmRemoveTitle = Confirm Removal
-confirmRemoveText = Are you sure you want to remove GameServer %d - %s?
-confirmRemoveAllText = Are you sure you want to remove ALL GameServers?
-gsListRetrieveError = There was an error while attempting to retrieve the list of currently registered GameServers.
-
-gsName = GameServer Name
-gsAction = Action
-
-registerGS = Register GameServer
-serverName = Server name:
-save = Save
-cancel = Cancel
-saveHexId = The hexid.txt file should be saved on GameServer's 'configs' folder to properly complete this process.
-hexidDest = Choose hexid file destination folder...
-
-purpose = Allows to register/remove GameServers from LoginServer.
-options = Options:
-fallbackOpt = If during the register operation the specified GameServer ID is in use, an attempt with the first available ID will be made.
-forceOpt = Forces GameServer register operation to overwrite a previous registration on the specified ID, if necessary.
-cmdOpt = Forces this application to run in console mode, even if GUI is supported.
-helpOpt = Shows this help message and exits.
-languageOpt = Attempts to use the language for the specified locale, on failure reverts to auto-detection.
-registerOpt1 = Registers a GameServer on ID <id> and saves the hexid.txt file on <hexid_dest_dir>.
-registerOpt2 = You can provide a negative value for <id> to register under the first available ID.
-registerOpt3 = Nothing is done if <id> is already in use, unless --force or --fallback is used.
-unregisterOpt = Removes the GameServer specified by <id>, use "all" to remove all currently registered GameServers.
-wrongUnregisterArg = wrong argument for GameServer removal, specify a numeric ID or "all" without quotes to remove all.
-noAction = No action to be taken.
-checkingIdInUse = Checking if GameServer ID %d is in use...
-removingGsId = Removing GameServer ID: %d
-forcingRegistration = Forcing registration on ID %d, an existing registration on this ID is being overwritten.
-fallingBack = Trying to register on the first available ID.
-registrationOk = GameServer successfully registered on LoginServer with ID %d.
-unregisterOk = GameServer ID: %d was successfully removed from LoginServer.
-unregisterAllOk = All GameServers were successfully removed.
-noFreeId = There was no free ID available to register.
-sqlErrorRegister = An SQL error occurred while trying to register the GameServer.
-ioErrorRegister = An error saving the hexid file occurred while trying to register the GameServer.
-errorRegister = An error occurred while trying to register the GameServer.
-errorUnregister = An error occurred while trying to remove the GameServer.
-sqlErrorUnregister = An SQL error occurred while trying to remove the GameServer.
-sqlErrorUnregisterAll = An SQL error occurred while trying to remove ALL GameServers.
-noServerNames = No available names for GameServer, verify servername.xml file exists in the LoginServer folder.
-noNameForId = No name for ID: %d
-idIsNotFree = This ID is not available.
-noServerForId = No GameServer is registered on ID: %d
-
-
-cmdMenuRegister = Register GameServer
-cmdMenuListNames = List GameServers Names and IDs
-cmdMenuRemoveGS = Remove GameServer
-cmdMenuRemoveAll = Remove ALL GameServers
-cmdMenuExit = Exit
-yourChoice = Choice:
-invalidChoice = Invalid Choice: %s
-gsInUse = In Use
-gsFree = Free
-enterDesiredId = Enter desired ID:
-
-credits = © 2008-2009 L2J Team. All rights reserved.
-langText = Language: English
-icons = Icons by http://www.famfamfam.com
-translation = Translation: L2J Team
-bugReports = Bug Reports:

+ 0 - 5
dist/login/RegisterGameServer.bat

@@ -1,5 +0,0 @@
-@echo off
-title L2J - Register Game Server
-color 17
-java -Djava.util.logging.config.file=console.cfg -cp ./../libs/*;l2jlogin.jar com.l2jserver.tools.gsregistering.BaseGameServerRegister -c
-pause

BIN
dist/login/RegisterGameServer.exe


+ 0 - 2
dist/login/RegisterGameServer.sh

@@ -1,2 +0,0 @@
-#!/bin/sh
-java -Djava.util.logging.config.file=console.cfg -cp ./../libs/*:l2jlogin.jar com.l2jserver.tools.gsregistering.GameServerRegister -c

+ 0 - 22
dist/login/startSQLAccountManager.bat

@@ -1,22 +0,0 @@
-@echo off
-title L2J - SQL Account Manager
-color 17
-java -Djava.util.logging.config.file=console.cfg -cp ./../libs/*;l2jlogin.jar com.l2jserver.tools.accountmanager.SQLAccountManager
-if %errorlevel% == 0 (
-echo.
-echo Execution successful
-echo.
-) else (
-echo.
-echo An error has occurred while running the L2J Account Manager!
-echo.
-echo Possible reasons for this to happen:
-echo.
-echo - Missing .jar files or ../libs directory.
-echo - MySQL server not running or incorrect MySQL settings:
-echo    check ./config/loginserver.properties
-echo - Wrong data types or values out of range were provided:
-echo    specify correct values for each required field
-echo.
-)
-pause

+ 0 - 2
dist/login/startSQLAccountManager.sh

@@ -1,2 +0,0 @@
-#!/bin/sh
-java -Djava.util.logging.config.file=console.cfg -cp ./../libs/*:l2jlogin.jar com.l2jserver.tools.accountmanager.SQLAccountManager

+ 0 - 266
src/main/java/com/l2jserver/tools/accountmanager/SQLAccountManager.java

@@ -1,266 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.accountmanager;
-
-import java.security.MessageDigest;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Base64;
-import java.util.Scanner;
-
-import com.l2jserver.Config;
-import com.l2jserver.Server;
-import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
-
-/**
- * This class SQL Account Manager
- * @author netimperia
- */
-public class SQLAccountManager
-{
-	private static String _uname = "";
-	private static String _pass = "";
-	private static String _level = "";
-	private static String _mode = "";
-	
-	public static void main(String[] args)
-	{
-		Server.serverMode = Server.MODE_LOGINSERVER;
-		Config.load();
-		
-		try (Scanner _scn = new Scanner(System.in))
-		{
-			while (true)
-			{
-				System.out.println("Please choose an option");
-				System.out.println();
-				System.out.println("1 - Create new account or update existing one (change pass and access level)");
-				System.out.println("2 - Change access level");
-				System.out.println("3 - Delete existing account");
-				System.out.println("4 - List accounts and access levels");
-				System.out.println("5 - Exit");
-				while (!(_mode.equals("1") || _mode.equals("2") || _mode.equals("3") || _mode.equals("4") || _mode.equals("5")))
-				{
-					System.out.print("Your choice: ");
-					_mode = _scn.next();
-				}
-				
-				if (_mode.equals("1") || _mode.equals("2") || _mode.equals("3"))
-				{
-					while (_uname.trim().length() == 0)
-					{
-						System.out.print("Username: ");
-						_uname = _scn.next().toLowerCase();
-					}
-					
-					if (_mode.equals("1"))
-					{
-						while (_pass.trim().length() == 0)
-						{
-							System.out.print("Password: ");
-							_pass = _scn.next();
-						}
-					}
-					
-					if (_mode.equals("1") || _mode.equals("2"))
-					{
-						while (_level.trim().length() == 0)
-						{
-							System.out.print("Access level: ");
-							_level = _scn.next();
-						}
-					}
-				}
-				
-				if (_mode.equals("1"))
-				{
-					// Add or Update
-					addOrUpdateAccount(_uname.trim(), _pass.trim(), _level.trim());
-				}
-				else if (_mode.equals("2"))
-				{
-					// Change Level
-					changeAccountLevel(_uname.trim(), _level.trim());
-				}
-				else if (_mode.equals("3"))
-				{
-					// Delete
-					System.out.print("WARNING: This will not delete the gameserver data (characters, items, etc..)");
-					System.out.print(" it will only delete the account login server data.");
-					System.out.println();
-					System.out.print("Do you really want to delete this account? Y/N: ");
-					String yesno = _scn.next();
-					if ((yesno != null) && yesno.equalsIgnoreCase("Y"))
-					{
-						deleteAccount(_uname.trim());
-					}
-					else
-					{
-						System.out.println("Deletion cancelled.");
-					}
-				}
-				else if (_mode.equals("4"))
-				{
-					// List
-					_mode = "";
-					System.out.println();
-					System.out.println("Please choose a listing mode");
-					System.out.println();
-					System.out.println("1 - Banned accounts only (accessLevel < 0)");
-					System.out.println("2 - GM/privileged accounts (accessLevel > 0");
-					System.out.println("3 - Regular accounts only (accessLevel = 0)");
-					System.out.println("4 - List all");
-					while (!(_mode.equals("1") || _mode.equals("2") || _mode.equals("3") || _mode.equals("4")))
-					{
-						System.out.print("Your choice: ");
-						_mode = _scn.next();
-					}
-					System.out.println();
-					printAccInfo(_mode);
-				}
-				else if (_mode.equals("5"))
-				{
-					System.exit(0);
-				}
-				
-				_uname = "";
-				_pass = "";
-				_level = "";
-				_mode = "";
-				System.out.println();
-			}
-		}
-	}
-	
-	private static void printAccInfo(String m)
-	{
-		int count = 0;
-		String q = "SELECT login, accessLevel FROM accounts ";
-		if (m.equals("1"))
-		{
-			q = q.concat("WHERE accessLevel < 0");
-		}
-		else if (m.equals("2"))
-		{
-			q = q.concat("WHERE accessLevel > 0");
-		}
-		else if (m.equals("3"))
-		{
-			q = q.concat("WHERE accessLevel = 0");
-		}
-		q = q.concat(" ORDER BY login ASC");
-		
-		try (Connection con = ConnectionFactory.getInstance().getConnection();
-			PreparedStatement ps = con.prepareStatement(q);
-			ResultSet rset = ps.executeQuery())
-		{
-			while (rset.next())
-			{
-				System.out.println(rset.getString("login") + " -> " + rset.getInt("accessLevel"));
-				count++;
-			}
-			
-			System.out.println("Displayed accounts: " + count);
-		}
-		catch (SQLException e)
-		{
-			System.out.println("There was error while displaying accounts:");
-			System.out.println(e.getMessage());
-		}
-	}
-	
-	private static void addOrUpdateAccount(String account, String password, String level)
-	{
-		try (Connection con = ConnectionFactory.getInstance().getConnection();
-			PreparedStatement ps = con.prepareStatement("REPLACE accounts(login, password, accessLevel) VALUES (?, ?, ?)"))
-		{
-			MessageDigest md = MessageDigest.getInstance("SHA");
-			byte[] newPassword;
-			newPassword = password.getBytes("UTF-8");
-			newPassword = md.digest(newPassword);
-			
-			ps.setString(1, account);
-			ps.setString(2, Base64.getEncoder().encodeToString(newPassword));
-			ps.setString(3, level);
-			if (ps.executeUpdate() > 0)
-			{
-				
-				System.out.println("Account " + account + " has been created or updated");
-			}
-			else
-			{
-				System.out.println("Account " + account + " does not exist");
-			}
-		}
-		catch (Exception e)
-		{
-			System.out.println("There was error while adding/updating account:");
-			System.out.println(e.getMessage());
-		}
-	}
-	
-	private static void changeAccountLevel(String account, String level)
-	{
-		try (Connection con = ConnectionFactory.getInstance().getConnection();
-			PreparedStatement ps = con.prepareStatement("UPDATE accounts SET accessLevel = ? WHERE login = ?"))
-		{
-			ps.setString(1, level);
-			ps.setString(2, account);
-			if (ps.executeUpdate() > 0)
-			{
-				
-				System.out.println("Account " + account + " has been updated");
-			}
-			else
-			{
-				System.out.println("Account " + account + " does not exist");
-			}
-		}
-		catch (SQLException e)
-		{
-			System.out.println("There was error while updating account:");
-			System.out.println(e.getMessage());
-		}
-	}
-	
-	private static void deleteAccount(String account)
-	{
-		try (Connection con = ConnectionFactory.getInstance().getConnection();
-			PreparedStatement ps = con.prepareStatement("DELETE FROM accounts WHERE login = ?"))
-		{
-			ps.setString(1, account);
-			if (ps.executeUpdate() > 0)
-			{
-				
-				System.out.println("Account " + account + " has been deleted");
-			}
-			else
-			{
-				System.out.println("Account " + account + " does not exist");
-			}
-		}
-		catch (SQLException e)
-		{
-			System.out.println("There was error while deleting account:");
-			System.out.println(e.getMessage());
-		}
-	}
-}

+ 0 - 108
src/main/java/com/l2jserver/tools/dbinstaller/DatabaseInstaller.java

@@ -1,108 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.dbinstaller;
-
-import java.awt.HeadlessException;
-
-import javax.swing.UIManager;
-
-import com.l2jserver.tools.dbinstaller.frontend.stdio.DBInstallerStdio;
-import com.l2jserver.tools.dbinstaller.frontend.swing.DBConfigGUI;
-import com.l2jserver.tools.util.app.IApplicationFrontend;
-
-/**
- * Code basically merged from LauncherLS/GS to remove the code duplication.
- * @author HorridoJoho
- */
-public final class DatabaseInstaller
-{
-	private static IApplicationFrontend _frontend;
-	
-	private final String _installScriptsPath;
-	private final String _cleanScript;
-	private final String _defaultDatabase;
-	
-	public DatabaseInstaller(String installScriptsPath, String cleanScript, String defaultDatabase)
-	{
-		_installScriptsPath = installScriptsPath;
-		_cleanScript = cleanScript;
-		_defaultDatabase = defaultDatabase;
-	}
-	
-	public void run(String args[])
-	{
-		if ((args != null) && (args.length > 0))
-		{
-			new DBInstallerStdio(_defaultDatabase, _installScriptsPath, _cleanScript, getArg("-h", args), getArg("-p", args), getArg("-u", args), getArg("-pw", args), getArg("-d", args), getArg("-m", args));
-			return;
-		}
-		
-		try
-		{
-			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
-			new DBConfigGUI(_defaultDatabase, _installScriptsPath, _cleanScript);
-		}
-		catch (HeadlessException e)
-		{
-			new DBInstallerStdio(_defaultDatabase, _installScriptsPath, _cleanScript);
-		}
-		catch (Throwable t)
-		{
-			t.printStackTrace();
-		}
-	}
-	
-	public String getPath()
-	{
-		return _installScriptsPath;
-	}
-	
-	public String getCleanScript()
-	{
-		return _cleanScript;
-	}
-	
-	public String getDefaultDatabase()
-	{
-		return _defaultDatabase;
-	}
-	
-	public static IApplicationFrontend getFrontend()
-	{
-		return _frontend;
-	}
-	
-	protected static String getArg(String arg, String[] args)
-	{
-		try
-		{
-			int i = 0;
-			do
-			{
-				// Nothing is missing here.
-			}
-			while (!arg.equalsIgnoreCase(args[i++]));
-			return args[i];
-		}
-		catch (Exception e)
-		{
-			return null;
-		}
-	}
-}

+ 0 - 31
src/main/java/com/l2jserver/tools/dbinstaller/LauncherGS.java

@@ -1,31 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.dbinstaller;
-
-/**
- * Main for the game database installer.
- * @author mrTJO, HorridoJoho
- */
-public class LauncherGS
-{
-	public static void main(String[] args)
-	{
-		new DatabaseInstaller("../sql/game/", "gs_cleanup.sql", "l2jgs").run(args);
-	}
-}

+ 0 - 31
src/main/java/com/l2jserver/tools/dbinstaller/LauncherLS.java

@@ -1,31 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.dbinstaller;
-
-/**
- * Main for the login database installer.
- * @author mrTJO, HorridoJoho
- */
-public class LauncherLS
-{
-	public static void main(String[] args)
-	{
-		new DatabaseInstaller("../sql/login/", "ls_cleanup.sql", "l2jls").run(args);
-	}
-}

+ 0 - 183
src/main/java/com/l2jserver/tools/dbinstaller/RunTasks.java

@@ -1,183 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.dbinstaller;
-
-import java.io.File;
-import java.sql.Connection;
-import java.util.prefs.Preferences;
-
-import com.l2jserver.tools.util.SQLUtil;
-import com.l2jserver.tools.util.app.IApplicationFrontend;
-import com.l2jserver.util.file.filter.SQLFilter;
-
-/**
- * @author mrTJO, HorridoJoho
- */
-public class RunTasks extends Thread
-{
-	IApplicationFrontend _frontend;
-	Connection _con;
-	boolean _cleanInstall;
-	String _db;
-	String _sqlDir;
-	String _cleanUpFile;
-	
-	public RunTasks(IApplicationFrontend frontend, Connection con, String db, String sqlDir, String cleanUpFile, boolean cleanInstall)
-	{
-		_frontend = frontend;
-		_con = con;
-		_db = db;
-		_cleanInstall = cleanInstall;
-		_sqlDir = sqlDir;
-		_cleanUpFile = cleanUpFile;
-	}
-	
-	@Override
-	public void run()
-	{
-		try
-		{
-			File sqlDir = new File(_sqlDir);
-			if (!sqlDir.exists())
-			{
-				_frontend.reportError(true, null, "The directory {0} does not exist!", sqlDir.getAbsolutePath());
-				return;
-			}
-			
-			try
-			{
-				_frontend.reportInfo(false, "Backup database...");
-				SQLUtil.createDump(_con, _db);
-			}
-			catch (Exception e)
-			{
-				_frontend.reportError(true, e, "Failed to backup database!");
-				return;
-			}
-			
-			File updDir = new File(sqlDir, "updates");
-			Preferences prefs = Preferences.userRoot();
-			if (_cleanInstall)
-			{
-				try
-				{
-					_frontend.reportInfo(false, "Executing SQL cleanup script...");
-					SQLUtil.executeSQLScript(_con, new File(_cleanUpFile));
-				}
-				catch (Exception e)
-				{
-					_frontend.reportError(true, e, "Failed to execute SQL cleanup script {0}!", _cleanUpFile);
-					return;
-				}
-				
-				if (updDir.exists())
-				{
-					StringBuilder sb = new StringBuilder();
-					for (File cf : updDir.listFiles(new SQLFilter()))
-					{
-						sb.append(cf.getName() + ';');
-					}
-					prefs.put(_db + "_upd", sb.toString());
-				}
-			}
-			else if (updDir.exists())
-			{
-				_frontend.reportInfo(false, "Installing update SQL scripts...");
-				for (File cf : updDir.listFiles(new SQLFilter()))
-				{
-					if (!prefs.get(_db + "_upd", "").contains(cf.getName()))
-					{
-						if (!_cleanInstall)
-						{
-							try
-							{
-								_frontend.reportInfo(false, "Installing {0}...", cf);
-								SQLUtil.executeSQLScript(_con, cf);
-							}
-							catch (Exception e)
-							{
-								_frontend.reportError(true, e, "Failed to execute SQL update file {0}!", cf);
-								return;
-							}
-						}
-						prefs.put(_db + "_upd", prefs.get(_db + "_upd", "") + cf.getName() + ";");
-					}
-				}
-			}
-			
-			_frontend.reportInfo(false, "Installing basic SQL scripts...");
-			for (File f : sqlDir.listFiles(new SQLFilter()))
-			{
-				try
-				{
-					_frontend.reportInfo(false, "Installing {0}...", f);
-					SQLUtil.executeSQLScript(_con, f);
-				}
-				catch (Exception e)
-				{
-					_frontend.reportError(true, e, "Failed to execute basics SQL file {0}!", f);
-					return;
-				}
-			}
-			
-			File cusDir = new File(_sqlDir, "custom");
-			if (cusDir.exists() && _frontend.requestUserConfirm("Install custom tables? (Y/N) "))
-			{
-				_frontend.reportInfo(false, "Installing custom tables...");
-				for (File f : cusDir.listFiles(new SQLFilter()))
-				{
-					try
-					{
-						_frontend.reportInfo(false, "Installing {0}...", f);
-						SQLUtil.executeSQLScript(_con, f);
-					}
-					catch (Exception e)
-					{
-						_frontend.reportError(true, e, "Failed to execute customs SQL file {0}!", f);
-					}
-				}
-			}
-			
-			File modsDir = new File(_sqlDir, "mods");
-			if (modsDir.exists() && _frontend.requestUserConfirm("Install mod tables? (Y/N) "))
-			{
-				_frontend.reportInfo(false, "Installing mod tables...");
-				for (File f : modsDir.listFiles(new SQLFilter()))
-				{
-					try
-					{
-						_frontend.reportInfo(false, "Installing {0}...", f);
-						SQLUtil.executeSQLScript(_con, f);
-					}
-					catch (Exception e)
-					{
-						_frontend.reportError(true, e, "Failed to execute mods SQL file {0}!", f);
-					}
-				}
-			}
-			
-			_frontend.reportInfo(true, "Database installation complete.");
-		}
-		finally
-		{
-			SQLUtil.close(_con);
-			_frontend.close();
-		}
-	}
-}

+ 0 - 249
src/main/java/com/l2jserver/tools/dbinstaller/frontend/stdio/DBInstallerStdio.java

@@ -1,249 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.dbinstaller.frontend.stdio;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.sql.Connection;
-import java.text.MessageFormat;
-import java.util.Scanner;
-import java.util.prefs.Preferences;
-
-import com.l2jserver.tools.dbinstaller.RunTasks;
-import com.l2jserver.tools.util.SQLUtil;
-import com.l2jserver.tools.util.app.IApplicationFrontend;
-import com.l2jserver.tools.util.io.CloseShieldedInputStream;
-
-/**
- * @author mrTJO, HorridoJoho
- */
-public class DBInstallerStdio implements IApplicationFrontend
-{
-	Connection _con;
-	
-	public DBInstallerStdio(String db, String dir, String cleanUpScript)
-	{
-		reportInfo(false, "Welcome to L2J Database installer");
-		Preferences prop = Preferences.userRoot();
-		while (_con == null)
-		{
-			String dbHost = requestUserInput("Host ({0}): ", prop.get("dbHost_" + db, "localhost"));
-			String dbPort = requestUserInput("Port ({0}): ", prop.get("dbPort_" + db, "3306"));
-			String dbUser = requestUserInput("Username ({0}): ", prop.get("dbUser_" + db, "root"));
-			String dbPass = requestUserInput("Password: ");
-			String dbDbse = requestUserInput("Database ({0}): ", prop.get("dbDbse_" + db, db));
-			
-			dbHost = dbHost.isEmpty() ? prop.get("dbHost_" + db, "localhost") : dbHost;
-			dbPort = dbPort.isEmpty() ? prop.get("dbPort_" + db, "3306") : dbPort;
-			dbUser = dbUser.isEmpty() ? prop.get("dbUser_" + db, "root") : dbUser;
-			dbDbse = dbDbse.isEmpty() ? prop.get("dbDbse_" + db, db) : dbDbse;
-			
-			try
-			{
-				reportInfo(false, "Connecting to SQL server at {0}:{1} with user {2}...", dbHost, dbPort, dbUser);
-				_con = SQLUtil.connect(dbHost, dbPort, dbUser, dbPass, dbDbse);
-				db = dbDbse;
-			}
-			catch (Exception e)
-			{
-				reportError(true, e, "Failed to establish connection with user {0} to SQL server at {1}:{2}!", dbUser, dbHost, dbPort);
-			}
-		}
-		
-		String resp = requestUserInput("(C)lean install, (U)pdate or (Q)uit? ");
-		if (resp.equalsIgnoreCase("c"))
-		{
-			if (requestUserConfirm("A clean install will delete your current database! Do you want to continue? (Y/N)? "))
-			{
-				run(dir, cleanUpScript, db, resp);
-			}
-		}
-		else if (resp.equalsIgnoreCase("u"))
-		{
-			run(dir, cleanUpScript, db, resp);
-		}
-	}
-	
-	/**
-	 * Database Console Installer constructor.
-	 * @param defDatabase the default database name
-	 * @param dir the SQL script's directory
-	 * @param cleanUpScript the clean up SQL script
-	 * @param host the host name
-	 * @param port the port
-	 * @param user the user name
-	 * @param pass the password
-	 * @param database the database name
-	 * @param mode the mode, c: Clean, u:update
-	 */
-	public DBInstallerStdio(String defDatabase, String dir, String cleanUpScript, String host, String port, String user, String pass, String database, String mode)
-	{
-		if ((database == null) || database.isEmpty())
-		{
-			database = defDatabase;
-		}
-		
-		try
-		{
-			reportInfo(false, "Connecting to SQL server at {0}:{1} with user {2}...", host, port, user);
-			_con = SQLUtil.connect(host, port, user, pass, database);
-		}
-		catch (Exception e)
-		{
-			reportError(true, e, "Failed to establish connection with user {0} to SQL server at {1}:{2}!", user, host, port);
-			return;
-		}
-		
-		run(dir, cleanUpScript, database, mode);
-	}
-	
-	private void run(String dir, String cleanUpScript, String database, String mode)
-	{
-		try
-		{
-			SQLUtil.ensureDatabaseUsage(_con, database);
-		}
-		catch (Exception e)
-		{
-			reportError(true, e, MessageFormat.format("Failed to ensure that the database {0} exists and is in use!", database));
-			return;
-		}
-		
-		if ((mode != null) && ("c".equalsIgnoreCase(mode) || "u".equalsIgnoreCase(mode)))
-		{
-			final RunTasks rt = new RunTasks(this, _con, database, dir, cleanUpScript, "c".equalsIgnoreCase(mode));
-			rt.run();
-		}
-	}
-	
-	private void clearPendingInput()
-	{
-		try
-		{
-			System.in.read(new byte[System.in.available()]);
-		}
-		catch (IOException e)
-		{
-			e.printStackTrace();
-		}
-	}
-	
-	private void drawReportAttention(PrintStream ps)
-	{
-		ps.println("Press any key to continue...");
-		try
-		{
-			clearPendingInput();
-			System.in.read();
-		}
-		catch (IOException e)
-		{
-			e.printStackTrace();
-		}
-	}
-	
-	@Override
-	public void reportInfo(boolean drawAttention, String message)
-	{
-		System.out.println(message);
-		if (drawAttention)
-		{
-			drawReportAttention(System.out);
-		}
-	}
-	
-	@Override
-	public void reportInfo(boolean drawAttention, String message, Object... args)
-	{
-		reportInfo(drawAttention, MessageFormat.format(message, args));
-	}
-	
-	@Override
-	public void reportWarn(boolean drawAttention, String message)
-	{
-		System.out.println(message);
-		if (drawAttention)
-		{
-			drawReportAttention(System.out);
-		}
-	}
-	
-	@Override
-	public void reportWarn(boolean drawAttention, String message, Object... args)
-	{
-		reportWarn(drawAttention, MessageFormat.format(message, args));
-	}
-	
-	@Override
-	public void reportError(boolean drawAttention, String message)
-	{
-		System.err.println(message);
-		if (drawAttention)
-		{
-			drawReportAttention(System.err);
-		}
-	}
-	
-	@Override
-	public void reportError(boolean drawAttention, Throwable t, String message)
-	{
-		if (t != null)
-		{
-			message += MessageFormat.format("\n\nReason:\n{0}", t.getMessage());
-		}
-		reportError(drawAttention, message);
-	}
-	
-	@Override
-	public void reportError(boolean drawAttention, Throwable t, String message, Object... args)
-	{
-		reportError(drawAttention, t, MessageFormat.format(message, args));
-	}
-	
-	@Override
-	public String requestUserInput(String message, Object... args)
-	{
-		clearPendingInput();
-		System.out.print(MessageFormat.format(message, args));
-		String res = "";
-		try (Scanner scn = new Scanner(new CloseShieldedInputStream(System.in)))
-		{
-			res = scn.nextLine();
-		}
-		return res;
-	}
-	
-	@Override
-	public boolean requestUserConfirm(String message, Object... args)
-	{
-		clearPendingInput();
-		System.out.print(MessageFormat.format(message, args));
-		String res = "";
-		try (Scanner scn = new Scanner(new CloseShieldedInputStream(System.in)))
-		{
-			res = scn.next();
-		}
-		return res.equalsIgnoreCase("y") ? true : false;
-	}
-	
-	@Override
-	public void close()
-	{
-	}
-}

+ 0 - 114
src/main/java/com/l2jserver/tools/dbinstaller/frontend/swing/AbstractGUI.java

@@ -1,114 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.dbinstaller.frontend.swing;
-
-import java.text.MessageFormat;
-
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-
-import com.l2jserver.tools.util.app.IApplicationFrontend;
-
-/**
- * @author HorridoJoho
- */
-public abstract class AbstractGUI extends JFrame implements IApplicationFrontend
-{
-	private static final long serialVersionUID = 1L;
-	
-	protected AbstractGUI(String title)
-	{
-		super(title);
-	}
-	
-	@Override
-	public void reportInfo(boolean drawAttention, String message)
-	{
-		if (drawAttention)
-		{
-			JOptionPane.showMessageDialog(this, message, "Database Installer", JOptionPane.INFORMATION_MESSAGE);
-		}
-	}
-	
-	@Override
-	public final void reportInfo(boolean drawAttention, String message, Object... args)
-	{
-		reportInfo(drawAttention, MessageFormat.format(message, args));
-	}
-	
-	@Override
-	public void reportWarn(boolean drawAttention, String message)
-	{
-		if (drawAttention)
-		{
-			JOptionPane.showMessageDialog(this, message, "Database Installer", JOptionPane.WARNING_MESSAGE);
-		}
-	}
-	
-	@Override
-	public final void reportWarn(boolean drawAttention, String message, Object... args)
-	{
-		reportWarn(drawAttention, MessageFormat.format(message, args));
-	}
-	
-	@Override
-	public void reportError(boolean drawAttention, String message)
-	{
-		if (drawAttention)
-		{
-			JOptionPane.showMessageDialog(this, message, "Database Installer", JOptionPane.ERROR_MESSAGE);
-		}
-	}
-	
-	@Override
-	public final void reportError(boolean drawAttention, Throwable t, String message)
-	{
-		if (t != null)
-		{
-			message += MessageFormat.format("\n\nReason:\n{0}", t.getMessage());
-		}
-		
-		reportError(drawAttention, message);
-	}
-	
-	@Override
-	public final void reportError(boolean drawAttention, Throwable t, String message, Object... args)
-	{
-		reportError(drawAttention, t, MessageFormat.format(message, args));
-	}
-	
-	@Override
-	public final String requestUserInput(String message, Object... args)
-	{
-		throw new UnsupportedOperationException();
-	}
-	
-	@Override
-	public final boolean requestUserConfirm(String message, Object... args)
-	{
-		return JOptionPane.showConfirmDialog(this, MessageFormat.format(message, args), "Database Installer", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == 0;
-	}
-	
-	@Override
-	public void close()
-	{
-		setVisible(false);
-		dispose();
-	}
-}

+ 0 - 214
src/main/java/com/l2jserver/tools/dbinstaller/frontend/swing/DBConfigGUI.java

@@ -1,214 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.dbinstaller.frontend.swing;
-
-import java.awt.Dimension;
-import java.awt.Toolkit;
-import java.awt.event.ActionListener;
-import java.sql.Connection;
-import java.text.MessageFormat;
-import java.util.prefs.Preferences;
-
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPasswordField;
-import javax.swing.JTextField;
-import javax.swing.SpringLayout;
-import javax.swing.SwingConstants;
-import javax.swing.WindowConstants;
-
-import com.l2jserver.tools.dbinstaller.RunTasks;
-import com.l2jserver.tools.images.ImagesTable;
-import com.l2jserver.tools.util.SQLUtil;
-import com.l2jserver.tools.util.SwingUtil;
-import com.l2jserver.tools.util.swing.SpringUtilities;
-
-/**
- * @author mrTJO, HorridoJoho
- */
-public class DBConfigGUI extends AbstractGUI
-{
-	private static final long serialVersionUID = -8391792251140797076L;
-	
-	JTextField _dbHost;
-	JTextField _dbPort;
-	JTextField _dbUser;
-	JPasswordField _dbPass;
-	JTextField _dbDbse;
-	
-	String _db;
-	String _dir;
-	String _cleanUp;
-	
-	Preferences _prop;
-	
-	public DBConfigGUI(String db, String dir, String cleanUp)
-	{
-		super("L2J Database Installer");
-		setLayout(new SpringLayout());
-		setDefaultLookAndFeelDecorated(true);
-		setIconImage(ImagesTable.getImage("l2j.png").getImage());
-		
-		_db = db;
-		_dir = dir;
-		_cleanUp = cleanUp;
-		
-		int width = 320;
-		int height = 240;
-		Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
-		
-		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
-		setBounds((resolution.width - width) / 2, (resolution.height - height) / 2, width, height);
-		setResizable(false);
-		
-		_prop = Preferences.userRoot();
-		
-		// Host
-		JLabel labelDbHost = new JLabel("Host: ", SwingConstants.LEFT);
-		add(labelDbHost);
-		_dbHost = new JTextField(15);
-		_dbHost.setText(_prop.get("dbHost_" + db, "localhost"));
-		labelDbHost.setLabelFor(_dbHost);
-		add(_dbHost);
-		
-		// Port
-		JLabel labelDbPort = new JLabel("Port: ", SwingConstants.LEFT);
-		add(labelDbPort);
-		_dbPort = new JTextField(15);
-		_dbPort.setText(_prop.get("dbPort_" + db, "3306"));
-		labelDbPort.setLabelFor(_dbPort);
-		add(_dbPort);
-		
-		// Username
-		JLabel labelDbUser = new JLabel("Username: ", SwingConstants.LEFT);
-		add(labelDbUser);
-		_dbUser = new JTextField(15);
-		_dbUser.setText(_prop.get("dbUser_" + db, "root"));
-		labelDbUser.setLabelFor(_dbUser);
-		add(_dbUser);
-		
-		// Password
-		JLabel labelDbPass = new JLabel("Password: ", SwingConstants.LEFT);
-		add(labelDbPass);
-		_dbPass = new JPasswordField(15);
-		_dbPass.setText(_prop.get("dbPass_" + db, ""));
-		labelDbPass.setLabelFor(_dbPass);
-		add(_dbPass);
-		
-		// Database
-		JLabel labelDbDbse = new JLabel("Database: ", SwingConstants.LEFT);
-		add(labelDbDbse);
-		_dbDbse = new JTextField(15);
-		_dbDbse.setText(_prop.get("dbDbse_" + db, db));
-		labelDbDbse.setLabelFor(_dbDbse);
-		add(_dbDbse);
-		
-		// Quit
-		JButton btnCancel = new JButton("Quit");
-		btnCancel.addActionListener(e -> close());
-		add(btnCancel);
-		
-		ActionListener connectListener = e ->
-		{
-			Connection con = null;
-			try
-			{
-				
-				final JOptionPane optionPane = new JOptionPane(MessageFormat.format("Connecting to SQL server at {0}:{1} with user {2}...", _dbHost.getText(), _dbPort.getText(), _dbUser.getText()), JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] {}, null);
-				con = SwingUtil.runBackgroundTaskWithDialog(this, "Database Installer", optionPane, () -> SQLUtil.connect(_dbHost.getText(), _dbPort.getText(), _dbUser.getText(), new String(_dbPass.getPassword()), _dbDbse.getText()));
-			}
-			catch (Throwable t)
-			{
-				reportError(true, t, "Failed to establish connection with user {0} to SQL server at {1}:{2}!", _dbUser.getText(), _dbHost.getText(), _dbPort.getText());
-				return;
-			}
-			
-			try
-			{
-				final Connection con2 = con;
-				final JOptionPane optionPane = new JOptionPane(MessageFormat.format("Ensuring that database {0} exists and is in use...", _dbDbse.getText()), JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] {}, null);
-				SwingUtil.runBackgroundTaskWithDialog(this, "Database Installer", optionPane, () ->
-				{
-					SQLUtil.ensureDatabaseUsage(con2, _dbDbse.getText());
-					return null;
-				});
-			}
-			catch (Throwable t)
-			{
-				SQLUtil.close(con);
-				reportError(true, t, MessageFormat.format("Failed to ensure that the database {0} exists and is in use!", _dbDbse.getText()));
-				return;
-			}
-			
-			_prop.put("dbHost_" + _db, _dbHost.getText());
-			_prop.put("dbPort_" + _db, _dbPort.getText());
-			_prop.put("dbUser_" + _db, _dbUser.getText());
-			_prop.put("dbDbse_" + _db, _dbDbse.getText());
-			
-			try
-			{
-				boolean cleanInstall = false;
-				
-				Object[] options =
-				{
-					"Full Install",
-					"Upgrade",
-					"Abbort"
-				};
-				int n = JOptionPane.showOptionDialog(null, "Select the installation type for your database:", "Database Installer", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
-				if ((n == 2) || (n == -1))
-				{
-					SQLUtil.close(con);
-					return;
-				}
-				
-				if (n == 0)
-				{
-					if (!requestUserConfirm("A clean install will delete your current database! Do you want to continue?"))
-					{
-						SQLUtil.close(con);
-						return;
-					}
-					
-					cleanInstall = true;
-				}
-				
-				DBInstallerGUI dbi = new DBInstallerGUI();
-				RunTasks task = new RunTasks(dbi, con, _db, _dir, _cleanUp, cleanInstall);
-				task.setPriority(Thread.MAX_PRIORITY);
-				task.start();
-			}
-			catch (Throwable t)
-			{
-				SQLUtil.close(con);
-				reportError(true, t, "Failed to launch database installation!");
-			}
-		};
-		
-		// Connect
-		JButton btnConnect = new JButton("Connect");
-		btnConnect.addActionListener(connectListener);
-		add(btnConnect);
-		
-		SpringUtilities.makeCompactGrid(getContentPane(), 6, 2, 5, 5, 5, 5);
-		
-		setVisible(true);
-	}
-}

+ 0 - 91
src/main/java/com/l2jserver/tools/dbinstaller/frontend/swing/DBInstallerGUI.java

@@ -1,91 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.dbinstaller.frontend.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.Toolkit;
-
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.WindowConstants;
-import javax.swing.text.DefaultCaret;
-
-import com.l2jserver.tools.images.ImagesTable;
-
-/**
- * @author mrTJO, HorridoJoho
- */
-public class DBInstallerGUI extends AbstractGUI
-{
-	private static final long serialVersionUID = -1005504757826370170L;
-	
-	private final JTextArea _progArea;
-	
-	public DBInstallerGUI()
-	{
-		super("L2J Database Installer");
-		setLayout(new BorderLayout());
-		setDefaultLookAndFeelDecorated(true);
-		setIconImage(ImagesTable.getImage("l2j.png").getImage());
-		
-		int width = 480;
-		int height = 360;
-		Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
-		
-		setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
-		setBounds((resolution.width - width) / 2, (resolution.height - height) / 2, width, height);
-		setResizable(false);
-		
-		_progArea = new JTextArea();
-		_progArea.setEditable(false);
-		DefaultCaret caret = (DefaultCaret) _progArea.getCaret();
-		caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
-		
-		add(new JScrollPane(_progArea), BorderLayout.CENTER);
-		setVisible(true);
-	}
-	
-	private void appendToTextArea(String message)
-	{
-		_progArea.append(message);
-		_progArea.append("\n");
-	}
-	
-	@Override
-	public void reportInfo(boolean drawAttention, String message)
-	{
-		appendToTextArea(message);
-		super.reportInfo(drawAttention, message);
-	}
-	
-	@Override
-	public void reportWarn(boolean drawAttention, String message)
-	{
-		appendToTextArea(message);
-		super.reportWarn(drawAttention, message);
-	}
-	
-	@Override
-	public void reportError(boolean drawAttention, String message)
-	{
-		appendToTextArea(message);
-		super.reportError(drawAttention, message);
-	}
-}

+ 0 - 605
src/main/java/com/l2jserver/tools/gsregistering/BaseGameServerRegister.java

@@ -1,605 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.gsregistering;
-
-import java.awt.HeadlessException;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.math.BigInteger;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Locale;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.ResourceBundle;
-
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-
-import com.l2jserver.Config;
-import com.l2jserver.Server;
-import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
-import com.l2jserver.loginserver.GameServerTable;
-import com.l2jserver.tools.i18n.LanguageControl;
-import com.l2jserver.util.Util;
-
-/**
- * The Class BaseGameServerRegister.
- * @author KenM
- */
-public abstract class BaseGameServerRegister
-{
-	private boolean _loaded = false;
-	private ResourceBundle _bundle;
-	
-	/**
-	 * The main method.
-	 * @param args the arguments
-	 */
-	public static void main(String[] args)
-	{
-		Locale locale = null;
-		boolean gui = true;
-		boolean interactive = true;
-		boolean force = false;
-		boolean fallback = false;
-		BaseTask task = null;
-		
-		ResourceBundle bundle = null;
-		try
-		{
-			locale = Locale.getDefault();
-			bundle = ResourceBundle.getBundle("gsregister.GSRegister", locale, LanguageControl.INSTANCE);
-		}
-		catch (Throwable t)
-		{
-			System.out.println("FATAL: Failed to load default translation.");
-			System.exit(666);
-		}
-		
-		String arg;
-		for (int i = 0; i < args.length; i++)
-		{
-			arg = args[i];
-			
-			// --cmd : no gui
-			if (arg.equals("-c") || arg.equals("--cmd"))
-			{
-				gui = false;
-			}
-			// --force : Forces GameServer register operations to overwrite a server if necessary
-			else if (arg.equals("-f") || arg.equals("--force"))
-			{
-				force = true;
-			}
-			// --fallback : If an register operation fails due to ID already being in use it will then try to register first available ID
-			else if (arg.equals("-b") || arg.equals("--fallback"))
-			{
-				fallback = true;
-			}
-			// --register <id> <hexid_dest_dir> : Register GameServer with ID <id> and output hexid on <hexid_dest_dir>
-			// Fails if <id> already in use, unless -force is used (overwrites)
-			else if (arg.equals("-r") || arg.equals("--register"))
-			{
-				gui = false;
-				interactive = false;
-				int id = Integer.parseInt(args[++i]);
-				String dir = args[++i];
-				
-				task = new RegisterTask(id, dir, force, fallback);
-			}
-			// --unregister <id> : Removes GameServer denoted by <id>
-			else if (arg.equals("-u") || arg.equals("--unregister"))
-			{
-				gui = false;
-				interactive = false;
-				String gsId = args[++i];
-				if (gsId.equalsIgnoreCase("all"))
-				{
-					task = new UnregisterAllTask();
-				}
-				else
-				{
-					try
-					{
-						int id = Integer.parseInt(gsId);
-						task = new UnregisterTask(id);
-					}
-					catch (NumberFormatException e)
-					{
-						if (bundle != null)
-						{
-							System.out.printf(bundle.getString("wrongUnregisterArg") + Config.EOL, gsId);
-						}
-						System.exit(1);
-					}
-				}
-			}
-			// --language <locale> : Sets the app to use the specified locale, overriding auto-detection
-			else if (arg.equals("-l") || arg.equals("--language"))
-			{
-				String loc = args[++i];
-				Locale[] availableLocales = Locale.getAvailableLocales();
-				Locale l;
-				for (int j = 0; (j < availableLocales.length) && (locale == null); j++)
-				{
-					l = availableLocales[j];
-					if (l.toString().equals(loc))
-					{
-						locale = l;
-					}
-				}
-				if (locale == null)
-				{
-					System.out.println("Specified locale '" + loc + "' was not found, using default behaviour.");
-				}
-				else
-				{
-					try
-					{
-						bundle = ResourceBundle.getBundle("gsregister.GSRegister", locale, LanguageControl.INSTANCE);
-					}
-					catch (Throwable t)
-					{
-						System.out.println("Failed to load translation ''");
-					}
-				}
-			}
-			// --help : Prints usage/arguments/credits
-			else if (arg.equals("-h") || arg.equals("--help"))
-			{
-				gui = false;
-				interactive = false;
-				
-				BaseGameServerRegister.printHelp(bundle);
-			}
-		}
-		
-		try
-		{
-			if (gui)
-			{
-				BaseGameServerRegister.startGUI(bundle);
-			}
-			else
-			{
-				if (interactive)
-				{
-					BaseGameServerRegister.startCMD(bundle);
-				}
-				else
-				{
-					// if there is a task, do it, else the app has already finished
-					if (task != null)
-					{
-						task.setBundle(bundle);
-						task.run();
-					}
-				}
-			}
-		}
-		catch (HeadlessException e)
-		{
-			BaseGameServerRegister.startCMD(bundle);
-		}
-	}
-	
-	/**
-	 * Prints the help.
-	 * @param bundle the bundle
-	 */
-	private static void printHelp(ResourceBundle bundle)
-	{
-		String[] help =
-		{
-			bundle.getString("purpose"),
-			"",
-			bundle.getString("options"),
-			"-b, --fallback\t\t\t\t" + bundle.getString("fallbackOpt"),
-			"-c, --cmd\t\t\t\t" + bundle.getString("cmdOpt"),
-			"-f, --force\t\t\t\t" + bundle.getString("forceOpt"),
-			"-h, --help\t\t\t\t" + bundle.getString("helpOpt"),
-			"-l, --language\t\t\t\t" + bundle.getString("languageOpt"),
-			"-r, --register <id> <hexid_dest_dir>\t" + bundle.getString("registerOpt1"),
-			"\t\t\t\t\t" + bundle.getString("registerOpt2"),
-			"\t\t\t\t\t" + bundle.getString("registerOpt3"),
-			"",
-			"-u, --unregister <id>|all\t\t" + bundle.getString("unregisterOpt"),
-			"",
-			bundle.getString("credits"),
-			bundle.getString("bugReports") + " http://www.l2jserver.com"
-			
-			/*
-			 * "-b, --fallback\t\t\t\tIf an register operation fails due to ID already being in use it will then try to register first available ID", "-c, --cmd\t\t\t\tForces application to run in command-line mode even if the GUI is supported.",
-			 * "-f, --force\t\t\t\tForces GameServer register operations to overwrite a server if necessary", "-h, --help\t\t\t\tPrints this help message", "-l, --language <locale>\t\t\t\tAsks the application to use the specified locale, overriding auto-detection",
-			 * "-r, --register <id> <hexid_dest_dir>\tRegister GameServer with ID <id> and output hexid on <hexid_dest_dir>", "\t\t\t\t\tUse a negative value on <id> to register the first available ID", "\t\t\t\t\tFails if <id> already in use, unless --force is used (overwrites)", "",
-			 * "-u, --unregister <id>|all\t\tRemoves GameServer denoted by <id>, use \"all\" for removing all registered GameServers", "", "Copyright (C) L2J Team 2008-2012.", "Report bugs: http://www.l2jserver.com"
-			 */
-		};
-		
-		for (String str : help)
-		{
-			System.out.println(str);
-		}
-	}
-	
-	/**
-	 * Start the GUI.
-	 * @param bundle the bundle.
-	 */
-	private static void startGUI(final ResourceBundle bundle)
-	{
-		try
-		{
-			// avoid that ugly Metal LaF
-			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
-		}
-		catch (Exception e)
-		{
-			// couldn't care less
-		}
-		
-		SwingUtilities.invokeLater(() ->
-		{
-			GUserInterface gui = new GUserInterface(bundle);
-			gui.getFrame().setVisible(true);
-		});
-	}
-	
-	/**
-	 * Start the CMD.
-	 * @param bundle the bundle.
-	 */
-	private static void startCMD(final ResourceBundle bundle)
-	{
-		GameServerRegister cmdUi = new GameServerRegister(bundle);
-		try
-		{
-			cmdUi.consoleUI();
-		}
-		catch (IOException e)
-		{
-			cmdUi.showError("I/O exception trying to get input from keyboard.", e);
-		}
-	}
-	
-	/**
-	 * Instantiates a new base game server register.
-	 * @param bundle the bundle.
-	 */
-	public BaseGameServerRegister(ResourceBundle bundle)
-	{
-		setBundle(bundle);
-	}
-	
-	/**
-	 * Load.
-	 */
-	public void load()
-	{
-		Server.serverMode = Server.MODE_LOGINSERVER;
-		
-		Config.load();
-		GameServerTable.getInstance();
-		
-		_loaded = true;
-	}
-	
-	/**
-	 * Checks if is loaded.
-	 * @return true, if is loaded
-	 */
-	public boolean isLoaded()
-	{
-		return _loaded;
-	}
-	
-	/**
-	 * Sets the bundle.
-	 * @param bundle the bundle to set.
-	 */
-	public void setBundle(ResourceBundle bundle)
-	{
-		_bundle = bundle;
-	}
-	
-	/**
-	 * Gets the bundle.
-	 * @return the bundle.
-	 */
-	public ResourceBundle getBundle()
-	{
-		return _bundle;
-	}
-	
-	/**
-	 * Show the error.
-	 * @param msg the msg.
-	 * @param t the t.
-	 */
-	public abstract void showError(String msg, Throwable t);
-	
-	/**
-	 * Unregister the game server.
-	 * @param id the game server id.
-	 * @throws SQLException the SQL exception.
-	 */
-	public static void unregisterGameServer(int id) throws SQLException
-	{
-		try (Connection con = ConnectionFactory.getInstance().getConnection();
-			PreparedStatement ps = con.prepareStatement("DELETE FROM gameservers WHERE server_id = ?"))
-		
-		{
-			ps.setInt(1, id);
-			ps.executeUpdate();
-		}
-		GameServerTable.getInstance().getRegisteredGameServers().remove(id);
-	}
-	
-	/**
-	 * Unregister all game servers.
-	 * @throws SQLException the SQL exception
-	 */
-	public static void unregisterAllGameServers() throws SQLException
-	{
-		try (Connection con = ConnectionFactory.getInstance().getConnection();
-			Statement s = con.createStatement())
-		{
-			s.executeUpdate("DELETE FROM gameservers");
-		}
-		GameServerTable.getInstance().getRegisteredGameServers().clear();
-	}
-	
-	/**
-	 * Register a game server.
-	 * @param id the id of the game server.
-	 * @param outDir the out dir.
-	 * @throws IOException Signals that an I/O exception has occurred.
-	 */
-	public static void registerGameServer(int id, String outDir) throws IOException
-	{
-		byte[] hexId = Util.generateHex(16);
-		GameServerTable.getInstance().registerServerOnDB(hexId, id, "");
-		
-		Properties hexSetting = new Properties();
-		File file = new File(outDir, "hexid.txt");
-		// Create a new empty file only if it doesn't exist
-		file.createNewFile();
-		try (OutputStream out = new FileOutputStream(file))
-		{
-			hexSetting.setProperty("ServerID", String.valueOf(id));
-			hexSetting.setProperty("HexID", new BigInteger(hexId).toString(16));
-			hexSetting.store(out, "The HexId to Auth into LoginServer");
-		}
-	}
-	
-	/**
-	 * Register first available.
-	 * @param outDir the out dir
-	 * @return the int
-	 * @throws IOException Signals that an I/O exception has occurred.
-	 */
-	public static int registerFirstAvailable(String outDir) throws IOException
-	{
-		for (Entry<Integer, String> e : GameServerTable.getInstance().getServerNames().entrySet())
-		{
-			if (!GameServerTable.getInstance().hasRegisteredGameServerOnId(e.getKey()))
-			{
-				BaseGameServerRegister.registerGameServer(e.getKey(), outDir);
-				return e.getKey();
-			}
-		}
-		return -1;
-	}
-	
-	/**
-	 * The Class BaseTask.
-	 */
-	protected static abstract class BaseTask implements Runnable
-	{
-		private ResourceBundle _bundle;
-		
-		/**
-		 * Sets the bundle.
-		 * @param bundle The bundle to set.
-		 */
-		public void setBundle(ResourceBundle bundle)
-		{
-			_bundle = bundle;
-		}
-		
-		/**
-		 * Gets the bundle.
-		 * @return Returns the bundle.
-		 */
-		public ResourceBundle getBundle()
-		{
-			return _bundle;
-		}
-		
-		/**
-		 * Show the error.
-		 * @param msg the msg
-		 * @param t the t
-		 */
-		public void showError(String msg, Throwable t)
-		{
-			String title;
-			if (getBundle() != null)
-			{
-				title = getBundle().getString("error");
-				msg += Config.EOL + getBundle().getString("reason") + ' ' + t.getLocalizedMessage();
-			}
-			else
-			{
-				title = "Error";
-				msg += Config.EOL + "Cause: " + t.getLocalizedMessage();
-			}
-			System.out.println(title + ": " + msg);
-		}
-	}
-	
-	/**
-	 * The Class RegisterTask.
-	 */
-	private static class RegisterTask extends BaseTask
-	{
-		private final int _id;
-		private final String _outDir;
-		private boolean _force;
-		private boolean _fallback;
-		
-		/**
-		 * Instantiates a new register task.
-		 * @param id the id.
-		 * @param outDir the out dir.
-		 * @param force the force.
-		 * @param fallback the fallback.
-		 */
-		public RegisterTask(int id, String outDir, boolean force, boolean fallback)
-		{
-			_id = id;
-			_outDir = outDir;
-			_force = force;
-			_fallback = fallback;
-		}
-		
-		@Override
-		public void run()
-		{
-			try
-			{
-				if (_id < 0)
-				{
-					int registeredId = BaseGameServerRegister.registerFirstAvailable(_outDir);
-					
-					if (registeredId < 0)
-					{
-						System.out.println(getBundle().getString("noFreeId"));
-					}
-					else
-					{
-						System.out.printf(getBundle().getString("registrationOk") + Config.EOL, registeredId);
-					}
-				}
-				else
-				{
-					System.out.printf(getBundle().getString("checkingIdInUse") + Config.EOL, _id);
-					if (GameServerTable.getInstance().hasRegisteredGameServerOnId(_id))
-					{
-						System.out.println(getBundle().getString("yes"));
-						if (_force)
-						{
-							System.out.printf(getBundle().getString("forcingRegistration") + Config.EOL, _id);
-							BaseGameServerRegister.unregisterGameServer(_id);
-							BaseGameServerRegister.registerGameServer(_id, _outDir);
-							System.out.printf(getBundle().getString("registrationOk") + Config.EOL, _id);
-						}
-						else if (_fallback)
-						{
-							System.out.println(getBundle().getString("fallingBack"));
-							int registeredId = BaseGameServerRegister.registerFirstAvailable(_outDir);
-							
-							if (registeredId < 0)
-							{
-								System.out.println(getBundle().getString("noFreeId"));
-							}
-							else
-							{
-								System.out.printf(getBundle().getString("registrationOk") + Config.EOL, registeredId);
-							}
-						}
-						else
-						{
-							System.out.println(getBundle().getString("noAction"));
-						}
-					}
-					else
-					{
-						System.out.println(getBundle().getString("no"));
-						BaseGameServerRegister.registerGameServer(_id, _outDir);
-					}
-				}
-			}
-			catch (SQLException e)
-			{
-				showError(getBundle().getString("sqlErrorRegister"), e);
-			}
-			catch (IOException e)
-			{
-				showError(getBundle().getString("ioErrorRegister"), e);
-			}
-		}
-	}
-	
-	/**
-	 * The Class UnregisterTask.
-	 */
-	private static class UnregisterTask extends BaseTask
-	{
-		private final int _id;
-		
-		/**
-		 * Instantiates a new unregister task.
-		 * @param id the task id.
-		 */
-		public UnregisterTask(int id)
-		{
-			_id = id;
-			
-		}
-		
-		@Override
-		public void run()
-		{
-			System.out.printf(getBundle().getString("removingGsId") + Config.EOL, _id);
-			try
-			{
-				BaseGameServerRegister.unregisterGameServer(_id);
-			}
-			catch (SQLException e)
-			{
-				showError(getBundle().getString("sqlErrorRegister"), e);
-			}
-		}
-	}
-	
-	/**
-	 * The Class UnregisterAllTask.
-	 */
-	protected static class UnregisterAllTask extends BaseTask
-	{
-		@Override
-		public void run()
-		{
-			try
-			{
-				BaseGameServerRegister.unregisterAllGameServers();
-			}
-			catch (SQLException e)
-			{
-				showError(getBundle().getString("sqlErrorUnregisterAll"), e);
-			}
-		}
-	}
-}

+ 0 - 389
src/main/java/com/l2jserver/tools/gsregistering/GUserInterface.java

@@ -1,389 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.gsregistering;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.sql.SQLException;
-import java.util.ResourceBundle;
-
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLayeredPane;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JProgressBar;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.SwingUtilities;
-import javax.swing.WindowConstants;
-import javax.swing.table.DefaultTableModel;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
-
-import com.l2jserver.Config;
-import com.l2jserver.loginserver.GameServerTable;
-import com.l2jserver.tools.images.ImagesTable;
-
-/**
- * @author KenM
- */
-public class GUserInterface extends BaseGameServerRegister implements ActionListener
-{
-	private final JFrame _frame;
-	private final JTableModel _dtm;
-	protected final JProgressBar _progressBar;
-	
-	public JTable _gsTable;
-	
-	public GUserInterface(ResourceBundle bundle)
-	{
-		super(bundle);
-		
-		_frame = new JFrame();
-		getFrame().setTitle(getBundle().getString("toolName"));
-		getFrame().setSize(600, 400);
-		getFrame().setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
-		getFrame().setLayout(new GridBagLayout());
-		GridBagConstraints cons = new GridBagConstraints();
-		
-		JFrame.setDefaultLookAndFeelDecorated(true);
-		getFrame().setIconImage(ImagesTable.getImage("l2j.png").getImage());
-		
-		JMenuBar menubar = new JMenuBar();
-		getFrame().setJMenuBar(menubar);
-		
-		JMenu fileMenu = new JMenu(getBundle().getString("fileMenu"));
-		
-		JMenuItem exitItem = new JMenuItem(getBundle().getString("exitItem"));
-		exitItem.addActionListener(this);
-		exitItem.setActionCommand("exit");
-		
-		fileMenu.add(exitItem);
-		
-		JMenu helpMenu = new JMenu(getBundle().getString("helpMenu"));
-		
-		JMenuItem aboutItem = new JMenuItem(getBundle().getString("aboutItem"));
-		aboutItem.addActionListener(this);
-		aboutItem.setActionCommand("about");
-		
-		helpMenu.add(aboutItem);
-		
-		menubar.add(fileMenu);
-		menubar.add(helpMenu);
-		
-		JButton btnRegister = new JButton(getBundle().getString("btnRegister"), ImagesTable.getImage("add.png"));
-		btnRegister.addActionListener(this);
-		btnRegister.setActionCommand("register");
-		getFrame().add(btnRegister, cons);
-		
-		cons.gridx = 1;
-		cons.anchor = GridBagConstraints.LINE_END;
-		JButton btnRemoveAll = new JButton(getBundle().getString("btnRemoveAll"), ImagesTable.getImage("cross.png"));
-		btnRemoveAll.addActionListener(this);
-		btnRemoveAll.setActionCommand("removeAll");
-		getFrame().add(btnRemoveAll, cons);
-		
-		String name = getBundle().getString("gsName");
-		String action = getBundle().getString("gsAction");
-		
-		_dtm = new JTableModel(new Object[]
-		{
-			"ID",
-			name,
-			action
-		});
-		_gsTable = new JTable(_dtm);
-		_gsTable.addMouseListener(new JTableButtonMouseListener(_gsTable));
-		
-		_gsTable.getColumnModel().getColumn(0).setMaxWidth(30);
-		
-		TableColumn actionCollumn = _gsTable.getColumnModel().getColumn(2);
-		actionCollumn.setCellRenderer(new ButtonCellRenderer());
-		
-		cons.fill = GridBagConstraints.BOTH;
-		cons.gridx = 0;
-		cons.gridy = 1;
-		cons.weighty = 1.0;
-		cons.weightx = 1.0;
-		cons.gridwidth = 2;
-		JLayeredPane layer = new JLayeredPane();
-		layer.setLayout(new BoxLayout(layer, BoxLayout.PAGE_AXIS));
-		layer.add(new JScrollPane(_gsTable), 0);
-		_progressBar = new JProgressBar();
-		_progressBar.setIndeterminate(true);
-		_progressBar.setVisible(false);
-		layer.add(_progressBar, BorderLayout.CENTER, 1);
-		// layer.setV
-		getFrame().add(layer, cons);
-		
-		refreshAsync();
-	}
-	
-	public void refreshAsync()
-	{
-		Thread t = new Thread(() -> GUserInterface.this.refreshServers(), "LoaderThread");
-		t.start();
-	}
-	
-	@Override
-	public void load()
-	{
-		SwingUtilities.invokeLater(() -> _progressBar.setVisible(true));
-		
-		super.load();
-		
-		SwingUtilities.invokeLater(() -> _progressBar.setVisible(false));
-	}
-	
-	@Override
-	public void showError(String msg, Throwable t)
-	{
-		String title;
-		if (getBundle() != null)
-		{
-			title = getBundle().getString("error");
-			msg += Config.EOL + getBundle().getString("reason") + ' ' + t.getLocalizedMessage();
-		}
-		else
-		{
-			title = "Error";
-			msg += Config.EOL + "Cause: " + t.getLocalizedMessage();
-		}
-		JOptionPane.showMessageDialog(getFrame(), msg, title, JOptionPane.ERROR_MESSAGE);
-	}
-	
-	protected void refreshServers()
-	{
-		if (!isLoaded())
-		{
-			load();
-		}
-		
-		// load succeeded?
-		if (isLoaded())
-		{
-			SwingUtilities.invokeLater(() ->
-			{
-				int size = GameServerTable.getInstance().getServerNames().size();
-				if (size == 0)
-				{
-					String title = getBundle().getString("error");
-					String msg = getBundle().getString("noServerNames");
-					JOptionPane.showMessageDialog(getFrame(), msg, title, JOptionPane.ERROR_MESSAGE);
-					System.exit(1);
-				}
-				// reset
-				_dtm.setRowCount(0);
-				
-				for (final int id : GameServerTable.getInstance().getRegisteredGameServers().keySet())
-				{
-					String name = GameServerTable.getInstance().getServerNameById(id);
-					JButton button = new JButton(getBundle().getString("btnRemove"), ImagesTable.getImage("cross.png"));
-					button.addActionListener(e ->
-					{
-						String sid = String.valueOf(id);
-						String sname = GameServerTable.getInstance().getServerNameById(id);
-						
-						int choice = JOptionPane.showConfirmDialog(getFrame(), getBundle().getString("confirmRemoveText").replace("%d", sid).replace("%s", sname), getBundle().getString("confirmRemoveTitle"), JOptionPane.YES_NO_OPTION);
-						if (choice == JOptionPane.YES_OPTION)
-						{
-							try
-							{
-								BaseGameServerRegister.unregisterGameServer(id);
-								GUserInterface.this.refreshAsync();
-							}
-							catch (SQLException e1)
-							{
-								GUserInterface.this.showError(getBundle().getString("errorUnregister"), e1);
-							}
-						}
-					});
-					_dtm.addRow(new Object[]
-					{
-						id,
-						name,
-						button
-					});
-				}
-			});
-		}
-	}
-	
-	@Override
-	public void actionPerformed(ActionEvent e)
-	{
-		String cmd = e.getActionCommand();
-		
-		if (cmd.equals("register"))
-		{
-			RegisterDialog rd = new RegisterDialog(this);
-			rd.setVisible(true);
-		}
-		else if (cmd.equals("exit"))
-		{
-			System.exit(0);
-		}
-		else if (cmd.equals("about"))
-		{
-			JOptionPane.showMessageDialog(getFrame(), getBundle().getString("credits") + Config.EOL + "http://www.l2jserver.com" + Config.EOL + Config.EOL + getBundle().getString("icons") + Config.EOL + Config.EOL + getBundle().getString("langText") + Config.EOL
-				+ getBundle().getString("translation"), getBundle().getString("aboutItem"), JOptionPane.INFORMATION_MESSAGE, ImagesTable.getImage("l2jserverlogo.png"));
-		}
-		else if (cmd.equals("removeAll"))
-		{
-			int choice = JOptionPane.showConfirmDialog(getFrame(), getBundle().getString("confirmRemoveAllText"), getBundle().getString("confirmRemoveTitle"), JOptionPane.YES_NO_OPTION);
-			if (choice == JOptionPane.YES_OPTION)
-			{
-				try
-				{
-					BaseGameServerRegister.unregisterAllGameServers();
-					refreshAsync();
-				}
-				catch (SQLException e1)
-				{
-					GUserInterface.this.showError(getBundle().getString("errorUnregister"), e1);
-				}
-			}
-		}
-	}
-	
-	/**
-	 * @return Returns the frame.
-	 */
-	public JFrame getFrame()
-	{
-		return _frame;
-	}
-	
-	protected class ButtonCellRenderer implements TableCellRenderer
-	{
-		@Override
-		public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
-		{
-			return (Component) value;
-		}
-	}
-	
-	/**
-	 * Forward mouse-events from table to buttons inside.<br>
-	 * Buttons animate properly.
-	 * @author KenM
-	 */
-	private class JTableButtonMouseListener implements MouseListener
-	{
-		private final JTable _table;
-		
-		public JTableButtonMouseListener(JTable table)
-		{
-			_table = table;
-		}
-		
-		private void forwardEvent(MouseEvent e)
-		{
-			TableColumnModel columnModel = _table.getColumnModel();
-			int column = columnModel.getColumnIndexAtX(e.getX());
-			int row = e.getY() / _table.getRowHeight();
-			Object value;
-			
-			if ((row >= _table.getRowCount()) || (row < 0) || (column >= _table.getColumnCount()) || (column < 0))
-			{
-				return;
-			}
-			
-			value = _table.getValueAt(row, column);
-			
-			if (value instanceof JButton)
-			{
-				final JButton b = (JButton) value;
-				if (e.getID() == MouseEvent.MOUSE_PRESSED)
-				{
-					b.getModel().setPressed(true);
-					b.getModel().setArmed(true);
-					_table.repaint();
-				}
-				else if (e.getID() == MouseEvent.MOUSE_RELEASED)
-				{
-					b.doClick();
-				}
-			}
-		}
-		
-		@Override
-		public void mouseEntered(MouseEvent e)
-		{
-			forwardEvent(e);
-		}
-		
-		@Override
-		public void mouseExited(MouseEvent e)
-		{
-			forwardEvent(e);
-		}
-		
-		@Override
-		public void mousePressed(MouseEvent e)
-		{
-			forwardEvent(e);
-		}
-		
-		@Override
-		public void mouseClicked(MouseEvent e)
-		{
-			forwardEvent(e);
-		}
-		
-		@Override
-		public void mouseReleased(MouseEvent e)
-		{
-			forwardEvent(e);
-		}
-	}
-	
-	private class JTableModel extends DefaultTableModel
-	{
-		private static final long serialVersionUID = -5907903982876753479L;
-		
-		public JTableModel(Object[] columnNames)
-		{
-			super(columnNames, 0);
-		}
-		
-		@Override
-		public boolean isCellEditable(int row, int column)
-		{
-			return false;
-		}
-		
-		@Override
-		public Class<?> getColumnClass(int column)
-		{
-			return getValueAt(0, column).getClass();
-		}
-	}
-}

+ 0 - 343
src/main/java/com/l2jserver/tools/gsregistering/GameServerRegister.java

@@ -1,343 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.gsregistering;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.sql.SQLException;
-import java.util.Map.Entry;
-import java.util.ResourceBundle;
-
-import com.l2jserver.Config;
-import com.l2jserver.loginserver.GameServerTable;
-
-public class GameServerRegister extends BaseGameServerRegister
-{
-	private LineNumberReader _in;
-	
-	public static void main(String[] args)
-	{
-		// Backwards compatibility, redirect to the new one
-		BaseGameServerRegister.main(args);
-	}
-	
-	/**
-	 * @param bundle
-	 */
-	public GameServerRegister(ResourceBundle bundle)
-	{
-		super(bundle);
-		load();
-		
-		int size = GameServerTable.getInstance().getServerNames().size();
-		if (size == 0)
-		{
-			System.out.println(getBundle().getString("noServerNames"));
-			System.exit(1);
-		}
-	}
-	
-	public void consoleUI() throws IOException
-	{
-		_in = new LineNumberReader(new InputStreamReader(System.in));
-		boolean choiceOk = false;
-		String choice;
-		
-		while (true)
-		{
-			hr();
-			System.out.println("GSRegister");
-			System.out.println(Config.EOL);
-			System.out.println("1 - " + getBundle().getString("cmdMenuRegister"));
-			System.out.println("2 - " + getBundle().getString("cmdMenuListNames"));
-			System.out.println("3 - " + getBundle().getString("cmdMenuRemoveGS"));
-			System.out.println("4 - " + getBundle().getString("cmdMenuRemoveAll"));
-			System.out.println("5 - " + getBundle().getString("cmdMenuExit"));
-			
-			do
-			{
-				System.out.print(getBundle().getString("yourChoice") + ' ');
-				choice = _in.readLine();
-				try
-				{
-					int choiceNumber = Integer.parseInt(choice);
-					choiceOk = true;
-					
-					switch (choiceNumber)
-					{
-						case 1:
-							registerNewGS();
-							break;
-						case 2:
-							listGSNames();
-							break;
-						case 3:
-							unregisterSingleGS();
-							break;
-						case 4:
-							unregisterAllGS();
-							break;
-						case 5:
-							System.exit(0);
-							break;
-						default:
-							System.out.printf(getBundle().getString("invalidChoice") + Config.EOL, choice);
-							choiceOk = false;
-					}
-					
-				}
-				catch (NumberFormatException nfe)
-				{
-					System.out.printf(getBundle().getString("invalidChoice") + Config.EOL, choice);
-				}
-			}
-			while (!choiceOk);
-		}
-	}
-	
-	/**
-	 * 
-	 */
-	private void hr()
-	{
-		System.out.println("_____________________________________________________" + Config.EOL);
-	}
-	
-	/**
-	 * 
-	 */
-	private void listGSNames()
-	{
-		int idMaxLen = 0;
-		int nameMaxLen = 0;
-		for (Entry<Integer, String> e : GameServerTable.getInstance().getServerNames().entrySet())
-		{
-			if (e.getKey().toString().length() > idMaxLen)
-			{
-				idMaxLen = e.getKey().toString().length();
-			}
-			if (e.getValue().length() > nameMaxLen)
-			{
-				nameMaxLen = e.getValue().length();
-			}
-		}
-		idMaxLen += 2;
-		nameMaxLen += 2;
-		
-		String id;
-		boolean inUse;
-		String gsInUse = getBundle().getString("gsInUse");
-		String gsFree = getBundle().getString("gsFree");
-		int gsStatusMaxLen = Math.max(gsInUse.length(), gsFree.length()) + 2;
-		for (Entry<Integer, String> e : GameServerTable.getInstance().getServerNames().entrySet())
-		{
-			id = e.getKey().toString();
-			System.out.print(id);
-			
-			for (int i = id.length(); i < idMaxLen; i++)
-			{
-				System.out.print(' ');
-			}
-			System.out.print("| ");
-			
-			System.out.print(e.getValue());
-			
-			for (int i = e.getValue().length(); i < nameMaxLen; i++)
-			{
-				System.out.print(' ');
-			}
-			System.out.print("| ");
-			
-			inUse = GameServerTable.getInstance().hasRegisteredGameServerOnId(e.getKey());
-			String inUseStr = (inUse ? gsInUse : gsFree);
-			System.out.print(inUseStr);
-			
-			for (int i = inUseStr.length(); i < gsStatusMaxLen; i++)
-			{
-				System.out.print(' ');
-			}
-			System.out.println('|');
-		}
-	}
-	
-	/**
-	 * @throws IOException
-	 */
-	private void unregisterAllGS() throws IOException
-	{
-		if (yesNoQuestion(getBundle().getString("confirmRemoveAllText")))
-		{
-			try
-			{
-				BaseGameServerRegister.unregisterAllGameServers();
-				System.out.println(getBundle().getString("unregisterAllOk"));
-			}
-			catch (SQLException e)
-			{
-				showError(getBundle().getString("sqlErrorUnregisterAll"), e);
-			}
-		}
-	}
-	
-	private boolean yesNoQuestion(String question) throws IOException
-	{
-		
-		do
-		{
-			hr();
-			System.out.println(question);
-			System.out.println("1 - " + getBundle().getString("yes"));
-			System.out.println("2 - " + getBundle().getString("no"));
-			System.out.print(getBundle().getString("yourChoice") + ' ');
-			String choice;
-			choice = _in.readLine();
-			if (choice != null)
-			{
-				if (choice.equals("1"))
-				{
-					return true;
-				}
-				else if (choice.equals("2"))
-				{
-					return false;
-				}
-				else
-				{
-					System.out.printf(getBundle().getString("invalidChoice") + Config.EOL, choice);
-				}
-			}
-		}
-		while (true);
-	}
-	
-	/**
-	 * @throws IOException
-	 */
-	private void unregisterSingleGS() throws IOException
-	{
-		String line;
-		int id = Integer.MIN_VALUE;
-		
-		do
-		{
-			System.out.print(getBundle().getString("enterDesiredId") + ' ');
-			line = _in.readLine();
-			try
-			{
-				id = Integer.parseInt(line);
-			}
-			catch (NumberFormatException e)
-			{
-				System.out.printf(getBundle().getString("invalidChoice") + Config.EOL, line);
-			}
-		}
-		while (id == Integer.MIN_VALUE);
-		
-		String name = GameServerTable.getInstance().getServerNameById(id);
-		if (name == null)
-		{
-			System.out.printf(getBundle().getString("noNameForId") + Config.EOL, id);
-		}
-		else
-		{
-			if (GameServerTable.getInstance().hasRegisteredGameServerOnId(id))
-			{
-				System.out.printf(getBundle().getString("confirmRemoveText") + Config.EOL, id, name);
-				try
-				{
-					BaseGameServerRegister.unregisterGameServer(id);
-					System.out.printf(getBundle().getString("unregisterOk") + Config.EOL, id);
-				}
-				catch (SQLException e)
-				{
-					showError(getBundle().getString("sqlErrorUnregister"), e);
-				}
-				
-			}
-			else
-			{
-				System.out.printf(getBundle().getString("noServerForId") + Config.EOL, id);
-			}
-		}
-		
-	}
-	
-	private void registerNewGS() throws IOException
-	{
-		String line;
-		int id = Integer.MIN_VALUE;
-		
-		do
-		{
-			System.out.println(getBundle().getString("enterDesiredId"));
-			line = _in.readLine();
-			try
-			{
-				id = Integer.parseInt(line);
-			}
-			catch (NumberFormatException e)
-			{
-				System.out.printf(getBundle().getString("invalidChoice") + Config.EOL, line);
-			}
-		}
-		while (id == Integer.MIN_VALUE);
-		
-		String name = GameServerTable.getInstance().getServerNameById(id);
-		if (name == null)
-		{
-			System.out.printf(getBundle().getString("noNameForId") + Config.EOL, id);
-		}
-		else
-		{
-			if (GameServerTable.getInstance().hasRegisteredGameServerOnId(id))
-			{
-				System.out.println(getBundle().getString("idIsNotFree"));
-			}
-			else
-			{
-				try
-				{
-					BaseGameServerRegister.registerGameServer(id, ".");
-				}
-				catch (IOException e)
-				{
-					showError(getBundle().getString("ioErrorRegister"), e);
-				}
-			}
-		}
-	}
-	
-	@Override
-	public void showError(String msg, Throwable t)
-	{
-		String title;
-		if (getBundle() != null)
-		{
-			title = getBundle().getString("error");
-			msg += Config.EOL + getBundle().getString("reason") + ' ' + t.getLocalizedMessage();
-		}
-		else
-		{
-			title = "Error";
-			msg += Config.EOL + "Cause: " + t.getLocalizedMessage();
-		}
-		System.out.println(title + ": " + msg);
-	}
-}

+ 0 - 199
src/main/java/com/l2jserver/tools/gsregistering/RegisterDialog.java

@@ -1,199 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.gsregistering;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JDialog;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
-import javax.swing.JTextPane;
-import javax.swing.WindowConstants;
-import javax.swing.filechooser.FileFilter;
-
-import com.l2jserver.loginserver.GameServerTable;
-
-/**
- * @author KenM
- */
-public class RegisterDialog extends JDialog implements ActionListener
-{
-	private static final long serialVersionUID = 1L;
-	
-	private final ResourceBundle _bundle;
-	private final JComboBox<ComboServer> _combo;
-	private final GUserInterface _owner;
-	
-	public RegisterDialog(final GUserInterface owner)
-	{
-		super(owner.getFrame(), true);
-		_owner = owner;
-		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
-		_bundle = owner.getBundle();
-		setTitle(_bundle.getString("registerGS"));
-		setResizable(false);
-		setLayout(new GridBagLayout());
-		GridBagConstraints cons = new GridBagConstraints();
-		cons.weightx = 0.5;
-		cons.weighty = 0.5;
-		cons.gridx = 0;
-		cons.gridy = 0;
-		cons.fill = GridBagConstraints.BOTH;
-		
-		final JLabel label = new JLabel(_bundle.getString("serverName"));
-		this.add(label, cons);
-		
-		_combo = new JComboBox<>();
-		_combo.setEditable(false);
-		for (Map.Entry<Integer, String> entry : GameServerTable.getInstance().getServerNames().entrySet())
-		{
-			if (!GameServerTable.getInstance().hasRegisteredGameServerOnId(entry.getKey()))
-			{
-				_combo.addItem(new ComboServer(entry.getKey(), entry.getValue()));
-			}
-		}
-		cons.gridx = 1;
-		cons.gridy = 0;
-		this.add(_combo, cons);
-		
-		cons.gridx = 0;
-		cons.gridy = 1;
-		cons.gridwidth = 2;
-		JTextPane textPane = new JTextPane();
-		textPane.setText(_bundle.getString("saveHexId"));
-		textPane.setEditable(false);
-		textPane.setBackground(label.getBackground());
-		this.add(textPane, cons);
-		cons.gridwidth = 1;
-		
-		JButton btnSave = new JButton(_bundle.getString("save"));
-		btnSave.setActionCommand("save");
-		btnSave.addActionListener(this);
-		cons.gridx = 0;
-		cons.gridy = 2;
-		this.add(btnSave, cons);
-		
-		JButton btnCancel = new JButton(_bundle.getString("cancel"));
-		btnCancel.setActionCommand("cancel");
-		btnCancel.addActionListener(this);
-		cons.gridx = 1;
-		cons.gridy = 2;
-		this.add(btnCancel, cons);
-		
-		final double leftSize = Math.max(label.getPreferredSize().getWidth(), btnSave.getPreferredSize().getWidth());
-		final double rightSize = Math.max(_combo.getPreferredSize().getWidth(), btnCancel.getPreferredSize().getWidth());
-		
-		final double height = _combo.getPreferredSize().getHeight() + (4 * textPane.getPreferredSize().getHeight()) + btnSave.getPreferredSize().getHeight();
-		this.setSize((int) (leftSize + rightSize + 30), (int) (height + 20));
-		
-		setLocationRelativeTo(owner.getFrame());
-	}
-	
-	class ComboServer
-	{
-		private final int _id;
-		private final String _name;
-		
-		public ComboServer(int id, String name)
-		{
-			_id = id;
-			_name = name;
-		}
-		
-		/**
-		 * @return Returns the id.
-		 */
-		public int getId()
-		{
-			return _id;
-		}
-		
-		/**
-		 * @return Returns the name.
-		 */
-		public String getName()
-		{
-			return _name;
-		}
-		
-		@Override
-		public String toString()
-		{
-			return getName();
-		}
-	}
-	
-	@Override
-	public void actionPerformed(ActionEvent e)
-	{
-		String cmd = e.getActionCommand();
-		
-		if (cmd.equals("save"))
-		{
-			ComboServer server = (ComboServer) _combo.getSelectedItem();
-			int gsId = server.getId();
-			
-			JFileChooser fc = new JFileChooser();
-			// fc.setS
-			fc.setDialogTitle(_bundle.getString("hexidDest"));
-			fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
-			fc.setFileFilter(new FileFilter()
-			{
-				
-				@Override
-				public boolean accept(File f)
-				{
-					return f.isDirectory();
-				}
-				
-				@Override
-				public String getDescription()
-				{
-					return null;
-				}
-				
-			});
-			fc.showOpenDialog(this);
-			
-			try
-			{
-				BaseGameServerRegister.registerGameServer(gsId, fc.getSelectedFile().getAbsolutePath());
-				_owner.refreshAsync();
-				setVisible(false);
-			}
-			catch (IOException e1)
-			{
-				_owner.showError(_bundle.getString("ioErrorRegister"), e1);
-			}
-		}
-		else if (cmd.equals("cancel"))
-		{
-			setVisible(false);
-		}
-	}
-}

+ 0 - 37
src/main/java/com/l2jserver/tools/util/ResourceUtil.java

@@ -1,37 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.util;
-
-/**
- * @author HorridoJoho
- */
-public final class ResourceUtil
-{
-	public static void close(AutoCloseable res)
-	{
-		try
-		{
-			res.close();
-		}
-		catch (Exception e)
-		{
-			e.printStackTrace();
-		}
-	}
-}

+ 0 - 286
src/main/java/com/l2jserver/tools/util/SQLUtil.java

@@ -1,286 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.util;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Formatter;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Scanner;
-
-import com.l2jserver.tools.util.io.FileWriterStdout;
-import com.l2jserver.util.file.filter.SQLFilter;
-
-/**
- * SQL helpers.
- * @author HorridoJoho
- */
-public final class SQLUtil
-{
-	public static Connection connect(String host, String port, String user, String password, String db) throws SQLException
-	{
-		final String url = String.format("jdbc:mysql://%s:%s", host, port);
-		final Properties info = new Properties();
-		info.put("user", user);
-		info.put("password", password);
-		info.put("useSSL", "false");
-		info.put("serverTimezone", "UTC");
-		info.put("allowPublicKeyRetrieval", "true");
-		return DriverManager.getConnection(url, info);
-	}
-	
-	public static void close(Connection con)
-	{
-		ResourceUtil.close(con);
-	}
-	
-	public static void createDump(Connection con, String db) throws IOException, SQLException
-	{
-		try (Formatter form = new Formatter())
-		{
-			try (Statement s = con.createStatement();
-				ResultSet rset = s.executeQuery("SHOW TABLES"))
-			{
-				File dump = new File("dumps", form.format("%1$s_dump_%2$tY%2$tm%2$td-%2$tH%2$tM%2$tS.sql", db, new GregorianCalendar().getTime()).toString());
-				new File("dumps").mkdir();
-				dump.createNewFile();
-				
-				if (rset.last())
-				{
-					// int rows = rset.getRow();
-					rset.beforeFirst();
-				}
-				
-				try (FileWriter fileWriter = new FileWriter(dump);
-					FileWriterStdout fws = new FileWriterStdout(fileWriter))
-				{
-					while (rset.next())
-					{
-						fws.println("CREATE TABLE `" + rset.getString(1) + "`");
-						fws.println("(");
-						try (Statement desc = con.createStatement();
-							ResultSet dset = desc.executeQuery("DESC " + rset.getString(1)))
-						{
-							Map<String, List<String>> keys = new HashMap<>();
-							boolean isFirst = true;
-							while (dset.next())
-							{
-								if (!isFirst)
-								{
-									fws.println(",");
-								}
-								fws.print("\t`" + dset.getString(1) + "`");
-								fws.print(" " + dset.getString(2));
-								if (dset.getString(3).equals("NO"))
-								{
-									fws.print(" NOT NULL");
-								}
-								if (!dset.getString(4).isEmpty())
-								{
-									if (!keys.containsKey(dset.getString(4)))
-									{
-										keys.put(dset.getString(4), new ArrayList<String>());
-									}
-									keys.get(dset.getString(4)).add(dset.getString(1));
-								}
-								if (dset.getString(5) != null)
-								{
-									fws.print(" DEFAULT '" + dset.getString(5) + "'");
-								}
-								if (!dset.getString(6).isEmpty())
-								{
-									fws.print(" " + dset.getString(6));
-								}
-								isFirst = false;
-							}
-							if (keys.containsKey("PRI"))
-							{
-								fws.println(",");
-								fws.print("\tPRIMARY KEY (");
-								isFirst = true;
-								for (String key : keys.get("PRI"))
-								{
-									if (!isFirst)
-									{
-										fws.print(", ");
-									}
-									fws.print("`" + key + "`");
-									isFirst = false;
-								}
-								fws.print(")");
-							}
-							if (keys.containsKey("MUL"))
-							{
-								fws.println(",");
-								isFirst = true;
-								for (String key : keys.get("MUL"))
-								{
-									if (!isFirst)
-									{
-										fws.println(", ");
-									}
-									fws.print("\tKEY `key_" + key + "` (`" + key + "`)");
-									isFirst = false;
-								}
-							}
-							fws.println();
-							fws.println(");");
-							fws.flush();
-						}
-						
-						try (Statement desc = con.createStatement();
-							ResultSet dset = desc.executeQuery("SELECT * FROM " + rset.getString(1)))
-						{
-							boolean isFirst = true;
-							int cnt = 0;
-							while (dset.next())
-							{
-								if ((cnt % 100) == 0)
-								{
-									fws.println("INSERT INTO `" + rset.getString(1) + "` VALUES ");
-								}
-								else
-								{
-									fws.println(",");
-								}
-								
-								fws.print("\t(");
-								boolean isInFirst = true;
-								for (int i = 1; i <= dset.getMetaData().getColumnCount(); i++)
-								{
-									if (!isInFirst)
-									{
-										fws.print(", ");
-									}
-									
-									if (dset.getString(i) == null)
-									{
-										fws.print("NULL");
-									}
-									else
-									{
-										fws.print("'" + dset.getString(i).replace("\'", "\\\'") + "'");
-									}
-									isInFirst = false;
-								}
-								fws.print(")");
-								isFirst = false;
-								
-								if ((cnt % 100) == 99)
-								{
-									fws.println(";");
-								}
-								cnt++;
-							}
-							if (!isFirst && ((cnt % 100) != 0))
-							{
-								fws.println(";");
-							}
-							fws.println();
-							fws.flush();
-						}
-					}
-					fws.flush();
-				}
-			}
-		}
-	}
-	
-	public static void ensureDatabaseUsage(Connection con, String db) throws SQLException
-	{
-		try (Statement s = con.createStatement())
-		{
-			s.execute("CREATE DATABASE IF NOT EXISTS `" + db + "`");
-			s.execute("USE `" + db + "`");
-		}
-	}
-	
-	public static void executeSQLScript(Connection con, File file) throws FileNotFoundException, SQLException
-	{
-		String line = "";
-		try (Statement stmt = con.createStatement();
-			Scanner scn = new Scanner(file))
-		{
-			StringBuilder sb = new StringBuilder();
-			while (scn.hasNextLine())
-			{
-				line = scn.nextLine();
-				if (line.startsWith("--"))
-				{
-					continue;
-				}
-				else if (line.contains("--"))
-				{
-					line = line.split("--")[0];
-				}
-				
-				line = line.trim();
-				if (!line.isEmpty())
-				{
-					sb.append(line + System.getProperty("line.separator"));
-				}
-				
-				if (line.endsWith(";"))
-				{
-					stmt.execute(sb.toString());
-					sb = new StringBuilder();
-				}
-			}
-		}
-	}
-	
-	public static void executeDirectoryOfSQLScripts(Connection con, File dir, boolean skipErrors) throws FileNotFoundException, SQLException
-	{
-		final File[] files = dir.listFiles(new SQLFilter());
-		if (files != null)
-		{
-			Arrays.sort(files);
-			for (File file : files)
-			{
-				if (skipErrors)
-				{
-					try
-					{
-						executeSQLScript(con, file);
-					}
-					catch (Throwable t)
-					{
-					}
-				}
-				else
-				{
-					executeSQLScript(con, file);
-				}
-			}
-		}
-	}
-}

+ 0 - 52
src/main/java/com/l2jserver/tools/util/SwingUtil.java

@@ -1,52 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.util;
-
-import java.awt.Container;
-import java.awt.Window;
-
-import javax.swing.JDialog;
-import javax.swing.WindowConstants;
-
-import com.l2jserver.tools.util.swing.BackgroundTask;
-import com.l2jserver.tools.util.swing.BackgroundTaskRunner;
-
-/**
- * @author HorridoJoho
- */
-public final class SwingUtil
-{
-	public static <T> T runBackgroundTaskWithDialog(Window owner, String title, Container contentPane, BackgroundTask<T> task) throws Throwable
-	{
-		final JDialog dialog = new JDialog(owner, title);
-		dialog.setContentPane(contentPane);
-		dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
-		dialog.pack();
-		dialog.setLocationByPlatform(true);
-		dialog.setLocationRelativeTo(owner);
-		
-		BackgroundTaskRunner<T> runner = new BackgroundTaskRunner<>(dialog, task);
-		dialog.dispose();
-		if (runner.getThrown() != null)
-		{
-			throw runner.getThrown();
-		}
-		return runner.getResult();
-	}
-}

+ 0 - 45
src/main/java/com/l2jserver/tools/util/app/IApplicationFrontend.java

@@ -1,45 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.util.app;
-
-/**
- * @author HorridoJoho
- */
-public interface IApplicationFrontend
-{
-	void reportInfo(boolean drawAttention, String message);
-	
-	void reportInfo(boolean drawAttention, String message, Object... args);
-	
-	void reportWarn(boolean drawAttention, String message);
-	
-	void reportWarn(boolean drawAttention, String message, Object... args);
-	
-	void reportError(boolean drawAttention, String message);
-	
-	void reportError(boolean drawAttention, Throwable t, String message);
-	
-	void reportError(boolean drawAttention, Throwable t, String message, Object... args);
-	
-	String requestUserInput(String message, Object... args);
-	
-	boolean requestUserConfirm(String message, Object... args);
-	
-	void close();
-}

+ 0 - 148
src/main/java/com/l2jserver/tools/util/io/CloseShieldedInputStream.java

@@ -1,148 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.util.io;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Prevent the underlying input stream to close.
- * @author Joe Cheng, Zoey76
- */
-public class CloseShieldedInputStream extends InputStream
-{
-	private InputStream _in = null;
-	
-	/**
-	 * Instantiates a new close shielded input stream.
-	 * @param in the in
-	 */
-	public CloseShieldedInputStream(InputStream in)
-	{
-		_in = in;
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void close()
-	{
-		_in = null;
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public int read() throws IOException
-	{
-		if (_in == null)
-		{
-			throw new IOException("Stream is null!");
-		}
-		return _in.read();
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public int read(byte b[]) throws IOException
-	{
-		if (_in == null)
-		{
-			throw new IOException("Stream is null!");
-		}
-		return _in.read(b);
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public int read(byte b[], int off, int len) throws IOException
-	{
-		if (_in == null)
-		{
-			throw new IOException("Stream is null!");
-		}
-		return _in.read(b, off, len);
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public long skip(long n) throws IOException
-	{
-		if (_in == null)
-		{
-			throw new IOException("Stream is null!");
-		}
-		return _in.skip(n);
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public synchronized void mark(int readlimit)
-	{
-		if (_in != null)
-		{
-			_in.mark(readlimit);
-		}
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public boolean markSupported()
-	{
-		if (_in == null)
-		{
-			return false;
-		}
-		return _in.markSupported();
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public synchronized void reset() throws IOException
-	{
-		if (_in == null)
-		{
-			throw new IOException("Stream is null!");
-		}
-		_in.reset();
-	}
-	
-	/**
-	 * Gets the underlying stream.
-	 * @return the underlying stream
-	 */
-	public InputStream getUnderlyingStream()
-	{
-		return _in;
-	}
-}

+ 0 - 49
src/main/java/com/l2jserver/tools/util/io/FileWriterStdout.java

@@ -1,49 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.util.io;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-
-/**
- * @author mrTJO
- */
-public class FileWriterStdout extends BufferedWriter
-{
-	public FileWriterStdout(FileWriter fileWriter)
-	{
-		super(fileWriter);
-	}
-	
-	public void println() throws IOException
-	{
-		append(System.getProperty("line.separator"));
-	}
-	
-	public void println(String line) throws IOException
-	{
-		append(line + System.getProperty("line.separator"));
-	}
-	
-	public void print(String text) throws IOException
-	{
-		append(text);
-	}
-}

+ 0 - 28
src/main/java/com/l2jserver/tools/util/swing/BackgroundTask.java

@@ -1,28 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.util.swing;
-
-/**
- * @author HorridoJoho
- */
-@FunctionalInterface
-public interface BackgroundTask<T>
-{
-	T get() throws Throwable;
-}

+ 0 - 116
src/main/java/com/l2jserver/tools/util/swing/BackgroundTaskRunner.java

@@ -1,116 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.tools.util.swing;
-
-import java.awt.Dialog;
-import java.awt.Dialog.ModalityType;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import java.util.Objects;
-
-/**
- * @author HorridoJoho
- */
-public class BackgroundTaskRunner<T> implements Runnable, ComponentListener
-{
-	private final Dialog _dialog;
-	private final BackgroundTask<T> _task;
-	private final Thread _thread;
-	
-	private Throwable _thrown;
-	private T _result;
-	
-	public BackgroundTaskRunner(Dialog dialog, BackgroundTask<T> task)
-	{
-		Objects.requireNonNull(dialog);
-		Objects.requireNonNull(task);
-		_dialog = dialog;
-		_task = task;
-		_thread = new Thread(this, "L2J-TOOLS-BackgroundTaskRunner");
-		
-		_dialog.setModalityType(ModalityType.APPLICATION_MODAL);
-		_dialog.addComponentListener(this);
-		_dialog.setVisible(true);
-	}
-	
-	@Override
-	public void run()
-	{
-		try
-		{
-			_result = _task.get();
-		}
-		catch (Throwable t)
-		{
-			_thrown = t;
-		}
-		finally
-		{
-			finishDialog();
-		}
-	}
-	
-	private void finishDialog()
-	{
-		if (_dialog != null)
-		{
-			_dialog.removeComponentListener(this);
-			_dialog.setVisible(false);
-		}
-	}
-	
-	public Throwable getThrown()
-	{
-		return _thrown;
-	}
-	
-	public T getResult()
-	{
-		return _result;
-	}
-	
-	@Override
-	public void componentResized(ComponentEvent e)
-	{
-	}
-	
-	@Override
-	public void componentMoved(ComponentEvent e)
-	{
-	}
-	
-	@Override
-	public void componentShown(ComponentEvent e)
-	{
-		try
-		{
-			_thread.start();
-		}
-		catch (Throwable t)
-		{
-			_thrown = t;
-			finishDialog();
-		}
-	}
-	
-	@Override
-	public void componentHidden(ComponentEvent e)
-	{
-	}
-}

+ 0 - 226
src/main/java/com/l2jserver/tools/util/swing/SpringUtilities.java

@@ -1,226 +0,0 @@
-/*
- * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- *   - Neither the name of Oracle or the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.l2jserver.tools.util.swing;
-
-import java.awt.Component;
-import java.awt.Container;
-
-import javax.swing.Spring;
-import javax.swing.SpringLayout;
-
-/**
- * A 1.4 file that provides utility methods for creating form- or grid-style layouts with SpringLayout.<br>
- * These utilities are used by several programs, such as SpringBox and SpringCompactGrid.
- */
-public class SpringUtilities
-{
-	/**
-	 * A debugging utility that prints to stdout the component's minimum, preferred, and maximum sizes.
-	 * @param c
-	 */
-	public static void printSizes(Component c)
-	{
-		System.out.println("minimumSize = " + c.getMinimumSize());
-		System.out.println("preferredSize = " + c.getPreferredSize());
-		System.out.println("maximumSize = " + c.getMaximumSize());
-	}
-	
-	/**
-	 * Aligns the first <code>rows</code> * <code>cols</code> components of <code>parent</code> in a grid. Each component is as big as the maximum preferred width and height of the components. The parent is made just big enough to fit them all.
-	 * @param parent
-	 * @param rows number of rows
-	 * @param cols number of columns
-	 * @param initialX x location to start the grid at
-	 * @param initialY y location to start the grid at
-	 * @param xPad x padding between cells
-	 * @param yPad y padding between cells
-	 */
-	public static void makeGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad)
-	{
-		SpringLayout layout;
-		try
-		{
-			layout = (SpringLayout) parent.getLayout();
-		}
-		catch (ClassCastException exc)
-		{
-			System.err.println("The first argument to makeGrid must use SpringLayout.");
-			return;
-		}
-		
-		Spring xPadSpring = Spring.constant(xPad);
-		Spring yPadSpring = Spring.constant(yPad);
-		Spring initialXSpring = Spring.constant(initialX);
-		Spring initialYSpring = Spring.constant(initialY);
-		int max = rows * cols;
-		
-		// Calculate Springs that are the max of the width/height so that all
-		// cells have the same size.
-		Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
-		Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
-		for (int i = 1; i < max; i++)
-		{
-			SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));
-			
-			maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
-			maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
-		}
-		
-		// Apply the new width/height Spring. This forces all the
-		// components to have the same size.
-		for (int i = 0; i < max; i++)
-		{
-			SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));
-			
-			cons.setWidth(maxWidthSpring);
-			cons.setHeight(maxHeightSpring);
-		}
-		
-		// Then adjust the x/y constraints of all the cells so that they
-		// are aligned in a grid.
-		SpringLayout.Constraints lastCons = null;
-		SpringLayout.Constraints lastRowCons = null;
-		for (int i = 0; i < max; i++)
-		{
-			SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));
-			if ((i % cols) == 0)
-			{ // start of new row
-				lastRowCons = lastCons;
-				cons.setX(initialXSpring);
-			}
-			else
-			{
-				// x position depends on previous component
-				if (lastCons != null)
-				{
-					cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), xPadSpring));
-				}
-			}
-			
-			if ((i / cols) == 0)
-			{
-				// first row
-				cons.setY(initialYSpring);
-			}
-			else
-			{
-				// y position depends on previous row
-				if (lastRowCons != null)
-				{
-					cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH), yPadSpring));
-				}
-			}
-			lastCons = cons;
-		}
-		
-		// Set the parent's size.
-		SpringLayout.Constraints pCons = layout.getConstraints(parent);
-		if (lastCons != null)
-		{
-			pCons.setConstraint(SpringLayout.SOUTH, Spring.sum(Spring.constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH)));
-			pCons.setConstraint(SpringLayout.EAST, Spring.sum(Spring.constant(xPad), lastCons.getConstraint(SpringLayout.EAST)));
-		}
-	}
-	
-	/* Used by makeCompactGrid. */
-	private static SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols)
-	{
-		SpringLayout layout = (SpringLayout) parent.getLayout();
-		Component c = parent.getComponent((row * cols) + col);
-		return layout.getConstraints(c);
-	}
-	
-	/**
-	 * Aligns the first <code>rows</code> * <code>cols</code> components of <code>parent</code> in a grid. Each component in a column is as wide as the maximum preferred width of the components in that column; height is similarly determined for each row. The parent is made just big enough to fit
-	 * them all.
-	 * @param parent
-	 * @param rows number of rows
-	 * @param cols number of columns
-	 * @param initialX x location to start the grid at
-	 * @param initialY y location to start the grid at
-	 * @param xPad x padding between cells
-	 * @param yPad y padding between cells
-	 */
-	public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad)
-	{
-		SpringLayout layout;
-		try
-		{
-			layout = (SpringLayout) parent.getLayout();
-		}
-		catch (ClassCastException exc)
-		{
-			System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
-			return;
-		}
-		
-		// Align all cells in each column and make them the same width.
-		Spring x = Spring.constant(initialX);
-		for (int c = 0; c < cols; c++)
-		{
-			Spring width = Spring.constant(0);
-			for (int r = 0; r < rows; r++)
-			{
-				width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());
-			}
-			for (int r = 0; r < rows; r++)
-			{
-				SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
-				constraints.setX(x);
-				constraints.setWidth(width);
-			}
-			x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
-		}
-		
-		// Align all cells in each row and make them the same height.
-		Spring y = Spring.constant(initialY);
-		for (int r = 0; r < rows; r++)
-		{
-			Spring height = Spring.constant(0);
-			for (int c = 0; c < cols; c++)
-			{
-				height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight());
-			}
-			for (int c = 0; c < cols; c++)
-			{
-				SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
-				constraints.setY(y);
-				constraints.setHeight(height);
-			}
-			y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
-		}
-		
-		// Set the parent's size.
-		SpringLayout.Constraints pCons = layout.getConstraints(parent);
-		pCons.setConstraint(SpringLayout.SOUTH, y);
-		pCons.setConstraint(SpringLayout.EAST, x);
-	}
-}

+ 0 - 40
src/main/java/com/l2jserver/util/file/filter/SQLFilter.java

@@ -1,40 +0,0 @@
-/*
- * Copyright © 2004-2019 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.util.file.filter;
-
-import java.io.File;
-import java.io.FileFilter;
-
-/**
- * Specialized {@link FileFilter} class.<br>
- * Accepts <b>files</b> ending with ".sql" only.
- * @author Zoey76
- */
-public class SQLFilter implements FileFilter
-{
-	@Override
-	public boolean accept(File f)
-	{
-		if ((f == null) || !f.isFile())
-		{
-			return false;
-		}
-		return f.getName().toLowerCase().endsWith(".sql");
-	}
-}