Converted some of the management server to kotlin

Added json configs for management server
Cleaned up some files
This commit is contained in:
Woah
2021-03-08 03:55:45 -05:00
parent ca2e5520b0
commit 439b2e9ef8
114 changed files with 820 additions and 1476 deletions
@@ -0,0 +1,64 @@
package ms.system.mysql
import ms.system.util.ManagementConstants
import ms.system.util.ManagementConstants.Companion.DATABASE_HOST_ADDRESS
import ms.system.util.ManagementConstants.Companion.DATABASE_NAME
import ms.system.util.ManagementConstants.Companion.DATABASE_PASSWORD
import ms.system.util.ManagementConstants.Companion.DATABASE_PORT
import ms.system.util.ManagementConstants.Companion.DATABASE_USERNAME
import java.sql.Connection
import java.sql.DriverManager
import java.sql.SQLException
/**
* Manages the sql connections.
* @author Vexia
*/
object SQLManager {
/**
* IF the sql manager is initialized.
*/
var isInitialized = false
/**
* Initializes the sql manager.
*/
@JvmStatic
fun init() {
isInitialized = true
WorldListSQLHandler.clearWorldList()
}
/**
* Gets a connection from the pool.
* @return The connection.
*/
@JvmStatic
val connection: Connection?
get() {
try {
return DriverManager.getConnection(
"jdbc:mysql://$DATABASE_HOST_ADDRESS:$DATABASE_PORT/$DATABASE_NAME?useTimezone=true&serverTimezone=UTC",
DATABASE_USERNAME,
DATABASE_PASSWORD
)
} catch (e: SQLException) {
println("Error: Mysql error message=" + e.message + ".")
}
return null
}
/**
* Releases the connection so it's available for usage.
* @param connection The connection.
*/
@JvmStatic
fun close(connection: Connection) {
try {
connection.close()
} catch (e: SQLException) {
e.printStackTrace()
}
}
}