Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,29 @@ repositories {
maven {
url = uri("https://repo.codemc.org/repository/maven-public/")
}

maven {
name = "winlogon-libs"
url = uri("https://maven.winlogon.org/releases/")
}

mavenCentral()
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.21.6-R0.1-SNAPSHOT")
compileOnly("dev.jorel:commandapi-bukkit-core:10.0.1")
compileOnly("com.github.oshi:oshi-core-java11:6.8.0")

compileOnly("com.zaxxer:HikariCP:6.3.0")
compileOnly("org.postgresql:postgresql:42.7.7")
compileOnly("com.mysql:mysql-connector-j:9.3.0")
compileOnly("io.lettuce:lettuce-core:6.7.1.RELEASE")

compileOnly("org.winlogon:asynccraftr:0.1.0")

testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.11.4")
testImplementation("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
testImplementation("io.papermc.paper:paper-api:1.21.6-R0.1-SNAPSHOT")
testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
}

Expand Down
42 changes: 42 additions & 0 deletions src/main/kotlin/org/winlogon/infohub/ChoiceStorage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.winlogon.infohub

import net.kyori.adventure.util.TriState
import java.nio.file.Path
import java.util.UUID
import java.time.Duration

interface ChoiceStorage {
fun init() {}
fun isConfigOkay(): Boolean = true
fun getChoice(playerUuid: UUID): TriState
fun setChoice(playerUuid: UUID, choice: Boolean)
}

sealed class DataSource {
data class Database(
val config: DatabaseMetadata,
val backupInterval: Duration? = null
) : DataSource()

data class World(val pdcConfig: PdcConfig) : DataSource()
}

data class DatabaseMetadata(
val type: DatabaseType,
val host: String,
val port: Int,
val database: String,
val username: String,
val password: String,
val table: String = "infohub_choices"
)

data class PdcConfig(
val backupInterval: Duration?,
val usesDatabase: Boolean
)

enum class DatabaseType {
POSTGRESQL,
MYSQL
}
45 changes: 32 additions & 13 deletions src/main/kotlin/org/winlogon/infohub/InfoHubLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,45 @@ import org.eclipse.aether.artifact.DefaultArtifact
import org.eclipse.aether.graph.Dependency
import org.eclipse.aether.repository.RemoteRepository

class ScalaPluginLoader : PluginLoader {
class InfoHubLoader : PluginLoader {
override fun classloader(classpathBuilder: PluginClasspathBuilder) {
val resolver = MavenLibraryResolver()

resolver.addRepository(
RemoteRepository.Builder(
"central",
"default",
"https://repo.maven.apache.org/maven2/"
).build()
val repositories = mapOf(
"central" to MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR,
"winlogon-libs" to "https://maven.winlogon.org/releases/",
)

resolver.addDependency(
Dependency(
DefaultArtifact("com.github.oshi:oshi-core-java11:6.8.0"),
null
)
val dependencies = mapOf(
"com.github.oshi:oshi-core-java11" to "6.8.0",

"com.zaxxer:HikariCP" to "6.3.0",
"org.postgresql:postgresql" to "42.7.7",
"com.mysql:mysql-connector-j" to "9.3.0",
"io.lettuce:lettuce-core" to "6.7.1.RELEASE",

"org.winlogon:asynccraftr" to "0.1.0",
)

repositories.forEach { (name, url) ->
resolver.addRepository(
RemoteRepository.Builder(
name,
"default",
url
).build()
)
}

dependencies.forEach { (dependencyPackage, version) ->
resolver.addDependency(
Dependency(
DefaultArtifact("$dependencyPackage:$version"),
null
)
)
}

classpathBuilder.addLibrary(resolver)
}
}

Loading