Skip to content

Commit

Permalink
conflicts smh
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonP01 committed Dec 25, 2024
2 parents 1f6dec3 + 7d4db09 commit bdfe97a
Show file tree
Hide file tree
Showing 91 changed files with 1,563 additions and 1,291 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.11.0
2024.12.1
38 changes: 19 additions & 19 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
[versions]
# platforms
kotlin-core = "2.0.20"
kotlin-core = "2.1.0"
kotlin-coroutine = "1.9.0"
kotlin-runtime = "4.0.0"
kotlinx-serialization = "1.7.3"
java = "17"
mindustry = "146"

# libraries
distributor = "4.0.0-rc.3"
junit = "5.11.3"
testcontainers = "1.20.3"
guava = "33.3.1-jre"
hoplite = "2.8.2"
deepl = "1.6.0"
distributor = "4.0.2"
junit = "5.11.4"
testcontainers = "1.20.4"
guava = "33.4.0-jre"
hoplite = "2.9.0"
slf4j = "2.0.16"
slf4md = "1.0.0"
sql4md = "1.1.0"
password4j = "1.8.2"
rabbitmq-client = "5.22.0"
jsoup = "1.18.1"
rabbitmq-client = "5.24.0"
jsoup = "1.18.3"
okhttp = "4.12.0"
classgraph = "4.8.177"
classgraph = "4.8.179"
logback = "1.5.12"
hikari = "6.1.0"
exposed = "0.56.0"
hikari = "6.2.1"
exposed = "0.57.0"
h2 = "2.3.232"
mariadb = "3.5.0"
mariadb = "3.5.1"
caffeine = "3.1.8"
prettytime = "5.0.9.Final"
time4j = "4.38"
nohorny = "3.0.0-beta.1"
nohorny = "3.0.0"
jda = "5.2.1"
cloud-core = "2.0.0"
cloud-translations = "1.0.0-SNAPSHOT"
ahocorasick = "0.6.3"
minio = "8.5.13"
flex = "1.0.0-SNAPSHOT"
minio = "8.5.14"
flex = "1.0.0"
influxdb = "7.2.0"

# gradle plugins
toxopid = "4.1.0"
toxopid = "4.1.1"
indra = "3.1.3"
spotless = "6.25.0"
shadow = "8.3.5"
ktlint = "0.49.1"
ktor-gradle = "3.0.1"
ktor-gradle = "3.0.2"

