From 2ec8f01ab7b81a62cb932e02f19dd776af652606 Mon Sep 17 00:00:00 2001
From: Nicholas Rose <35816886+nicholasgrose@users.noreply.github.com>
Date: Sat, 19 Oct 2024 17:58:21 -0500
Subject: [PATCH] Project cleanup
---
.gitignore | 3 +++
.idea/misc.xml | 5 +++-
.idea/modules.xml | 1 +
.idea/modules/Gateway.iml | 9 +++++++
.idea/modules/Gateway.main.iml | 4 ++++
.../Gateway__qodanaScan_.xml | 24 +++++++++++++++++++
..._runChecks_.xml => Gateway__runLints_.xml} | 5 ++--
build.gradle.kts | 3 ++-
gradle/libs.versions.toml | 3 +++
qodana.yaml | 12 ++++++++++
.../gateway/config/markers/CommonDecoder.kt | 2 +-
.../bot/message/GroupAndPaginateItems.kt | 1 -
.../commands/arguments/ConfigListArgs.kt | 4 ++--
.../framework/data/context/BukkitContext.kt | 6 ++---
.../data/context/FrameworkContext.kt | 12 +++++-----
.../rose/gateway/minecraft/component/Color.kt | 8 +++----
.../gateway/minecraft/logging/LogFormatter.kt | 2 +-
.../rose/gateway/minecraft/logging/Logger.kt | 3 +--
.../gateway/minecraft/server/ServerInfo.kt | 2 +-
19 files changed, 84 insertions(+), 25 deletions(-)
create mode 100644 .idea/modules/Gateway.iml
create mode 100644 .idea/runConfigurations/Gateway__qodanaScan_.xml
rename .idea/runConfigurations/{Gateway__runChecks_.xml => Gateway__runLints_.xml} (80%)
create mode 100644 qodana.yaml
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/misc.xml b/.idea/misc.xml
index b0c49b80..bd523c22 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,6 +5,9 @@
+
+
+
@@ -22,5 +25,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index b378a676..540b3025 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,6 +2,7 @@
+
diff --git a/.idea/modules/Gateway.iml b/.idea/modules/Gateway.iml
new file mode 100644
index 00000000..d11e1fbc
--- /dev/null
+++ b/.idea/modules/Gateway.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/Gateway.main.iml b/.idea/modules/Gateway.main.iml
index bbeeb3ec..746f1fd6 100644
--- a/.idea/modules/Gateway.main.iml
+++ b/.idea/modules/Gateway.main.iml
@@ -11,4 +11,8 @@
+
+
+
+
\ 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 80f494f2..8ed7110b 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,6 +8,7 @@ plugins {
alias(libs.plugins.run.paper)
alias(libs.plugins.ktlint)
alias(libs.plugins.detekt)
+ alias(libs.plugins.qodana)
}
val version: String by project
@@ -91,7 +92,7 @@ tasks {
mustRunAfter(ktlintFormat)
}
- create("runChecks") {
+ create("runLints") {
dependsOn(ktlintFormat, detekt)
}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 2da51319..af7daf15 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -26,6 +26,8 @@ runPaper = "2.3.1"
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" }
@@ -45,3 +47,4 @@ 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/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/config/markers/CommonDecoder.kt b/src/main/kotlin/com/rose/gateway/config/markers/CommonDecoder.kt
index be5da0ed..0b0d02d8 100644
--- a/src/main/kotlin/com/rose/gateway/config/markers/CommonDecoder.kt
+++ b/src/main/kotlin/com/rose/gateway/config/markers/CommonDecoder.kt
@@ -53,6 +53,6 @@ open class CommonDecoder : NullHandlingDecoder {
* @param classifier The class we want to check
* @return true if it passes all conditions, false otherwise
*/
- fun isSupportedClassifier(classifier: KClass<*>): Boolean =
+ 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/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/minecraft/commands/arguments/ConfigListArgs.kt b/src/main/kotlin/com/rose/gateway/minecraft/commands/arguments/ConfigListArgs.kt
index bb027bd4..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>(
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/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/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/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,