diff --git a/.github/workflows/pull_request_check.yml b/.github/workflows/pull_request_check.yml
index a0364ce9..3e1e816b 100644
--- a/.github/workflows/pull_request_check.yml
+++ b/.github/workflows/pull_request_check.yml
@@ -3,6 +3,7 @@ name: Check Pull Request
on:
pull_request:
branches:
+ - develop**
- main
paths:
@@ -41,7 +42,7 @@ jobs:
- uses: actions/checkout@v3
# https://github.com/marketplace/actions/run-ktlint-with-reviewdog
- - uses: ScaCap/action-ktlint@1.4
+ - uses: ScaCap/action-ktlint@1.5.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
ktlint_version: '0.45.2'
@@ -57,7 +58,7 @@ jobs:
# https://github.com/marketplace/actions/run-detekt-with-reviewdog
- name: Run detekt with reviewdog
- uses: alaegin/Detekt-Action@v1.22.0-RC3
+ uses: alaegin/Detekt-Action@v1.22.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
detekt_config: config/detekt/detekt.yml
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index b5bd7d9b..62c5aa01 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -41,5 +41,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index 0e65ceac..0fc31131 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index b378a676..38456f76 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,6 +3,7 @@
+
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index f100c917..f1df886a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,14 +1,14 @@
plugins {
// https://kotlinlang.org/
- kotlin("jvm") version "1.7.21"
+ kotlin("jvm") version "1.8.10"
// https://kotlinlang.org/docs/serialization.html
- kotlin("plugin.serialization") version "1.7.21"
+ kotlin("plugin.serialization") version "1.8.10"
// https://github.com/johnrengelman/shadow
- id("com.github.johnrengelman.shadow") version "7.1.2"
+ id("com.github.johnrengelman.shadow") version "8.1.1"
// https://github.com/jpenilla/run-paper
id("xyz.jpenilla.run-paper") version "2.0.1"
// https://github.com/jlleitschuh/ktlint-gradle
- id("org.jlleitschuh.gradle.ktlint") version "11.0.0"
+ id("org.jlleitschuh.gradle.ktlint") version "11.3.1"
// https://detekt.dev/
id("io.gitlab.arturbosch.detekt") version "1.22.0"
}
@@ -42,7 +42,7 @@ repositories {
}
maven {
name = "Kotlin Discord"
- url = uri("https://maven.kotlindiscord.com/repository/maven-public/")
+ url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
}
maven {
name = "Jitpack"
@@ -90,7 +90,7 @@ tasks {
processResources {
filesMatching("plugin.yml") {
expand(
- "version" to version
+ "version" to version,
)
}
}
diff --git a/gradle.properties b/gradle.properties
index d1c4e430..ebbcbd63 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,25 +1,25 @@
# Project info
-version=1.5.0
+version=1.6.0-alpha-1
group=com.rose.gateway
# Plugin configuration
# https://github.com/pinterest/ktlint
# Must use 0.45.2 until https://github.com/JLLeitschuh/ktlint-gradle/pull/595 is closed and plugin updated
ktlintVersion=0.45.2
# Dependencies
-minecraftVersion=1.19.3
-# https://papermc.io/using-the-api#gradle
+minecraftVersion=1.19.4
+# https://docs.papermc.io/paper/dev/project-setup
paperApiRevision=R0.1
# https://github.com/sksamuel/hoplite
-hopliteVersion=2.7.0
+hopliteVersion=2.7.3
# https://github.com/charleskorn/kaml
-kamlVersion=0.49.0
+kamlVersion=0.53.0
# https://kordex.kotlindiscord.com/
-kordexVersion=1.5.6-SNAPSHOT
+kordexVersion=1.5.7-SNAPSHOT
# https://github.com/utybo/Lixy
lixyVersion=master-SNAPSHOT
# https://ktor.io/
-ktorVersion=2.2.1
+ktorVersion=2.2.4
# Compilation options for Kotlin
jvmVersion=17
-kotlinLanguageVersion=1.7
-kotlinApiVersion=1.7
+kotlinLanguageVersion=1.8
+kotlinApiVersion=1.8
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index f398c33c..bdc9a83b 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-7.6-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
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 e5d080b5..b84b8859 100644
--- a/src/main/kotlin/com/rose/gateway/config/schema/ChatConfig.kt
+++ b/src/main/kotlin/com/rose/gateway/config/schema/ChatConfig.kt
@@ -1,6 +1,7 @@
package com.rose.gateway.config.schema
import com.rose.gateway.config.markers.CommonExtensionConfig
+import com.rose.gateway.config.markers.ConfigItem
import com.rose.gateway.discord.bot.extensions.chat.ChatExtension
import com.rose.gateway.shared.serialization.SurrogateBasedSerializer
import com.rose.gateway.shared.serialization.SurrogateConverter
@@ -9,30 +10,39 @@ import kotlinx.serialization.Serializable
/**
* Config options for the "chat extension"
*
+ * @property showRoleColor Whether Discord role colors are shown
* @constructor Creates a "chat config" with the provided data
*
* @param enabled Whether the extension is enabled
*/
@Serializable(with = ChatConfigSerializer::class)
class ChatConfig(
- enabled: Boolean
+ enabled: Boolean,
+ @ConfigItem("Whether Discord role colors are shown in Minecraft chat") val showRoleColor: Boolean
) : CommonExtensionConfig(enabled, ChatExtension.extensionName())
/**
* Surrogate for serialization of [ChatConfig]
*
* @property enabled Whether the extension is enabled
+ * @property showRoleColor Whether Discord role colors are shown
* @constructor Create a "chat config" surrogate with the provided data
*
* @see ChatConfig
* @see ChatConfigSerializer
*/
@Serializable
-data class ChatConfigSurrogate(val enabled: Boolean) {
+data class ChatConfigSurrogate(val enabled: Boolean, val showRoleColor: Boolean) {
companion object : SurrogateConverter {
- override fun fromBase(base: ChatConfig): ChatConfigSurrogate = ChatConfigSurrogate(base.enabled)
+ override fun fromBase(base: ChatConfig): ChatConfigSurrogate = ChatConfigSurrogate(
+ base.enabled,
+ base.showRoleColor
+ )
- override fun toBase(surrogate: ChatConfigSurrogate): ChatConfig = ChatConfig(surrogate.enabled)
+ override fun toBase(surrogate: ChatConfigSurrogate): ChatConfig = ChatConfig(
+ surrogate.enabled,
+ surrogate.showRoleColor
+ )
}
}
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 4e22b818..54bb5900 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
@@ -3,7 +3,6 @@ package com.rose.gateway.discord.bot.extensions.about
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
-import com.rose.gateway.GatewayPlugin
import com.rose.gateway.config.PluginConfig
import com.rose.gateway.config.access.aboutExtensionEnabled
import com.rose.gateway.config.access.secondaryColor
@@ -11,6 +10,7 @@ import com.rose.gateway.discord.bot.extensions.ExtensionToggle
import com.rose.gateway.minecraft.logging.Logger
import dev.kord.common.Color
import dev.kord.rest.builder.message.create.embed
+import org.bukkit.Bukkit
import org.koin.core.component.inject
/**
@@ -29,22 +29,20 @@ class AboutExtension : Extension() {
override fun isEnabled(): Boolean = config.aboutExtensionEnabled()
}
- private val plugin: GatewayPlugin by inject()
-
override val name = extensionName()
override suspend fun setup() {
ephemeralSlashCommand {
name = "version"
- description = "Gives the current version of the Gateway plugin"
+ description = "Gives the current version of the Minecraft server"
action {
Logger.info("${user.asUserOrNull()?.username} requested plugin version!")
respond {
embed {
- title = plugin.description.version
- description = "All versions are available at https://github.com/nicholasgrose/Gateway/releases."
+ title = "Minecraft Version"
+ description = Bukkit.getMinecraftVersion()
color = Color(config.secondaryColor().value())
}
}
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 d4a89f2e..6ed49f31 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
@@ -29,7 +29,7 @@ class ChannelMentionTokenProcessor : TokenProcessor ".component(),
+ )
+ }
+
+ val roleColor = event.member!!.getTopRole()?.color?.let { TextColor.color(it.rgb) }
+
return join(
"<".component(),
- member(event.member!!),
- "> ".component()
+ member(event.member!!).color(roleColor),
+ "> ".component(),
)
}
@@ -70,7 +83,7 @@ object DiscordMessageProcessor : KoinComponent {
return join(
"(Replying to ".primaryComponent().italic(),
referenceComponent,
- ") ".primaryComponent().italic()
+ ") ".primaryComponent().italic(),
)
}
@@ -109,7 +122,7 @@ object DiscordMessageProcessor : KoinComponent {
private suspend fun referencedMessageAuthor(referencedMessage: Message, event: MessageCreateEvent): Member? {
val referencedAuthor = referencedMessage.author?.id ?: return null
- return event.getGuild()?.getMemberOrNull(referencedAuthor)
+ return event.getGuildOrNull()?.getMemberOrNull(referencedAuthor)
}
private val textProcessor = TextProcessor(
@@ -118,8 +131,8 @@ object DiscordMessageProcessor : KoinComponent {
UserMentionTokenProcessor(),
RoleMentionTokenProcessor(),
ChannelMentionTokenProcessor(),
- TextTokenProcessor()
- )
+ TextTokenProcessor(),
+ ),
)
/**
@@ -148,9 +161,9 @@ object DiscordMessageProcessor : KoinComponent {
event.message.attachments.mapIndexed { index, attachment ->
"Attachment$index".tertiaryComponent().italic().underlined()
.showTextOnHover("Open attachment link".component()).openUrlOnClick(attachment.url)
- }
+ },
),
- ")".primaryComponent().italic()
+ ")".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 d8578e0f..d7044d3c 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
@@ -33,7 +33,7 @@ class RoleMentionTokenProcessor : TokenProcessor,
override suspend fun process(token: LixyToken, additionalData: MessageCreateEvent): Component {
val snowflakeString = token.string.substring(SNOWFLAKE_START_INDEX until token.string.length - 1)
val id = Snowflake(snowflakeString)
- val role = additionalData.getGuild()!!.getRoleOrNull(id) ?: return token.string.component()
+ val role = additionalData.getGuildOrNull()?.getRoleOrNull(id) ?: return token.string.component()
return "@${role.name}".primaryComponent()
}
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 7ef40398..a91713c3 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
@@ -34,7 +34,7 @@ class UserMentionTokenProcessor : TokenProcessor,
override suspend fun process(token: LixyToken, additionalData: MessageCreateEvent): Component {
val snowflakeString = token.string.substring(SNOWFLAKE_START_INDEX until token.string.length - 1)
val id = Snowflake(snowflakeString)
- val member = additionalData.getGuild()!!.getMemberOrNull(id) ?: return token.string.component()
+ val member = additionalData.getGuildOrNull()?.getMemberOrNull(id) ?: return token.string.component()
return atMember(member, config.primaryColor())
}
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 4654b669..292c6e8b 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
@@ -23,8 +23,8 @@ private val textProcessor = TextProcessor(
RoleMentionTokenProcessor(),
UserQuoteMentionTokenProcessor(),
UserMentionTokenProcessor(),
- TextTokenProcessor()
- )
+ TextTokenProcessor(),
+ ),
)
/**
@@ -36,7 +36,7 @@ private val textProcessor = TextProcessor(
*/
suspend fun discordMessage(
message: String,
- event: AsyncChatEvent
+ event: AsyncChatEvent,
): (MessageCreateBuilder.() -> Unit)? {
return discordMessageWithContent(message) { result ->
val playerName = event.player.name
@@ -69,7 +69,7 @@ suspend fun discordMessage(message: String): (MessageCreateBuilder.() -> Unit)?
*/
suspend fun discordMessageWithContent(
message: String,
- contentProvider: (MessageProcessingResult) -> String
+ contentProvider: (MessageProcessingResult) -> String,
): (MessageCreateBuilder.() -> Unit)? {
val result = processMessageText(message)
val discordContent = contentProvider(result)
@@ -78,7 +78,9 @@ suspend fun discordMessageWithContent(
{
content = discordContent
}
- } else null
+ } else {
+ null
+ }
}
/**
@@ -96,10 +98,10 @@ private suspend fun processMessageText(message: String): MessageProcessingResult
join(
messageTextParts.map {
it.minecraftMessage
- }
+ },
),
messageTextParts.joinToString(separator = "") { part ->
part.discordMessage
- }
+ },
)
}
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 375b0f28..55784a04 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
@@ -23,7 +23,7 @@ class RoleMentionTokenProcessor : TokenProcessor {
@Language("RegExp")
override fun regexPattern(): String {
- return "@R=[^\\s@]+"
+ return "@[rR]=[^\\s@]+"
}
override suspend fun process(token: LixyToken, additionalData: Unit): TokenProcessingResult {
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 610bc972..ff2d31a7 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
@@ -23,7 +23,7 @@ class RoleQuoteMentionTokenProcessor : TokenProcessor