[libraries]
# libraries
Expand All @@ -60,7 +60,6 @@ testcontainers-minio = { module = "org.testcontainers:minio", version.ref = "tes
guava = { module = "com.google.guava:guava", version.ref = "guava" }
hoplite-core = { module = "com.sksamuel.hoplite:hoplite-core", version.ref = "hoplite" }
hoplite-yaml = { module = "com.sksamuel.hoplite:hoplite-yaml", version.ref = "hoplite" }
deepl = { module = "com.deepl.api:deepl-java", version.ref = "deepl" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }
password4j = { module = "com.password4j:password4j", version.ref = "password4j" }
Expand Down Expand Up @@ -90,6 +89,7 @@ cloud-translations-core = { module = "org.incendo:cloud-translations-core", vers
ahocorasick = { module = "org.ahocorasick:ahocorasick", version.ref = "ahocorasick" }
minio = { module = "io.minio:minio", version.ref = "minio" }
flex = { module = "com.xpdustry:flex", version.ref = "flex" }
influxdb = { module = "com.influxdb:influxdb-client-kotlin", version.ref = "influxdb" }

# gradle plugins
toxopid = { module = "com.xpdustry:toxopid", version.ref = "toxopid" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 2 additions & 1 deletion imperium-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dependencies {
api(libs.guava)
api(libs.hoplite.core)
api(libs.hoplite.yaml)
api(libs.deepl)
api(libs.password4j)
api(libs.rabbitmq.client)
api(libs.okhttp)
Expand All @@ -33,6 +32,8 @@ dependencies {
api(libs.prettytime)
api(libs.time4j.core)
testRuntimeOnly(libs.h2)

api(libs.influxdb)
}

// We love OOMs :^)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import com.xpdustry.imperium.common.bridge.RequestingPlayerTracker
import com.xpdustry.imperium.common.config.ImperiumConfig
import com.xpdustry.imperium.common.config.ImperiumConfigProvider
import com.xpdustry.imperium.common.config.MessengerConfig
import com.xpdustry.imperium.common.config.MetricConfig
import com.xpdustry.imperium.common.config.NetworkConfig
import com.xpdustry.imperium.common.config.StorageConfig
import com.xpdustry.imperium.common.config.TranslatorConfig
import com.xpdustry.imperium.common.config.WebhookConfig
import com.xpdustry.imperium.common.content.MindustryMapManager
import com.xpdustry.imperium.common.content.SimpleMindustryMapManager
Expand All @@ -43,6 +43,8 @@ import com.xpdustry.imperium.common.inject.provider
import com.xpdustry.imperium.common.message.Messenger
import com.xpdustry.imperium.common.message.NoopMessenger
import com.xpdustry.imperium.common.message.RabbitmqMessenger
import com.xpdustry.imperium.common.metrics.InfluxDBRegistry
import com.xpdustry.imperium.common.metrics.MetricsRegistry
import com.xpdustry.imperium.common.network.Discovery
import com.xpdustry.imperium.common.network.SimpleDiscovery
import com.xpdustry.imperium.common.network.VpnApiIoDetection
Expand All @@ -56,9 +58,6 @@ import com.xpdustry.imperium.common.storage.MinioStorageBucket
import com.xpdustry.imperium.common.storage.StorageBucket
import com.xpdustry.imperium.common.time.SimpleTimeRenderer
import com.xpdustry.imperium.common.time.TimeRenderer
import com.xpdustry.imperium.common.translator.DeeplTranslator
import com.xpdustry.imperium.common.translator.LibreTranslateTranslator
import com.xpdustry.imperium.common.translator.Translator
import com.xpdustry.imperium.common.user.SimpleUserManager
import com.xpdustry.imperium.common.user.UserManager
import com.xpdustry.imperium.common.version.ImperiumVersion
Expand All @@ -74,15 +73,7 @@ import okhttp3.Dispatcher
import okhttp3.OkHttpClient

fun MutableInstanceManager.registerCommonModule() {
provider(ImperiumConfigProvider())

provider<Translator> {
when (val config = get<ImperiumConfig>().translator) {
is TranslatorConfig.None -> Translator.Noop
is TranslatorConfig.LibreTranslate -> LibreTranslateTranslator(config, get())
is TranslatorConfig.DeepL -> DeeplTranslator(config, get())
}
}
provider(ImperiumConfigProvider)

provider<Discovery> { SimpleDiscovery(get(), get("discovery"), get()) }

Expand Down Expand Up @@ -156,6 +147,14 @@ fun MutableInstanceManager.registerCommonModule() {
is StorageConfig.Minio -> MinioStorageBucket(config, get())
}
}

provider<MetricsRegistry> {
val config = get<ImperiumConfig>()
when (config.metrics) {
is MetricConfig.InfluxDB -> InfluxDBRegistry(config.server, config.metrics, get())
is MetricConfig.None -> MetricsRegistry.None
}
}
}

fun MutableInstanceManager.registerApplication(application: ImperiumApplication) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
package com.xpdustry.imperium.common.bridge

import com.xpdustry.imperium.common.message.Message
import com.xpdustry.imperium.common.security.Identity
import kotlinx.serialization.Serializable

@Serializable
data class BridgeChatMessage(val serverName: String, val sender: Identity, val message: String) :
Message
data class BridgeChatMessage(
val serverName: String,
val senderName: String,
val discord: Long,
val message: String
) : Message
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,17 @@ private val SUPPORTED_LANGUAGE =
data class ImperiumConfig(
val network: NetworkConfig = NetworkConfig(),
val testing: Boolean = false,
val translator: TranslatorConfig = TranslatorConfig.None,
val database: DatabaseConfig = DatabaseConfig.H2(),
val messenger: MessengerConfig = MessengerConfig.None,
val server: ServerConfig = ServerConfig("unknown"),
val generatorId: Int = 0,
val language: Locale = Locale.ENGLISH,
// TODO Remove this goofy aah way of loading locales
val supportedLanguages: Set<Locale> = SUPPORTED_LANGUAGE,
val webhook: WebhookConfig = WebhookConfig.None,
val discord: DiscordConfig? = null,
val mindustry: MindustryConfig? = null,
val webserver: WebserverConfig? = null,
val storage: StorageConfig = StorageConfig.Local
val discord: DiscordConfig = DiscordConfig(),
val mindustry: MindustryConfig = MindustryConfig(),
val webserver: WebserverConfig = WebserverConfig(),
val storage: StorageConfig = StorageConfig.Local,
val metrics: MetricConfig = MetricConfig.None
)

data class NetworkConfig(
Expand All @@ -73,14 +71,6 @@ data class NetworkConfig(
}
}

sealed interface TranslatorConfig {
data object None : TranslatorConfig

data class LibreTranslate(val ltEndpoint: URL, val ltToken: Secret) : TranslatorConfig

data class DeepL(val deeplToken: Secret) : TranslatorConfig
}

sealed interface DatabaseConfig {
data class H2(val memory: Boolean = false, val database: String = "imperium") : DatabaseConfig

Expand Down Expand Up @@ -108,8 +98,6 @@ sealed interface MessengerConfig {
data class ServerConfig(
val name: String,
val displayName: String = name.capitalize(),
// TODO Fix the autoupdate spamming github API
val autoUpdate: Boolean = false
) {
val identity: Identity.Server
get() = Identity.Server(name)
Expand All @@ -131,9 +119,9 @@ sealed interface WebhookConfig {

// TODO Cleanup roles (ranks, permission, special) listing and lookup
data class DiscordConfig(
val token: Secret,
val categories: Categories,
val channels: Channels,
val token: Secret = Secret(""),
val categories: Categories = Categories(),
val channels: Channels = Channels(),
val ranks2roles: Map<Rank, Long> = emptyMap(),
val permissions2roles: Map<Permission, Long> = emptyMap(),
val achievements2roles: Map<Achievement, Long> = emptyMap(),
Expand All @@ -149,18 +137,18 @@ data class DiscordConfig(
}

data class Categories(
val liveChat: Long,
val liveChat: Long = 0,
)

data class Channels(
val notifications: Long,
val maps: Long,
val reports: Long,
val notifications: Long = 0,
val maps: Long = 0,
val reports: Long = 0,
)
}

data class MindustryConfig(
val gamemode: MindustryGamemode,
val gamemode: MindustryGamemode = MindustryGamemode.SURVIVAL,
val quotes: List<String> = listOf("Bonjour", "The best mindustry server of all time"),
val hub: Hub = Hub(),
val history: History = History(),
Expand Down Expand Up @@ -225,3 +213,15 @@ sealed interface StorageConfig {
val bucket: String = "imperium",
) : StorageConfig
}

sealed interface MetricConfig {
data object None : MetricConfig

data class InfluxDB(
val endpoint: URL,
val token: Secret,
val organization: String,
val bucket: String = "imperium",
val interval: Duration = 10.seconds
) : MetricConfig
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,42 @@
*/
package com.xpdustry.imperium.common.config

import com.sksamuel.hoplite.ConfigException
import com.sksamuel.hoplite.ConfigFailure
import com.sksamuel.hoplite.ConfigLoaderBuilder
import com.sksamuel.hoplite.KebabCaseParamMapper
import com.sksamuel.hoplite.addPathSource
import com.sksamuel.hoplite.fp.getOrElse
import com.xpdustry.imperium.common.inject.InstanceManager
import com.xpdustry.imperium.common.inject.InstanceProvider
import com.xpdustry.imperium.common.inject.get
import com.xpdustry.imperium.common.misc.LoggerDelegate
import java.nio.file.Path
import kotlin.io.path.absolutePathString
import kotlin.io.path.notExists

class ImperiumConfigProvider : InstanceProvider<ImperiumConfig> {
override fun create(instances: InstanceManager): ImperiumConfig {
val file = instances.get<Path>("directory").resolve("config.yaml")
if (file.notExists()) {
error("A config file is required. Please create one at ${file.absolutePathString()}")
}
return ConfigLoaderBuilder.empty()
object ImperiumConfigProvider : InstanceProvider<ImperiumConfig> {
private val logger by LoggerDelegate()

override fun create(instances: InstanceManager) =
ConfigLoaderBuilder.empty()
.withClassLoader(ImperiumConfigProvider::class.java.classLoader)
.addDefaultDecoders()
.addDefaultPreprocessors()
.addDefaultParamMappers()
.addParameterMapper(KebabCaseParamMapper)
.addDefaultPropertySources()
.addDefaultParsers() // YamlParser is loaded via ServiceLoader here
.addPathSource(file)
.addPathSource(
instances.get<Path>("directory").resolve("config.yaml"),
optional = true,
allowEmpty = true)
.addDecoder(ColorDecoder())
.strict()
.withReport()
.withReportPrintFn(logger::debug)
.build()
.loadConfigOrThrow()
}
.loadConfig<ImperiumConfig>()
.getOrElse {
if (it is ConfigFailure.UndefinedTree) ImperiumConfig()
else throw ConfigException(it.description())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,23 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.xpdustry.imperium.mindustry.ui.popup
package com.xpdustry.imperium.common.control

import arc.util.Align
import com.xpdustry.imperium.mindustry.ui.Pane
import com.xpdustry.imperium.common.application.ExitStatus
import com.xpdustry.imperium.common.message.Message
import kotlinx.serialization.Serializable

data class PopupPane(
var content: String = "",
var shiftX: Int = 0,
var shiftY: Int = 0,
var alignement: PopupAlignement = PopupAlignement.CENTER,
) : Pane

enum class PopupAlignement(val align: Int) {
TOP_LEFT(Align.topLeft),
TOP(Align.top),
TOP_RIGHT(Align.topRight),
LEFT(Align.left),
CENTER(Align.center),
RIGHT(Align.right),
BOTTOM_LEFT(Align.bottomLeft),
BOTTOM(Align.bottom),
BOTTOM_RIGHT(Align.bottomRight),
@Serializable
data class RemoteActionMessage(val target: String?, val action: Action, val immediate: Boolean) :
Message {
enum class Action {
RESTART,
EXIT
}
}

fun RemoteActionMessage.Action.toExitStatus() =
when (this) {
RemoteActionMessage.Action.EXIT -> ExitStatus.EXIT
RemoteActionMessage.Action.RESTART -> ExitStatus.RESTART
}
Loading

0 comments on commit bdfe97a

Please sign in to comment.