From 7e011ae635e33877fe0bf0a27b692d16877c27bc Mon Sep 17 00:00:00 2001
From: Nicholas Rose <35816886+nicholasgrose@users.noreply.github.com>
Date: Sun, 20 Oct 2024 15:23:27 -0500
Subject: [PATCH] Cleanup part two: CI/CD overhaul
---
.editorconfig | 6 ++
.github/workflows/publish_release.yml | 24 +++---
.github/workflows/pull_request_check.yml | 45 +++++------
.idea/detekt.xml | 7 ++
.idea/developer-tools.xml | 6 ++
...ay__runLints_.xml => Gateway__detekt_.xml} | 4 +-
CHANGELOG.md | 22 ++++++
build.gradle.kts | 75 ++++++++-----------
dev.env | 2 +
gradle.properties | 10 +--
gradle/libs.versions.toml | 26 ++++---
settings.gradle.kts | 13 ++--
.../rose/gateway/config/GatewayConfigFile.kt | 3 +-
.../discord/bot/checks/MessageCheck.kt | 7 +-
.../bot/extensions/about/AboutExtension.kt | 13 ++--
.../bot/extensions/chat/ChatExtension.kt | 4 +-
.../bot/extensions/chat/GameChatEvent.kt | 4 +-
.../discord/bot/extensions/ip/IpExtension.kt | 5 +-
.../bot/extensions/list/ListExtension.kt | 9 ++-
.../bot/extensions/tps/TpsExtension.kt | 9 ++-
.../whitelist/WhitelistArguments.kt | 5 +-
.../whitelist/WhitelistExtension.kt | 35 +++++----
.../commands/arguments/ConfigListArgs.kt | 1 +
.../commands/parsers/ProcessorParser.kt | 5 +-
.../commands/runners/ConfigCommands.kt | 8 +-
.../gateway/shared/parsing/TextProcessor.kt | 3 +-
src/main/resources/plugin.yml | 4 +-
.../translations/discord/strings.properties | 29 +++++++
28 files changed, 221 insertions(+), 163 deletions(-)
create mode 100644 .idea/detekt.xml
create mode 100644 .idea/developer-tools.xml
rename .idea/runConfigurations/{Gateway__runLints_.xml => Gateway__detekt_.xml} (84%)
create mode 100644 CHANGELOG.md
create mode 100644 dev.env
create mode 100644 src/main/resources/translations/discord/strings.properties
diff --git a/.editorconfig b/.editorconfig
index 33905f72..7c687731 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,6 +1,9 @@
root = true
[*]
+charset = utf-8
+trim_trailing_whitespace = true
+max_line_length = 120
insert_final_newline = true
[{*.kt,*.kts}]
@@ -10,3 +13,6 @@ ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
ij_kotlin_packages_to_use_import_on_demand = unset
+
+[*.yml]
+indent_size = 2
diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml
index 8255c2b5..0ed4ca66 100644
--- a/.github/workflows/publish_release.yml
+++ b/.github/workflows/publish_release.yml
@@ -19,14 +19,15 @@ jobs:
- uses: actions/checkout@v4
# https://github.com/marketplace/actions/setup-java-jdk
- - name: Set up JDK 17
+ - name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- - name: Set gradlew execution permission
- run: chmod u+x gradlew
+ # https://github.com/marketplace/actions/build-with-gradle
+ - name: Set up Gradle
+ uses: gradle/actions/setup-gradle@v4
# https://github.com/marketplace/actions/generate-version
- name: Get release version
@@ -36,18 +37,11 @@ jobs:
version-file: gradle.properties
version-file-extraction-pattern: '(?<=version=).+'
- # https://github.com/marketplace/actions/semver-parser
- - name: Parse release version
- uses: apexskier/github-semver-parse@v1
- id: semver
- with:
- version: ${{ env.RELEASE_VERSION }}
+ - name: Get changelog
+ run: ./gradlew getChangelog --console=plain -q --no-header --no-summary > LATEST_CHANGES.md
- # https://github.com/marketplace/actions/gradle-build-action
- name: Build artifacts
- uses: gradle/actions/setup-gradle@v3
- with:
- arguments: shadowJar
+ run: ./gradlew shadowJar
# https://github.com/marketplace/actions/create-release
- name: Create release
@@ -55,7 +49,7 @@ jobs:
with:
name: Gateway ${{ env.RELEASE_VERSION }}
tag: v${{ env.RELEASE_VERSION }}
- generateReleaseNotes: true
+ bodyFile: 'LATEST_CHANGES.md'
artifacts: 'build/libs/*.jar'
- prerelease: ${{ !!steps.semver.outputs.prerelease }}
+ prerelease: ${{ !!env.RELEASE_VERSION_PRERELEASE }}
token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/pull_request_check.yml b/.github/workflows/pull_request_check.yml
index 12675da6..35a0c1b4 100644
--- a/.github/workflows/pull_request_check.yml
+++ b/.github/workflows/pull_request_check.yml
@@ -4,7 +4,7 @@ on:
pull_request:
branches:
- stable
- - develop
+ - dev
paths:
- '**/*.kt'
@@ -19,47 +19,36 @@ jobs:
- uses: actions/checkout@v4
# https://github.com/marketplace/actions/setup-java-jdk
- - name: Set up JDK 17
+ - name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- - name: Set gradlew execution permission
- run: chmod u+x gradlew
+ # https://github.com/marketplace/actions/build-with-gradle
+ - name: Set up Gradle
+ uses: gradle/actions/setup-gradle@v4
- # https://github.com/marketplace/actions/gradle-build-action
- name: Build artifacts
- uses: gradle/actions/setup-gradle@v3
- with:
- arguments: shadowJar
+ run: ./gradlew shadowJar
- ktlint:
+ detekt:
runs-on: ubuntu-latest
steps:
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v4
- # https://github.com/marketplace/actions/run-ktlint-with-reviewdog
- - uses: ScaCap/action-ktlint@v1.9.0
+ # https://github.com/marketplace/actions/setup-java-jdk
+ - name: Set up JDK
+ uses: actions/setup-java@v4
with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- ktlint_version: '1.3.1'
- reporter: github-pr-review
- fail_on_error: true
-
- detekt:
- runs-on: ubuntu-latest
+ java-version: 21
+ distribution: temurin
- steps:
- # https://github.com/marketplace/actions/checkout
- - uses: actions/checkout@v4
+ # https://github.com/marketplace/actions/build-with-gradle
+ - name: Set up Gradle
+ uses: gradle/actions/setup-gradle@v4
- # https://github.com/marketplace/actions/run-detekt-with-reviewdog
- - name: Run detekt with reviewdog
- uses: alaegin/Detekt-Action@v1.23.6
- with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- detekt_config: config/detekt/detekt.yml
- detekt_build_upon_default_config: true
+ - name: Run Detekt
+ run: ./gradlew detekt
diff --git a/.idea/detekt.xml b/.idea/detekt.xml
new file mode 100644
index 00000000..ee7289c6
--- /dev/null
+++ b/.idea/detekt.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/developer-tools.xml b/.idea/developer-tools.xml
new file mode 100644
index 00000000..5421cc50
--- /dev/null
+++ b/.idea/developer-tools.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Gateway__runLints_.xml b/.idea/runConfigurations/Gateway__detekt_.xml
similarity index 84%
rename from .idea/runConfigurations/Gateway__runLints_.xml
rename to .idea/runConfigurations/Gateway__detekt_.xml
index 240d83de..43c649c2 100644
--- a/.idea/runConfigurations/Gateway__runLints_.xml
+++ b/.idea/runConfigurations/Gateway__detekt_.xml
@@ -1,5 +1,5 @@
-
+
@@ -10,7 +10,7 @@
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..bb9c75a1
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,22 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## 1.6.4 - 2024-10-20
+
+### Added
+
+- A better changelog (this)
+- Quality of life enhancements for development
+
+### Changed
+
+- Some minor fixes to Discord commands to have consistent punctuation
+- Moved Discord strings to a new location to support future i18n
+- Updated Kordex and relevant plugins
+
+### Removed
+
+- Unnecessary plugin build steps
diff --git a/build.gradle.kts b/build.gradle.kts
index dafe4070..f5e8915a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,16 +1,17 @@
import dev.kordex.gradle.plugins.kordex.DataCollection
+import io.github.klahap.dotenv.DotEnvBuilder.Companion.dotEnv
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
-import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kordex)
alias(libs.plugins.shadow)
+ alias(libs.plugins.dotenv)
alias(libs.plugins.run.paper)
- alias(libs.plugins.ktlint)
alias(libs.plugins.detekt)
alias(libs.plugins.qodana)
+ alias(libs.plugins.changelog)
}
val version: String by project
@@ -20,21 +21,32 @@ val jvmTargetVersion: String by project
val kotlinTargetVersion: String by project
val minecraftTestVersion: String by project
-val ktlintVersion: String by project
-val detektVersion: String by project
-
project.group = group
project.version = version
+kordEx {
+ jvmTarget = jvmTargetVersion.toInt()
+
+ bot {
+ // See https://docs.kordex.dev/data-collection.html
+ dataCollection(DataCollection.Standard)
+ }
+
+ i18n {
+ classPackage = "gateway.i18n"
+ translationBundle = "discord.strings"
+ }
+}
+
repositories {
mavenCentral()
gradlePluginPortal()
- maven("https://repo.kordex.dev/snapshots/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://jitpack.io")
}
dependencies {
+ detektPlugins(libs.detekt.formatting)
compileOnly(libs.paper.api)
implementation(libs.bundles.hoplite)
implementation(libs.kaml)
@@ -42,32 +54,14 @@ dependencies {
}
detekt {
- config.from("config/detekt/detekt.yml")
buildUponDefaultConfig = true
- toolVersion = detektVersion
-}
-
-ktlint {
- version = ktlintVersion
-}
-
-kordEx {
- jvmTarget = jvmTargetVersion.toInt()
-
- bot {
- // See https://docs.kordex.dev/data-collection.html
- dataCollection(DataCollection.Standard)
-
- mainClass = "com.rose.gateway.discord.bot.DiscordBotKt"
- }
+ config.from("config/detekt/detekt.yml")
}
tasks {
compileKotlin {
compilerOptions {
jvmTarget = JvmTarget.fromTarget(jvmTargetVersion)
- apiVersion = KotlinVersion.fromVersion(kotlinTargetVersion)
- languageVersion = KotlinVersion.fromVersion(kotlinTargetVersion)
}
}
@@ -79,30 +73,21 @@ tasks {
}
}
- jar.configure {
- onlyIf { false }
- }
-
shadowJar {
- archiveBaseName.set(rootProject.name)
- archiveClassifier.set("")
- archiveVersion.set(rootProject.version.toString())
+ archiveBaseName = rootProject.name
+ archiveClassifier = ""
+ archiveVersion = rootProject.version.toString()
mergeServiceFiles()
}
runServer {
- this.minecraftVersion(minecraftTestVersion)
- }
-
- detekt.configure {
- mustRunAfter(ktlintFormat)
- }
-
- create("runLints") {
- dependsOn(ktlintFormat, detekt)
- }
-
- clean {
- delete("build")
+ version = minecraftTestVersion
+
+ // Adding environment variables useful for testing
+ environment(
+ dotEnv {
+ addFile("$rootDir/dev.env")
+ },
+ )
}
}
diff --git a/dev.env b/dev.env
new file mode 100644
index 00000000..49e9b805
--- /dev/null
+++ b/dev.env
@@ -0,0 +1,2 @@
+# Kordex look at this
+ENVIRONMENT=dev
diff --git a/gradle.properties b/gradle.properties
index 5fe6cb0a..293556ef 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,13 +1,7 @@
# Project info
-version=1.6.3
+version=1.6.4
group=com.rose.gateway
-# Target versions for compiled app
+# Target version for compiled app
jvmTargetVersion=21
-kotlinTargetVersion=2.0
# Version to use for testing
minecraftTestVersion=1.21.1
-# Code style configuration
-# https://github.com/pinterest/ktlint
-ktlintVersion=1.3.1
-# https://detekt.dev/
-detektVersion=1.23.7
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 02ec5de7..3b054d04 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -9,7 +9,7 @@ hoplite = "2.8.2"
# https://github.com/charleskorn/kaml
kaml = "0.61.0"
# https://docs.kordex.dev/getting-started
-kordexPlugin = "1.4.2"
+kordex-plugin = "1.5.2"
# https://tegral.zoroark.guru/docs/modules/core/niwen/
tegral = "0.0.4"
@@ -19,17 +19,22 @@ shadow = "8.3.3"
# Testing tools
# https://github.com/jpenilla/run-paper
-runPaper = "2.3.1"
+run-paper = "2.3.1"
+# https://github.com/klahap/dotenv
+dotenv = "1.1.3"
-# Code style
-# https://github.com/jlleitschuh/ktlint-gradle
-ktlint-plugin = "12.1.1"
+# Code style and static analysis
# https://detekt.dev/
-detekt-plugin = "1.23.7"
+detekt = "1.23.7"
# https://www.jetbrains.com/help/qodana/qodana-gradle-plugin.html
qodana = "2024.2.3"
+# Release tools
+# https://github.com/JetBrains/gradle-changelog-plugin
+changelog = "2.2.1"
+
[libraries]
+detekt-formatting = { group = "io.gitlab.arturbosch.detekt" ,name = "detekt-formatting", version.ref = "detekt" }
paper-api = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper-api" }
hoplite-core = { group = "com.sksamuel.hoplite", name = "hoplite-core", version.ref = "hoplite" }
hoplite-yaml = { group = "com.sksamuel.hoplite", name = "hoplite-yaml", version.ref = "hoplite" }
@@ -42,9 +47,10 @@ hoplite = ["hoplite-core", "hoplite-yaml"]
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
-kordex = { id = "dev.kordex.gradle.kordex", version.ref = "kordexPlugin" }
+kordex = { id = "dev.kordex.gradle.kordex", version.ref = "kordex-plugin" }
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
-run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "runPaper" }
-ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint-plugin" }
-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt-plugin" }
+run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "run-paper" }
+dotenv = { id = "io.github.klahap.dotenv", version.ref = "dotenv" }
+detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
+changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
diff --git a/settings.gradle.kts b/settings.gradle.kts
index d8a8ac0e..96e329b9 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,11 +1,12 @@
-rootProject.name = "Gateway"
-
pluginManagement {
repositories {
gradlePluginPortal()
- maven {
- name = "Integrated Server"
- url = uri("https://repo.jpenilla.xyz/snapshots/")
- }
+ mavenCentral()
+
+ maven("https://repo.jpenilla.xyz/snapshots/")
+ maven("https://snapshots-repo.kordex.dev")
+ maven("https://releases-repo.kordex.dev")
}
}
+
+rootProject.name = "Gateway"
diff --git a/src/main/kotlin/com/rose/gateway/config/GatewayConfigFile.kt b/src/main/kotlin/com/rose/gateway/config/GatewayConfigFile.kt
index 80333de3..cf395913 100644
--- a/src/main/kotlin/com/rose/gateway/config/GatewayConfigFile.kt
+++ b/src/main/kotlin/com/rose/gateway/config/GatewayConfigFile.kt
@@ -65,7 +65,8 @@ class GatewayConfigFile : KoinComponent {
* @return The non-nullable type
*/
@Suppress("MaxLineLength")
- private fun T?.notNullWithMissingDefaultConfigMessage(): T = this.notNull("default config resource does not exist to be loaded")
+ private fun T?.notNullWithMissingDefaultConfigMessage(): T =
+ this.notNull("default config resource does not exist to be loaded")
/**
* Ensures that a configuration file exists to be loaded
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/checks/MessageCheck.kt b/src/main/kotlin/com/rose/gateway/discord/bot/checks/MessageCheck.kt
index d4723a70..6125f045 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/checks/MessageCheck.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/checks/MessageCheck.kt
@@ -5,6 +5,7 @@ import dev.kord.core.Kord
import dev.kordex.core.checks.channelFor
import dev.kordex.core.checks.messageFor
import dev.kordex.core.checks.types.Check
+import gateway.i18n.Translations
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@@ -26,7 +27,7 @@ object MessageCheck : KoinComponent {
if (bot.state.botChannels.contains(channel)) {
pass()
} else {
- fail("Channel is not configured bot channel.")
+ fail(Translations.Checks.Chat.Channel.NotBotChannel.fail)
}
}
@@ -38,8 +39,8 @@ object MessageCheck : KoinComponent {
val author = messageFor(event)?.asMessageOrNull()?.author
when {
- author == null -> fail("No author found.")
- author.id == kordClient.selfId -> fail("Is self.")
+ author == null -> fail(Translations.Checks.Chat.Self.NoAuthor.fail)
+ author.id == kordClient.selfId -> fail(Translations.Checks.Chat.Self.OwnId.fail)
else -> pass()
}
}
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/about/AboutExtension.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/about/AboutExtension.kt
index 74448495..c3de6e3a 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/about/AboutExtension.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/about/AboutExtension.kt
@@ -9,6 +9,7 @@ import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
+import gateway.i18n.Translations
import org.bukkit.Bukkit
import org.koin.core.component.inject
@@ -19,9 +20,9 @@ import org.koin.core.component.inject
*/
class AboutExtension : Extension() {
/**
- * Companion
+ * Toggle for the about extension
*
- * @constructor Create empty Companion
+ * @constructor Create toggle
*/
companion object : ExtensionToggle {
private val config: PluginConfig by inject()
@@ -37,8 +38,8 @@ class AboutExtension : Extension() {
override suspend fun setup() {
ephemeralSlashCommand {
- name = "version"
- description = "Gives the current version of the Minecraft server"
+ name = Translations.Commands.Version.name
+ description = Translations.Commands.Version.description
action {
Logger.info("${user.asUserOrNull()?.username} requested plugin version!")
@@ -54,8 +55,8 @@ class AboutExtension : Extension() {
}
ephemeralSlashCommand {
- name = "blockgod"
- description = "Summon the block god for but a moment"
+ name = Translations.Commands.BlockGod.name
+ description = Translations.Commands.BlockGod.description
action {
Logger.info("${user.asUserOrNull()?.username} used the super secret command!")
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/ChatExtension.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/ChatExtension.kt
index 7e308bfe..a69fb3ce 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/ChatExtension.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/ChatExtension.kt
@@ -18,9 +18,9 @@ import org.koin.core.component.inject
*/
class ChatExtension : Extension() {
/**
- * Companion
+ * The chat extension's toggle
*
- * @constructor Create empty Companion
+ * @constructor Create the toggle
*/
companion object : ExtensionToggle {
private val config: PluginConfig by inject()
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/GameChatEvent.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/GameChatEvent.kt
index 65aa9475..d11fd2fb 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/GameChatEvent.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/GameChatEvent.kt
@@ -17,9 +17,9 @@ class GameChatEvent(
val message: MessageCreateBuilder.() -> Unit,
) : KordExEvent {
/**
- * Companion
+ * Provides easy event triggers
*
- * @constructor Create empty Companion
+ * @constructor Construct the trigger object
*/
companion object : KoinComponent {
private val bot: DiscordBotController by inject()
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/ip/IpExtension.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/ip/IpExtension.kt
index 5a34dbfc..c29eb1f5 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/ip/IpExtension.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/ip/IpExtension.kt
@@ -10,6 +10,7 @@ import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
+import gateway.i18n.Translations
import org.koin.core.component.inject
/**
@@ -37,8 +38,8 @@ class IpExtension : Extension() {
override suspend fun setup() {
ephemeralSlashCommand {
- name = "ip"
- description = "Displays the server IP"
+ name = Translations.Commands.Ip.name
+ description = Translations.Commands.Ip.description
action {
Logger.info("${user.asUserOrNull()?.username} requested server IP!")
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/list/ListExtension.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/list/ListExtension.kt
index 83dee489..b2cf90a1 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/list/ListExtension.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/list/ListExtension.kt
@@ -14,6 +14,7 @@ import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
+import gateway.i18n.Translations
import org.koin.core.component.inject
/**
@@ -23,9 +24,9 @@ import org.koin.core.component.inject
*/
class ListExtension : Extension() {
/**
- * Companion
+ * Toggle for the list extension
*
- * @constructor Create empty Companion
+ * @constructor Creates the toggle
*/
companion object : ExtensionToggle {
private val config: PluginConfig by inject()
@@ -41,8 +42,8 @@ class ListExtension : Extension() {
override suspend fun setup() {
ephemeralSlashCommand {
- name = "list"
- description = "Lists all online players"
+ name = Translations.Commands.List.name
+ description = Translations.Commands.List.description
action {
Logger.info("${user.asUserOrNull()?.username} requested player list!")
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/tps/TpsExtension.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/tps/TpsExtension.kt
index 05b1f798..dbeeee19 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/tps/TpsExtension.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/tps/TpsExtension.kt
@@ -9,6 +9,7 @@ import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
+import gateway.i18n.Translations
import org.koin.core.component.inject
import kotlin.math.roundToInt
@@ -19,9 +20,9 @@ import kotlin.math.roundToInt
*/
class TpsExtension : Extension() {
/**
- * Companion
+ * Toggle for the TPS extension
*
- * @constructor Create empty Companion
+ * @constructor Creates the extension's toggle
*/
companion object : ExtensionToggle {
private val config: PluginConfig by inject()
@@ -37,8 +38,8 @@ class TpsExtension : Extension() {
override suspend fun setup() {
ephemeralSlashCommand {
- name = "tps"
- description = "Queries the server for its current TPS"
+ name = Translations.Commands.Tps.name
+ description = Translations.Commands.Tps.description
action {
val tps = ServerInfo.tps
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/whitelist/WhitelistArguments.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/whitelist/WhitelistArguments.kt
index 915b2b7e..377a52a3 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/whitelist/WhitelistArguments.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/whitelist/WhitelistArguments.kt
@@ -2,6 +2,7 @@ package com.rose.gateway.discord.bot.extensions.whitelist
import dev.kordex.core.commands.Arguments
import dev.kordex.core.commands.converters.impl.string
+import gateway.i18n.Translations
/**
* Arguments for whitelist-related Discord commands
@@ -13,7 +14,7 @@ class WhitelistArguments : Arguments() {
* The username specified
*/
val username by string {
- name = "username"
- description = "The user to modify the whitelist status of."
+ name = Translations.Commands.Whitelist.Args.Username.name
+ description = Translations.Commands.Whitelist.Args.Username.description
}
}
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/whitelist/WhitelistExtension.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/whitelist/WhitelistExtension.kt
index b0121c6a..b5a36f93 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/whitelist/WhitelistExtension.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/whitelist/WhitelistExtension.kt
@@ -19,6 +19,7 @@ import dev.kordex.core.commands.application.slash.EphemeralSlashCommandContext
import dev.kordex.core.commands.application.slash.ephemeralSubCommand
import dev.kordex.core.extensions.Extension
import dev.kordex.core.extensions.ephemeralSlashCommand
+import gateway.i18n.Translations
import org.koin.core.component.inject
/**
@@ -28,9 +29,9 @@ import org.koin.core.component.inject
*/
class WhitelistExtension : Extension() {
/**
- * Companion
+ * Toggle object for the whitelist extension
*
- * @constructor Create empty Companion
+ * @constructor Create toggle
*/
companion object : ExtensionToggle {
private val config: PluginConfig by inject()
@@ -46,12 +47,12 @@ class WhitelistExtension : Extension() {
override suspend fun setup() {
ephemeralSlashCommand {
- name = "whitelist"
- description = "Runs an operation that relates to the server whitelist."
+ name = Translations.Commands.Whitelist.name
+ description = Translations.Commands.Whitelist.description
ephemeralSubCommand(::WhitelistArguments) {
- name = "add"
- description = "Adds a player to the whitelist"
+ name = Translations.Commands.Whitelist.Subcommands.Add.name
+ description = Translations.Commands.Whitelist.Subcommands.Add.description
action {
Logger.info("${user.asUserOrNull()?.username} added ${arguments.username} to whitelist!")
@@ -63,8 +64,8 @@ class WhitelistExtension : Extension() {
}
ephemeralSubCommand(::WhitelistArguments) {
- name = "remove"
- description = "Removes a player from the whitelist"
+ name = Translations.Commands.Whitelist.Subcommands.Remove.name
+ description = Translations.Commands.Whitelist.Subcommands.Remove.description
action {
Logger.info("${user.asUserOrNull()?.username} removed ${arguments.username} from whitelist!")
@@ -76,8 +77,8 @@ class WhitelistExtension : Extension() {
}
ephemeralSubCommand {
- name = "list"
- description = "Lists all currently whitelisted players"
+ name = Translations.Commands.Whitelist.Subcommands.List.name
+ description = Translations.Commands.Whitelist.Subcommands.List.description
action {
Logger.info("${user.asUserOrNull()?.username} requested list of whitelisted players!")
@@ -115,8 +116,9 @@ class WhitelistExtension : Extension() {
}
}
- @Suppress("MaxLineLength")
- private suspend fun EphemeralSlashCommandContext.whitelistAddResponse(state: WhitelistState) {
+ private suspend fun EphemeralSlashCommandContext.whitelistAddResponse(
+ state: WhitelistState,
+ ) {
respond {
when (state) {
WhitelistState.STATE_MODIFIED ->
@@ -136,16 +138,17 @@ class WhitelistExtension : Extension() {
WhitelistState.STATE_INVALID ->
embed {
title = "Whitelist Addition Failed"
- @Suppress("MaxLineLength")
- description = "An error occurred adding **${arguments.username.discordBoldSafe()}** to whitelist."
+ description =
+ "An error occurred adding **${arguments.username.discordBoldSafe()}** to whitelist."
color = Color(config.warningColor().value())
}
}
}
}
- @Suppress("MaxLineLength")
- private suspend fun EphemeralSlashCommandContext.whitelistRemoveResponse(state: WhitelistState) {
+ private suspend fun EphemeralSlashCommandContext.whitelistRemoveResponse(
+ state: WhitelistState,
+ ) {
respond {
when (state) {
WhitelistState.STATE_MODIFIED ->
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/arguments/ConfigListArgs.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/arguments/ConfigListArgs.kt
index 933b19ec..36f490b2 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/arguments/ConfigListArgs.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/arguments/ConfigListArgs.kt
@@ -34,6 +34,7 @@ open class ConfigListArgs, P : ArgParser.(
TabCompleteContext,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ProcessorParser.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ProcessorParser.kt
index 0315d84f..c9b76a21 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ProcessorParser.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ProcessorParser.kt
@@ -15,8 +15,9 @@ import com.rose.gateway.minecraft.commands.framework.runner.ParserBuilder
* @return The built parser
*/
@Suppress("MaxLineLength")
-fun CommandArgs.processor(body: ProcessorParserBuilder.() -> Unit): ProcessorParser where A : CommandArgs =
- genericParser(::ProcessorParserBuilder, body)
+fun CommandArgs.processor(
+ body: ProcessorParserBuilder.() -> Unit,
+): ProcessorParser where A : CommandArgs = genericParser(::ProcessorParserBuilder, body)
/**
* Parser for a custom-processed argument
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/ConfigCommands.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/ConfigCommands.kt
index 9ddc323d..e5ad23e7 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/ConfigCommands.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/ConfigCommands.kt
@@ -70,7 +70,9 @@ object ConfigCommands {
* @return Whether the command succeeded
*/
@Suppress("MaxLineLength")
- fun addConfiguration(context: CommandExecuteContext): Boolean where A : ConfigListArgs, P : StringParser {
+ fun addConfiguration(
+ context: CommandExecuteContext,
+ ): Boolean where A : ConfigListArgs, P : StringParser {
val configItem = context.args.item
val values = context.args.value
@@ -130,7 +132,9 @@ object ConfigCommands {
* @return Whether the command succeeded
*/
@Suppress("MaxLineLength")
- fun removeConfiguration(context: CommandExecuteContext): Boolean where A : ConfigListArgs, P : StringParser {
+ fun removeConfiguration(
+ context: CommandExecuteContext,
+ ): Boolean where A : ConfigListArgs, P : StringParser {
val configItem = context.args.item
val values = context.args.value
diff --git a/src/main/kotlin/com/rose/gateway/shared/parsing/TextProcessor.kt b/src/main/kotlin/com/rose/gateway/shared/parsing/TextProcessor.kt
index 96b99173..a394c6a4 100644
--- a/src/main/kotlin/com/rose/gateway/shared/parsing/TextProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/shared/parsing/TextProcessor.kt
@@ -60,5 +60,6 @@ class TextProcessor(
* @see TokenProcessor
*/
@Suppress("MaxLineLength")
- private fun processorFor(token: Token): TokenProcessor = tokenProcessorMap[token.tokenType]!!
+ private fun processorFor(token: Token): TokenProcessor =
+ tokenProcessorMap[token.tokenType]!!
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 2eeb892d..fba6fe3e 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -6,7 +6,7 @@ description: Provides a configurable set of features that link the in-game chat
website: https://github.com/nicholasgrose/Gateway
main: com.rose.gateway.GatewayPlugin
-api-version: 1.20
+api-version: 1.21
load: POSTWORLD
commands:
@@ -16,7 +16,7 @@ commands:
aliases:
- d
permission: gateway.discord
- permission-message: You do not have control your Discord interactions!
+ permission-message: You do not have permission to control your Discord interactions!
gateway:
description: Controls the Gateway plugin.
usage: /gateway
diff --git a/src/main/resources/translations/discord/strings.properties b/src/main/resources/translations/discord/strings.properties
new file mode 100644
index 00000000..4c950536
--- /dev/null
+++ b/src/main/resources/translations/discord/strings.properties
@@ -0,0 +1,29 @@
+commands.whitelist.name=whitelist
+commands.whitelist.description=Runs an operation that relates to the server whitelist
+commands.whitelist.subcommands.add.name=add
+commands.whitelist.subcommands.add.description=Adds a player to the whitelist
+commands.whitelist.subcommands.remove.name=remove
+commands.whitelist.subcommands.remove.description=Removes a player from the whitelist
+commands.whitelist.subcommands.list.name=list
+commands.whitelist.subcommands.list.description=Lists all currently whitelisted players
+commands.whitelist.args.username.name=username
+commands.whitelist.args.username.description=The user to modify the whitelist status of
+
+commands.tps.name=tps
+commands.tps.description=Queries the server for its current TPS
+
+commands.list.name=list
+commands.list.description=Lists all online players
+
+commands.ip.name=ip
+commands.ip.description=Displays the server IP
+
+commands.version.name=version
+commands.version.description=Gives the current version of the Minecraft server
+
+commands.blockGod.name=blockgod
+commands.blockGod.description=Summon the block god for but a moment
+
+checks.chat.channel.notBotChannel.fail=Channel is not configured bot channel
+checks.chat.self.noAuthor.fail=No author found
+checks.chat.self.ownId.fail=Is self