diff --git a/.editorconfig b/.editorconfig
index 54f391eb..33905f72 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,2 +1,12 @@
-[*.{kt,kts}]
-max_line_length = 120
+root = true
+
+[*]
+insert_final_newline = true
+
+[{*.kt,*.kts}]
+ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
+
+# Disable wildcard imports entirely
+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
diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml
index e2ee760b..02a7d9f0 100644
--- a/.github/workflows/publish_release.yml
+++ b/.github/workflows/publish_release.yml
@@ -1,61 +1,61 @@
name: Publish Release
on:
- push:
- branches:
- - stable
+ push:
+ branches:
+ - stable
- paths:
- - '**/gradle.properties'
+ paths:
+ - '**/gradle.properties'
- workflow_dispatch:
+ workflow_dispatch:
jobs:
- publish:
- runs-on: ubuntu-latest
-
- steps:
- # https://github.com/marketplace/actions/checkout
- - uses: actions/checkout@v4
-
- # https://github.com/marketplace/actions/setup-java-jdk
- - name: Set up JDK 17
- uses: actions/setup-java@v3
- with:
- java-version: 17
- distribution: temurin
-
- - name: Set gradlew execution permission
- run: chmod u+x gradlew
-
- # https://github.com/marketplace/actions/generate-version
- - name: Get release version
- uses: HardNorth/github-version-generate@v1.3.0
- with:
- version-source: file
- 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 }}
-
- # https://github.com/marketplace/actions/gradle-build-action
- - name: Build artifacts
- uses: gradle/gradle-build-action@v2
- with:
- arguments: build
-
- # https://github.com/marketplace/actions/create-release
- - name: Create release
- uses: ncipollo/release-action@v1
- with:
- name: Gateway ${{ env.RELEASE_VERSION }}
- tag: v${{ env.RELEASE_VERSION }}
- generateReleaseNotes: true
- artifacts: 'build/libs/*.jar'
- prerelease: ${{ !!steps.semver.outputs.prerelease }}
- token: ${{ secrets.GITHUB_TOKEN }}
+ publish:
+ runs-on: ubuntu-latest
+
+ steps:
+ # https://github.com/marketplace/actions/checkout
+ - uses: actions/checkout@v4
+
+ # https://github.com/marketplace/actions/setup-java-jdk
+ - name: Set up JDK 17
+ 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/generate-version
+ - name: Get release version
+ uses: HardNorth/github-version-generate@v1.4.0
+ with:
+ version-source: file
+ 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 }}
+
+ # https://github.com/marketplace/actions/gradle-build-action
+ - name: Build artifacts
+ uses: gradle/actions/setup-gradle@v3
+ with:
+ arguments: build
+
+ # https://github.com/marketplace/actions/create-release
+ - name: Create release
+ uses: ncipollo/release-action@v1
+ with:
+ name: Gateway ${{ env.RELEASE_VERSION }}
+ tag: v${{ env.RELEASE_VERSION }}
+ generateReleaseNotes: true
+ artifacts: 'build/libs/*.jar'
+ prerelease: ${{ !!steps.semver.outputs.prerelease }}
+ token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/pull_request_check.yml b/.github/workflows/pull_request_check.yml
index 881e1e1f..096c49aa 100644
--- a/.github/workflows/pull_request_check.yml
+++ b/.github/workflows/pull_request_check.yml
@@ -1,66 +1,66 @@
name: Check Pull Request
on:
- pull_request:
- branches:
- - stable
- - develop
+ pull_request:
+ branches:
+ - stable
+ - develop
- paths:
- - '**/*.kt'
- - '**/*.kts'
+ paths:
+ - '**/*.kt'
+ - '**/*.kts'
jobs:
- build:
- runs-on: ubuntu-latest
+ build:
+ runs-on: ubuntu-latest
- steps:
- # https://github.com/marketplace/actions/checkout
- - uses: actions/checkout@v4
+ steps:
+ # https://github.com/marketplace/actions/checkout
+ - uses: actions/checkout@v4
- # https://github.com/marketplace/actions/setup-java-jdk
- - name: Set up JDK 17
- uses: actions/setup-java@v3
- with:
- java-version: 17
- distribution: temurin
+ # https://github.com/marketplace/actions/setup-java-jdk
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ java-version: 21
+ distribution: temurin
- - name: Set gradlew execution permission
- run: chmod u+x gradlew
+ - name: Set gradlew execution permission
+ run: chmod u+x gradlew
- # https://github.com/marketplace/actions/gradle-build-action
- - name: Build artifacts
- uses: gradle/gradle-build-action@v2
- with:
- arguments: build --stacktrace
+ # https://github.com/marketplace/actions/gradle-build-action
+ - name: Build artifacts
+ uses: gradle/actions/setup-gradle@v3
+ with:
+ arguments: build --stacktrace
- ktlint:
- runs-on: ubuntu-latest
+ ktlint:
+ runs-on: ubuntu-latest
- steps:
- # https://github.com/marketplace/actions/checkout
- - uses: actions/checkout@v4
+ 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.8.0
- with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- ktlint_version: '1.0.1'
- reporter: github-pr-review
- fail_on_error: true
+ # https://github.com/marketplace/actions/run-ktlint-with-reviewdog
+ - uses: ScaCap/action-ktlint@v1.9.0
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ ktlint_version: '1.3.1'
+ reporter: github-pr-review
+ fail_on_error: true
- detekt:
- runs-on: ubuntu-latest
+ detekt:
+ runs-on: ubuntu-latest
- steps:
- # https://github.com/marketplace/actions/checkout
- - uses: actions/checkout@v4
+ steps:
+ # https://github.com/marketplace/actions/checkout
+ - uses: actions/checkout@v4
- # https://github.com/marketplace/actions/run-detekt-with-reviewdog
- - name: Run detekt with reviewdog
- uses: alaegin/Detekt-Action@v1.23.3
- with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- detekt_config: config/detekt/detekt.yml
- detekt_build_upon_default_config: true
- reporter: github-pr-review
+ # 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
+ reporter: github-pr-review
diff --git a/.gitignore b/.gitignore
index 7ad9fcc2..6e52f056 100644
--- a/.gitignore
+++ b/.gitignore
@@ -91,3 +91,6 @@ gradle-app.setting
# Paper run
run/
+
+# Gradle docker cache
+.gradleDocker
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 73f69e09..00000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
-# Editor-based HTTP Client requests
-/httpRequests/
diff --git a/.idea/aws.xml b/.idea/aws.xml
deleted file mode 100644
index 8e173182..00000000
--- a/.idea/aws.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml
deleted file mode 100644
index 9da0b8ca..00000000
--- a/.idea/checkstyle-idea.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/checkstyleidea-libs/readme.txt b/.idea/checkstyleidea-libs/readme.txt
deleted file mode 100644
index b4fa42cc..00000000
--- a/.idea/checkstyleidea-libs/readme.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-This folder contains libraries copied from the "Gateway" project.
-It is managed by the CheckStyle-IDEA IDE plugin.
-Do not modify this folder while the IDE is running.
-When the IDE is stopped, you may delete this folder at any time. It will be recreated as needed.
-In order to prevent the CheckStyle-IDEA IDE plugin from creating this folder,
-uncheck the "Copy libraries from project directory" option in the CheckStyle-IDEA settings dialog.
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
deleted file mode 100644
index a2157208..00000000
--- a/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
deleted file mode 100644
index 79ee123c..00000000
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index b589d56e..b86273d9 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/detekt.xml b/.idea/detekt.xml
deleted file mode 100644
index 31ac8051..00000000
--- a/.idea/detekt.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
- true
- $PROJECT_DIR$/config/detekt/detekt.yml
-
-
\ No newline at end of file
diff --git a/.idea/discord.xml b/.idea/discord.xml
deleted file mode 100644
index d8e95616..00000000
--- a/.idea/discord.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index d079ef83..00000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/ktor.xml b/.idea/git_toolbox_blame.xml
similarity index 50%
rename from .idea/ktor.xml
rename to .idea/git_toolbox_blame.xml
index fac1a302..7dc12496 100644
--- a/.idea/ktor.xml
+++ b/.idea/git_toolbox_blame.xml
@@ -1,6 +1,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/git_toolbox_prj.xml b/.idea/git_toolbox_prj.xml
index bcb1d9df..02b915b8 100644
--- a/.idea/git_toolbox_prj.xml
+++ b/.idea/git_toolbox_prj.xml
@@ -6,11 +6,6 @@
-
-
-
-
-
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index bcb3df23..00000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,3274 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 62c5aa01..3ae08c1f 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -16,35 +16,25 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index ae3f30ae..c224ad56 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/ktlint-plugin.xml b/.idea/ktlint-plugin.xml
new file mode 100644
index 00000000..bee5678e
--- /dev/null
+++ b/.idea/ktlint-plugin.xml
@@ -0,0 +1,6 @@
+
+
+
+ DISTRACT_FREE
+
+
\ No newline at end of file
diff --git a/.idea/ktlint.xml b/.idea/ktlint.xml
deleted file mode 100644
index 8da8cdf6..00000000
--- a/.idea/ktlint.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- false
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 3e1453cd..bd523c22 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,16 +1,29 @@
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+ Android Lint: Security
+
+
+
+
+ Android
+
+
+
+
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 3806feff..540b3025 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -4,10 +4,6 @@
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/Gateway.iml b/.idea/modules/Gateway.iml
index 19d4940b..d11e1fbc 100644
--- a/.idea/modules/Gateway.iml
+++ b/.idea/modules/Gateway.iml
@@ -2,6 +2,7 @@
+
diff --git a/.idea/modules/Gateway.main.iml b/.idea/modules/Gateway.main.iml
index ba9402ec..746f1fd6 100644
--- a/.idea/modules/Gateway.main.iml
+++ b/.idea/modules/Gateway.main.iml
@@ -1,10 +1,5 @@
-
-
-
-
-
@@ -12,6 +7,7 @@
PAPER
ADVENTURE
+ 1
diff --git a/.idea/modules/Gateway.test.iml b/.idea/modules/Gateway.test.iml
deleted file mode 100644
index f5de878b..00000000
--- a/.idea/modules/Gateway.test.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
- PAPER
- ADVENTURE
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/GitHub.Gateway.main.iml b/.idea/modules/GitHub.Gateway.main.iml
deleted file mode 100644
index f5de878b..00000000
--- a/.idea/modules/GitHub.Gateway.main.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
- PAPER
- ADVENTURE
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/Projects.GitHub.Gateway.main.iml b/.idea/modules/Projects.GitHub.Gateway.main.iml
deleted file mode 100644
index bbeeb3ec..00000000
--- a/.idea/modules/Projects.GitHub.Gateway.main.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
- PAPER
- ADVENTURE
-
- 1
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/com.rose.gateway.Gateway.main.iml b/.idea/modules/com.rose.gateway.Gateway.main.iml
deleted file mode 100644
index f5de878b..00000000
--- a/.idea/modules/com.rose.gateway.Gateway.main.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
- PAPER
- ADVENTURE
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Gateway__qodanaScan_.xml b/.idea/runConfigurations/Gateway__qodanaScan_.xml
new file mode 100644
index 00000000..36cd9a21
--- /dev/null
+++ b/.idea/runConfigurations/Gateway__qodanaScan_.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Gateway__runChecks_.xml b/.idea/runConfigurations/Gateway__runLints_.xml
similarity index 80%
rename from .idea/runConfigurations/Gateway__runChecks_.xml
rename to .idea/runConfigurations/Gateway__runLints_.xml
index 0a6a9a5e..240d83de 100644
--- a/.idea/runConfigurations/Gateway__runChecks_.xml
+++ b/.idea/runConfigurations/Gateway__runLints_.xml
@@ -1,5 +1,5 @@
-
+
@@ -10,7 +10,7 @@
-
+
@@ -18,6 +18,7 @@
true
true
false
+ false
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 22d0c582..8ed7110b 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,34 +1,23 @@
+import org.jetbrains.kotlin.gradle.dsl.JvmTarget
+import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
+
plugins {
- // https://kotlinlang.org/
- kotlin("jvm") version "1.9.21"
- // https://kotlinlang.org/docs/serialization.html
- kotlin("plugin.serialization") version "1.9.21"
- // https://github.com/johnrengelman/shadow
- id("com.github.johnrengelman.shadow") version "8.1.1"
- // https://github.com/jpenilla/run-paper
- id("xyz.jpenilla.run-paper") version "2.2.2"
- // https://github.com/jlleitschuh/ktlint-gradle
- id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
- // https://detekt.dev/
- id("io.gitlab.arturbosch.detekt") version "1.23.3"
+ alias(libs.plugins.kotlin.jvm)
+ alias(libs.plugins.kotlin.serialization)
+ alias(libs.plugins.shadow)
+ alias(libs.plugins.run.paper)
+ alias(libs.plugins.ktlint)
+ alias(libs.plugins.detekt)
+ alias(libs.plugins.qodana)
}
val version: String by project
val group: String by project
-val ktlintVersion: String by project
-
-val minecraftVersion: String by project
-val paperApiRevision: String by project
-val kordexVersion: String by project
-val tegralVersion: String by project
-val kamlVersion: String by project
-val ktorVersion: String by project
-val hopliteVersion: String by project
+val minecraftTestVersion: String by project
-val jvmVersion: String by project
-val kotlinLanguageVersion: String by project
-val kotlinApiVersion: String by project
+val ktlintVersion: String by project
+val detektVersion: String by project
project.group = group
project.version = version
@@ -36,32 +25,17 @@ project.version = version
repositories {
mavenCentral()
gradlePluginPortal()
- maven {
- name = "PaperMC"
- url = uri("https://papermc.io/repo/repository/maven-public/")
- }
- maven {
- name = "Kotlin Discord"
- url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
- }
- maven {
- name = "Jitpack"
- url = uri("https://jitpack.io")
- }
+ maven("https://repo.papermc.io/repository/maven-public/")
+ maven("https://s01.oss.sonatype.org/content/repositories/snapshots")
+ maven("https://jitpack.io")
}
dependencies {
- // Paper plugin development API.
- compileOnly("io.papermc.paper:paper-api:$minecraftVersion-$paperApiRevision-SNAPSHOT")
- // Config library that provides nice parsing error descriptions.
- implementation("com.sksamuel.hoplite:hoplite-core:$hopliteVersion")
- implementation("com.sksamuel.hoplite:hoplite-yaml:$hopliteVersion")
- // Library that supports loading and (more importantly) saving to YAML files.
- implementation("com.charleskorn.kaml:kaml:$kamlVersion")
- // Library for Discord bots.
- implementation("com.kotlindiscord.kord.extensions:kord-extensions:$kordexVersion")
- // Lexer library that supports regex.
- implementation("guru.zoroark.tegral:tegral-niwen-lexer:$tegralVersion")
+ compileOnly(libs.paper.api)
+ implementation(libs.bundles.hoplite)
+ implementation(libs.kaml)
+ implementation(libs.kordex)
+ implementation(libs.tegral)
}
ktlint {
@@ -71,15 +45,19 @@ ktlint {
detekt {
config.from("config/detekt/detekt.yml")
buildUponDefaultConfig = true
+ toolVersion = detektVersion
+}
+
+java {
+ toolchain.languageVersion = JavaLanguageVersion.of(21)
}
tasks {
compileKotlin {
- kotlinOptions {
- jvmTarget = jvmVersion
- apiVersion = kotlinApiVersion
- languageVersion = kotlinLanguageVersion
- freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn")
+ compilerOptions {
+ jvmTarget = JvmTarget.JVM_21
+ apiVersion = KotlinVersion.KOTLIN_2_0
+ languageVersion = KotlinVersion.KOTLIN_2_0
}
}
@@ -107,16 +85,14 @@ tasks {
}
runServer {
- val minecraftVersion: String by project
-
- this.minecraftVersion(minecraftVersion)
+ this.minecraftVersion(minecraftTestVersion)
}
detekt.configure {
mustRunAfter(ktlintFormat)
}
- create("runChecks") {
+ create("runLints") {
dependsOn(ktlintFormat, detekt)
}
diff --git a/gradle.properties b/gradle.properties
index e91c7466..a4354c00 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,24 +1,10 @@
# Project info
-version=1.6.2
+version=1.6.3
group=com.rose.gateway
-# Plugin configuration
+# Version to use for testing
+minecraftTestVersion=1.21.1
+# Code style configuration
# https://github.com/pinterest/ktlint
-ktlintVersion=1.0.1
-# Dependencies
-minecraftVersion=1.20.2
-# https://docs.papermc.io/paper/dev/project-setup
-paperApiRevision=R0.1
-# https://github.com/sksamuel/hoplite
-hopliteVersion=2.7.5
-# https://github.com/charleskorn/kaml
-kamlVersion=0.55.0
-# https://kordex.kotlindiscord.com/
-kordexVersion=1.6.0-SNAPSHOT
-# https://tegral.zoroark.guru/docs/modules/core/niwen/
-tegralVersion=0.0.4
-# https://ktor.io/
-ktorVersion=2.3.6
-# Compilation options for Kotlin
-jvmVersion=17
-kotlinLanguageVersion=1.9
-kotlinApiVersion=1.9
+ktlintVersion=1.3.1
+# https://detekt.dev/
+detektVersion=1.23.7
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 00000000..af7daf15
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,50 @@
+[versions]
+# Dependencies
+# https://kotlinlang.org/
+kotlin = "2.0.21"
+# https://docs.papermc.io/paper/dev/project-setup
+paper-api = "1.21.1-R0.1-SNAPSHOT"
+# https://github.com/sksamuel/hoplite
+hoplite = "2.8.2"
+# https://github.com/charleskorn/kaml
+kaml = "0.61.0"
+# https://kordex.kotlindiscord.com/
+kordex = "1.9.0-SNAPSHOT"
+# https://tegral.zoroark.guru/docs/modules/core/niwen/
+tegral = "0.0.4"
+
+# Build tools
+# https://github.com/johnrengelman/shadow
+shadow = "8.3.3"
+
+# Testing tools
+# https://github.com/jpenilla/run-paper
+runPaper = "2.3.1"
+
+# Code style
+# https://github.com/jlleitschuh/ktlint-gradle
+ktlint-plugin = "12.1.1"
+# https://detekt.dev/
+detekt-plugin = "1.23.7"
+# https://www.jetbrains.com/help/qodana/qodana-gradle-plugin.html
+qodana = "2024.2.3"
+
+[libraries]
+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" }
+kaml = { group = "com.charleskorn.kaml", name = "kaml", version.ref = "kaml" }
+kordex = { group = "com.kotlindiscord.kord.extensions", name = "kord-extensions", version.ref = "kordex" }
+tegral = { group = "guru.zoroark.tegral", name = "tegral-niwen-lexer", version.ref = "tegral" }
+
+[bundles]
+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" }
+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" }
+qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 033e24c4..e6441136 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 3fa8f862..df97d72b 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
index fcb6fca1..b740cf13 100755
--- a/gradlew
+++ b/gradlew
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-# Collect all arguments for the java command;
-# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
-# shell script including quotes and variable substitutions, so put them in
-# double quotes to make sure that they get re-expanded; and
-# * put everything else in single quotes, so that it's not re-expanded.
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
diff --git a/gradlew.bat b/gradlew.bat
index 93e3f59f..25da30db 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
diff --git a/qodana.yaml b/qodana.yaml
new file mode 100644
index 00000000..0548c043
--- /dev/null
+++ b/qodana.yaml
@@ -0,0 +1,12 @@
+# Qodana configuration:
+# https://www.jetbrains.com/help/qodana/qodana-yaml.html
+
+version: 1.0
+linter: jetbrains/qodana-jvm-community:2024.2
+projectJDK: "21"
+profile:
+ name: qodana.recommended
+exclude:
+ - name: All
+ paths:
+ - .qodana
diff --git a/src/main/kotlin/com/rose/gateway/GatewayPlugin.kt b/src/main/kotlin/com/rose/gateway/GatewayPlugin.kt
index d5d8388a..e15f3f40 100644
--- a/src/main/kotlin/com/rose/gateway/GatewayPlugin.kt
+++ b/src/main/kotlin/com/rose/gateway/GatewayPlugin.kt
@@ -18,7 +18,9 @@ import org.koin.core.component.inject
*
* @constructor Creates a Gateway plugin. Should not be called except when the plugin is initially loaded by the server
*/
-class GatewayPlugin : JavaPlugin(), KoinComponent {
+class GatewayPlugin :
+ JavaPlugin(),
+ KoinComponent {
init {
initializeKoin(this)
}
diff --git a/src/main/kotlin/com/rose/gateway/config/ConfigStringMap.kt b/src/main/kotlin/com/rose/gateway/config/ConfigStringMap.kt
index 9d996471..a0b283e7 100644
--- a/src/main/kotlin/com/rose/gateway/config/ConfigStringMap.kt
+++ b/src/main/kotlin/com/rose/gateway/config/ConfigStringMap.kt
@@ -78,9 +78,7 @@ class ConfigStringMap : KoinComponent {
* @param configString The config path to pull from the map
* @return The matched item or null, if none matched
*/
- fun fromString(configString: String): Item<*>? {
- return itemMap[configString]
- }
+ fun fromString(configString: String): Item<*>? = itemMap[configString]
/**
* All config strings
diff --git a/src/main/kotlin/com/rose/gateway/config/GatewayConfigFile.kt b/src/main/kotlin/com/rose/gateway/config/GatewayConfigFile.kt
index 0ddfda90..80333de3 100644
--- a/src/main/kotlin/com/rose/gateway/config/GatewayConfigFile.kt
+++ b/src/main/kotlin/com/rose/gateway/config/GatewayConfigFile.kt
@@ -8,6 +8,7 @@ import com.rose.gateway.minecraft.logging.Logger
import com.rose.gateway.shared.error.notNull
import com.sksamuel.hoplite.ConfigException
import com.sksamuel.hoplite.ConfigLoaderBuilder
+import com.sksamuel.hoplite.ExperimentalHoplite
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.serialization.encodeToString
@@ -22,6 +23,11 @@ import java.nio.file.Path
* @constructor Creates a gateway config file
*/
class GatewayConfigFile : KoinComponent {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
private const val DEFAULT_CONFIG_FILE_RESOURCE_NAME = "default_gateway_config.yaml"
private const val DEFAULT_CONFIG_FILE_RESOURCE_PATH = "/$DEFAULT_CONFIG_FILE_RESOURCE_NAME"
@@ -33,16 +39,6 @@ class GatewayConfigFile : KoinComponent {
private val pluginDirPath = plugin.dataFolder.path.replace("\\", "/")
private val configPath = Path.of("$pluginDirPath/$CONFIG_FILE_NAME")
- /**
- * The default configuration that is used as an internal fallback
- */
- val defaultConfig =
- run {
- Logger.info("Loading fallback config...")
-
- loadConfig(DEFAULT_CONFIG_FILE_RESOURCE_PATH).notNullWithMissingDefaultConfigMessage()
- }
-
/**
* Loads the gateway config file, creating it if it is missing
*
@@ -54,9 +50,9 @@ class GatewayConfigFile : KoinComponent {
val config = loadConfig(configPath.toString())
return if (config == null) {
- Logger.warning("Fell back to default config.")
+ Logger.warning("Fell back to default config. Loading fallback...")
- defaultConfig
+ loadConfig(DEFAULT_CONFIG_FILE_RESOURCE_PATH).notNullWithMissingDefaultConfigMessage()
} else {
config
}
@@ -68,9 +64,8 @@ class GatewayConfigFile : KoinComponent {
* @param T The type to guarantee the value is
* @return The non-nullable type
*/
- private fun T?.notNullWithMissingDefaultConfigMessage(): T {
- return this.notNull("default config resource does not exist to be loaded")
- }
+ @Suppress("MaxLineLength")
+ 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
@@ -94,13 +89,11 @@ class GatewayConfigFile : KoinComponent {
private suspend fun createConfigurationFile() {
withContext(Dispatchers.IO) {
val defaultConfig =
- plugin.loader.getResourceAsStream(DEFAULT_CONFIG_FILE_RESOURCE_NAME)
+ plugin.loader
+ .getResourceAsStream(DEFAULT_CONFIG_FILE_RESOURCE_NAME)
.notNullWithMissingDefaultConfigMessage()
- .readAllBytes()
- Files.createDirectories(configPath.parent)
- Files.createFile(configPath)
- Files.write(configPath, defaultConfig)
+ Files.copy(defaultConfig, configPath)
}
}
@@ -111,13 +104,14 @@ class GatewayConfigFile : KoinComponent {
* @param path The path to load the config from
* @return The loaded config or null, if it can't be loaded
*/
+ @OptIn(ExperimentalHoplite::class)
private fun loadConfig(path: String): Config? {
Logger.info("Loading configuration...")
return try {
val config: Config =
ConfigLoaderBuilder
- .empty()
+ .newBuilder()
.withClassLoader(plugin.loader)
.addDefaultDecoders()
.addDefaultPreprocessors()
@@ -125,8 +119,9 @@ class GatewayConfigFile : KoinComponent {
.addDefaultPropertySources()
.addDefaultParsers()
.addDecoder(CommonDecoder())
+ .withExplicitSealedTypes()
.build()
- .loadConfigOrThrow(path)
+ .loadConfigOrThrow(path, DEFAULT_CONFIG_FILE_RESOURCE_PATH)
Logger.info("Configuration loaded successfully.")
config
} catch (error: ConfigException) {
diff --git a/src/main/kotlin/com/rose/gateway/config/Item.kt b/src/main/kotlin/com/rose/gateway/config/Item.kt
index 9c5409a7..5b54aa16 100644
--- a/src/main/kotlin/com/rose/gateway/config/Item.kt
+++ b/src/main/kotlin/com/rose/gateway/config/Item.kt
@@ -44,10 +44,9 @@ data class Item(
*
* @return The object found
*/
- private fun containingObject(): ConfigObject {
- return containingObject(pluginConfig.config)
+ private fun containingObject(): ConfigObject =
+ containingObject(pluginConfig.config)
.notNull("no ConfigObject exists that contains referenced item: $this")
- }
/**
* Finds the [ConfigObject] that contains this item's property using a depth-first search
diff --git a/src/main/kotlin/com/rose/gateway/config/PluginConfig.kt b/src/main/kotlin/com/rose/gateway/config/PluginConfig.kt
index a2e6c419..b9296640 100644
--- a/src/main/kotlin/com/rose/gateway/config/PluginConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/PluginConfig.kt
@@ -31,34 +31,14 @@ class PluginConfig : KoinComponent {
/**
* Reload the full config from the disk
- *
- * @return Whether the config was successfully loaded
*/
- suspend fun reloadConfig(): Boolean {
+ suspend fun reloadConfig() {
config = configFile.safelyLoadConfig()
-
- return if (notLoaded()) {
- pluginCoroutineScope.launch {
- bot.close()
- }
-
- false
- } else {
- pluginCoroutineScope.launch {
- bot.rebuild()
- }
-
- true
+ pluginCoroutineScope.launch {
+ bot.rebuild()
}
}
- /**
- * Determines whether the config was loaded by comparing it to the default config
- *
- * @return Whether the user-defined config was successfully loaded
- */
- fun notLoaded(): Boolean = config == configFile.defaultConfig
-
/**
* Saves the current config to disk, replacing the existing config file
*/
@@ -79,9 +59,7 @@ class PluginConfig : KoinComponent {
* @param item The config path to get the item with
* @return The item that matches the provided path or null if no match was found
*/
- operator fun get(item: String): Item<*>? {
- return stringMap.fromString(item)
- }
+ operator fun get(item: String): Item<*>? = stringMap.fromString(item)
/**
* Gets a particularly typed item based on its path string
diff --git a/src/main/kotlin/com/rose/gateway/config/access/AboutExtensionEnabled.kt b/src/main/kotlin/com/rose/gateway/config/access/AboutExtensionEnabled.kt
index dc744a39..ad1dce4e 100644
--- a/src/main/kotlin/com/rose/gateway/config/access/AboutExtensionEnabled.kt
+++ b/src/main/kotlin/com/rose/gateway/config/access/AboutExtensionEnabled.kt
@@ -7,6 +7,4 @@ import com.rose.gateway.config.PluginConfig
*
* @return Whether the extension is enabled
*/
-fun PluginConfig.aboutExtensionEnabled(): Boolean {
- return config.bot.extensions.about.enabled
-}
+fun PluginConfig.aboutExtensionEnabled(): Boolean = config.bot.extensions.about.enabled
diff --git a/src/main/kotlin/com/rose/gateway/config/access/BotConfiguration.kt b/src/main/kotlin/com/rose/gateway/config/access/BotConfiguration.kt
index 1660c8b7..a07bdf1e 100644
--- a/src/main/kotlin/com/rose/gateway/config/access/BotConfiguration.kt
+++ b/src/main/kotlin/com/rose/gateway/config/access/BotConfiguration.kt
@@ -7,15 +7,11 @@ import com.rose.gateway.config.PluginConfig
*
* @return The Discord bot's token
*/
-fun PluginConfig.botToken(): String {
- return config.bot.token
-}
+fun PluginConfig.botToken(): String = config.bot.token
/**
* Gives the bot channels from the plugin config
*
* @return The Discord bot's bot channels
*/
-fun PluginConfig.botChannels(): List {
- return config.bot.botChannels
-}
+fun PluginConfig.botChannels(): List = config.bot.botChannels
diff --git a/src/main/kotlin/com/rose/gateway/config/access/ChatExtensionEnabled.kt b/src/main/kotlin/com/rose/gateway/config/access/ChatExtensionEnabled.kt
index 53d8167c..c1d20606 100644
--- a/src/main/kotlin/com/rose/gateway/config/access/ChatExtensionEnabled.kt
+++ b/src/main/kotlin/com/rose/gateway/config/access/ChatExtensionEnabled.kt
@@ -7,6 +7,4 @@ import com.rose.gateway.config.PluginConfig
*
* @return Whether the extension is enabled
*/
-fun PluginConfig.chatExtensionEnabled(): Boolean {
- return config.bot.extensions.chat.enabled
-}
+fun PluginConfig.chatExtensionEnabled(): Boolean = config.bot.extensions.chat.enabled
diff --git a/src/main/kotlin/com/rose/gateway/config/access/IpExtension.kt b/src/main/kotlin/com/rose/gateway/config/access/IpExtension.kt
index 836d90d0..24584add 100644
--- a/src/main/kotlin/com/rose/gateway/config/access/IpExtension.kt
+++ b/src/main/kotlin/com/rose/gateway/config/access/IpExtension.kt
@@ -7,15 +7,11 @@ import com.rose.gateway.config.PluginConfig
*
* @return Whether the extension is enabled
*/
-fun PluginConfig.ipExtensionEnabled(): Boolean {
- return config.bot.extensions.ip.enabled
-}
+fun PluginConfig.ipExtensionEnabled(): Boolean = config.bot.extensions.ip.enabled
/**
* The IP to display with the IP extension
*
* @return The IP to display
*/
-fun PluginConfig.displayIp(): String {
- return config.bot.extensions.ip.displayIp
-}
+fun PluginConfig.displayIp(): String = config.bot.extensions.ip.displayIp
diff --git a/src/main/kotlin/com/rose/gateway/config/access/ListExtension.kt b/src/main/kotlin/com/rose/gateway/config/access/ListExtension.kt
index a9dcad40..f1c4256f 100644
--- a/src/main/kotlin/com/rose/gateway/config/access/ListExtension.kt
+++ b/src/main/kotlin/com/rose/gateway/config/access/ListExtension.kt
@@ -7,15 +7,11 @@ import com.rose.gateway.config.PluginConfig
*
* @return Whether the extension is enabled
*/
-fun PluginConfig.listExtensionEnabled(): Boolean {
- return config.bot.extensions.list.enabled
-}
+fun PluginConfig.listExtensionEnabled(): Boolean = config.bot.extensions.list.enabled
/**
* Gives the maximum number of players that can be displayed on each list page
*
* @return The maximum number of players per page
*/
-fun PluginConfig.maxPlayersPerListPage(): Int {
- return config.bot.extensions.list.maxPlayersPerPage
-}
+fun PluginConfig.maxPlayersPerListPage(): Int = config.bot.extensions.list.maxPlayersPerPage
diff --git a/src/main/kotlin/com/rose/gateway/config/access/MinecraftConfig.kt b/src/main/kotlin/com/rose/gateway/config/access/MinecraftConfig.kt
index 87ad10b4..32da58bd 100644
--- a/src/main/kotlin/com/rose/gateway/config/access/MinecraftConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/access/MinecraftConfig.kt
@@ -9,33 +9,25 @@ import net.kyori.adventure.text.format.TextColor
*
* @return The color in a form usable for Minecraft
*/
-fun PluginConfig.primaryColor(): TextColor {
- return config.minecraft.primaryColor.asTextColor()
-}
+fun PluginConfig.primaryColor(): TextColor = config.minecraft.primaryColor.asTextColor()
/**
* Gives the Minecraft secondary color from the plugin config
*
* @return The color in a form usable for Minecraft
*/
-fun PluginConfig.secondaryColor(): TextColor {
- return config.minecraft.secondaryColor.asTextColor()
-}
+fun PluginConfig.secondaryColor(): TextColor = config.minecraft.secondaryColor.asTextColor()
/**
* Gives the Minecraft tertiary color from the plugin config
*
* @return The color in a form usable for Minecraft
*/
-fun PluginConfig.tertiaryColor(): TextColor {
- return config.minecraft.tertiaryColor.asTextColor()
-}
+fun PluginConfig.tertiaryColor(): TextColor = config.minecraft.tertiaryColor.asTextColor()
/**
* Gives the Minecraft warning color from the plugin config
*
* @return The color in a form usable for Minecraft
*/
-fun PluginConfig.warningColor(): TextColor {
- return config.minecraft.warningColor.asTextColor()
-}
+fun PluginConfig.warningColor(): TextColor = config.minecraft.warningColor.asTextColor()
diff --git a/src/main/kotlin/com/rose/gateway/config/access/TpsExtensionEnabled.kt b/src/main/kotlin/com/rose/gateway/config/access/TpsExtensionEnabled.kt
index c2119d5a..70a2d49f 100644
--- a/src/main/kotlin/com/rose/gateway/config/access/TpsExtensionEnabled.kt
+++ b/src/main/kotlin/com/rose/gateway/config/access/TpsExtensionEnabled.kt
@@ -7,6 +7,4 @@ import com.rose.gateway.config.PluginConfig
*
* @return Whether the extension is enabled
*/
-fun PluginConfig.tpsExtensionEnabled(): Boolean {
- return config.bot.extensions.tps.enabled
-}
+fun PluginConfig.tpsExtensionEnabled(): Boolean = config.bot.extensions.tps.enabled
diff --git a/src/main/kotlin/com/rose/gateway/config/access/WhitelistExtension.kt b/src/main/kotlin/com/rose/gateway/config/access/WhitelistExtension.kt
index 76f15606..0a87f007 100644
--- a/src/main/kotlin/com/rose/gateway/config/access/WhitelistExtension.kt
+++ b/src/main/kotlin/com/rose/gateway/config/access/WhitelistExtension.kt
@@ -7,15 +7,11 @@ import com.rose.gateway.config.PluginConfig
*
* @return Whether the extension is enabled
*/
-fun PluginConfig.whitelistExtensionEnabled(): Boolean {
- return config.bot.extensions.whitelist.enabled
-}
+fun PluginConfig.whitelistExtensionEnabled(): Boolean = config.bot.extensions.whitelist.enabled
/**
* Gives the maximum number of players that can be displayed on each whitelist page
*
* @return The maximum number of players per page
*/
-fun PluginConfig.maxPlayersPerWhitelistPage(): Int {
- return config.bot.extensions.whitelist.maxPlayersPerPage
-}
+fun PluginConfig.maxPlayersPerWhitelistPage(): Int = config.bot.extensions.whitelist.maxPlayersPerPage
diff --git a/src/main/kotlin/com/rose/gateway/config/markers/CommonDecoder.kt b/src/main/kotlin/com/rose/gateway/config/markers/CommonDecoder.kt
index e933c0e9..0b0d02d8 100644
--- a/src/main/kotlin/com/rose/gateway/config/markers/CommonDecoder.kt
+++ b/src/main/kotlin/com/rose/gateway/config/markers/CommonDecoder.kt
@@ -17,6 +17,11 @@ import kotlin.reflect.KType
* @constructor Create a Common decoder
*/
open class CommonDecoder : NullHandlingDecoder {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
/**
* The data class decoder this decoder uses internally
@@ -28,20 +33,26 @@ open class CommonDecoder : NullHandlingDecoder {
node: Node,
type: KType,
context: DecoderContext,
- ): ConfigResult {
- return DECODER.safeDecode(node, type, context)
- }
+ ): ConfigResult = DECODER.safeDecode(node, type, context)
+ /**
+ * Checks if the decoder supports the given type.
+ *
+ * @param type The type to check.
+ * @return True if the type is supported, false otherwise.
+ */
override fun supports(type: KType): Boolean {
val classifier = type.classifier
-
- return if (classifier is KClass<*>) {
- !classifier.isData &&
- !classifier.isSealed &&
- !classifier.isInline() &&
- classifier canBe ConfigObject::class
- } else {
- false
- }
+ return classifier is KClass<*> && isSupportedClassifier(classifier)
}
+
+ /**
+ * Check if the classifier is not a data class, sealed class, inline class
+ * and can be a ConfigObject.
+ *
+ * @param classifier The class we want to check
+ * @return true if it passes all conditions, false otherwise
+ */
+ private fun isSupportedClassifier(classifier: KClass<*>): Boolean =
+ !classifier.isData && !classifier.isSealed && !classifier.isInline() && classifier canBe ConfigObject::class
}
diff --git a/src/main/kotlin/com/rose/gateway/config/markers/CommonExtensionConfig.kt b/src/main/kotlin/com/rose/gateway/config/markers/CommonExtensionConfig.kt
index 19adb10b..a66cdae7 100644
--- a/src/main/kotlin/com/rose/gateway/config/markers/CommonExtensionConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/markers/CommonExtensionConfig.kt
@@ -18,7 +18,8 @@ import org.koin.core.component.inject
open class CommonExtensionConfig(
enabled: Boolean,
@Transient val extensionName: String = "None",
-) : KoinComponent, ConfigObject {
+) : KoinComponent,
+ ConfigObject {
private val bot: DiscordBotController by inject()
private val pluginsScope: PluginCoroutineScope by inject()
@@ -40,9 +41,13 @@ open class CommonExtensionConfig(
private fun modifyExtensionLoadedStatus(enabled: Boolean) {
pluginsScope.launch {
if (enabled) {
- bot.discordBot.kordexBot.await()?.loadExtension(extensionName)
+ bot.discordBot.kordexBot
+ .await()
+ ?.loadExtension(extensionName)
} else {
- bot.discordBot.kordexBot.await()?.unloadExtension(extensionName)
+ bot.discordBot.kordexBot
+ .await()
+ ?.unloadExtension(extensionName)
}
}
}
diff --git a/src/main/kotlin/com/rose/gateway/config/markers/FilterConfigItems.kt b/src/main/kotlin/com/rose/gateway/config/markers/FilterConfigItems.kt
index 4a9ab5dc..828763d0 100644
--- a/src/main/kotlin/com/rose/gateway/config/markers/FilterConfigItems.kt
+++ b/src/main/kotlin/com/rose/gateway/config/markers/FilterConfigItems.kt
@@ -10,9 +10,7 @@ import kotlin.reflect.KProperty
* @see KProperty
* @see ConfigItem
*/
-fun Collection>.filterConfigItems(): List> {
- return this.filter { it.isConfigItem() }
-}
+fun Collection>.filterConfigItems(): List> = this.filter { it.isConfigItem() }
/**
* Determines whether the [KProperty] has the [ConfigItem] annotation
@@ -22,6 +20,4 @@ fun Collection>.filterConfigItems(): List> {
* @see KProperty
* @see ConfigItem
*/
-fun KProperty<*>.isConfigItem(): Boolean {
- return this.annotations.any { it is ConfigItem }
-}
+fun KProperty<*>.isConfigItem(): Boolean = this.annotations.any { it is ConfigItem }
diff --git a/src/main/kotlin/com/rose/gateway/config/schema/AboutConfig.kt b/src/main/kotlin/com/rose/gateway/config/schema/AboutConfig.kt
index be9081af..6d9e42f7 100644
--- a/src/main/kotlin/com/rose/gateway/config/schema/AboutConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/schema/AboutConfig.kt
@@ -28,7 +28,14 @@ class AboutConfig(
* @see AboutConfigSerializer
*/
@Serializable
-data class AboutConfigSurrogate(val enabled: Boolean) {
+data class AboutConfigSurrogate(
+ val enabled: Boolean,
+) {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : SurrogateConverter {
override fun fromBase(base: AboutConfig): AboutConfigSurrogate = AboutConfigSurrogate(base.enabled)
diff --git a/src/main/kotlin/com/rose/gateway/config/schema/BotConfig.kt b/src/main/kotlin/com/rose/gateway/config/schema/BotConfig.kt
index c2a003ea..3c976f9d 100644
--- a/src/main/kotlin/com/rose/gateway/config/schema/BotConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/schema/BotConfig.kt
@@ -28,7 +28,8 @@ class BotConfig(
token: String,
botChannels: List,
@ConfigItem val extensions: ExtensionsConfig,
-) : KoinComponent, ConfigObject {
+) : KoinComponent,
+ ConfigObject {
private val pluginCoroutineScope: PluginCoroutineScope by inject()
private val bot: DiscordBotController by inject()
@@ -74,6 +75,11 @@ data class BotConfigSurrogate(
val botChannels: List,
val extensions: ExtensionsConfig,
) {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : SurrogateConverter {
override fun fromBase(base: BotConfig): BotConfigSurrogate =
BotConfigSurrogate(
diff --git a/src/main/kotlin/com/rose/gateway/config/schema/ChatConfig.kt b/src/main/kotlin/com/rose/gateway/config/schema/ChatConfig.kt
index 27f639a9..37dedcdc 100644
--- a/src/main/kotlin/com/rose/gateway/config/schema/ChatConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/schema/ChatConfig.kt
@@ -32,7 +32,15 @@ class ChatConfig(
* @see ChatConfigSerializer
*/
@Serializable
-data class ChatConfigSurrogate(val enabled: Boolean, val showRoleColor: Boolean) {
+data class ChatConfigSurrogate(
+ val enabled: Boolean,
+ val showRoleColor: Boolean,
+) {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : SurrogateConverter {
override fun fromBase(base: ChatConfig): ChatConfigSurrogate =
ChatConfigSurrogate(
diff --git a/src/main/kotlin/com/rose/gateway/config/schema/IpConfig.kt b/src/main/kotlin/com/rose/gateway/config/schema/IpConfig.kt
index f7f045f7..57655623 100644
--- a/src/main/kotlin/com/rose/gateway/config/schema/IpConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/schema/IpConfig.kt
@@ -33,7 +33,15 @@ class IpConfig(
* @see IpConfigSerializer
*/
@Serializable
-data class IpConfigSurrogate(val enabled: Boolean, val displayIp: String) {
+data class IpConfigSurrogate(
+ val enabled: Boolean,
+ val displayIp: String,
+) {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : SurrogateConverter {
override fun fromBase(base: IpConfig): IpConfigSurrogate = IpConfigSurrogate(base.enabled, base.displayIp)
diff --git a/src/main/kotlin/com/rose/gateway/config/schema/ListConfig.kt b/src/main/kotlin/com/rose/gateway/config/schema/ListConfig.kt
index 0ec16201..f9c4433a 100644
--- a/src/main/kotlin/com/rose/gateway/config/schema/ListConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/schema/ListConfig.kt
@@ -34,7 +34,15 @@ class ListConfig(
* @see ListConfigSerializer
*/
@Serializable
-data class ListConfigSurrogate(val enabled: Boolean, val maxPlayersPerPage: Int) {
+data class ListConfigSurrogate(
+ val enabled: Boolean,
+ val maxPlayersPerPage: Int,
+) {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : SurrogateConverter {
override fun fromBase(base: ListConfig): ListConfigSurrogate =
ListConfigSurrogate(
diff --git a/src/main/kotlin/com/rose/gateway/config/schema/TpsConfig.kt b/src/main/kotlin/com/rose/gateway/config/schema/TpsConfig.kt
index 4dd09272..315d6aef 100644
--- a/src/main/kotlin/com/rose/gateway/config/schema/TpsConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/schema/TpsConfig.kt
@@ -28,7 +28,14 @@ class TpsConfig(
* @see TpsConfigSerializer
*/
@Serializable
-data class TpsConfigSurrogate(val enabled: Boolean) {
+data class TpsConfigSurrogate(
+ val enabled: Boolean,
+) {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : SurrogateConverter {
override fun fromBase(base: TpsConfig): TpsConfigSurrogate = TpsConfigSurrogate(base.enabled)
diff --git a/src/main/kotlin/com/rose/gateway/config/schema/WhitelistConfig.kt b/src/main/kotlin/com/rose/gateway/config/schema/WhitelistConfig.kt
index a6de0b92..fadeca2a 100644
--- a/src/main/kotlin/com/rose/gateway/config/schema/WhitelistConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/schema/WhitelistConfig.kt
@@ -35,7 +35,15 @@ class WhitelistConfig(
* @see WhitelistConfigSerializer
*/
@Serializable
-data class WhitelistConfigSurrogate(val enabled: Boolean, val maxPlayersPerPage: Int) {
+data class WhitelistConfigSurrogate(
+ val enabled: Boolean,
+ val maxPlayersPerPage: Int,
+) {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : SurrogateConverter {
override fun fromBase(base: WhitelistConfig): WhitelistConfigSurrogate =
WhitelistConfigSurrogate(base.enabled, base.maxPlayersPerPage)
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/BotState.kt b/src/main/kotlin/com/rose/gateway/discord/bot/BotState.kt
index 0b57b88d..868a9c94 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/BotState.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/BotState.kt
@@ -61,7 +61,9 @@ class BotState : KoinComponent {
if (ClientInfo.hasChannelPermissions(
channel,
DiscordBotConstants.REQUIRED_PERMISSIONS,
- ) && channel is TextChannel && channel.name in validBotChannels
+ ) &&
+ channel is TextChannel &&
+ channel.name in validBotChannels
) {
botChannels.add(channel)
// The guilds are only added if they have valid channels for message sending.
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/BotStatus.kt b/src/main/kotlin/com/rose/gateway/discord/bot/BotStatus.kt
index cc274b62..63326274 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/BotStatus.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/BotStatus.kt
@@ -7,7 +7,10 @@ package com.rose.gateway.discord.bot
* @property reason Why the bot is in that status
* @constructor Creates a bot status with the given info
*/
-enum class BotStatus(val status: String, var reason: String = "") {
+enum class BotStatus(
+ val status: String,
+ var reason: String = "",
+) {
/**
* Represents that the bot has not yet started
*
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/DiscordBot.kt b/src/main/kotlin/com/rose/gateway/discord/bot/DiscordBot.kt
index b58bfbb7..8bf9efe3 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/DiscordBot.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/DiscordBot.kt
@@ -41,17 +41,11 @@ class DiscordBot : KoinComponent {
*
* @return The build bot or null, if building failed
*/
- suspend fun safelyBuildBot(): Result =
+ private suspend fun safelyBuildBot(): Result =
tryKordOperation("Constructing Discord Bot") {
- if (config.notLoaded()) {
- Logger.warning("Bot construction failed because no configuration is loaded.")
+ Logger.info("Building Discord bot...")
- Result.failure(Exception("No valid configuration is loaded."))
- } else {
- Logger.info("Building Discord bot...")
-
- Result.success(buildBot(config.botToken()))
- }
+ Result.success(buildBot(config.botToken()))
}
/**
@@ -147,11 +141,4 @@ class DiscordBot : KoinComponent {
* @return The Kord client or null, if no Discord bot exists
*/
suspend fun kordClient(): Kord? = kordexBot.await()?.getKoin()?.get()
-
- /**
- * Checks if the bot has yet been built
- *
- * @return Whether the bot was built
- */
- suspend fun isBuilt(): Boolean = kordexBot.await() != null
}
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/DiscordBotController.kt b/src/main/kotlin/com/rose/gateway/discord/bot/DiscordBotController.kt
index 5ec8871a..c3f4508f 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/DiscordBotController.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/DiscordBotController.kt
@@ -27,19 +27,19 @@ class DiscordBotController : KoinComponent {
/**
* Starts the Discord bot
*/
- suspend fun start() {
+ fun start() {
Logger.info("Starting Discord bot...")
state.status = BotStatus.STARTING
launchConcurrentBot()
- Logger.info("Discord bot ready!")
+ Logger.info("Discord bot started!")
}
/**
* Launches the bot in a new parallel task
*/
- private suspend fun launchConcurrentBot() {
+ private fun launchConcurrentBot() {
state.botJob =
pluginScope.launch {
val runResult =
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/client/ClientInfo.kt b/src/main/kotlin/com/rose/gateway/discord/bot/client/ClientInfo.kt
index 1c03f32b..213784d5 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/client/ClientInfo.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/client/ClientInfo.kt
@@ -36,7 +36,6 @@ object ClientInfo : KoinComponent {
* @param channel The channel to check the permissions for
* @return The permissions the bot has in the given channel
*/
- private suspend fun permissionsForChannel(channel: GuildChannel): Permissions {
- return channel.permissionsForMember(bot.discordBot.kordClient()!!.selfId)
- }
+ private suspend fun permissionsForChannel(channel: GuildChannel): Permissions =
+ channel.permissionsForMember(bot.discordBot.kordClient()!!.selfId)
}
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 4ee633da..5285d8a3 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
@@ -18,6 +18,11 @@ import org.koin.core.component.inject
* @constructor Create an "about extension"
*/
class AboutExtension : Extension() {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : ExtensionToggle {
private val config: PluginConfig by inject()
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 f4e30f1b..cad751b2 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
@@ -17,6 +17,11 @@ import org.koin.core.component.inject
* @constructor Create a "chat extension"
*/
class ChatExtension : Extension() {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
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 28dcfaed..702c9ad8 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
@@ -13,7 +13,14 @@ import org.koin.core.component.inject
* @property message The message to print in Discord
* @constructor Creates a game chat event with the given message
*/
-class GameChatEvent(val message: MessageCreateBuilder.() -> Unit) : KordExEvent {
+class GameChatEvent(
+ val message: MessageCreateBuilder.() -> Unit,
+) : KordExEvent {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : KoinComponent {
private val bot: DiscordBotController by inject()
@@ -24,7 +31,9 @@ class GameChatEvent(val message: MessageCreateBuilder.() -> Unit) : KordExEvent
* @receiver The [DiscordBot]
*/
suspend fun trigger(message: MessageCreateBuilder.() -> Unit) {
- bot.discordBot.kordexBot.await()?.send(GameChatEvent(message))
+ bot.discordBot.kordexBot
+ .await()
+ ?.send(GameChatEvent(message))
}
}
}
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/ChannelMentionTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/ChannelMentionTokenProcessor.kt
index f1fba49f..d1366943 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/ChannelMentionTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/ChannelMentionTokenProcessor.kt
@@ -16,7 +16,9 @@ import org.koin.core.component.KoinComponent
*
* @constructor Create a channel mention token processor
*/
-class ChannelMentionTokenProcessor : TokenProcessor, KoinComponent {
+class ChannelMentionTokenProcessor :
+ TokenProcessor,
+ KoinComponent {
override fun tokenType(): TokenType = DiscordChatComponent.CHANNEL_MENTION
@Language("RegExp")
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/DiscordMessageProcessor.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/DiscordMessageProcessor.kt
index 7e8355d0..80002b9d 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/DiscordMessageProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/DiscordMessageProcessor.kt
@@ -38,14 +38,13 @@ object DiscordMessageProcessor : KoinComponent {
* @param event The event to convert to a [Component]
* @return The text after processing
*/
- suspend fun createMessage(event: MessageCreateEvent): Component {
- return join(
+ suspend fun createMessage(event: MessageCreateEvent): Component =
+ join(
generateNameBlock(event),
generateMessagePrefixBlock(event),
generateMessageBlock(event),
generateMessageSuffixBlock(event),
)
- }
/**
* Creates the name block to show in Minecraft
@@ -54,7 +53,12 @@ object DiscordMessageProcessor : KoinComponent {
* @return The name block
*/
private suspend fun generateNameBlock(event: MessageCreateEvent): Component {
- if (!(config.config.bot.extensions.chat.showRoleColor) || event.member!!.roles.toList().isEmpty()) {
+ if (!(config.config.bot.extensions.chat.showRoleColor) ||
+ event.member!!
+ .roles
+ .toList()
+ .isEmpty()
+ ) {
return join(
"<".component(),
member(event.member!!),
@@ -62,7 +66,11 @@ object DiscordMessageProcessor : KoinComponent {
)
}
- val roleColor = event.member!!.getTopRole()?.color?.let { TextColor.color(it.rgb) }
+ val roleColor =
+ event.member!!
+ .getTopRole()
+ ?.color
+ ?.let { TextColor.color(it.rgb) }
return join(
"<".component(),
@@ -148,9 +156,8 @@ object DiscordMessageProcessor : KoinComponent {
* @param event The event ot pull data from
* @return The message for Minecraft
*/
- private suspend fun generateMessageBlock(event: MessageCreateEvent): Component {
- return join(textProcessor.parseText(event.message.content, event))
- }
+ private suspend fun generateMessageBlock(event: MessageCreateEvent): Component =
+ join(textProcessor.parseText(event.message.content, event))
/**
* Generates the suffix [Component] for Minecraft
@@ -166,8 +173,12 @@ object DiscordMessageProcessor : KoinComponent {
join(
JoinConfiguration.separator(", ".primaryComponent().italic()),
event.message.attachments.mapIndexed { index, attachment ->
- "Attachment$index".tertiaryComponent().italic().underlined()
- .showTextOnHover("Open attachment link".component()).openUrlOnClick(attachment.url)
+ "Attachment$index"
+ .tertiaryComponent()
+ .italic()
+ .underlined()
+ .showTextOnHover("Open attachment link".component())
+ .openUrlOnClick(attachment.url)
},
),
")".primaryComponent().italic(),
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/RoleMentionTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/RoleMentionTokenProcessor.kt
index ae1dcc4a..0bc2180f 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/RoleMentionTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/RoleMentionTokenProcessor.kt
@@ -16,7 +16,14 @@ import org.koin.core.component.KoinComponent
*
* @constructor Create a role mention token processor
*/
-class RoleMentionTokenProcessor : TokenProcessor, KoinComponent {
+class RoleMentionTokenProcessor :
+ TokenProcessor,
+ KoinComponent {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
private const val SNOWFLAKE_START_INDEX = 3
}
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/TextTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/TextTokenProcessor.kt
index 11c3e632..e8894df6 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/TextTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/TextTokenProcessor.kt
@@ -22,7 +22,5 @@ class TextTokenProcessor : TokenProcessor {
override suspend fun process(
token: Token,
additionalData: MessageCreateEvent,
- ): Component {
- return token.string.component()
- }
+ ): Component = token.string.component()
}
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/UrlTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/UrlTokenProcessor.kt
index 6ba8ee11..5fa2aaab 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/UrlTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/UrlTokenProcessor.kt
@@ -28,7 +28,9 @@ class UrlTokenProcessor : TokenProcessor {
): Component {
val url = token.string
- return url.component().underlined()
+ return url
+ .component()
+ .underlined()
.showTextOnHover("Click to open url".component())
.openUrlOnClick(url)
}
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/UserMentionTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/UserMentionTokenProcessor.kt
index 60719bc6..ec208399 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/UserMentionTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/extensions/chat/processing/UserMentionTokenProcessor.kt
@@ -19,9 +19,16 @@ import org.koin.core.component.inject
*
* @constructor Create a user mention token processor
*/
-class UserMentionTokenProcessor : TokenProcessor, KoinComponent {
+class UserMentionTokenProcessor :
+ TokenProcessor,
+ KoinComponent {
private val config: PluginConfig by inject()
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
private const val SNOWFLAKE_START_INDEX = 2
}
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 c383ed08..39cb0524 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
@@ -18,6 +18,11 @@ import org.koin.core.component.inject
* @constructor Creates an "IP extension"
*/
class IpExtension : Extension() {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : ExtensionToggle {
private val config: PluginConfig by inject()
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 69d812e4..e3df7220 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
@@ -22,6 +22,11 @@ import org.koin.core.component.inject
* @constructor Create a "list extension"
*/
class ListExtension : Extension() {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : ExtensionToggle {
private val config: PluginConfig by inject()
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 27000ad9..60ee9b3c 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
@@ -18,6 +18,11 @@ import kotlin.math.roundToInt
* @constructor Create a TPS extension
*/
class TpsExtension : Extension() {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : ExtensionToggle {
private val config: PluginConfig by inject()
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 74ac1188..1f9064aa 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
@@ -27,6 +27,11 @@ import org.koin.core.component.inject
* @constructor Create a "whitelist extension"
*/
class WhitelistExtension : Extension() {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object : ExtensionToggle {
private val config: PluginConfig by inject()
@@ -110,63 +115,59 @@ class WhitelistExtension : Extension() {
}
}
- private suspend fun EphemeralSlashCommandContext.whitelistAddResponse(
- state: WhitelistState,
- ) {
+ @Suppress("MaxLineLength")
+ private suspend fun EphemeralSlashCommandContext.whitelistAddResponse(state: WhitelistState) {
respond {
when (state) {
WhitelistState.STATE_MODIFIED ->
embed {
title = "Whitelist Changed"
- description =
- "**${arguments.username.discordBoldSafe()}** successfully added to whitelist."
- color = Color(WhitelistExtension.config.primaryColor().value())
+ description = "**${arguments.username.discordBoldSafe()}** successfully added to whitelist."
+ color = Color(config.primaryColor().value())
}
WhitelistState.STATE_SUSTAINED ->
embed {
title = "Whitelist Not Changed"
description = "**${arguments.username.discordBoldSafe()}** already exists in whitelist."
- color = Color(WhitelistExtension.config.secondaryColor().value())
+ color = Color(config.secondaryColor().value())
}
WhitelistState.STATE_INVALID ->
embed {
title = "Whitelist Addition Failed"
- description =
- "An error occurred adding **${arguments.username.discordBoldSafe()}** to whitelist."
- color = Color(WhitelistExtension.config.warningColor().value())
+ @Suppress("MaxLineLength")
+ description = "An error occurred adding **${arguments.username.discordBoldSafe()}** to whitelist."
+ color = Color(config.warningColor().value())
}
}
}
}
- private suspend fun EphemeralSlashCommandContext.whitelistRemoveResponse(
- state: WhitelistState,
- ) {
+ @Suppress("MaxLineLength")
+ private suspend fun EphemeralSlashCommandContext.whitelistRemoveResponse(state: WhitelistState) {
respond {
when (state) {
WhitelistState.STATE_MODIFIED ->
embed {
title = "Whitelist Changed"
- description =
- "**${arguments.username.discordBoldSafe()}** successfully removed from whitelist."
- color = Color(WhitelistExtension.config.primaryColor().value())
+ description = "**${arguments.username.discordBoldSafe()}** successfully removed from whitelist."
+ color = Color(config.primaryColor().value())
}
WhitelistState.STATE_SUSTAINED ->
embed {
title = "Whitelist Not Changed"
description = "**${arguments.username.discordBoldSafe()}** does not exist in whitelist."
- color = Color(WhitelistExtension.config.secondaryColor().value())
+ color = Color(config.secondaryColor().value())
}
WhitelistState.STATE_INVALID ->
embed {
title = "Whitelist Removal Failed"
- description = "Error occurred removing" +
- " **${arguments.username.discordBoldSafe()}** from whitelist."
- color = Color(WhitelistExtension.config.warningColor().value())
+ description =
+ "Error occurred removing" + " **${arguments.username.discordBoldSafe()}** from whitelist."
+ color = Color(config.warningColor().value())
}
}
}
diff --git a/src/main/kotlin/com/rose/gateway/discord/bot/message/GroupAndPaginateItems.kt b/src/main/kotlin/com/rose/gateway/discord/bot/message/GroupAndPaginateItems.kt
index f399351a..eb1a4c59 100644
--- a/src/main/kotlin/com/rose/gateway/discord/bot/message/GroupAndPaginateItems.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/bot/message/GroupAndPaginateItems.kt
@@ -17,7 +17,6 @@ import dev.kord.rest.builder.message.create.FollowupMessageCreateBuilder
* @receiver Editing paginator builder
*
* @see group
- * @see editingPaginator
*/
suspend fun EphemeralSlashCommandContext<*, *>.groupAndPaginateItems(
displayItems: Collection,
diff --git a/src/main/kotlin/com/rose/gateway/discord/text/DiscordBoldSafe.kt b/src/main/kotlin/com/rose/gateway/discord/text/DiscordBoldSafe.kt
index 3deaedf2..1f330ecc 100644
--- a/src/main/kotlin/com/rose/gateway/discord/text/DiscordBoldSafe.kt
+++ b/src/main/kotlin/com/rose/gateway/discord/text/DiscordBoldSafe.kt
@@ -5,6 +5,4 @@ package com.rose.gateway.discord.text
*
* @return The bold-safe string
*/
-fun String.discordBoldSafe(): String {
- return this.replace("**", "\\**")
-}
+fun String.discordBoldSafe(): String = this.replace("**", "\\**")
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/CommandRegistry.kt b/src/main/kotlin/com/rose/gateway/minecraft/CommandRegistry.kt
index 5832f174..6eb40f4c 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/CommandRegistry.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/CommandRegistry.kt
@@ -106,12 +106,6 @@ object CommandRegistry : KoinComponent {
ConfigMonitoringRunner.saveConfig(context)
}
}
-
- subcommand("status") {
- runner { context ->
- ConfigMonitoringRunner.sendConfigurationStatus(context.bukkit.sender)
- }
- }
}
}
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/ActionListener.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/ActionListener.kt
index 7d770746..47307dad 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/ActionListener.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/ActionListener.kt
@@ -17,7 +17,9 @@ import org.koin.core.component.inject
*
* @constructor Create an action listener
*/
-class ActionListener : Listener, KoinComponent {
+class ActionListener :
+ Listener,
+ KoinComponent {
private val config: PluginConfig by inject()
private val pluginCoroutineScope: PluginCoroutineScope by inject()
@@ -31,7 +33,9 @@ class ActionListener : Listener, KoinComponent {
pluginCoroutineScope.launchIfChatExtensionEnabled(config) {
val deathMessage = event.deathMessage() ?: return@launchIfChatExtensionEnabled
val plainTextMessage =
- PlainTextComponentSerializer.plainText().serialize(deathMessage)
+ PlainTextComponentSerializer
+ .plainText()
+ .serialize(deathMessage)
.replaceFirst(event.player.name, "**${event.player.name.discordBoldSafe()}**")
GameChatEvent.trigger {
@@ -50,7 +54,9 @@ class ActionListener : Listener, KoinComponent {
pluginCoroutineScope.launchIfChatExtensionEnabled(config) {
val advancementMessage = event.message() ?: return@launchIfChatExtensionEnabled
val advancementText =
- PlainTextComponentSerializer.plainText().serialize(advancementMessage)
+ PlainTextComponentSerializer
+ .plainText()
+ .serialize(advancementMessage)
.replaceFirst(event.player.name, "**${event.player.name.discordBoldSafe()}**")
GameChatEvent.trigger {
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/ChatListener.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/ChatListener.kt
index 72657557..9ba45be5 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/ChatListener.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/ChatListener.kt
@@ -20,7 +20,9 @@ import org.koin.core.component.inject
*
* @constructor Create empty Chat listener
*/
-class ChatListener : Listener, KoinComponent {
+class ChatListener :
+ Listener,
+ KoinComponent {
private val config: PluginConfig by inject()
private val pluginCoroutineScope: PluginCoroutineScope by inject()
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/CommandListener.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/CommandListener.kt
index 6430af66..2f5190f3 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/CommandListener.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/CommandListener.kt
@@ -16,7 +16,9 @@ import org.koin.core.component.inject
*
* @constructor Create a command listener
*/
-class CommandListener : Listener, KoinComponent {
+class CommandListener :
+ Listener,
+ KoinComponent {
private val config: PluginConfig by inject()
private val pluginCoroutineScope: PluginCoroutineScope by inject()
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/ConnectionListener.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/ConnectionListener.kt
index e9c904af..c7ad71da 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/ConnectionListener.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/ConnectionListener.kt
@@ -15,7 +15,9 @@ import org.koin.core.component.inject
*
* @constructor Create connection listener
*/
-class ConnectionListener : Listener, KoinComponent {
+class ConnectionListener :
+ Listener,
+ KoinComponent {
private val config: PluginConfig by inject()
private val pluginCoroutineScope: PluginCoroutineScope by inject()
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/ConvertToDiscordMessage.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/ConvertToDiscordMessage.kt
index 1b194c0a..78076851 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/ConvertToDiscordMessage.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/ConvertToDiscordMessage.kt
@@ -38,15 +38,14 @@ private val textProcessor =
suspend fun discordMessage(
message: String,
event: AsyncChatEvent,
-): (MessageCreateBuilder.() -> Unit)? {
- return discordMessageWithContent(message) { result ->
+): (MessageCreateBuilder.() -> Unit)? =
+ discordMessageWithContent(message) { result ->
val playerName = event.player.name
event.message(result.minecraftMessage)
"**${playerName.discordBoldSafe()} »** ${result.discordMessage}"
}
-}
/**
* Creates a Discord message for some chat message
@@ -54,11 +53,10 @@ suspend fun discordMessage(
* @param message The message to create the Discord message from
* @return The Discord message or null, if it could not be parsed
*/
-suspend fun discordMessage(message: String): (MessageCreateBuilder.() -> Unit)? {
- return discordMessageWithContent(message) { result ->
+suspend fun discordMessage(message: String): (MessageCreateBuilder.() -> Unit)? =
+ discordMessageWithContent(message) { result ->
result.discordMessage
}
-}
/**
* Parses the message and then creates a Discord message containing the content derived from the result
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleMentionTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleMentionTokenProcessor.kt
index 21b63443..72735b9c 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleMentionTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleMentionTokenProcessor.kt
@@ -13,18 +13,19 @@ import org.intellij.lang.annotations.Language
* @constructor Create a role mention token processor
*/
class RoleMentionTokenProcessor : TokenProcessor {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
private const val ROLE_MENTION_START_INDEX = 3
}
- override fun tokenType(): TokenType {
- return ChatComponent.ROLE_MENTION
- }
+ override fun tokenType(): TokenType = ChatComponent.ROLE_MENTION
@Language("RegExp")
- override fun regexPattern(): String {
- return "@[rR]=[^\\s@]+"
- }
+ override fun regexPattern(): String = "@[rR]=[^\\s@]+"
override suspend fun process(
token: Token,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleQuoteMentionTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleQuoteMentionTokenProcessor.kt
index 23bfb3ab..bcb9667c 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleQuoteMentionTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/RoleQuoteMentionTokenProcessor.kt
@@ -13,18 +13,19 @@ import org.intellij.lang.annotations.Language
* @constructor Create a role quote-mention token processor
*/
class RoleQuoteMentionTokenProcessor : TokenProcessor {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
private const val ROLE_QUOTE_MENTION_START_INDEX = 4
}
- override fun tokenType(): TokenType {
- return ChatComponent.ROLE_QUOTE_MENTION
- }
+ override fun tokenType(): TokenType = ChatComponent.ROLE_QUOTE_MENTION
@Language("RegExp")
- override fun regexPattern(): String {
- return "@[rR]=\"((\\\\\")|[^\"])+\""
- }
+ override fun regexPattern(): String = "@[rR]=\"((\\\\\")|[^\"])+\""
override suspend fun process(
token: Token,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/TextChannelMentionTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/TextChannelMentionTokenProcessor.kt
index 536d0cf7..717d5b18 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/TextChannelMentionTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/TextChannelMentionTokenProcessor.kt
@@ -17,21 +17,24 @@ import org.koin.core.component.inject
*
* @constructor Create a text channel mention token processor
*/
-class TextChannelMentionTokenProcessor : TokenProcessor, KoinComponent {
+class TextChannelMentionTokenProcessor :
+ TokenProcessor,
+ KoinComponent {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
private const val TEXT_CHANNEL_MENTION_START_INDEX = 3
}
private val bot: DiscordBotController by inject()
- override fun tokenType(): TokenType {
- return ChatComponent.TEXT_CHANNEL_MENTION
- }
+ override fun tokenType(): TokenType = ChatComponent.TEXT_CHANNEL_MENTION
@Language("RegExp")
- override fun regexPattern(): String {
- return "@[cC]=[^\\s@]+"
- }
+ override fun regexPattern(): String = "@[cC]=[^\\s@]+"
override suspend fun process(
token: Token,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/TextTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/TextTokenProcessor.kt
index 521c285f..c3f43519 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/TextTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/TextTokenProcessor.kt
@@ -13,14 +13,10 @@ import org.intellij.lang.annotations.Language
* @constructor Create a text token processor
*/
class TextTokenProcessor : TokenProcessor {
- override fun tokenType(): TokenType {
- return ChatComponent.TEXT
- }
+ override fun tokenType(): TokenType = ChatComponent.TEXT
@Language("RegExp")
- override fun regexPattern(): String {
- return ".[^@]*"
- }
+ override fun regexPattern(): String = ".[^@]*"
override suspend fun process(
token: Token,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UrlTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UrlTokenProcessor.kt
index b0cc6abd..50c679d5 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UrlTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UrlTokenProcessor.kt
@@ -16,14 +16,10 @@ import org.intellij.lang.annotations.Language
* @constructor Create a URL token processor
*/
class UrlTokenProcessor : TokenProcessor {
- override fun tokenType(): TokenType {
- return ChatComponent.URL
- }
+ override fun tokenType(): TokenType = ChatComponent.URL
@Language("RegExp")
- override fun regexPattern(): String {
- return "(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"
- }
+ override fun regexPattern(): String = "(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"
override suspend fun process(
token: Token,
@@ -31,7 +27,9 @@ class UrlTokenProcessor : TokenProcessor {
): TokenProcessingResult {
val url = token.string
val component =
- url.component().underlined()
+ url
+ .component()
+ .underlined()
.showTextOnHover("Click to open url".component())
.openUrlOnClick(url)
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UserMentionTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UserMentionTokenProcessor.kt
index 04abb64b..22b64d20 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UserMentionTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UserMentionTokenProcessor.kt
@@ -13,18 +13,19 @@ import org.intellij.lang.annotations.Language
* @constructor Create a user mention token processor
*/
class UserMentionTokenProcessor : TokenProcessor {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
private const val USER_MENTION_START_INDEX = 1
}
- override fun tokenType(): TokenType {
- return ChatComponent.USER_MENTION
- }
+ override fun tokenType(): TokenType = ChatComponent.USER_MENTION
@Language("RegExp")
- override fun regexPattern(): String {
- return "@[^\\s@]+"
- }
+ override fun regexPattern(): String = "@[^\\s@]+"
override suspend fun process(
token: Token,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UserQuoteMentionTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UserQuoteMentionTokenProcessor.kt
index f8d8064f..28d2955b 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UserQuoteMentionTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/UserQuoteMentionTokenProcessor.kt
@@ -13,18 +13,19 @@ import org.intellij.lang.annotations.Language
* @constructor Create a role quote-mention token processor
*/
class UserQuoteMentionTokenProcessor : TokenProcessor {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
private const val USER_QUOTE_MENTION_START_INDEX = 2
}
- override fun tokenType(): TokenType {
- return ChatComponent.USER_QUOTE_MENTION
- }
+ override fun tokenType(): TokenType = ChatComponent.USER_QUOTE_MENTION
@Language("RegExp")
- override fun regexPattern(): String {
- return "@\"((\\\\\")|[^\"])+\""
- }
+ override fun regexPattern(): String = "@\"((\\\\\")|[^\"])+\""
override suspend fun process(
token: Token,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/VoiceChannelMentionTokenProcessor.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/VoiceChannelMentionTokenProcessor.kt
index a84a36e2..974c8e0e 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/VoiceChannelMentionTokenProcessor.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/VoiceChannelMentionTokenProcessor.kt
@@ -17,21 +17,24 @@ import org.koin.core.component.inject
*
* @constructor Create a voice channel mention token processor
*/
-class VoiceChannelMentionTokenProcessor : TokenProcessor, KoinComponent {
+class VoiceChannelMentionTokenProcessor :
+ TokenProcessor,
+ KoinComponent {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
private const val VOICE_CHANNEL_MENTION_START_INDEX = 3
}
private val bot: DiscordBotController by inject()
- override fun tokenType(): TokenType {
- return ChatComponent.VOICE_CHANNEL_MENTION
- }
+ override fun tokenType(): TokenType = ChatComponent.VOICE_CHANNEL_MENTION
@Language("RegExp")
- override fun regexPattern(): String {
- return "@[vV]=[^\\s@]+"
- }
+ override fun regexPattern(): String = "@[vV]=[^\\s@]+"
override suspend fun process(
token: Token,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/result/MentionResult.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/result/MentionResult.kt
index 705e1035..f5e24c53 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/result/MentionResult.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/result/MentionResult.kt
@@ -29,12 +29,11 @@ object MentionResult : KoinComponent {
fun mention(
minecraftText: String,
discordText: String,
- ): TokenProcessingResult {
- return TokenProcessingResult(
+ ): TokenProcessingResult =
+ TokenProcessingResult(
minecraftText.primaryComponent(),
discordText,
)
- }
/**
* Creates a [TokenProcessingResult] representing a role mention in Discord
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/result/TokenProcessingResult.kt b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/result/TokenProcessingResult.kt
index 6914fe11..3edc5abc 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/result/TokenProcessingResult.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/chat/processing/tokens/result/TokenProcessingResult.kt
@@ -14,6 +14,11 @@ data class TokenProcessingResult(
val minecraftMessage: Component,
val discordMessage: String,
) {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
/**
* Creates a [TokenProcessingResult] representing a failed Discord mention
@@ -21,11 +26,10 @@ data class TokenProcessingResult(
* @param text The text as it appeared in Minecraft
* @return The [TokenProcessingResult] for the failure
*/
- fun error(text: String): TokenProcessingResult {
- return TokenProcessingResult(
+ fun error(text: String): TokenProcessingResult =
+ TokenProcessingResult(
text.warningComponent(),
text,
)
- }
}
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/color/AsTextColor.kt b/src/main/kotlin/com/rose/gateway/minecraft/color/AsTextColor.kt
index dc194f8d..7b27dac4 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/color/AsTextColor.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/color/AsTextColor.kt
@@ -7,6 +7,4 @@ import net.kyori.adventure.text.format.TextColor
*
* @return The string as a text color
*/
-fun String.asTextColor(): TextColor {
- return TextColor.fromHexString(this)!!
-}
+fun String.asTextColor(): TextColor = TextColor.fromHexString(this)!!
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/arguments/ConfigArgs.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/arguments/ConfigArgs.kt
index 2c494f16..b10df8b7 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/arguments/ConfigArgs.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/arguments/ConfigArgs.kt
@@ -27,14 +27,10 @@ import kotlin.reflect.typeOf
* @property item The config item referenced
* @property value The config item's value
*/
-abstract class ConfigArgs<
- T : Any,
- A : ConfigArgs,
- P : ArgParser,
- >(
+abstract class ConfigArgs(
configType: KType,
valueArg: A.() -> P,
-) : CommandArgs() {
+) : CommandArgs () where T : Any, A : ConfigArgs, P : ArgParser {
/**
* The config item of the given type that was specified
*/
@@ -57,42 +53,45 @@ abstract class ConfigArgs<
*
* @constructor Create config boolean args
*/
-class ConfigBooleanArgs : ConfigArgs>(
- typeOf(),
- {
- boolean {
- name = "VALUE"
- description = "Boolean to use the item with."
- }
- },
-)
+class ConfigBooleanArgs :
+ ConfigArgs>(
+ typeOf(),
+ {
+ boolean {
+ name = "VALUE"
+ description = "Boolean to use the item with."
+ }
+ },
+ )
/**
* Config args for int values
*
* @constructor Create config boolean args
*/
-class ConfigIntArgs : ConfigArgs>(
- typeOf(),
- {
- int {
- name = "VALUE"
- description = "Integer to use the item with."
- }
- },
-)
+class ConfigIntArgs :
+ ConfigArgs>(
+ typeOf(),
+ {
+ int {
+ name = "VALUE"
+ description = "Integer to use the item with."
+ }
+ },
+ )
/**
* Config args for string values
*
* @constructor Create config string args
*/
-class ConfigStringArgs : ConfigArgs>(
- typeOf(),
- {
- string {
- name = "VALUE"
- description = "String to use the item with."
- }
- },
-)
+class ConfigStringArgs :
+ ConfigArgs>(
+ typeOf(),
+ {
+ string {
+ name = "VALUE"
+ description = "String to use the item with."
+ }
+ },
+ )
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 60f6baa3..933b19ec 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
@@ -35,10 +35,10 @@ open class ConfigListArgs, P : ArgParser.(
+ private val stringCompleter: StringParser.(
TabCompleteContext,
) -> List,
- val stringValidator: StringParser.(
+ private val stringValidator: StringParser.(
ParseResult.Success,
) -> Boolean,
) : ConfigListArgs>(
@@ -50,8 +50,8 @@ class StringListConfigArgs(
*
* @return THe constructed parser
*/
- fun parser(): ListParser> {
- return list {
+ fun parser(): ListParser> =
+ list {
name = "VALUES"
description = "Values to add."
element =
@@ -62,7 +62,6 @@ class StringListConfigArgs(
validator = stringValidator
}
}
- }
}
/**
@@ -100,12 +99,9 @@ fun removeStringListConfigArgs(): StringListConfigArgs =
},
)
-private fun StringParser.existingValues(
- context: TabCompleteContext,
-): List {
- return if (context.args.wasSuccessful(context.completingParser)) {
+private fun existingValues(context: TabCompleteContext): List =
+ if (context.args.wasSuccessful(context.completingParser)) {
context.args.value
} else {
listOf()
}
-}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/completers/ConfigCompleter.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/completers/ConfigCompleter.kt
index 2d656508..f3527abd 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/completers/ConfigCompleter.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/completers/ConfigCompleter.kt
@@ -38,8 +38,7 @@ object ConfigCompleter : KoinComponent {
*/
fun configItemsWithType(
type: KType,
- ): P.(TabCompleteContext) -> List
- where A : CommandArgs, P : ArgParser {
+ ): P.(TabCompleteContext) -> List where A : CommandArgs, P : ArgParser {
val items = config.allItems()
val matchedItems =
items.filter {
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/Command.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/Command.kt
index 80569b6d..4dbce638 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/Command.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/Command.kt
@@ -12,7 +12,9 @@ import com.rose.gateway.minecraft.commands.framework.data.executor.ExecutorArgsP
* @property definition This command's definition
* @constructor Create a command
*/
-class Command(val definition: CommandDefinition) {
+class Command(
+ val definition: CommandDefinition,
+) {
/**
* Parses the arguments of a context and then executes on the result
*
@@ -72,9 +74,10 @@ class Command(val definition: CommandDefinition) {
executorArgsPairs: List>,
): List {
val tabCompletions =
- executorArgsPairs.map {
- it.executor.completions(context)
- }.flatten()
+ executorArgsPairs
+ .map {
+ it.executor.completions(context)
+ }.flatten()
return tabCompletions
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/CommandBuilder.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/CommandBuilder.kt
index f761d668..fd0af5f5 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/CommandBuilder.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/CommandBuilder.kt
@@ -12,7 +12,9 @@ import com.rose.gateway.minecraft.commands.framework.runner.NoArgs
* @property name The name of the command to build
* @constructor Create an empty command builder
*/
-class CommandBuilder(val name: String) {
+class CommandBuilder(
+ val name: String,
+) {
/**
* The executors for this command
*/
@@ -23,14 +25,13 @@ class CommandBuilder(val name: String) {
*
* @return The command that was built
*/
- fun build(): Command {
- return Command(
+ fun build(): Command =
+ Command(
CommandDefinition(
name = name,
executors = executors,
),
)
- }
/**
* Add a runner to this command that does not use any arguments
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommand.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommand.kt
index 8424e8d8..859611aa 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommand.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommand.kt
@@ -15,7 +15,10 @@ import org.bukkit.plugin.java.JavaPlugin
* @property command The framework command to use for execution
* @constructor Create a Minecraft command
*/
-class MinecraftCommand(val command: Command) : org.bukkit.command.CommandExecutor, TabCompleter {
+class MinecraftCommand(
+ val command: Command,
+) : org.bukkit.command.CommandExecutor,
+ TabCompleter {
override fun onCommand(
sender: CommandSender,
bukkitCommand: org.bukkit.command.Command,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommands.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommands.kt
index 7776b7d8..4b87d843 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommands.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommands.kt
@@ -23,7 +23,9 @@ fun minecraftCommands(initializer: MinecraftCommandsBuilder.() -> Unit): Minecra
* @property builder The builder for these commands
* @constructor Create minecraft commands for some commands
*/
-class MinecraftCommands(private val builder: MinecraftCommandsBuilder) {
+class MinecraftCommands(
+ private val builder: MinecraftCommandsBuilder,
+) {
/**
* Register these commands with a plugin
*
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommandsBuilder.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommandsBuilder.kt
index 6239041f..7b5426f6 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommandsBuilder.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/MinecraftCommandsBuilder.kt
@@ -34,7 +34,5 @@ class MinecraftCommandsBuilder {
*
* @return The created command group
*/
- fun build(): MinecraftCommands {
- return MinecraftCommands(this)
- }
+ fun build(): MinecraftCommands = MinecraftCommands(this)
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/context/BukkitContext.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/context/BukkitContext.kt
index fe726323..b234a95a 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/context/BukkitContext.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/context/BukkitContext.kt
@@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender
* @property args The args that exist for the action
* @constructor Create a Bukkit context
*/
-public sealed class BukkitContext(
+sealed class BukkitContext(
val sender: CommandSender,
val command: Command,
val args: Array,
@@ -26,7 +26,7 @@ public sealed class BukkitContext(
* @param command The command that is completing
* @param args The args that exist at the moment of completion
*/
- public class TabComplete(
+ class TabComplete(
sender: CommandSender,
command: Command,
val alias: String,
@@ -43,7 +43,7 @@ public sealed class BukkitContext(
* @param command The command that is executing
* @param args The args that were passed in for execution
*/
- public class CommandExecute(
+ class CommandExecute(
sender: CommandSender,
command: Command,
val label: String,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/context/FrameworkContext.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/context/FrameworkContext.kt
index e201842d..b576d9da 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/context/FrameworkContext.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/context/FrameworkContext.kt
@@ -12,7 +12,7 @@ import com.rose.gateway.minecraft.commands.framework.runner.CommandArgs
* @property args The args in use
* @constructor Create a framework context
*/
-public sealed class FrameworkContext>(
+sealed class FrameworkContext >(
val command: Command,
val args: A,
) {
@@ -27,7 +27,7 @@ public sealed class FrameworkContext >(
* @param command The command in use
* @param args The args in use
*/
- public sealed class BukkitCommand>(
+ sealed class BukkitCommand>(
val bukkit: B,
command: Command,
args: A,
@@ -42,7 +42,7 @@ public sealed class FrameworkContext>(
* @param command The command in use
* @param args The args in use
*/
- public class CommandExecute >(
+ class CommandExecute >(
bukkit: BukkitContext.CommandExecute,
command: Command,
args: A,
@@ -59,7 +59,7 @@ public sealed class FrameworkContext >(
* @param command The command in use
* @param args The args in use
*/
- public class TabComplete >(
+ class TabComplete >(
bukkit: BukkitContext.TabComplete,
command: Command,
args: A,
@@ -71,9 +71,9 @@ public sealed class FrameworkContext >(
/**
* @see FrameworkContext.BukkitCommand.CommandExecute
*/
-public typealias CommandExecuteContext = FrameworkContext.BukkitCommand.CommandExecute
+typealias CommandExecuteContext = FrameworkContext.BukkitCommand.CommandExecute
/**
* @see FrameworkContext.BukkitCommand.TabComplete
*/
-public typealias TabCompleteContext = FrameworkContext.BukkitCommand.TabComplete
+typealias TabCompleteContext = FrameworkContext.BukkitCommand.TabComplete
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/executor/ExecutorArgsPair.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/executor/ExecutorArgsPair.kt
index fb79879f..fd2f2647 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/executor/ExecutorArgsPair.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/data/executor/ExecutorArgsPair.kt
@@ -14,6 +14,11 @@ data class ExecutorArgsPair >(
val executor: CommandExecutor ,
val args: A,
) {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
/**
* Creates an paired executor and args instance from a list of raw args
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/ArgParser.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/ArgParser.kt
index 707c9c84..6503641c 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/ArgParser.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/ArgParser.kt
@@ -36,13 +36,12 @@ abstract class ArgParser, P : ArgParser>(
* @param context The context of this tab completion
* @return A list of possible tab completions
*/
- fun completions(context: TabCompleteContext): List {
- return when {
+ fun completions(context: TabCompleteContext): List =
+ when {
builder.completesAfterSatisfied -> builder.completer(self(), context)
context.args.wasSuccessful(this) -> listOf()
else -> builder.completer(self(), context)
}
- }
@Suppress("UNCHECKED_CAST")
private fun self(): P = this as P
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/CommandArgs.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/CommandArgs.kt
index f193d9f2..7727ac9d 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/CommandArgs.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/CommandArgs.kt
@@ -152,9 +152,10 @@ open class CommandArgs> {
if (allUsages.isEmpty()) {
usageList.toList()
} else {
- usageList.flatMap { usage ->
- allUsages.map { existingUsage -> "$existingUsage $usage" }
- }.toList()
+ usageList
+ .flatMap { usage ->
+ allUsages.map { existingUsage -> "$existingUsage $usage" }
+ }.toList()
}
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/ParseResult.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/ParseResult.kt
index 9475ae5b..c041229e 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/ParseResult.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/runner/ParseResult.kt
@@ -10,7 +10,9 @@ import com.rose.gateway.minecraft.commands.framework.data.parser.ParseContext
* @property context The new context after parsing
* @constructor Create a parse result
*/
-sealed class ParseResult>(val context: ParseContext) {
+sealed class ParseResult>(
+ val context: ParseContext,
+) {
/**
* A successful parse result
*
@@ -21,7 +23,10 @@ sealed class ParseResult>(val context: ParseContext) {
*
* @param context The new context after parsing
*/
- class Success>(val result: T, context: ParseContext) : ParseResult(context)
+ class Success>(
+ val result: T,
+ context: ParseContext,
+ ) : ParseResult(context)
/**
* A failed parse result
@@ -32,5 +37,7 @@ sealed class ParseResult>(val context: ParseContext) {
*
* @param context The new context after parsing
*/
- class Failure>(context: ParseContext) : ParseResult(context)
+ class Failure>(
+ context: ParseContext,
+ ) : ParseResult(context)
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/subcommand/SubcommandArgs.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/subcommand/SubcommandArgs.kt
index b1d773e7..726b2af9 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/subcommand/SubcommandArgs.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/framework/subcommand/SubcommandArgs.kt
@@ -18,7 +18,14 @@ import com.rose.gateway.minecraft.commands.parsers.stringParser
* @property command The command this subcommand executes
* @constructor Create empty subcommand args for a command
*/
-class SubcommandArgs(val command: Command) : CommandArgs() {
+class SubcommandArgs(
+ val command: Command,
+) : CommandArgs() {
+ /**
+ * Companion
+ *
+ * @constructor Create empty Companion
+ */
companion object {
/**
* Gives a constructor for [SubcommandArgs] that use a specific command
@@ -26,11 +33,10 @@ class SubcommandArgs(val command: Command) : CommandArgs() {
* @param command The command the subcommand executes
* @return A constructor a the command's [SubcommandArgs]
*/
- fun forCommand(command: Command): () -> SubcommandArgs {
- return {
+ fun forCommand(command: Command): () -> SubcommandArgs =
+ {
SubcommandArgs(command)
}
- }
}
private val subcommandParser =
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/BooleanParser.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/BooleanParser.kt
index 0a060d96..a2d0bb33 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/BooleanParser.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/BooleanParser.kt
@@ -25,8 +25,10 @@ fun > CommandArgs .boolean(body: BooleanParserBuilder .()
*
* @param builder The builder that defines this parser
*/
-class BooleanParser >(builder: BooleanParserBuilder ) :
- ArgParser>(builder) {
+class BooleanParser(
+ builder: BooleanParserBuilder ,
+) : ArgParser>(builder)
+ where A : CommandArgs {
override fun typeName(): String = "Boolean"
private val internalParser =
@@ -65,7 +67,5 @@ class BooleanParserBuilder > : ParserBuilder {
- return BooleanParser(this)
- }
+ override fun build(): BooleanParser = BooleanParser(this)
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ConfigItemParser.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ConfigItemParser.kt
index 2e876232..ca462000 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ConfigItemParser.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ConfigItemParser.kt
@@ -29,8 +29,10 @@ fun > CommandArgs .configItem(body: ConfigItemParserBuilder
*
* @param builder The builder that defines this parser
*/
-class ConfigItemParser >(builder: ConfigItemParserBuilder ) :
- ArgParser- , A, ConfigItemParser
>(builder), KoinComponent {
+class ConfigItemParser >(
+ builder: ConfigItemParserBuilder ,
+) : ArgParser- , A, ConfigItemParser
>(builder),
+ KoinComponent {
private val config: PluginConfig by inject()
override fun typeName(): String = "ConfigItemType"
@@ -68,7 +70,5 @@ class ConfigItemParser >(builder: ConfigItemParserBuilder )
class ConfigItemParserBuilder > : ParserBuilder- , A, ConfigItemParser
>() {
override fun checkValidity() = Unit
- override fun build(): ConfigItemParser {
- return ConfigItemParser(this)
- }
+ override fun build(): ConfigItemParser = ConfigItemParser(this)
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/IntParser.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/IntParser.kt
index 43bd9253..c93b3755 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/IntParser.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/IntParser.kt
@@ -14,8 +14,7 @@ import com.rose.gateway.minecraft.commands.framework.runner.ParserBuilder
* @receiver The builder for the parser
* @return The built parser
*/
-fun CommandArgs .int(body: IntParserBuilder .() -> Unit): IntParser
- where A : CommandArgs =
+fun CommandArgs .int(body: IntParserBuilder .() -> Unit): IntParser where A : CommandArgs =
genericParser(::IntParserBuilder, body)
/**
@@ -26,8 +25,9 @@ fun CommandArgs .int(body: IntParserBuilder .() -> Unit): IntParser
*
* @param builder The builder that defines this parser
*/
-class IntParser >(builder: IntParserBuilder ) :
- ArgParser>(builder) {
+class IntParser>(
+ builder: IntParserBuilder ,
+) : ArgParser>(builder) {
override fun typeName(): String = "Int"
private val internalParser =
@@ -62,7 +62,5 @@ class IntParser>(builder: IntParserBuilder ) :
class IntParserBuilder > : ParserBuilder>() {
override fun checkValidity() = Unit
- override fun build(): IntParser {
- return IntParser(this)
- }
+ override fun build(): IntParser = IntParser(this)
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ListParser.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ListParser.kt
index c45c8cdd..c57dfec8 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ListParser.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/ListParser.kt
@@ -28,8 +28,10 @@ fun , R : ArgParser> CommandArgs.list(
*
* @param builder The builder that defines this parser
*/
-class ListParser(override val builder: ListParserBuilder) :
- ArgParser, A, ListParser>(builder)
+@Suppress("MaxLineLength")
+class ListParser(
+ override val builder: ListParserBuilder,
+) : ArgParser, A, ListParser>(builder)
where T : Any, A : CommandArgs, P : ArgParser {
private val parser = builder.element
@@ -64,8 +66,9 @@ class ListParser(override val builder: ListParserBuilder) :
* @param P The type of the parser for list elements
* @constructor Creates a list parser builder
*/
-class ListParserBuilder, P : ArgParser> :
- ParserBuilder, A, ListParser>() {
+class ListParserBuilder :
+ ParserBuilder, A, ListParser>()
+ where T : Any, A : CommandArgs, P : ArgParser {
init {
completer = {
element.completions(it)
@@ -87,7 +90,5 @@ class ListParserBuilder, P : ArgParser> :
if (!::element.isInitialized) error("no type given for list argument")
}
- override fun build(): ListParser {
- return ListParser(this)
- }
+ override fun build(): ListParser = ListParser(this)
}
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 3618e5e9..0315d84f 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
@@ -14,10 +14,9 @@ import com.rose.gateway.minecraft.commands.framework.runner.ParserBuilder
* @receiver The builder for the parser
* @return The built parser
*/
-fun CommandArgs.processor(
- body: ProcessorParserBuilder.() -> Unit,
-): ProcessorParser
- where A : CommandArgs = genericParser(::ProcessorParserBuilder, body)
+@Suppress("MaxLineLength")
+fun CommandArgs.processor(body: ProcessorParserBuilder.() -> Unit): ProcessorParser where A : CommandArgs =
+ genericParser(::ProcessorParserBuilder, body)
/**
* Parser for a custom-processed argument
@@ -28,13 +27,13 @@ fun CommandArgs.processor(
*
* @param builder The builder that defines this parser
*/
-class ProcessorParser>(override val builder: ProcessorParserBuilder) :
- ArgParser>(builder) {
+@Suppress("MaxLineLength")
+class ProcessorParser(
+ override val builder: ProcessorParserBuilder,
+) : ArgParser>(builder) where A : CommandArgs {
override fun typeName(): String = "CustomProcessor"
- override fun parseValue(context: ParseContext ): ParseResult {
- return builder.processor(context)
- }
+ override fun parseValue(context: ParseContext): ParseResult = builder.processor(context)
}
/**
@@ -58,7 +57,5 @@ class ProcessorParserBuilder> : ParserBuilder {
- return ProcessorParser(this)
- }
+ override fun build(): ProcessorParser = ProcessorParser(this)
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/StringParser.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/StringParser.kt
index e671459f..0e632711 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/StringParser.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/StringParser.kt
@@ -36,8 +36,10 @@ fun > CommandArgs .string(body: StringParserBuilder .() -
*
* @param builder The builder that defines this parser
*/
-class StringParser >(override val builder: StringParserBuilder ) :
- ArgParser>(builder) {
+class StringParser(
+ override val builder: StringParserBuilder ,
+) : ArgParser>(builder)
+ where A : CommandArgs {
override fun typeName(): String = "String"
override fun parseValue(context: ParseContext ): ParseResult {
@@ -99,7 +101,5 @@ class StringParserBuilder> : ParserBuilder {
- return StringParser(this)
- }
+ override fun build(): StringParser = StringParser(this)
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/TypedConfigItemParser.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/TypedConfigItemParser.kt
index c2391c05..aefda447 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/TypedConfigItemParser.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/parsers/TypedConfigItemParser.kt
@@ -32,8 +32,11 @@ fun > CommandArgs.typedConfigItem(
*
* @param builder The builder that defines this parser
*/
-class TypedConfigItemParser>(override val builder: TypedConfigItemParserBuilder) :
- ArgParser- , A, TypedConfigItemParser
>(builder), KoinComponent {
+class TypedConfigItemParser(
+ override val builder: TypedConfigItemParserBuilder,
+) : ArgParser- , A, TypedConfigItemParser
>(builder),
+ KoinComponent
+ where T : Any, A : CommandArgs {
private val config: PluginConfig by inject()
override fun typeName(): String = "ConfigItemType"
@@ -69,8 +72,8 @@ class TypedConfigItemParser>(override val builder: T
* @param A The args the parser will be a part of
* @constructor Creates a typed config item parser builder
*/
-class TypedConfigItemParserBuilder> :
- ParserBuilder- , A, TypedConfigItemParser
>() {
+class TypedConfigItemParserBuilder : ParserBuilder- , A, TypedConfigItemParser
>()
+ where T : Any, A : CommandArgs {
/**
* The KType for the config item
*/
@@ -80,7 +83,5 @@ class TypedConfigItemParserBuilder> :
if (!::type.isInitialized) error("No type give for item arg.")
}
- override fun build(): TypedConfigItemParser {
- return TypedConfigItemParser(this)
- }
+ override fun build(): TypedConfigItemParser = TypedConfigItemParser(this)
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/BotCommands.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/BotCommands.kt
index c2da8d83..0a9c0d0b 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/BotCommands.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/BotCommands.kt
@@ -37,7 +37,8 @@ object BotCommands : KoinComponent {
context.bukkit.sender,
join(
"Discord bot will now rebuild. ".component(),
- "Check Status".tertiaryComponent()
+ "Check Status"
+ .tertiaryComponent()
.showTextOnHover("Click to view status".component())
.runCommandOnClick("/gateway bot status"),
),
@@ -61,7 +62,8 @@ object BotCommands : KoinComponent {
context.bukkit.sender,
join(
"Discord bot will now restart. ".component(),
- "Check Status".tertiaryComponent()
+ "Check Status"
+ .tertiaryComponent()
.showTextOnHover("Click to view status".component())
.runCommandOnClick("/gateway bot status"),
),
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 9f77e3df..9ddc323d 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
@@ -69,10 +69,8 @@ object ConfigCommands {
* @param context The command context with the config list args
* @return Whether the command succeeded
*/
- fun addConfiguration(
- context: CommandExecuteContext,
- ): Boolean
- where A : ConfigListArgs, P : StringParser {
+ @Suppress("MaxLineLength")
+ fun addConfiguration(context: CommandExecuteContext): Boolean where A : ConfigListArgs, P : StringParser {
val configItem = context.args.item
val values = context.args.value
@@ -131,10 +129,8 @@ object ConfigCommands {
* @param context The command context with the config list args
* @return Whether the command succeeded
*/
- fun removeConfiguration(
- context: CommandExecuteContext,
- ): Boolean
- where A : ConfigListArgs, P : StringParser {
+ @Suppress("MaxLineLength")
+ 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/minecraft/commands/runners/ConfigMonitoringRunner.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/ConfigMonitoringRunner.kt
index c0220b58..cae0f982 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/ConfigMonitoringRunner.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/commands/runners/ConfigMonitoringRunner.kt
@@ -11,7 +11,6 @@ import com.rose.gateway.minecraft.component.italic
import com.rose.gateway.minecraft.component.item
import com.rose.gateway.minecraft.component.join
import com.rose.gateway.minecraft.component.joinNewLine
-import com.rose.gateway.minecraft.component.joinSpace
import com.rose.gateway.minecraft.component.plus
import com.rose.gateway.minecraft.component.primaryComponent
import com.rose.gateway.minecraft.component.runCommandOnClick
@@ -81,13 +80,8 @@ object ConfigMonitoringRunner : KoinComponent {
context.bukkit.sender.sendMessage("Loading configuration...")
pluginCoroutineScope.launch {
- val loadSuccessful = config.reloadConfig()
-
- if (loadSuccessful) {
- context.bukkit.sender.sendMessage("New configuration loaded successfully. Bot restarted.")
- } else {
- context.bukkit.sender.sendMessage("Failed to load new configuration. Bot stopped for safety.")
- }
+ config.reloadConfig()
+ context.bukkit.sender.sendMessage("Configuration loaded. Bot restarted.")
}
return true
@@ -108,25 +102,6 @@ object ConfigMonitoringRunner : KoinComponent {
return true
}
- /**
- * Command that sends the command sender the current status of the plugin configuration
- *
- * @param sender The sender to receive the message
- * @return Whether the command succeeded
- */
- fun sendConfigurationStatus(sender: CommandSender): Boolean {
- val configStatus = if (config.notLoaded()) "Not Loaded (Check logs to fix file and then reload)" else "Loaded"
-
- sender.sendMessage(
- joinSpace(
- "Config Status:".primaryComponent(),
- configStatus.component(),
- ),
- )
-
- return true
- }
-
/**
* Sends help for a config item to the sender of a command
*
@@ -147,8 +122,8 @@ object ConfigMonitoringRunner : KoinComponent {
* @param item The item to create the help message for
* @return The created help message
*/
- private fun itemHelpMessage(item: Item<*>): Component {
- return joinNewLine(
+ private fun itemHelpMessage(item: Item<*>): Component =
+ joinNewLine(
"Configuration Help:".primaryComponent(),
"Name: ".primaryComponent() + item.path.tertiaryComponent().italic(),
join(
@@ -158,9 +133,11 @@ object ConfigMonitoringRunner : KoinComponent {
),
"Current Value: ".primaryComponent() + item.value.toString().component(),
"Description: ".primaryComponent() + item.description.component(),
- "View All Configurations".secondaryComponent().underlined().italic()
+ "View All Configurations"
+ .secondaryComponent()
+ .underlined()
+ .italic()
.showTextOnHover("Click to view all configurations.".component())
.runCommandOnClick("/gateway config help"),
)
- }
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/component/Color.kt b/src/main/kotlin/com/rose/gateway/minecraft/component/Color.kt
index bd07e3ae..f854d957 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/component/Color.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/component/Color.kt
@@ -20,26 +20,26 @@ object Color : KoinComponent {
*
* @return The colored component
*/
- public fun Component.primary(): Component = this.color(config.primaryColor())
+ fun Component.primary(): Component = this.color(config.primaryColor())
/**
* Apply the secondary color to the component
*
* @return The colored component
*/
- public fun Component.secondary(): Component = this.color(config.secondaryColor())
+ fun Component.secondary(): Component = this.color(config.secondaryColor())
/**
* Apply the tertiary color to the component
*
* @return The colored component
*/
- public fun Component.tertiary(): Component = this.color(config.tertiaryColor())
+ fun Component.tertiary(): Component = this.color(config.tertiaryColor())
/**
* Apply the warning color to the component
*
* @return The colored component
*/
- public fun Component.warning(): Component = this.color(config.warningColor())
+ fun Component.warning(): Component = this.color(config.warningColor())
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/component/DiscordComponent.kt b/src/main/kotlin/com/rose/gateway/minecraft/component/DiscordComponent.kt
index dd9c3704..b61359d8 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/component/DiscordComponent.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/component/DiscordComponent.kt
@@ -14,9 +14,7 @@ import net.kyori.adventure.text.format.TextColor
fun atMember(
user: Member,
userColor: TextColor,
-): Component {
- return "@".primaryComponent() + member(user).color(userColor)
-}
+): Component = "@".primaryComponent() + member(user).color(userColor)
/**
* Creates a member [Component] for a Discord [Member]
@@ -24,7 +22,7 @@ fun atMember(
* @param user The user to create a [Component] for
* @return The member [Component]
*/
-fun member(user: Member): Component {
- return user.effectiveName.secondaryComponent()
+fun member(user: Member): Component =
+ user.effectiveName
+ .secondaryComponent()
.showTextOnHover("Username: ".component() + user.username.primaryComponent().italic())
-}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/component/Item.kt b/src/main/kotlin/com/rose/gateway/minecraft/component/Item.kt
index 373ead03..28f119db 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/component/Item.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/component/Item.kt
@@ -8,8 +8,10 @@ import net.kyori.adventure.text.Component
* @param itemName The name of the item to create the [Component] for
* @return The config item [Component]
*/
-fun item(itemName: String): Component {
- return itemName.tertiaryComponent().italic().showTextOnHover(
- "Get help for ".component() + itemName.tertiaryComponent().italic(),
- ).runCommandOnClick("/gateway config help $itemName")
-}
+fun item(itemName: String): Component =
+ itemName
+ .tertiaryComponent()
+ .italic()
+ .showTextOnHover(
+ "Get help for ".component() + itemName.tertiaryComponent().italic(),
+ ).runCommandOnClick("/gateway config help $itemName")
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/logging/LogFormatter.kt b/src/main/kotlin/com/rose/gateway/minecraft/logging/LogFormatter.kt
index 9f6d4035..f8cabea8 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/logging/LogFormatter.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/logging/LogFormatter.kt
@@ -12,7 +12,7 @@ import java.util.logging.SimpleFormatter
class LogFormatter : SimpleFormatter() {
private val dateTimeFormatter = DateTimeFormatter.ofPattern("EEE, yyyy-MM-dd HH:mm:ss")
- override fun format(record: LogRecord): String? {
+ override fun format(record: LogRecord): String {
val zdt =
ZonedDateTime.ofInstant(
record.instant,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/logging/Logger.kt b/src/main/kotlin/com/rose/gateway/minecraft/logging/Logger.kt
index 05efed55..cda869a6 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/logging/Logger.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/logging/Logger.kt
@@ -11,10 +11,9 @@ import java.util.logging.FileHandler
object Logger : KoinComponent {
private val plugin: GatewayPlugin by inject()
private val pluginLogger = plugin.logger
- private val handler: FileHandler
+ private val handler: FileHandler = FileHandler(plugin.dataFolder.path.plus("/gateway_log.txt"), true)
init {
- handler = FileHandler(plugin.dataFolder.path.plus("/gateway_log.txt"), true)
handler.formatter = LogFormatter()
pluginLogger.addHandler(handler)
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/server/Console.kt b/src/main/kotlin/com/rose/gateway/minecraft/server/Console.kt
index 8077038a..d49e66ba 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/server/Console.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/server/Console.kt
@@ -13,9 +13,7 @@ object Console {
* @param command The command to run
* @return Whether execution succeeded
*/
- fun runCommand(command: String): Boolean {
- return Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command)
- }
+ fun runCommand(command: String): Boolean = Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command)
/**
* Broadcasts a message to the entire server via the chat
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/server/Scheduler.kt b/src/main/kotlin/com/rose/gateway/minecraft/server/Scheduler.kt
index e9a3fa86..f6340799 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/server/Scheduler.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/server/Scheduler.kt
@@ -19,12 +19,11 @@ object Scheduler : KoinComponent {
* @receiver The Bukkit server scheduler
* @return The task being executed
*/
- fun runTask(task: () -> Unit): BukkitTask {
- return Bukkit.getScheduler().runTask(
+ fun runTask(task: () -> Unit): BukkitTask =
+ Bukkit.getScheduler().runTask(
plugin,
Runnable {
task()
},
)
- }
}
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/server/ServerInfo.kt b/src/main/kotlin/com/rose/gateway/minecraft/server/ServerInfo.kt
index 157ab2e4..b70430c0 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/server/ServerInfo.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/server/ServerInfo.kt
@@ -27,7 +27,7 @@ object ServerInfo {
* @property fifteenMinute The TPS over the past fifteen minutes
* @constructor Create a TPS snapshot
*/
- public data class TPS(
+ data class TPS(
val oneMinute: Double,
val fiveMinute: Double,
val fifteenMinute: Double,
diff --git a/src/main/kotlin/com/rose/gateway/minecraft/users/UserCount.kt b/src/main/kotlin/com/rose/gateway/minecraft/users/UserCount.kt
index 731752da..59cb84a9 100644
--- a/src/main/kotlin/com/rose/gateway/minecraft/users/UserCount.kt
+++ b/src/main/kotlin/com/rose/gateway/minecraft/users/UserCount.kt
@@ -16,7 +16,9 @@ import org.koin.core.component.inject
*
* @constructor Create a user count listener
*/
-class UserCount : Listener, KoinComponent {
+class UserCount :
+ Listener,
+ KoinComponent {
private val pluginCoroutineScope: PluginCoroutineScope by inject()
/**
diff --git a/src/main/kotlin/com/rose/gateway/shared/collections/builders/DequeOf.kt b/src/main/kotlin/com/rose/gateway/shared/collections/builders/DequeOf.kt
index 436b5b52..29b2d919 100644
--- a/src/main/kotlin/com/rose/gateway/shared/collections/builders/DequeOf.kt
+++ b/src/main/kotlin/com/rose/gateway/shared/collections/builders/DequeOf.kt
@@ -9,6 +9,4 @@ package com.rose.gateway.shared.collections.builders
*
* @see ArrayDeque
*/
-fun dequeOf(vararg elements: ElementType): ArrayDeque {
- return elements.toCollection(ArrayDeque())
-}
+fun dequeOf(vararg elements: ElementType): ArrayDeque = elements.toCollection(ArrayDeque())
diff --git a/src/main/kotlin/com/rose/gateway/shared/collections/builders/TrieOf.kt b/src/main/kotlin/com/rose/gateway/shared/collections/builders/TrieOf.kt
index 4cac2e7c..810ff734 100644
--- a/src/main/kotlin/com/rose/gateway/shared/collections/builders/TrieOf.kt
+++ b/src/main/kotlin/com/rose/gateway/shared/collections/builders/TrieOf.kt
@@ -10,6 +10,4 @@ import com.rose.gateway.shared.collections.trie.Trie
*
* @see Trie
*/
-fun trieOf(values: Collection