init database part
This commit is contained in:
parent
93ddf5994f
commit
32bb9628d3
|
|
@ -13,6 +13,7 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("stdlib"))
|
implementation(kotlin("stdlib"))
|
||||||
implementation(project(":common"))
|
implementation(project(":common"))
|
||||||
|
implementation("com.zaxxer:HikariCP:4.0.3")
|
||||||
@Suppress("VulnerableLibrariesLocal")
|
@Suppress("VulnerableLibrariesLocal")
|
||||||
compileOnly("io.github.waterfallmc:waterfall-api:1.19-R0.1-SNAPSHOT")
|
compileOnly("io.github.waterfallmc:waterfall-api:1.19-R0.1-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package cc.maxmc.msm.parent.database
|
||||||
|
|
||||||
|
import cc.maxmc.msm.parent.settings.Settings
|
||||||
|
import com.zaxxer.hikari.HikariConfig
|
||||||
|
|
||||||
|
class SQLDatabase {
|
||||||
|
val config = HikariConfig()
|
||||||
|
fun initDatabase() {
|
||||||
|
val db = Settings.Database
|
||||||
|
config.jdbcUrl = "jdbc:mysql://${db.address}:${db.port}"
|
||||||
|
config.username = db.username
|
||||||
|
config.password = db.password
|
||||||
|
config.schema = db.database
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getMatch(id: Int) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun recordMatch() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,8 +3,19 @@ package cc.maxmc.msm.parent.settings
|
||||||
import cc.maxmc.msm.parent.settings.SettingsReader.config
|
import cc.maxmc.msm.parent.settings.SettingsReader.config
|
||||||
|
|
||||||
object Settings {
|
object Settings {
|
||||||
val name
|
|
||||||
get() = config
|
|
||||||
val serverPort
|
val serverPort
|
||||||
get() = config.getInt("server_port", 25566)
|
get() = config.getInt("server_port", 25566)
|
||||||
|
|
||||||
|
object Database {
|
||||||
|
val address: String
|
||||||
|
get() = config.getString("database.address", "localhost")
|
||||||
|
val port: Int
|
||||||
|
get() = config.getInt("database.port", 12345)
|
||||||
|
val username: String
|
||||||
|
get() = config.getString("database.username", "root")
|
||||||
|
val password: String
|
||||||
|
get() = config.getString("database.password", "password")
|
||||||
|
val database: String
|
||||||
|
get() = config.getString("database.database", "multiserverman")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
parent:
|
serverPort: 12345
|
||||||
|
database:
|
||||||
address: 127.0.0.1
|
address: 127.0.0.1
|
||||||
port: 23333
|
port: 3306
|
||||||
|
username: "root"
|
||||||
|
password: "password"
|
||||||
|
database: "multiserverman"
|
||||||
Loading…
Reference in New Issue