diff --git a/build.gradle.kts b/build.gradle.kts index a6ce93ef..2afb3300 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,16 +1,16 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile val sharedGroup = "com.projectcitybuild.pcbridge" -val sharedVersion = "6.1.0" +val sharedVersion = "6.2.0" group = sharedGroup version = sharedVersion plugins { kotlin("jvm") version "1.9.22" + kotlin("plugin.serialization") version "2.0.21" id("org.jlleitschuh.gradle.ktlint") version "12.1.1" - id("org.jetbrains.kotlin.plugin.serialization") version "1.6.10" id("co.uzzu.dotenv.gradle") version "4.0.0" } @@ -29,11 +29,11 @@ subprojects { dependencies { // Kotlin implementation(kotlin("stdlib-jdk8")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") // Tests - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.0") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:2.0.21") testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2") testImplementation("org.mockito.kotlin:mockito-kotlin:5.0.0") @@ -53,7 +53,7 @@ subprojects { tasks.withType { kotlinOptions { - jvmTarget = "17" + jvmTarget = "21" } } diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/HttpService.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/HttpService.kt index 97de28a8..cbe14d04 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/HttpService.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/HttpService.kt @@ -2,9 +2,10 @@ package com.projectcitybuild.pcbridge.http import com.projectcitybuild.pcbridge.http.clients.PCBClientFactory import com.projectcitybuild.pcbridge.http.parsing.ResponseParser -import com.projectcitybuild.pcbridge.http.services.pcb.RegisterHttpService -import com.projectcitybuild.pcbridge.http.services.pcb.PlayerHttpService -import com.projectcitybuild.pcbridge.http.services.pcb.TelemetryHttpService +import com.projectcitybuild.pcbridge.http.services.ConfigHttpService +import com.projectcitybuild.pcbridge.http.services.RegisterHttpService +import com.projectcitybuild.pcbridge.http.services.PlayerHttpService +import com.projectcitybuild.pcbridge.http.services.TelemetryHttpService class HttpService( private val authToken: String, @@ -22,12 +23,15 @@ class HttpService( private val responseParser: ResponseParser get() = ResponseParser() + val config + get() = ConfigHttpService(pcbClient, responseParser) + val player get() = PlayerHttpService(pcbClient, responseParser) - val telemetry - get() = TelemetryHttpService(pcbClient, responseParser) - val register get() = RegisterHttpService(pcbClient, responseParser) + + val telemetry + get() = TelemetryHttpService(pcbClient, responseParser) } diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Account.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Account.kt similarity index 85% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Account.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Account.kt index e4407854..42e1eb97 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Account.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Account.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.responses +package com.projectcitybuild.pcbridge.http.models import com.google.gson.annotations.SerializedName import kotlinx.serialization.Serializable diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Badge.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Badge.kt similarity index 83% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Badge.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Badge.kt index 8db7b1eb..a98d2029 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Badge.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Badge.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.responses +package com.projectcitybuild.pcbridge.http.models import com.google.gson.annotations.SerializedName import kotlinx.serialization.Serializable diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/DonationPerk.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/DonationPerk.kt similarity index 91% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/DonationPerk.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/DonationPerk.kt index 5c0473f0..505384cd 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/DonationPerk.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/DonationPerk.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.responses +package com.projectcitybuild.pcbridge.http.models import com.google.gson.annotations.SerializedName import com.projectcitybuild.pcbridge.http.serialization.serializable.LocalDateTimeSerializer diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/DonationTier.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/DonationTier.kt similarity index 82% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/DonationTier.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/DonationTier.kt index dd512211..ebde4839 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/DonationTier.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/DonationTier.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.responses +package com.projectcitybuild.pcbridge.http.models import com.google.gson.annotations.SerializedName import kotlinx.serialization.Serializable diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Group.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Group.kt similarity index 84% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Group.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Group.kt index 3dc20553..aa413bb3 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Group.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Group.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.responses +package com.projectcitybuild.pcbridge.http.models import com.google.gson.annotations.SerializedName import kotlinx.serialization.Serializable diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/IPBan.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/IPBan.kt similarity index 95% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/IPBan.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/IPBan.kt index e560ee26..49fbf8ee 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/IPBan.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/IPBan.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.responses +package com.projectcitybuild.pcbridge.http.models import com.google.gson.annotations.SerializedName import com.projectcitybuild.pcbridge.http.serialization.serializable.LocalDateTimeSerializer diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Player.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Player.kt similarity index 92% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Player.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Player.kt index 043a8a68..28eb039d 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/Player.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/Player.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.responses +package com.projectcitybuild.pcbridge.http.models import com.google.gson.annotations.SerializedName import com.projectcitybuild.pcbridge.http.serialization.serializable.LocalDateTimeSerializer diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/PlayerBan.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/PlayerBan.kt similarity index 96% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/PlayerBan.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/PlayerBan.kt index bd6a28b9..088b9707 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/PlayerBan.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/PlayerBan.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.responses +package com.projectcitybuild.pcbridge.http.models import com.google.gson.annotations.SerializedName import com.projectcitybuild.pcbridge.http.serialization.serializable.LocalDateTimeSerializer diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/PlayerData.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/PlayerData.kt similarity index 90% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/PlayerData.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/PlayerData.kt index 63d1538c..644797d2 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/responses/PlayerData.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/PlayerData.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.responses +package com.projectcitybuild.pcbridge.http.models import com.google.gson.annotations.SerializedName import kotlinx.serialization.Serializable diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/RemoteConfig.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/RemoteConfig.kt new file mode 100644 index 00000000..0ef99d15 --- /dev/null +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/models/RemoteConfig.kt @@ -0,0 +1,66 @@ +@file:Suppress("ktlint:standard:max-line-length") + +package com.projectcitybuild.pcbridge.http.models + +import com.google.gson.annotations.SerializedName +import kotlinx.serialization.Serializable + +/** + * Key-values for the plugin fetched from the PCB web backend + */ +@Serializable +data class RemoteConfigKeyValues( + val localization: Localization = Localization(), + val chat: Chat = Chat(), + val warps: Warps = Warps(), + val integrations: Integrations = Integrations(), + val announcements: Announcements = Announcements(), + val messages: Messages = Messages(), +) { + @Serializable + data class Localization( + @SerializedName("time_zone") + val timeZone: String = "UTC", + val locale: String = "en-us", + ) + + @Serializable + data class Chat( + @SerializedName("badge_icon") + val badgeIcon: String = "★", + ) + + @Serializable + data class Warps( + @SerializedName("items_per_page") + val itemsPerPage: Int = 15, + ) + + @Serializable + data class Integrations( + @SerializedName("dynmap_warp_icon_name") + val dynmapWarpIconName: String = "portal", + ) + + @Serializable + data class Announcements( + @SerializedName("interval_in_mins") + val intervalInMins: Int = 30, + val messages: List = emptyList(), + ) + + @Serializable + data class Messages( + val join: String = "+ joined the server", + val leave: String = "- left the server (online for )", + @SerializedName("first_time_join") + val firstTimeJoin: String = "✦ Welcome §f%name%§d to the server!", + val welcome: String = "Welcome to PCB!", + ) +} + +@Serializable +data class RemoteConfigVersion( + val version: Int, + val config: RemoteConfigKeyValues, +) \ No newline at end of file diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/requests/PCBRequest.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/requests/PCBRequest.kt index aca552ee..5c2b74e0 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/requests/PCBRequest.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/requests/PCBRequest.kt @@ -1,6 +1,7 @@ package com.projectcitybuild.pcbridge.http.requests -import com.projectcitybuild.pcbridge.http.responses.PlayerData +import com.projectcitybuild.pcbridge.http.models.PlayerData +import com.projectcitybuild.pcbridge.http.models.RemoteConfigVersion import retrofit2.http.Field import retrofit2.http.FormUrlEncoded import retrofit2.http.GET @@ -52,4 +53,11 @@ internal interface PCBRequest { @Field(value = "uuid") playerUUID: String, @Field(value = "alias") playerName: String, ) + + /** + * Fetches the latest Minecraft config + */ + @POST("v2/minecraft/config") + @FormUrlEncoded + suspend fun getConfig(): RemoteConfigVersion } diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/ConfigHttpService.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/ConfigHttpService.kt new file mode 100644 index 00000000..04d9b3c1 --- /dev/null +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/ConfigHttpService.kt @@ -0,0 +1,18 @@ +package com.projectcitybuild.pcbridge.http.services + +import com.projectcitybuild.pcbridge.http.models.RemoteConfigVersion +import com.projectcitybuild.pcbridge.http.parsing.ResponseParser +import com.projectcitybuild.pcbridge.http.pcb +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import retrofit2.Retrofit + +class ConfigHttpService( + private val retrofit: Retrofit, + private val responseParser: ResponseParser, +) { + suspend fun get(): RemoteConfigVersion = + withContext(Dispatchers.IO) { + responseParser.parse(retrofit.pcb()::getConfig) + } +} diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/pcb/PlayerHttpService.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/PlayerHttpService.kt similarity index 85% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/pcb/PlayerHttpService.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/PlayerHttpService.kt index d29a7c33..61181136 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/pcb/PlayerHttpService.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/PlayerHttpService.kt @@ -1,8 +1,8 @@ -package com.projectcitybuild.pcbridge.http.services.pcb +package com.projectcitybuild.pcbridge.http.services import com.projectcitybuild.pcbridge.http.parsing.ResponseParser import com.projectcitybuild.pcbridge.http.pcb -import com.projectcitybuild.pcbridge.http.responses.PlayerData +import com.projectcitybuild.pcbridge.http.models.PlayerData import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import retrofit2.Retrofit diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/pcb/RegisterHttpService.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/RegisterHttpService.kt similarity index 94% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/pcb/RegisterHttpService.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/RegisterHttpService.kt index 1915d8da..49933a0b 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/pcb/RegisterHttpService.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/RegisterHttpService.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.services.pcb +package com.projectcitybuild.pcbridge.http.services import com.projectcitybuild.pcbridge.http.parsing.ResponseParser import com.projectcitybuild.pcbridge.http.pcb diff --git a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/pcb/TelemetryHttpService.kt b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/TelemetryHttpService.kt similarity index 92% rename from pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/pcb/TelemetryHttpService.kt rename to pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/TelemetryHttpService.kt index 94ef720f..4dd79578 100644 --- a/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/pcb/TelemetryHttpService.kt +++ b/pcbridge-http/src/main/kotlin/com/projectcitybuild/pcbridge/http/services/TelemetryHttpService.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.http.services.pcb +package com.projectcitybuild.pcbridge.http.services import com.projectcitybuild.pcbridge.http.parsing.ResponseParser import com.projectcitybuild.pcbridge.http.pcb diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/Container.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/Container.kt index e04e955b..a2ced05e 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/Container.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/Container.kt @@ -2,8 +2,8 @@ package com.projectcitybuild.pcbridge import com.github.shynixn.mccoroutine.bukkit.minecraftDispatcher import com.google.gson.reflect.TypeToken -import com.projectcitybuild.pcbridge.core.config.Config -import com.projectcitybuild.pcbridge.core.config.JsonStorage +import com.projectcitybuild.pcbridge.core.localconfig.LocalConfig +import com.projectcitybuild.pcbridge.core.localconfig.JsonStorage import com.projectcitybuild.pcbridge.core.database.DatabaseSession import com.projectcitybuild.pcbridge.core.database.DatabaseSource import com.projectcitybuild.pcbridge.core.datetime.DateTimeFormatter @@ -11,8 +11,9 @@ import com.projectcitybuild.pcbridge.core.datetime.LocalizedTime import com.projectcitybuild.pcbridge.core.errors.SentryReporter import com.projectcitybuild.pcbridge.core.permissions.Permissions import com.projectcitybuild.pcbridge.core.permissions.adapters.LuckPermsPermissions -import com.projectcitybuild.pcbridge.core.state.Store -import com.projectcitybuild.pcbridge.data.PluginConfig +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig +import com.projectcitybuild.pcbridge.core.store.Store +import com.projectcitybuild.pcbridge.data.LocalConfigKeyValues import com.projectcitybuild.pcbridge.features.announcements.listeners.AnnouncementEnableListener import com.projectcitybuild.pcbridge.features.announcements.repositories.AnnouncementRepository import com.projectcitybuild.pcbridge.features.bans.actions.AuthorizeConnection @@ -153,22 +154,22 @@ private fun Module.spigot(plugin: JavaPlugin) { private fun Module.core() { single { - Config( + LocalConfig( jsonStorage = - JsonStorage( - file = - get() - .dataFolder - .resolve("config.json"), - typeToken = object : TypeToken() {}, - ), + JsonStorage( + file = + get() + .dataFolder + .resolve("config.json"), + typeToken = object : TypeToken() {}, + ), ) } single { DatabaseSession().apply { - val configProvider = get() - val config = configProvider.get() + val localConfigProvider = get() + val config = localConfigProvider.get() connect(DatabaseSource.fromConfig(config)) } } withOptions { @@ -178,10 +179,10 @@ private fun Module.core() { single { SentryReporter( - config = get(), + localConfig = get(), ).apply { - val configProvider = get() - val config = configProvider.get() + val localConfigProvider = get() + val config = localConfigProvider.get() if (config.errorReporting.isSentryEnabled) { start() } @@ -191,7 +192,7 @@ private fun Module.core() { } factory { - val config = get().get() + val config = get().latest.config val zoneId = ZoneId.of(config.localization.timeZone) LocalizedTime( @@ -200,7 +201,7 @@ private fun Module.core() { } factory { - val config = get().get() + val config = get().latest.config DateTimeFormatter( locale = @@ -215,16 +216,23 @@ private fun Module.core() { } single { Store() } + + single { + RemoteConfig( + configHttpService = get().config, + eventBroadcaster = get(), + ) + } } private fun Module.webServer() { single { - val config = get().get() + val localConfig = get().get() HttpServer( config = HttpServerConfig( - authToken = config.webServer.token, - port = config.webServer.port, + authToken = localConfig.webServer.token, + port = localConfig.webServer.port, ), delegate = WebServerDelegate( eventBroadcaster = get(), @@ -235,12 +243,12 @@ private fun Module.webServer() { private fun Module.http() { single { - val config = get().get() + val localConfig = get().get() HttpService( - authToken = config.api.token, - baseURL = config.api.baseUrl, - withLogging = config.api.isLoggingEnabled, + authToken = localConfig.api.token, + baseURL = localConfig.api.baseUrl, + withLogging = localConfig.api.isLoggingEnabled, ) } } @@ -249,7 +257,7 @@ private fun Module.integrations() { single { DynmapIntegration( plugin = get(), - config = get(), + remoteConfig = get(), sentry = get(), warpRepository = get(), ) @@ -270,7 +278,7 @@ private fun Module.integrations() { private fun Module.announcements() { single { AnnouncementRepository( - config = get(), + remoteConfig = get(), store = get(), ) } @@ -278,7 +286,7 @@ private fun Module.announcements() { factory { AnnouncementEnableListener( announcementRepository = get(), - config = get(), + remoteConfig = get(), timer = get(), server = get(), plugin = get(), @@ -307,7 +315,7 @@ private fun Module.warps() { factory { WarpsCommand( warpRepository = get(), - config = get(), + remoteConfig = get(), server = get(), time = get(), ) @@ -323,13 +331,13 @@ private fun Module.joinMessages() { factory { AnnounceJoinListener( - config = get(), + remoteConfig = get(), ) } factory { AnnounceQuitListener( - config = get(), + remoteConfig = get(), store = get(), time = get(), ) @@ -337,7 +345,7 @@ private fun Module.joinMessages() { factory { FirstTimeJoinListener( - config = get(), + remoteConfig = get(), server = get(), playerConfigRepository = get(), time = get(), @@ -346,7 +354,7 @@ private fun Module.joinMessages() { factory { ServerOverviewJoinListener( - config = get(), + remoteConfig = get(), ) } } @@ -435,7 +443,7 @@ private fun Module.chat() { factory { ChatBadgeRepository( store = get(), - config = get(), + remoteConfig = get(), badgeFormatter = get(), badgeCache = get(named("badge_cache")), ) @@ -444,7 +452,7 @@ private fun Module.chat() { factory { ChatGroupRepository( permissions = get(), - config = get(), + localConfig = get(), chatGroupFormatter = get(), groupCache = get(named("group_cache")), ) @@ -533,7 +541,7 @@ private fun Module.groups() { factory { SyncRepository( - config = get(), + localConfig = get(), ) } diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/Plugin.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/Plugin.kt index bc97e40a..ccc1d23c 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/Plugin.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/Plugin.kt @@ -3,6 +3,7 @@ package com.projectcitybuild.pcbridge import com.github.shynixn.mccoroutine.bukkit.SuspendingJavaPlugin import com.projectcitybuild.pcbridge.core.errors.SentryReporter import com.projectcitybuild.pcbridge.core.errors.trace +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig import com.projectcitybuild.pcbridge.features.announcements.listeners.AnnouncementEnableListener import com.projectcitybuild.pcbridge.features.bans.listeners.AuthorizeConnectionListener import com.projectcitybuild.pcbridge.features.bans.listeners.IPBanRequestListener @@ -84,11 +85,14 @@ private class Lifecycle : KoinComponent { private val commandRegistry: SpigotCommandRegistry by inject() private val listenerRegistry: SpigotListenerRegistry by inject() private val httpServer: HttpServer by inject() + private val remoteConfig: RemoteConfig by inject() suspend fun boot() = sentry.trace { httpServer.start() + remoteConfig.fetch() + commandRegistry.apply { register( handler = get(), diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/WebServerDelegate.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/WebServerDelegate.kt index e5f2466b..ce88e74a 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/WebServerDelegate.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/WebServerDelegate.kt @@ -3,8 +3,8 @@ package com.projectcitybuild.pcbridge import com.projectcitybuild.pcbridge.features.bans.events.IPBanRequestedEvent import com.projectcitybuild.pcbridge.features.bans.events.UUIDBanRequestedEvent import com.projectcitybuild.pcbridge.features.groups.events.PlayerSyncRequestedEvent -import com.projectcitybuild.pcbridge.http.responses.IPBan -import com.projectcitybuild.pcbridge.http.responses.PlayerBan +import com.projectcitybuild.pcbridge.http.models.IPBan +import com.projectcitybuild.pcbridge.http.models.PlayerBan import com.projectcitybuild.pcbridge.support.spigot.SpigotEventBroadcaster import com.projectcitybuild.pcbridge.webserver.HttpServerDelegate import java.util.UUID diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/config/Config.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/config/Config.kt deleted file mode 100644 index 862be75f..00000000 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/config/Config.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.projectcitybuild.pcbridge.core.config - -import com.projectcitybuild.pcbridge.data.PluginConfig -import com.projectcitybuild.pcbridge.data.default - -class Config( - private val jsonStorage: JsonStorage, -) { - private var cache: PluginConfig? = null - - fun get(): PluginConfig { - val cache = cache - if (cache != null) { - return cache - } - return (jsonStorage.read() ?: PluginConfig.default()) - .also { this.cache = it } - } - - fun flush() { - cache = null - get() - } -} diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/database/DatabaseSource.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/database/DatabaseSource.kt index c7e51eac..b5a6a2ef 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/database/DatabaseSource.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/database/DatabaseSource.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.core.database -import com.projectcitybuild.pcbridge.data.PluginConfig +import com.projectcitybuild.pcbridge.data.LocalConfigKeyValues data class DatabaseSource( val hostName: String, @@ -10,7 +10,7 @@ data class DatabaseSource( val password: String, ) { companion object { - fun fromConfig(config: PluginConfig) = + fun fromConfig(config: LocalConfigKeyValues) = DatabaseSource( hostName = config.database.hostName, port = config.database.port, diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/errors/SentryReporter.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/errors/SentryReporter.kt index 33aeeb6d..2bfead0b 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/errors/SentryReporter.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/errors/SentryReporter.kt @@ -1,17 +1,17 @@ package com.projectcitybuild.pcbridge.core.errors -import com.projectcitybuild.pcbridge.core.config.Config +import com.projectcitybuild.pcbridge.core.localconfig.LocalConfig import com.projectcitybuild.pcbridge.core.logger.log import io.sentry.Sentry class SentryReporter( - private val config: Config, + private val localConfig: LocalConfig, ) { private var started = false fun start() { Sentry.init { options -> - options.dsn = config.get().errorReporting.sentryDsn + options.dsn = localConfig.get().errorReporting.sentryDsn } started = true log.info { "Sentry error reporting enabled" } diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/config/JsonStorage.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/localconfig/JsonStorage.kt similarity index 96% rename from pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/config/JsonStorage.kt rename to pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/localconfig/JsonStorage.kt index 648cf96d..1b7377bd 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/config/JsonStorage.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/localconfig/JsonStorage.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.core.config +package com.projectcitybuild.pcbridge.core.localconfig import com.google.gson.FieldNamingPolicy import com.google.gson.GsonBuilder diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/localconfig/LocalConfig.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/localconfig/LocalConfig.kt new file mode 100644 index 00000000..1f367eaf --- /dev/null +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/localconfig/LocalConfig.kt @@ -0,0 +1,24 @@ +package com.projectcitybuild.pcbridge.core.localconfig + +import com.projectcitybuild.pcbridge.data.LocalConfigKeyValues +import com.projectcitybuild.pcbridge.data.default + +class LocalConfig( + private val jsonStorage: JsonStorage, +) { + private var cache: LocalConfigKeyValues? = null + + fun get(): LocalConfigKeyValues { + val cache = cache + if (cache != null) { + return cache + } + return (jsonStorage.read() ?: LocalConfigKeyValues.default()) + .also { this.cache = it } + } + + fun flush() { + cache = null + get() + } +} diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/remoteconfig/events/RemoteConfigUpdatedEvent.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/remoteconfig/events/RemoteConfigUpdatedEvent.kt new file mode 100644 index 00000000..622a59b3 --- /dev/null +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/remoteconfig/events/RemoteConfigUpdatedEvent.kt @@ -0,0 +1,21 @@ +package com.projectcitybuild.pcbridge.core.remoteconfig.events + +import com.projectcitybuild.pcbridge.http.models.RemoteConfigVersion +import org.bukkit.event.Event +import org.bukkit.event.HandlerList + +class RemoteConfigUpdatedEvent( + val prev: RemoteConfigVersion?, + val next: RemoteConfigVersion, +) : Event() { + override fun getHandlers(): HandlerList { + return HANDLERS + } + + companion object { + private val HANDLERS = HandlerList() + + @JvmStatic + fun getHandlerList() = HANDLERS + } +} diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/remoteconfig/services/RemoteConfig.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/remoteconfig/services/RemoteConfig.kt new file mode 100644 index 00000000..6ad49159 --- /dev/null +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/remoteconfig/services/RemoteConfig.kt @@ -0,0 +1,45 @@ +package com.projectcitybuild.pcbridge.core.remoteconfig.services + +import com.projectcitybuild.pcbridge.core.logger.log +import com.projectcitybuild.pcbridge.core.remoteconfig.events.RemoteConfigUpdatedEvent +import com.projectcitybuild.pcbridge.http.models.RemoteConfigKeyValues +import com.projectcitybuild.pcbridge.http.models.RemoteConfigVersion +import com.projectcitybuild.pcbridge.http.services.ConfigHttpService +import com.projectcitybuild.pcbridge.support.spigot.SpigotEventBroadcaster + +class RemoteConfig( + private val configHttpService: ConfigHttpService, + private val eventBroadcaster: SpigotEventBroadcaster, +) { + private var cached: RemoteConfigVersion? = null + + val latest: RemoteConfigVersion + get() = cached!! + + suspend fun fetch(): RemoteConfigVersion { + log.info { "Fetching remote config..." } + + val next = try { + configHttpService.get() + } catch (e: Exception) { + log.error { "Failed to fetch remote config. Falling back to default config: ${e.message}" } + e.printStackTrace() + RemoteConfigVersion(-1, RemoteConfigKeyValues()) + } + set(next) + return next + } + + suspend fun set(next: RemoteConfigVersion) { + val prev = cached + cached = next + + if (prev != next) { + log.debug { "Remote config update detected. Broadcasting change..." } + + eventBroadcaster.broadcast( + RemoteConfigUpdatedEvent(prev, next) + ) + } + } +} \ No newline at end of file diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/state/ServerState.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/store/ServerState.kt similarity index 82% rename from pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/state/ServerState.kt rename to pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/store/ServerState.kt index 399ef00d..e29c1920 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/state/ServerState.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/store/ServerState.kt @@ -1,9 +1,9 @@ -package com.projectcitybuild.pcbridge.core.state +package com.projectcitybuild.pcbridge.core.store -import com.projectcitybuild.pcbridge.http.responses.Account -import com.projectcitybuild.pcbridge.http.responses.Badge -import com.projectcitybuild.pcbridge.http.responses.DonationPerk -import com.projectcitybuild.pcbridge.http.responses.PlayerData +import com.projectcitybuild.pcbridge.http.models.Account +import com.projectcitybuild.pcbridge.http.models.Badge +import com.projectcitybuild.pcbridge.http.models.DonationPerk +import com.projectcitybuild.pcbridge.http.models.PlayerData import com.projectcitybuild.pcbridge.http.serialization.serializable.LocalDateTimeSerializer import com.projectcitybuild.pcbridge.http.serialization.serializable.UUIDSerializer import kotlinx.serialization.Serializable diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/state/Store.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/store/Store.kt similarity index 94% rename from pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/state/Store.kt rename to pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/store/Store.kt index 6b6650d8..cbdeb7d1 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/state/Store.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/core/store/Store.kt @@ -1,4 +1,4 @@ -package com.projectcitybuild.pcbridge.core.state +package com.projectcitybuild.pcbridge.core.store import com.projectcitybuild.pcbridge.core.logger.log import kotlinx.coroutines.Dispatchers diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/data/LocalConfigKeyValues.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/data/LocalConfigKeyValues.kt new file mode 100644 index 00000000..716101b4 --- /dev/null +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/data/LocalConfigKeyValues.kt @@ -0,0 +1,126 @@ +@file:Suppress("ktlint:standard:max-line-length") + +package com.projectcitybuild.pcbridge.data + +import kotlinx.serialization.Serializable + +/** + * Key-values for the plugin configured through the local filesystem + */ +@Serializable +data class LocalConfigKeyValues( + val api: Api, + val database: Database, + val webServer: WebServer, + val errorReporting: ErrorReporting, + val groups: Groups, +) { + @Serializable + data class Api( + val token: String, + val baseUrl: String, + val isLoggingEnabled: Boolean, + ) + + @Serializable + data class Database( + val hostName: String, + val port: Int, + val name: String, + val username: String, + val password: String, + ) + + @Serializable + data class WebServer( + val token: String, + val port: Int, + ) + + @Serializable + data class ErrorReporting( + val isSentryEnabled: Boolean, + val sentryDsn: String, + ) + + @Serializable + data class Groups( + val displayPriority: DisplayPriority, + val donorTierGroupNames: DonorTierGroupNames, + ) { + @Serializable + data class DisplayPriority( + val builder: List, + val trust: List, + val donor: List, + ) + + @Serializable + data class DonorTierGroupNames( + val copper: String, + val iron: String, + val diamond: String, + ) + } +} + +fun LocalConfigKeyValues.Companion.default() = + LocalConfigKeyValues( + api = + LocalConfigKeyValues.Api( + token = "FILL_THIS_IN", + baseUrl = "https://projectcitybuild.com/api/", + isLoggingEnabled = false, + ), + database = + LocalConfigKeyValues.Database( + hostName = "127.0.0.1", + port = 3306, + name = "pcbridge", + username = "FILL_THIS_IN", + password = "FILL_THIS_IN", + ), + webServer = + LocalConfigKeyValues.WebServer( + token = "FILL_THIS_IN", + port = 8080, + ), + errorReporting = + LocalConfigKeyValues.ErrorReporting( + isSentryEnabled = false, + sentryDsn = "https://@sentry.io/", + ), + groups = + LocalConfigKeyValues.Groups( + displayPriority = + LocalConfigKeyValues.Groups.DisplayPriority( + builder = + listOf( + "architect", + "engineer", + "planner", + "builder", + "intern", + ), + trust = + listOf( + "developer", + "moderator", + "trusted+", + "trusted", + "member", + ), + donor = + listOf( + "donator", + "legacy-donator", + ), + ), + donorTierGroupNames = + LocalConfigKeyValues.Groups.DonorTierGroupNames( + copper = "copper_tier", + iron = "iron_tier", + diamond = "diamond_tier", + ), + ), + ) diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/data/PluginConfig.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/data/PluginConfig.kt deleted file mode 100644 index 9a0524a4..00000000 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/data/PluginConfig.kt +++ /dev/null @@ -1,210 +0,0 @@ -@file:Suppress("ktlint:standard:max-line-length") - -package com.projectcitybuild.pcbridge.data - -import kotlinx.serialization.Serializable - -@Serializable -data class PluginConfig( - val api: Api, - val database: Database, - val webServer: WebServer, - val errorReporting: ErrorReporting, - val localization: Localization, - val chatBadge: ChatBadge, - val warps: Warps, - val integrations: Integrations, - val announcements: Announcements, - val groups: Groups, - val messages: Messages, -) { - @Serializable - data class Api( - val token: String, - val baseUrl: String, - val isLoggingEnabled: Boolean, - ) - - @Serializable - data class Database( - val hostName: String, - val port: Int, - val name: String, - val username: String, - val password: String, - ) - - @Serializable - data class WebServer( - val token: String, - val port: Int, - ) - - @Serializable - data class ErrorReporting( - val isSentryEnabled: Boolean, - val sentryDsn: String, - ) - - @Serializable - data class Localization( - val timeZone: String, - val locale: String, - ) - - @Serializable - data class ChatBadge( - val icon: String, - ) - - @Serializable - data class Warps( - val itemsPerPage: Int, - ) - - @Serializable - data class Integrations( - val dynmap: Dynmap, - ) { - @Serializable - data class Dynmap( - val warpIconName: String, - ) - } - - @Serializable - data class Announcements( - val intervalInMins: Int, - val messages: List, - ) - - @Serializable - data class Groups( - val displayPriority: DisplayPriority, - val donorTierGroupNames: DonorTierGroupNames, - ) { - @Serializable - data class DisplayPriority( - val builder: List, - val trust: List, - val donor: List, - ) - - @Serializable - data class DonorTierGroupNames( - val copper: String, - val iron: String, - val diamond: String, - ) - } - - @Serializable - data class Messages( - val join: String, - val leave: String, - val firstTimeJoin: String, - val welcome: String, - ) - - companion object -} - -fun PluginConfig.Companion.default() = - PluginConfig( - api = - PluginConfig.Api( - token = "FILL_THIS_IN", - baseUrl = "https://projectcitybuild.com/api/", - isLoggingEnabled = false, - ), - database = - PluginConfig.Database( - hostName = "127.0.0.1", - port = 3306, - name = "pcbridge", - username = "FILL_THIS_IN", - password = "FILL_THIS_IN", - ), - webServer = - PluginConfig.WebServer( - token = "FILL_THIS_IN", - port = 8080, - ), - errorReporting = - PluginConfig.ErrorReporting( - isSentryEnabled = false, - sentryDsn = "https://@sentry.io/", - ), - localization = - PluginConfig.Localization( - timeZone = "UTC", - locale = "en-us", - ), - chatBadge = - PluginConfig.ChatBadge( - icon = "★", - ), - warps = - PluginConfig.Warps( - itemsPerPage = 15, - ), - integrations = - PluginConfig.Integrations( - dynmap = - PluginConfig.Integrations.Dynmap( - warpIconName = "portal", - ), - ), - announcements = - PluginConfig.Announcements( - intervalInMins = 30, - messages = - listOf( - "Join the Project City Build Discord server! Type /discord in game!", - "Donations are the only way to keep PCB running! If you would like to donate to the server, you can do so by typing /donate in game!", - "Vote for us to help keep PCB active! Type /vote in game!", - "Post screenshots of your builds to the #showcase channel on our Discord to be featured on the PCB Instagram! Type /discord to join!", - "Make sure to follow the Project City Build Instagram for features of YOUR builds! Type /instagram in game!", - ), - ), - groups = - PluginConfig.Groups( - displayPriority = - PluginConfig.Groups.DisplayPriority( - builder = - listOf( - "architect", - "engineer", - "planner", - "builder", - "intern", - ), - trust = - listOf( - "developer", - "moderator", - "trusted+", - "trusted", - "member", - ), - donor = - listOf( - "donator", - "legacy-donator", - ), - ), - donorTierGroupNames = - PluginConfig.Groups.DonorTierGroupNames( - copper = "copper_tier", - iron = "iron_tier", - diamond = "diamond_tier", - ), - ), - messages = - PluginConfig.Messages( - join = "+ %name% joined the server", - leave = "- %name% left the server (online for %time_online%)", - firstTimeJoin = "✦ Welcome §f%name%§d to the server!", - welcome = "Welcome to PCB!", - ), - ) diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/actions/StartAnnouncementTimer.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/actions/StartAnnouncementTimer.kt index a6d7b0ec..771fe67f 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/actions/StartAnnouncementTimer.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/actions/StartAnnouncementTimer.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.announcements.actions -import com.projectcitybuild.pcbridge.core.config.Config +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig import com.projectcitybuild.pcbridge.features.announcements.repositories.AnnouncementRepository import com.projectcitybuild.pcbridge.support.spigot.SpigotTimer import kotlinx.coroutines.runBlocking @@ -10,14 +10,14 @@ import java.util.concurrent.TimeUnit class StartAnnouncementTimer( private val repository: AnnouncementRepository, - private val config: Config, + private val remoteConfig: RemoteConfig, private val timer: SpigotTimer, private val server: Server, ) { private val timerId = "scheduled_announcements" - suspend fun start() { - val config = config.get() + fun start() { + val config = remoteConfig.latest.config val intervalInMins = config.announcements.intervalInMins timer.cancel(timerId) diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/listeners/AnnouncementEnableListener.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/listeners/AnnouncementEnableListener.kt index 44a46621..12873078 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/listeners/AnnouncementEnableListener.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/listeners/AnnouncementEnableListener.kt @@ -1,7 +1,7 @@ package com.projectcitybuild.pcbridge.features.announcements.listeners -import com.projectcitybuild.pcbridge.core.config.Config import com.projectcitybuild.pcbridge.core.logger.log +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig import com.projectcitybuild.pcbridge.features.announcements.actions.StartAnnouncementTimer import com.projectcitybuild.pcbridge.features.announcements.repositories.AnnouncementRepository import com.projectcitybuild.pcbridge.support.spigot.SpigotTimer @@ -15,7 +15,7 @@ import org.bukkit.plugin.java.JavaPlugin class AnnouncementEnableListener( private val announcementRepository: AnnouncementRepository, - private val config: Config, + private val remoteConfig: RemoteConfig, private val timer: SpigotTimer, private val server: Server, private val plugin: JavaPlugin, @@ -31,7 +31,7 @@ class AnnouncementEnableListener( action = StartAnnouncementTimer( announcementRepository, - config, + remoteConfig, timer, server, ) diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/repositories/AnnouncementRepository.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/repositories/AnnouncementRepository.kt index 92899dd9..bf4baa9a 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/repositories/AnnouncementRepository.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/announcements/repositories/AnnouncementRepository.kt @@ -1,17 +1,18 @@ package com.projectcitybuild.pcbridge.features.announcements.repositories -import com.projectcitybuild.pcbridge.core.config.Config -import com.projectcitybuild.pcbridge.core.state.Store +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig +import com.projectcitybuild.pcbridge.core.store.Store import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext class AnnouncementRepository( - private val config: Config, + private val remoteConfig: RemoteConfig, private val store: Store, ) { suspend fun getNextAnnouncement(): String = withContext(Dispatchers.IO) { - val announcements = config.get().announcements.messages + val config = remoteConfig.latest.config + val announcements = config.announcements.messages val lastBroadcastIndex = store.state.lastBroadcastIndex val nextIndex = (lastBroadcastIndex + 1) % announcements.size store.mutate { state -> diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/actions/AuthorizeConnection.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/actions/AuthorizeConnection.kt index 40270758..317f86da 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/actions/AuthorizeConnection.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/actions/AuthorizeConnection.kt @@ -1,8 +1,8 @@ package com.projectcitybuild.pcbridge.features.bans.actions -import com.projectcitybuild.pcbridge.http.responses.PlayerData -import com.projectcitybuild.pcbridge.http.responses.IPBan -import com.projectcitybuild.pcbridge.http.responses.PlayerBan +import com.projectcitybuild.pcbridge.http.models.PlayerData +import com.projectcitybuild.pcbridge.http.models.IPBan +import com.projectcitybuild.pcbridge.http.models.PlayerBan class AuthorizeConnection { sealed class ConnectResult { diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/ConnectionPermittedEvent.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/ConnectionPermittedEvent.kt index 19f3c60f..e9db644c 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/ConnectionPermittedEvent.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/ConnectionPermittedEvent.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.bans.events -import com.projectcitybuild.pcbridge.http.responses.PlayerData +import com.projectcitybuild.pcbridge.http.models.PlayerData import org.bukkit.event.Event import org.bukkit.event.HandlerList import java.util.UUID diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/IPBanRequestedEvent.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/IPBanRequestedEvent.kt index 63fbbc2e..0e1b72d9 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/IPBanRequestedEvent.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/IPBanRequestedEvent.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.bans.events -import com.projectcitybuild.pcbridge.http.responses.IPBan +import com.projectcitybuild.pcbridge.http.models.IPBan import org.bukkit.event.Event import org.bukkit.event.HandlerList diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/UUIDBanRequestedEvent.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/UUIDBanRequestedEvent.kt index 119c7b3f..3a4987f7 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/UUIDBanRequestedEvent.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/events/UUIDBanRequestedEvent.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.bans.events -import com.projectcitybuild.pcbridge.http.responses.PlayerBan +import com.projectcitybuild.pcbridge.http.models.PlayerBan import org.bukkit.event.Event import org.bukkit.event.HandlerList diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/repositories/PlayerRepository.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/repositories/PlayerRepository.kt index 96541ac3..34da3ad7 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/repositories/PlayerRepository.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/repositories/PlayerRepository.kt @@ -1,8 +1,8 @@ package com.projectcitybuild.pcbridge.features.bans.repositories import com.projectcitybuild.pcbridge.features.bans.utilities.Sanitizer -import com.projectcitybuild.pcbridge.http.responses.PlayerData -import com.projectcitybuild.pcbridge.http.services.pcb.PlayerHttpService +import com.projectcitybuild.pcbridge.http.models.PlayerData +import com.projectcitybuild.pcbridge.http.services.PlayerHttpService import java.net.InetAddress import java.util.UUID import kotlin.jvm.Throws diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/utilities/BanMessage.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/utilities/BanMessage.kt index e16b27c3..0aacc5cc 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/utilities/BanMessage.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/bans/utilities/BanMessage.kt @@ -1,7 +1,7 @@ package com.projectcitybuild.pcbridge.features.bans.utilities -import com.projectcitybuild.pcbridge.http.responses.IPBan -import com.projectcitybuild.pcbridge.http.responses.PlayerBan +import com.projectcitybuild.pcbridge.http.models.IPBan +import com.projectcitybuild.pcbridge.http.models.PlayerBan import net.kyori.adventure.text.minimessage.MiniMessage fun PlayerBan.toMiniMessage() = MiniMessage.miniMessage().deserialize( diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/ChatBadgeFormatter.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/ChatBadgeFormatter.kt index ecc3e8ca..c5feecbc 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/ChatBadgeFormatter.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/ChatBadgeFormatter.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.chat -import com.projectcitybuild.pcbridge.http.responses.Badge +import com.projectcitybuild.pcbridge.http.models.Badge import net.kyori.adventure.text.Component import net.kyori.adventure.text.event.HoverEvent import net.kyori.adventure.text.format.NamedTextColor diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/repositories/ChatBadgeRepository.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/repositories/ChatBadgeRepository.kt index 9446384a..49b6b972 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/repositories/ChatBadgeRepository.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/repositories/ChatBadgeRepository.kt @@ -1,14 +1,14 @@ package com.projectcitybuild.pcbridge.features.chat.repositories -import com.projectcitybuild.pcbridge.core.config.Config -import com.projectcitybuild.pcbridge.core.state.Store +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig +import com.projectcitybuild.pcbridge.core.store.Store import com.projectcitybuild.pcbridge.features.chat.ChatBadgeFormatter import io.github.reactivecircus.cache4k.Cache import net.kyori.adventure.text.Component import java.util.UUID class ChatBadgeRepository( - private val config: Config, + private val remoteConfig: RemoteConfig, private val store: Store, private val badgeCache: Cache, private val badgeFormatter: ChatBadgeFormatter, @@ -18,7 +18,8 @@ class ChatBadgeRepository( val badges = store.state.players[playerUUID]?.badges ?: emptyList() - val icon = config.get().chatBadge.icon + val config = remoteConfig.latest.config + val icon = config.chat.badgeIcon badgeFormatter.format(badges, icon) } diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/repositories/ChatGroupRepository.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/repositories/ChatGroupRepository.kt index d9f33e5d..256786c5 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/repositories/ChatGroupRepository.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/chat/repositories/ChatGroupRepository.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.chat.repositories -import com.projectcitybuild.pcbridge.core.config.Config +import com.projectcitybuild.pcbridge.core.localconfig.LocalConfig import com.projectcitybuild.pcbridge.core.permissions.Permissions import com.projectcitybuild.pcbridge.features.chat.ChatGroupFormatter import com.projectcitybuild.pcbridge.features.chat.ChatGroupType @@ -9,7 +9,7 @@ import java.util.UUID class ChatGroupRepository( private val permissions: Permissions, - private val config: Config, + private val localConfig: LocalConfig, private val chatGroupFormatter: ChatGroupFormatter, private val groupCache: Cache, ) { @@ -34,9 +34,9 @@ class ChatGroupRepository( map }, groupDisplayPriorities = mapOf( - Pair(ChatGroupType.TRUST, config.get().groups.displayPriority.trust), - Pair(ChatGroupType.BUILD, config.get().groups.displayPriority.builder), - Pair(ChatGroupType.DONOR, config.get().groups.displayPriority.donor), + Pair(ChatGroupType.TRUST, localConfig.get().groups.displayPriority.trust), + Pair(ChatGroupType.BUILD, localConfig.get().groups.displayPriority.builder), + Pair(ChatGroupType.DONOR, localConfig.get().groups.displayPriority.donor), ), suffix = permissions.getUserSuffix(playerUUID), prefix = permissions.getUserPrefix(playerUUID), diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/groups/actions/SyncPlayerGroups.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/groups/actions/SyncPlayerGroups.kt index e7e8ee69..b932dfc6 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/groups/actions/SyncPlayerGroups.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/groups/actions/SyncPlayerGroups.kt @@ -2,8 +2,8 @@ package com.projectcitybuild.pcbridge.features.groups.actions import com.projectcitybuild.pcbridge.core.permissions.Permissions import com.projectcitybuild.pcbridge.features.groups.repositories.SyncRepository -import com.projectcitybuild.pcbridge.http.responses.DonationPerk -import com.projectcitybuild.pcbridge.http.responses.Group +import com.projectcitybuild.pcbridge.http.models.DonationPerk +import com.projectcitybuild.pcbridge.http.models.Group import java.util.UUID class SyncPlayerGroups( diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/groups/repositories/SyncRepository.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/groups/repositories/SyncRepository.kt index e7e74afc..2ec6476e 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/groups/repositories/SyncRepository.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/groups/repositories/SyncRepository.kt @@ -1,17 +1,17 @@ package com.projectcitybuild.pcbridge.features.groups.repositories -import com.projectcitybuild.pcbridge.core.config.Config +import com.projectcitybuild.pcbridge.core.localconfig.LocalConfig import com.projectcitybuild.pcbridge.core.logger.log -import com.projectcitybuild.pcbridge.http.responses.DonationPerk +import com.projectcitybuild.pcbridge.http.models.DonationPerk class SyncRepository( - private val config: Config, + private val localConfig: LocalConfig, ) { fun getDonorTiers(perks: List): List { return perks.mapNotNull { donorPerk -> val tierName = donorPerk.donationTier.name - val groupNames = config.get().groups.donorTierGroupNames + val groupNames = localConfig.get().groups.donorTierGroupNames when (tierName) { "copper" -> groupNames.copper "iron" -> groupNames.iron diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/AnnounceJoinListener.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/AnnounceJoinListener.kt index 00664030..38b30f30 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/AnnounceJoinListener.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/AnnounceJoinListener.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.joinmessages.listeners -import com.projectcitybuild.pcbridge.core.config.Config +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig import net.kyori.adventure.text.Component import net.kyori.adventure.text.minimessage.MiniMessage import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder @@ -10,11 +10,11 @@ import org.bukkit.event.Listener import org.bukkit.event.player.PlayerJoinEvent class AnnounceJoinListener( - private val config: Config, + private val remoteConfig: RemoteConfig, ) : Listener { @EventHandler(priority = EventPriority.NORMAL) fun onPlayerJoin(event: PlayerJoinEvent) { - val joinMessage = config.get().messages.join + val joinMessage = remoteConfig.latest.config.messages.join event.joinMessage( MiniMessage.miniMessage().deserialize( diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/AnnounceQuitListener.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/AnnounceQuitListener.kt index 556d8a06..07eea157 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/AnnounceQuitListener.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/AnnounceQuitListener.kt @@ -1,8 +1,8 @@ package com.projectcitybuild.pcbridge.features.joinmessages.listeners -import com.projectcitybuild.pcbridge.core.config.Config import com.projectcitybuild.pcbridge.core.datetime.LocalizedTime -import com.projectcitybuild.pcbridge.core.state.Store +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig +import com.projectcitybuild.pcbridge.core.store.Store import net.kyori.adventure.text.Component import net.kyori.adventure.text.minimessage.MiniMessage import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder @@ -14,7 +14,7 @@ import java.time.Duration import java.time.LocalDateTime class AnnounceQuitListener( - private val config: Config, + private val remoteConfig: RemoteConfig, private val store: Store, private val time: LocalizedTime, ) : Listener { @@ -24,7 +24,7 @@ class AnnounceQuitListener( val joinTime = playerState?.connectedAt ?: time.now() val timeOnline = sessionTime(start = joinTime) - val leaveMessage = config.get().messages.leave + val leaveMessage = remoteConfig.latest.config.messages.leave event.quitMessage( MiniMessage.miniMessage().deserialize( diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/FirstTimeJoinListener.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/FirstTimeJoinListener.kt index c4d3d23a..58076b9a 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/FirstTimeJoinListener.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/FirstTimeJoinListener.kt @@ -1,8 +1,8 @@ package com.projectcitybuild.pcbridge.features.joinmessages.listeners -import com.projectcitybuild.pcbridge.core.config.Config import com.projectcitybuild.pcbridge.core.datetime.LocalizedTime import com.projectcitybuild.pcbridge.core.logger.log +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig import com.projectcitybuild.pcbridge.features.joinmessages.repositories.PlayerConfigRepository import net.kyori.adventure.text.Component import net.kyori.adventure.text.minimessage.MiniMessage @@ -16,7 +16,7 @@ import org.bukkit.event.player.PlayerJoinEvent class FirstTimeJoinListener( private val server: Server, private val playerConfigRepository: PlayerConfigRepository, - private val config: Config, + private val remoteConfig: RemoteConfig, private val time: LocalizedTime, ) : Listener { @EventHandler(priority = EventPriority.MONITOR) @@ -32,9 +32,10 @@ class FirstTimeJoinListener( log.debug { "Sending first-time welcome message for ${event.player.name}" } + val config = remoteConfig.latest.config val message = MiniMessage.miniMessage().deserialize( - config.get().messages.firstTimeJoin, + config.messages.firstTimeJoin, Placeholder.component("name", Component.text(event.player.name)), ) server.onlinePlayers diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/ServerOverviewJoinListener.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/ServerOverviewJoinListener.kt index 27d6a0ac..e1238b22 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/ServerOverviewJoinListener.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/joinmessages/listeners/ServerOverviewJoinListener.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.joinmessages.listeners -import com.projectcitybuild.pcbridge.core.config.Config +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig import net.kyori.adventure.text.minimessage.MiniMessage import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -8,11 +8,12 @@ import org.bukkit.event.Listener import org.bukkit.event.player.PlayerJoinEvent class ServerOverviewJoinListener( - private val config: Config, + private val remoteConfig: RemoteConfig, ) : Listener { @EventHandler(priority = EventPriority.MONITOR) fun onPlayerJoin(event: PlayerJoinEvent) { - val message = config.get().messages.welcome + val config = remoteConfig.latest.config + val message = config.messages.welcome event.player.sendMessage( MiniMessage.miniMessage().deserialize(message), diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/events/PlayerStateDestroyedEvent.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/events/PlayerStateDestroyedEvent.kt index d58dd69f..82706e90 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/events/PlayerStateDestroyedEvent.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/events/PlayerStateDestroyedEvent.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.playerstate.events -import com.projectcitybuild.pcbridge.core.state.PlayerState +import com.projectcitybuild.pcbridge.core.store.PlayerState import org.bukkit.event.Event import org.bukkit.event.HandlerList import java.util.UUID diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/events/PlayerStateUpdatedEvent.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/events/PlayerStateUpdatedEvent.kt index dca66e13..26d7a774 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/events/PlayerStateUpdatedEvent.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/events/PlayerStateUpdatedEvent.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.playerstate.events -import com.projectcitybuild.pcbridge.core.state.PlayerState +import com.projectcitybuild.pcbridge.core.store.PlayerState import org.bukkit.event.Event import org.bukkit.event.HandlerList import java.util.UUID diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/listeners/PlayerStateListener.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/listeners/PlayerStateListener.kt index e494813d..877efeb9 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/listeners/PlayerStateListener.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/listeners/PlayerStateListener.kt @@ -2,8 +2,8 @@ package com.projectcitybuild.pcbridge.features.playerstate.listeners import com.projectcitybuild.pcbridge.core.datetime.LocalizedTime import com.projectcitybuild.pcbridge.core.logger.log -import com.projectcitybuild.pcbridge.core.state.PlayerState -import com.projectcitybuild.pcbridge.core.state.Store +import com.projectcitybuild.pcbridge.core.store.PlayerState +import com.projectcitybuild.pcbridge.core.store.Store import com.projectcitybuild.pcbridge.features.bans.events.ConnectionPermittedEvent import com.projectcitybuild.pcbridge.features.playerstate.events.PlayerStateUpdatedEvent import com.projectcitybuild.pcbridge.features.playerstate.events.PlayerStateDestroyedEvent diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/listeners/PlayerSyncRequestListener.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/listeners/PlayerSyncRequestListener.kt index 5c5fe6da..a87a2fdf 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/listeners/PlayerSyncRequestListener.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/playerstate/listeners/PlayerSyncRequestListener.kt @@ -2,8 +2,8 @@ package com.projectcitybuild.pcbridge.features.playerstate.listeners import com.projectcitybuild.pcbridge.core.datetime.LocalizedTime import com.projectcitybuild.pcbridge.core.logger.log -import com.projectcitybuild.pcbridge.core.state.PlayerState -import com.projectcitybuild.pcbridge.core.state.Store +import com.projectcitybuild.pcbridge.core.store.PlayerState +import com.projectcitybuild.pcbridge.core.store.Store import com.projectcitybuild.pcbridge.features.bans.repositories.PlayerRepository import com.projectcitybuild.pcbridge.features.playerstate.events.PlayerStateUpdatedEvent import com.projectcitybuild.pcbridge.features.groups.events.PlayerSyncRequestedEvent diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/register/commands/CodeCommand.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/register/commands/CodeCommand.kt index 6f84bb13..2d2508b3 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/register/commands/CodeCommand.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/register/commands/CodeCommand.kt @@ -1,7 +1,7 @@ package com.projectcitybuild.pcbridge.features.register.commands import com.projectcitybuild.pcbridge.http.parsing.ResponseParser -import com.projectcitybuild.pcbridge.http.services.pcb.RegisterHttpService +import com.projectcitybuild.pcbridge.http.services.RegisterHttpService import com.projectcitybuild.pcbridge.support.messages.CommandHelpBuilder import com.projectcitybuild.pcbridge.support.spigot.BadCommandUsageException import com.projectcitybuild.pcbridge.support.spigot.CommandArgsParser diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/register/commands/RegisterCommand.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/register/commands/RegisterCommand.kt index beb092ad..4fa0b9d6 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/register/commands/RegisterCommand.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/register/commands/RegisterCommand.kt @@ -1,7 +1,7 @@ package com.projectcitybuild.pcbridge.features.register.commands import com.projectcitybuild.pcbridge.http.parsing.ResponseParser -import com.projectcitybuild.pcbridge.http.services.pcb.RegisterHttpService +import com.projectcitybuild.pcbridge.http.services.RegisterHttpService import com.projectcitybuild.pcbridge.support.messages.CommandHelpBuilder import com.projectcitybuild.pcbridge.support.spigot.BadCommandUsageException import com.projectcitybuild.pcbridge.support.spigot.CommandArgsParser diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/telemetry/repositories/TelemetryRepository.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/telemetry/repositories/TelemetryRepository.kt index 4e2b78f8..db76d06e 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/telemetry/repositories/TelemetryRepository.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/telemetry/repositories/TelemetryRepository.kt @@ -1,6 +1,6 @@ package com.projectcitybuild.pcbridge.features.telemetry.repositories -import com.projectcitybuild.pcbridge.http.services.pcb.TelemetryHttpService +import com.projectcitybuild.pcbridge.http.services.TelemetryHttpService import java.util.UUID class TelemetryRepository( diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/warps/commands/WarpsCommand.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/warps/commands/WarpsCommand.kt index 6cb65b2a..4002f920 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/warps/commands/WarpsCommand.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/features/warps/commands/WarpsCommand.kt @@ -1,7 +1,7 @@ package com.projectcitybuild.pcbridge.features.warps.commands -import com.projectcitybuild.pcbridge.core.config.Config import com.projectcitybuild.pcbridge.core.datetime.LocalizedTime +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig import com.projectcitybuild.pcbridge.features.warps.commands.warps.WarpCreateCommand import com.projectcitybuild.pcbridge.features.warps.commands.warps.WarpDeleteCommand import com.projectcitybuild.pcbridge.features.warps.commands.warps.WarpListCommand @@ -19,7 +19,7 @@ import org.bukkit.command.CommandSender class WarpsCommand( private val warpRepository: WarpRepository, - private val config: Config, + private val remoteConfig: RemoteConfig, private val server: Server, private val time: LocalizedTime, ) : SpigotCommand { @@ -64,7 +64,7 @@ class WarpsCommand( Args.Command.List -> WarpListCommand( warpRepository = warpRepository, - itemsPerPage = config.get().warps.itemsPerPage, + itemsPerPage = remoteConfig.latest.config.warps.itemsPerPage, ).run( sender = sender, args = diff --git a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/integrations/DynmapIntegration.kt b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/integrations/DynmapIntegration.kt index 405380d2..c463e0a6 100644 --- a/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/integrations/DynmapIntegration.kt +++ b/pcbridge-spigot/src/main/kotlin/com/projectcitybuild/pcbridge/integrations/DynmapIntegration.kt @@ -1,9 +1,9 @@ package com.projectcitybuild.pcbridge.integrations import com.github.shynixn.mccoroutine.bukkit.registerSuspendingEvents -import com.projectcitybuild.pcbridge.core.config.Config import com.projectcitybuild.pcbridge.core.errors.SentryReporter import com.projectcitybuild.pcbridge.core.logger.log +import com.projectcitybuild.pcbridge.core.remoteconfig.services.RemoteConfig import com.projectcitybuild.pcbridge.features.warps.events.WarpCreateEvent import com.projectcitybuild.pcbridge.features.warps.events.WarpDeleteEvent import com.projectcitybuild.pcbridge.features.warps.repositories.WarpRepository @@ -17,7 +17,7 @@ import org.dynmap.DynmapAPI class DynmapIntegration( private val plugin: JavaPlugin, private val warpRepository: WarpRepository, - private val config: Config, + private val remoteConfig: RemoteConfig, sentry: SentryReporter, ) : Listener, SpigotIntegration( pluginName = "dynmap", @@ -83,7 +83,8 @@ class DynmapIntegration( markers.forEach { it.deleteMarker() } } - val iconName = config.get().integrations.dynmap.warpIconName + val config = remoteConfig.latest.config + val iconName = config.integrations.dynmapWarpIconName val icon = markerAPI.getMarkerIcon(iconName) ?: throw DynmapMarkerIconNotFoundException() diff --git a/pcbridge-spigot/src/main/resources/plugin.yml b/pcbridge-spigot/src/main/resources/plugin.yml index dd5636cd..67a7c6ca 100644 --- a/pcbridge-spigot/src/main/resources/plugin.yml +++ b/pcbridge-spigot/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: PCBridge main: com.projectcitybuild.pcbridge.Plugin website: https://github.com/projectcitybuild/PCBridge author: Andy -version: 6.1.0 +version: 6.2.0 api-version: 1.20 softdepend: diff --git a/pcbridge-spigot/test/com/projectcitybuild/pcbridge/features/bans/actions/AuthorizeConnectionTest.kt b/pcbridge-spigot/test/com/projectcitybuild/pcbridge/features/bans/actions/AuthorizeConnectionTest.kt index e97efdb9..1634346d 100644 --- a/pcbridge-spigot/test/com/projectcitybuild/pcbridge/features/bans/actions/AuthorizeConnectionTest.kt +++ b/pcbridge-spigot/test/com/projectcitybuild/pcbridge/features/bans/actions/AuthorizeConnectionTest.kt @@ -1,8 +1,8 @@ package com.projectcitybuild.pcbridge.features.bans.actions -import com.projectcitybuild.pcbridge.http.responses.PlayerData -import com.projectcitybuild.pcbridge.http.responses.IPBan -import com.projectcitybuild.pcbridge.http.responses.PlayerBan +import com.projectcitybuild.pcbridge.http.models.PlayerData +import com.projectcitybuild.pcbridge.http.models.IPBan +import com.projectcitybuild.pcbridge.http.models.PlayerBan import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach diff --git a/pcbridge-web-server/src/main/kotlin/com/projectcitybuild/pcbridge/webserver/HttpServer.kt b/pcbridge-web-server/src/main/kotlin/com/projectcitybuild/pcbridge/webserver/HttpServer.kt index eb401faf..2bcacc92 100644 --- a/pcbridge-web-server/src/main/kotlin/com/projectcitybuild/pcbridge/webserver/HttpServer.kt +++ b/pcbridge-web-server/src/main/kotlin/com/projectcitybuild/pcbridge/webserver/HttpServer.kt @@ -1,7 +1,7 @@ package com.projectcitybuild.pcbridge.webserver -import com.projectcitybuild.pcbridge.http.responses.IPBan -import com.projectcitybuild.pcbridge.http.responses.PlayerBan +import com.projectcitybuild.pcbridge.http.models.IPBan +import com.projectcitybuild.pcbridge.http.models.PlayerBan import com.projectcitybuild.pcbridge.http.serialization.gson.LocalDateTimeTypeAdapter import io.ktor.http.HttpStatusCode import io.ktor.serialization.gson.gson