From 6b40049c1ba0a4bcd279cf4f69eab050df78580e Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Fri, 15 Mar 2024 22:47:28 -0400 Subject: [PATCH] Chore: Update geary, idofront, publish task --- .github/workflows/publish.yml | 6 ++-- build.gradle.kts | 21 ++++++------- chatty-paper/build.gradle.kts | 31 +++++++++---------- .../com/mineinabyss/chatty/ChattyChannel.kt | 21 +++++++------ .../com/mineinabyss/chatty/ChattyContext.kt | 7 ++--- .../com/mineinabyss/chatty/ChattyPlugin.kt | 8 ++--- .../chatty/listeners/ChatListener.kt | 29 +++++++++++------ .../chatty/listeners/ChattyProxyListener.kt | 9 +++--- .../chatty/queries/SpyingPlayers.kt | 13 -------- .../chatty/queries/SpyingPlayersQuery.kt | 10 ++++++ chatty-velocity/build.gradle.kts | 10 +++--- gradle.properties | 2 +- ...yLibs.versions.toml => libs.versions.toml} | 2 +- settings.gradle.kts | 6 ++-- 14 files changed, 90 insertions(+), 85 deletions(-) delete mode 100644 chatty-paper/src/main/kotlin/com/mineinabyss/chatty/queries/SpyingPlayers.kt create mode 100644 chatty-paper/src/main/kotlin/com/mineinabyss/chatty/queries/SpyingPlayersQuery.kt rename gradle/{chattyLibs.versions.toml => libs.versions.toml} (95%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f29ecf8..ec56bf3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,9 +13,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - uses: MineInAbyss/publish-action@master + - uses: MineInAbyss/publish-action@develop with: maven-metadata-url: https://repo.mineinabyss.com/releases/com/mineinabyss/chatty/maven-metadata.xml pages-path: build/dokka/htmlMultiModule/ diff --git a/build.gradle.kts b/build.gradle.kts index d4b4c7f..12dc636 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,17 +1,16 @@ -@Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.mia.kotlin.jvm) - alias(libs.plugins.kotlinx.serialization) - alias(libs.plugins.mia.papermc) - alias(libs.plugins.mia.testing) - alias(libs.plugins.mia.publication) - alias(libs.plugins.mia.autoversion) + alias(idofrontLibs.plugins.mia.kotlin.jvm) + alias(idofrontLibs.plugins.kotlinx.serialization) + alias(idofrontLibs.plugins.mia.papermc) + alias(idofrontLibs.plugins.mia.testing) + alias(idofrontLibs.plugins.mia.publication) + alias(idofrontLibs.plugins.mia.autoversion) } dependencies { // MineInAbyss platform - compileOnly(libs.kotlinx.serialization.json) - compileOnly(libs.kotlinx.serialization.kaml) - compileOnly(libs.kotlinx.coroutines) - compileOnly(libs.minecraft.mccoroutine) + compileOnly(idofrontLibs.kotlinx.serialization.json) + compileOnly(idofrontLibs.kotlinx.serialization.kaml) + compileOnly(idofrontLibs.kotlinx.coroutines) + compileOnly(idofrontLibs.minecraft.mccoroutine) } diff --git a/chatty-paper/build.gradle.kts b/chatty-paper/build.gradle.kts index 7c62bcd..f985c28 100644 --- a/chatty-paper/build.gradle.kts +++ b/chatty-paper/build.gradle.kts @@ -1,11 +1,10 @@ -@Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.mia.kotlin.jvm) - alias(libs.plugins.mia.papermc) - alias(libs.plugins.mia.testing) - alias(libs.plugins.mia.publication) - id(libs.plugins.mia.copyjar.get().pluginId) - alias(libs.plugins.kotlinx.serialization) + alias(idofrontLibs.plugins.mia.kotlin.jvm) + alias(idofrontLibs.plugins.mia.papermc) + alias(idofrontLibs.plugins.mia.testing) + alias(idofrontLibs.plugins.mia.publication) + id(idofrontLibs.plugins.mia.copyjar.get().pluginId) + alias(idofrontLibs.plugins.kotlinx.serialization) } repositories { @@ -17,21 +16,21 @@ repositories { dependencies { // MineInAbyss platform - compileOnly(libs.kotlinx.serialization.json) - compileOnly(libs.kotlinx.serialization.kaml) - compileOnly(libs.kotlinx.coroutines) - compileOnly(libs.minecraft.mccoroutine) - compileOnly(libs.bundles.idofront.core) + compileOnly(idofrontLibs.kotlinx.serialization.json) + compileOnly(idofrontLibs.kotlinx.serialization.kaml) + compileOnly(idofrontLibs.kotlinx.coroutines) + compileOnly(idofrontLibs.minecraft.mccoroutine) + compileOnly(idofrontLibs.bundles.idofront.core) // Other plugins - compileOnly(chattyLibs.geary.papermc) + compileOnly(libs.geary.papermc) /// Third-party plugins - compileOnly(chattyLibs.placeholderapi) - compileOnly(chattyLibs.discordsrv) + compileOnly(libs.placeholderapi) + compileOnly(libs.discordsrv) // Shaded - implementation(chattyLibs.imageloader) + implementation(libs.imageloader) } diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyChannel.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyChannel.kt index fa5549e..cde5d2e 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyChannel.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyChannel.kt @@ -1,9 +1,6 @@ package com.mineinabyss.chatty import com.mineinabyss.chatty.components.ChannelType -import com.mineinabyss.chatty.components.SpyOnChannels -import com.mineinabyss.chatty.queries.SpyingPlayers -import com.mineinabyss.geary.papermc.tracking.entities.toGeary import com.mineinabyss.idofront.textcomponents.miniMsg import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -29,7 +26,8 @@ data class ChattyChannel( val channelAliases: List = listOf(), ) { - @Serializable data class MessageDeletion( + @Serializable + data class MessageDeletion( val enabled: Boolean = false, val position: MessageDeletionPosition = MessageDeletionPosition.PREFIX, val format: String = "[X]", @@ -40,10 +38,13 @@ data class ChattyChannel( PREFIX, SUFFIX } } + val key by lazy { chatty.config.channels.entries.first { it.value == this }.key } - val messageColor: TextColor? get() = _messageColor?.let { - TextColor.fromHexString(_messageColor) ?: NamedTextColor.NAMES.value(_messageColor) ?: ("<$_messageColor>").miniMsg().color() - } + val messageColor: TextColor? + get() = _messageColor?.let { + TextColor.fromHexString(_messageColor) ?: NamedTextColor.NAMES.value(_messageColor) + ?: ("<$_messageColor>").miniMsg().color() + } fun getAudience(player: Player): Collection { @@ -65,9 +66,9 @@ data class ChattyChannel( } // Add spying players - val spies = chatty.spyingPlayers.run { - toList { query -> query.player.takeIf { query.spying.channels.contains(key) } }.filterNotNull() - } + val spies = chatty.spyingPlayers.map { + this.player.takeIf { spying.channels.contains(key) } + }.filterNotNull() audiences.addAll(spies) return audiences diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyContext.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyContext.kt index 7d38e1d..c987f32 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyContext.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyContext.kt @@ -1,10 +1,9 @@ package com.mineinabyss.chatty import com.mineinabyss.chatty.helpers.DiscordEmoteFixer -import com.mineinabyss.chatty.queries.SpyingPlayers -import com.mineinabyss.idofront.config.IdofrontConfig +import com.mineinabyss.chatty.queries.SpyingPlayersQuery +import com.mineinabyss.geary.systems.query.CachedQueryRunner import com.mineinabyss.idofront.di.DI -import org.bukkit.Bukkit const val chattyProxyChannel = "chatty:proxy" const val discordSrvChannel = "chatty:discordsrv" @@ -16,5 +15,5 @@ interface ChattyContext { val emotefixer: DiscordEmoteFixer val isPlaceholderApiLoaded: Boolean val isDiscordSRVLoaded: Boolean - val spyingPlayers: SpyingPlayers + val spyingPlayers: CachedQueryRunner } diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyPlugin.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyPlugin.kt index b494011..bef14eb 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyPlugin.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyPlugin.kt @@ -2,17 +2,17 @@ package com.mineinabyss.chatty import com.mineinabyss.chatty.components.ChannelData import com.mineinabyss.chatty.components.ChattyNickname -import com.mineinabyss.chatty.components.CommandSpy import com.mineinabyss.chatty.helpers.DiscordEmoteFixer import com.mineinabyss.chatty.listeners.ChatListener import com.mineinabyss.chatty.listeners.ChattyProxyListener import com.mineinabyss.chatty.listeners.DiscordListener import com.mineinabyss.chatty.listeners.PlayerListener import com.mineinabyss.chatty.placeholders.PlaceholderAPIHook -import com.mineinabyss.chatty.queries.SpyingPlayers +import com.mineinabyss.chatty.queries.SpyingPlayersQuery import com.mineinabyss.geary.autoscan.autoscan import com.mineinabyss.geary.helpers.componentId import com.mineinabyss.geary.modules.geary +import com.mineinabyss.geary.systems.builders.cachedQuery import com.mineinabyss.idofront.config.config import com.mineinabyss.idofront.di.DI import com.mineinabyss.idofront.plugin.listeners @@ -59,9 +59,7 @@ class ChattyPlugin : JavaPlugin() { override val emotefixer: DiscordEmoteFixer by config("emotefixer", dataFolder.toPath(), DiscordEmoteFixer()) override val isPlaceholderApiLoaded: Boolean = Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI") override val isDiscordSRVLoaded: Boolean = Bukkit.getPluginManager().isPluginEnabled("DiscordSRV") - override val spyingPlayers: SpyingPlayers = SpyingPlayers().apply { - registerIfNotRegistered() - } + override val spyingPlayers = geary.cachedQuery(SpyingPlayersQuery()) } DI.add(chattyContext) diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt index 6c3e873..f61bebe 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChatListener.kt @@ -7,9 +7,9 @@ import com.mineinabyss.chatty.components.ChannelData import com.mineinabyss.chatty.components.CommandSpy import com.mineinabyss.chatty.events.ChattyPlayerChatEvent import com.mineinabyss.chatty.helpers.* -import com.mineinabyss.geary.datatypes.family.family +import com.mineinabyss.geary.modules.geary import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull -import com.mineinabyss.geary.systems.accessors.Pointer +import com.mineinabyss.geary.systems.builders.cachedQuery import com.mineinabyss.geary.systems.query.GearyQuery import com.mineinabyss.idofront.textcomponents.serialize import io.papermc.paper.event.player.AsyncChatCommandDecorateEvent @@ -29,16 +29,16 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent @Suppress("UnstableApiUsage") class ChatListener : Listener { val plainText = PlainTextComponentSerializer.plainText() - val commandSpyQuery = CommandSpyQuery() + val commandSpyQuery = geary.cachedQuery(CommandSpyQuery()) class CommandSpyQuery : GearyQuery() { - val Pointer.player by get() - val Pointer.commandSpy by family { has() } + val player by get() + override fun ensure() = this { has() } } @EventHandler fun PlayerCommandPreprocessEvent.onPlayerCommand() { - commandSpyQuery.run { toList { it.player } }.filter { it != player }.forEach { p -> + commandSpyQuery.map { player }.filter { it != player }.forEach { p -> p.sendFormattedMessage(chatty.config.chat.commandSpyFormat, message, optionalPlayer = player) } } @@ -71,7 +71,11 @@ class ChatListener : Listener { if (chattyEvent.callEvent()) message(chattyEvent.message) else viewers().clear() - val simpleMessage = Component.textOfChildren(player.name().style(Style.style(TextDecoration.ITALIC)), Component.text(": "), baseMessage) + val simpleMessage = Component.textOfChildren( + player.name().style(Style.style(TextDecoration.ITALIC)), + Component.text(": "), + baseMessage + ) if (channel.logToConsole) Bukkit.getConsoleSender().sendMessage(simpleMessage) handleProxyMessage(player, channelId, channel, message(), simpleMessage) @@ -103,7 +107,8 @@ class ChatListener : Listener { else -> renderer { source, _, message, audience -> var finalMessage = message - finalMessage = handleChatFilters(finalMessage, player, audience as? Player) ?: return@renderer Component.empty() + finalMessage = handleChatFilters(finalMessage, player, audience as? Player) + ?: return@renderer Component.empty() finalMessage = formatPlayerPingMessage(source, pingedPlayer, audience, finalMessage) finalMessage = formatModerationMessage( channel.messageDeletion, @@ -120,7 +125,13 @@ class ChatListener : Listener { } } - private fun handleProxyMessage(player: Player, channelId: String, channel: ChattyChannel, message: Component, simpleMessage: Component) { + private fun handleProxyMessage( + player: Player, + channelId: String, + channel: ChattyChannel, + message: Component, + simpleMessage: Component + ) { if (!channel.proxy) return val proxyMessage = Component.textOfChildren(player.name(), Component.text(channelId), message, simpleMessage) player.sendPluginMessage(chatty.plugin, chattyProxyChannel, gson.serialize(proxyMessage).toByteArray()) diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChattyProxyListener.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChattyProxyListener.kt index 4160f3b..e7c4c23 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChattyProxyListener.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/listeners/ChattyProxyListener.kt @@ -36,10 +36,9 @@ class ChattyProxyListener : PluginMessageListener { val channel = chatty.config.channels[channelId] val onlinePlayers = Bukkit.getOnlinePlayers().filter { it.server == Bukkit.getServer() } - val canSpy = chatty.spyingPlayers.run { - toList { query -> query.player.takeIf { query.spying.channels.contains(channelId) } } - .filterNotNull() - } + val canSpy = chatty.spyingPlayers.map { + this.player.takeIf { spying.channels.contains(channelId) } + }.filterNotNull() // If the channel is not found, it is discord if (channel != null) { @@ -87,7 +86,7 @@ class ChattyProxyListener : PluginMessageListener { .run { if (!reserializer) MessageUtil.strip(this) else this } .run { if (translateMentions) - DiscordUtil.convertMentionsFromNames(this,DiscordSRV.getPlugin().mainGuild) + DiscordUtil.convertMentionsFromNames(this, DiscordSRV.getPlugin().mainGuild) else this } diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/queries/SpyingPlayers.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/queries/SpyingPlayers.kt deleted file mode 100644 index 5782fe1..0000000 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/queries/SpyingPlayers.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.mineinabyss.chatty.queries - -import com.mineinabyss.chatty.components.CommandSpy -import com.mineinabyss.chatty.components.SpyOnChannels -import com.mineinabyss.geary.datatypes.family.family -import com.mineinabyss.geary.systems.accessors.Pointer -import com.mineinabyss.geary.systems.query.GearyQuery -import org.bukkit.entity.Player - -class SpyingPlayers: GearyQuery() { - val Pointer.player by get() - val Pointer.spying by get() -} diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/queries/SpyingPlayersQuery.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/queries/SpyingPlayersQuery.kt new file mode 100644 index 0000000..a646798 --- /dev/null +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/queries/SpyingPlayersQuery.kt @@ -0,0 +1,10 @@ +package com.mineinabyss.chatty.queries + +import com.mineinabyss.chatty.components.SpyOnChannels +import com.mineinabyss.geary.systems.query.GearyQuery +import org.bukkit.entity.Player + +class SpyingPlayersQuery : GearyQuery() { + val player by get() + val spying by get() +} diff --git a/chatty-velocity/build.gradle.kts b/chatty-velocity/build.gradle.kts index c7c43bc..f5117c6 100644 --- a/chatty-velocity/build.gradle.kts +++ b/chatty-velocity/build.gradle.kts @@ -4,7 +4,7 @@ plugins { kotlin("plugin.serialization") id("com.github.johnrengelman.shadow") `maven-publish` - id(libs.plugins.mia.copyjar.get().pluginId) + id(idofrontLibs.plugins.mia.copyjar.get().pluginId) } copyJar { @@ -20,14 +20,14 @@ dependencies { implementation(kotlin("reflect")) // implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0") // api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:$coroutinesVersion")) - implementation(libs.kotlinx.coroutines) - implementation(libs.kotlinx.serialization.json) + implementation(idofrontLibs.kotlinx.coroutines) + implementation(idofrontLibs.kotlinx.serialization.json) // implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") // implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutinesVersion") implementation("net.kyori:adventure-extra-kotlin:4.11.0") - compileOnly(chattyLibs.velocity) - kapt(chattyLibs.velocity) + compileOnly(libs.velocity) + kapt(libs.velocity) } copyJar { diff --git a/gradle.properties b/gradle.properties index aef8327..6d1c625 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=com.mineinabyss version=0.7 -idofrontVersion=0.21.6 +idofrontVersion=0.23.0-dev.7 diff --git a/gradle/chattyLibs.versions.toml b/gradle/libs.versions.toml similarity index 95% rename from gradle/chattyLibs.versions.toml rename to gradle/libs.versions.toml index 68da411..14944a7 100644 --- a/gradle/chattyLibs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -geary = "0.29.5" +geary = "0.29.12-dev.6" velocity = "3.3.0-SNAPSHOT" discordsrv = "1.27.0" placeholderapi = "2.11.5" diff --git a/settings.gradle.kts b/settings.gradle.kts index 836030e..3fbe67c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -6,6 +6,7 @@ pluginManagement { mavenCentral() gradlePluginPortal() maven("https://repo.mineinabyss.com/releases") + maven("https://repo.mineinabyss.com/snapshots") maven("https://repo.papermc.io/repository/maven-public/") google() } @@ -24,14 +25,13 @@ dependencyResolutionManagement { repositories { maven("https://repo.mineinabyss.com/releases") + maven("https://repo.mineinabyss.com/snapshots") } versionCatalogs { - create("libs") { + create("idofrontLibs") { from("com.mineinabyss:catalog:$idofrontVersion") - version("kotlin", "1.9.22") } - create("chattyLibs").from(files("gradle/chattyLibs.versions.toml")) } }