From a23b8d2a779ab9cb623152e34176ea9f01edab48 Mon Sep 17 00:00:00 2001 From: ItsFlicker <1812496278@qq.com> Date: Sat, 19 Jul 2025 22:13:47 +0800 Subject: [PATCH 01/28] =?UTF-8?q?[2.3.6]=20=E5=8A=9F=E8=83=BD=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20&=20=E4=BF=AE=E5=A4=8D=20*=20=E7=BB=86=E5=8C=96?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E6=9D=83=E9=99=90=20*=20=E5=88=9D=E6=AD=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=85=B6=E4=BB=96=E9=9A=90=E8=BA=AB=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=20*=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E5=B0=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 4 +- build.gradle.kts | 7 +- gradle.properties | 2 +- plugin/build.gradle.kts | 1 + .../mc/trchat/api/ClientMessageManager.kt | 2 +- .../mc/trchat/api/ProxyMessageManager.kt | 2 +- project/module-compat/build.gradle.kts | 9 ++- .../mc/trchat/module/internal/hook/Hook.kt | 6 ++ .../trchat/module/internal/hook/HookPlugin.kt | 36 ++-------- .../trchat/module/internal/hook/HookUtil.kt | 27 ++++++++ .../internal/hook/impl/HookDiscordSRV.kt | 3 + .../internal/hook/impl/HookEcoEnchants.kt | 3 + .../internal/hook/impl/HookItemsAdder.kt | 3 + .../module/internal/hook/impl/HookNova.kt | 3 + .../internal/hook/impl/HookSayanVanish.kt | 19 ++++++ .../module/internal/hook/type/HookVanish.kt | 9 +++ project/module-nms/build.gradle.kts | 2 +- .../mc/trchat/api/impl/BukkitProxyManager.kt | 28 ++++---- .../trchat/module/display/channel/Channel.kt | 57 ++++++++-------- .../module/display/channel/PrivateChannel.kt | 68 ++++++++++--------- .../trchat/module/display/format/obj/Text.kt | 4 +- .../display/function/standard/Mention.kt | 5 +- .../module/internal/command/CommandHandler.kt | 9 +-- .../internal/command/main/CommandChannel.kt | 3 +- .../internal/command/main/CommandIgnore.kt | 6 +- .../internal/command/main/CommandMute.kt | 9 ++- .../trchat/module/internal/data/PlayerData.kt | 12 ---- .../internal/hook/ext/HookPlaceholderAPI.kt | 3 +- .../internal/listener/ListenerDiscordSRV.kt | 6 +- .../internal/listener/ListenerPackets.kt | 2 +- .../internal/listener/ListenerSignChange.kt | 7 +- .../internal/listener/ListenerTabComplete.kt | 1 + .../internal/proxy/BukkitProxyProcessor.kt | 21 ++++-- .../mc/trchat/util/color/MessageColors.kt | 61 ++++++++++------- .../src/main/resources/function.yml | 6 -- .../src/main/resources/lang/en_US.yml | 1 + .../src/main/resources/lang/zh_CN.yml | 1 + .../src/main/resources/settings.yml | 2 +- .../mc/trchat/api/impl/BungeeProxyManager.kt | 8 ++- .../listener/ListenerBungeeTransfer.kt | 10 ++- project/runtime-velocity/build.gradle.kts | 5 +- .../trchat/api/impl/VelocityProxyManager.kt | 8 ++- .../listener/ListenerVelocityTransfer.kt | 8 ++- 43 files changed, 286 insertions(+), 203 deletions(-) create mode 100644 project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/Hook.kt create mode 100644 project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/HookUtil.kt create mode 100644 project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookSayanVanish.kt create mode 100644 project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/type/HookVanish.kt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 96e8908b..3cab809f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: cache gradle packages uses: actions/cache@v4 with: @@ -18,7 +18,7 @@ jobs: - name: validate gradle wrapper uses: gradle/actions/wrapper-validation@v3 - name: setup jdk 8.0 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: adopt java-version: 8.0 diff --git a/build.gradle.kts b/build.gradle.kts index 15623385..54c4789e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,5 @@ import io.izzel.taboolib.gradle.* +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -37,7 +38,7 @@ subprojects { install(Bukkit, BungeeCord, Velocity) } version { - taboolib = "6.2.3-12d4045" + taboolib = "6.2.3-7105e58f" coroutines = null // isSkipKotlin = true // isSkipKotlinRelocate = true @@ -74,8 +75,8 @@ subprojects { options.encoding = "UTF-8" } tasks.withType { - kotlinOptions { - jvmTarget = "1.8" + compilerOptions { + jvmTarget = JvmTarget.JVM_1_8 freeCompilerArgs = listOf("-Xjvm-default=all", "-Xextended-compiler-checks") } } diff --git a/gradle.properties b/gradle.properties index 9b160314..bc6d1399 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=me.arasple.mc.trchat -version=2.3.5 +version=2.3.6 kotlin.incremental=true kotlin.incremental.java=true kotlin.incremental.useClasspathSnapshot=true diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 6f7600b1..7bc9b481 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -15,6 +15,7 @@ taboolib { name("EcoEnchants").with("bukkit").optional(true) name("ItemsAdder").with("bukkit").optional(true) name("Nova").with("bukkit").optional(true) + name("SayanVanish").with("bukkit").optional(true) name("Multiverse-Core").with("bukkit").loadafter(true) name("Geyser-Spigot").with("bukkit").loadafter(true) } diff --git a/project/common/src/main/kotlin/me/arasple/mc/trchat/api/ClientMessageManager.kt b/project/common/src/main/kotlin/me/arasple/mc/trchat/api/ClientMessageManager.kt index 8d44c0a1..2ebc9bf5 100644 --- a/project/common/src/main/kotlin/me/arasple/mc/trchat/api/ClientMessageManager.kt +++ b/project/common/src/main/kotlin/me/arasple/mc/trchat/api/ClientMessageManager.kt @@ -13,7 +13,7 @@ interface ClientMessageManager { fun close() = Unit - fun getPlayerNames(): Map + fun getPlayerNames(includeVanish: Boolean = false): Map fun getExactName(name: String): String? diff --git a/project/common/src/main/kotlin/me/arasple/mc/trchat/api/ProxyMessageManager.kt b/project/common/src/main/kotlin/me/arasple/mc/trchat/api/ProxyMessageManager.kt index c76d94f9..8a2d74f5 100644 --- a/project/common/src/main/kotlin/me/arasple/mc/trchat/api/ProxyMessageManager.kt +++ b/project/common/src/main/kotlin/me/arasple/mc/trchat/api/ProxyMessageManager.kt @@ -7,7 +7,7 @@ interface ProxyMessageManager { val executor: ExecutorService - val allNames: MutableMap> + val allNames: MutableMap>> fun sendMessage(recipient: Any, vararg args: String): Future<*> diff --git a/project/module-compat/build.gradle.kts b/project/module-compat/build.gradle.kts index 62f4ed45..5e86cf8e 100644 --- a/project/module-compat/build.gradle.kts +++ b/project/module-compat/build.gradle.kts @@ -2,22 +2,25 @@ repositories { maven("https://maven.devs.beer/") maven("https://nexus.scarsz.me/content/groups/public/") maven("https://repo.oraxen.com/releases") + maven("https://repo.sayandev.org/snapshots") // maven("https://repo.nexomc.com/releases") } dependencies { compileOnly(project(":project:common")) // compileOnly(project(":project:module-chat")) - compileOnly("ink.ptms.core:v12005:12005:universal") + compileOnly("ink.ptms.core:v12107:12107:universal") compileOnly("com.discordsrv:discordsrv:1.26.0") { isTransitive = false } compileOnly("com.willfp:eco:6.35.1") { isTransitive = false } compileOnly("dev.lone:api-itemsadder:4.0.10") { isTransitive = false } + compileOnly("io.th0rgal:oraxen:1.170.0") { isTransitive = false } // compileOnly("com.nexomc:nexo:0.7.0") - compileOnly("xyz.xenondevs.nova:nova-api:0.12.13") { isTransitive = false } - compileOnly("io.th0rgal:oraxen:1.170.0") { isTransitive = false } + + compileOnly("org.sayandev:sayanvanish-api:1.7.0-SNAPSHOT") { isTransitive = false } + compileOnly("org.sayandev:sayanvanish-bukkit:1.7.0-SNAPSHOT") { isTransitive = false } } taboolib { subproject = true } \ No newline at end of file diff --git a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/Hook.kt b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/Hook.kt new file mode 100644 index 00000000..241ba273 --- /dev/null +++ b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/Hook.kt @@ -0,0 +1,6 @@ +package me.arasple.mc.trchat.module.internal.hook + +import taboolib.common.platform.Platform + +@Target(AnnotationTarget.CLASS) +annotation class Hook(val platforms: Array = []) diff --git a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/HookPlugin.kt b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/HookPlugin.kt index 8df3adec..cb07a239 100644 --- a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/HookPlugin.kt +++ b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/HookPlugin.kt @@ -1,15 +1,12 @@ package me.arasple.mc.trchat.module.internal.hook -import me.arasple.mc.trchat.module.internal.hook.impl.HookDiscordSRV -import me.arasple.mc.trchat.module.internal.hook.impl.HookEcoEnchants -import me.arasple.mc.trchat.module.internal.hook.impl.HookItemsAdder -import me.arasple.mc.trchat.module.internal.hook.impl.HookNova import me.arasple.mc.trchat.module.internal.hook.type.HookDisplayItem import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack +import taboolib.common.io.runningClassesWithoutLibrary import taboolib.common.platform.Platform -import taboolib.common.platform.PlatformSide import taboolib.common.platform.function.console +import taboolib.common.platform.function.runningPlatform import taboolib.module.lang.sendLang import java.util.function.BiFunction @@ -17,15 +14,13 @@ import java.util.function.BiFunction * @author Arasple * @date 2021/1/26 22:04 */ -@PlatformSide(Platform.BUKKIT) object HookPlugin { - val registry = arrayListOf( - HookDiscordSRV(), - HookEcoEnchants(), - HookItemsAdder(), - HookNova() - ) + val registry = runningClassesWithoutLibrary + .filter { it.hasAnnotation(Hook::class.java) } + .filter { runningPlatform in it.getAnnotation(Hook::class.java).enumList("platforms") } + .map { it.newInstance() as HookAbstract } + .toMutableList() fun printInfo() { registry.filter { it.isHooked }.forEach { @@ -49,21 +44,4 @@ object HookPlugin { } }) } - - fun getDiscordSRV(): HookDiscordSRV { - return registry[0] as HookDiscordSRV - } - - fun getEcoEnchants(): HookEcoEnchants { - return registry[1] as HookEcoEnchants - } - - fun getItemsAdder(): HookItemsAdder { - return registry[2] as HookItemsAdder - } - - fun getNova(): HookNova { - return registry[3] as HookNova - } - } \ No newline at end of file diff --git a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/HookUtil.kt b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/HookUtil.kt new file mode 100644 index 00000000..68348c75 --- /dev/null +++ b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/HookUtil.kt @@ -0,0 +1,27 @@ +package me.arasple.mc.trchat.module.internal.hook + +import me.arasple.mc.trchat.module.internal.hook.impl.HookDiscordSRV +import me.arasple.mc.trchat.module.internal.hook.impl.HookItemsAdder +import me.arasple.mc.trchat.module.internal.hook.type.HookVanish +import org.bukkit.Bukkit +import org.bukkit.OfflinePlayer +import taboolib.common.util.unsafeLazy +import java.util.* + +val hookDiscordSRV by unsafeLazy { HookPlugin.registry.filterIsInstance().first() } +val hookItemsAdder by unsafeLazy { HookPlugin.registry.filterIsInstance().first() } + +fun OfflinePlayer.isVanished(): Boolean { + HookPlugin.registry.filterIsInstance().forEach { + if (it.isVanished(this)) return true + } + return false +} + +fun UUID.isVanished(): Boolean { + return Bukkit.getOfflinePlayer(this).isVanished() +} + +fun String.isVanished(): Boolean { + return Bukkit.getOfflinePlayer(this).isVanished() +} \ No newline at end of file diff --git a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookDiscordSRV.kt b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookDiscordSRV.kt index 43fb1429..af6d1996 100644 --- a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookDiscordSRV.kt +++ b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookDiscordSRV.kt @@ -1,8 +1,11 @@ package me.arasple.mc.trchat.module.internal.hook.impl import github.scarsz.discordsrv.DiscordSRV +import me.arasple.mc.trchat.module.internal.hook.Hook import me.arasple.mc.trchat.module.internal.hook.HookAbstract +import taboolib.common.platform.Platform +@Hook([Platform.BUKKIT]) class HookDiscordSRV : HookAbstract() { fun registerListener(listener: Any) { diff --git a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookEcoEnchants.kt b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookEcoEnchants.kt index 0e477ee3..9aa0d068 100644 --- a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookEcoEnchants.kt +++ b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookEcoEnchants.kt @@ -1,15 +1,18 @@ package me.arasple.mc.trchat.module.internal.hook.impl import com.willfp.eco.core.display.Display +import me.arasple.mc.trchat.module.internal.hook.Hook import me.arasple.mc.trchat.module.internal.hook.type.HookDisplayItem import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack +import taboolib.common.platform.Platform import taboolib.platform.util.isAir /** * @author ItsFlicker * @since 2022/2/5 22:30 */ +@Hook([Platform.BUKKIT]) class HookEcoEnchants : HookDisplayItem() { override fun displayItem(item: ItemStack, player: Player): ItemStack { diff --git a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookItemsAdder.kt b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookItemsAdder.kt index fd08f66e..acff96b6 100644 --- a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookItemsAdder.kt +++ b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookItemsAdder.kt @@ -1,13 +1,16 @@ package me.arasple.mc.trchat.module.internal.hook.impl import dev.lone.itemsadder.api.FontImages.FontImageWrapper +import me.arasple.mc.trchat.module.internal.hook.Hook import me.arasple.mc.trchat.module.internal.hook.HookAbstract import org.bukkit.entity.Player +import taboolib.common.platform.Platform /** * @author ItsFlicker * @since 2022/2/5 22:30 */ +@Hook([Platform.BUKKIT]) class HookItemsAdder : HookAbstract() { fun replaceFontImages(message: String, player: Player?): String { diff --git a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookNova.kt b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookNova.kt index b4f4b6d2..ba260c1c 100644 --- a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookNova.kt +++ b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookNova.kt @@ -1,8 +1,10 @@ package me.arasple.mc.trchat.module.internal.hook.impl +import me.arasple.mc.trchat.module.internal.hook.Hook import me.arasple.mc.trchat.module.internal.hook.type.HookDisplayItem import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack +import taboolib.common.platform.Platform import taboolib.common.platform.function.adaptPlayer import taboolib.library.xseries.XMaterial import taboolib.module.lang.getLocale @@ -10,6 +12,7 @@ import taboolib.platform.util.buildItem import taboolib.platform.util.isAir import xyz.xenondevs.nova.api.Nova +@Hook([Platform.BUKKIT]) class HookNova : HookDisplayItem() { override fun displayItem(item: ItemStack, player: Player): ItemStack { diff --git a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookSayanVanish.kt b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookSayanVanish.kt new file mode 100644 index 00000000..b052ce4a --- /dev/null +++ b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/impl/HookSayanVanish.kt @@ -0,0 +1,19 @@ +package me.arasple.mc.trchat.module.internal.hook.impl + +import me.arasple.mc.trchat.module.internal.hook.Hook +import me.arasple.mc.trchat.module.internal.hook.type.HookVanish +import org.bukkit.OfflinePlayer +import org.sayandev.sayanvanish.bukkit.api.SayanVanishBukkitAPI.Companion.user +import taboolib.common.platform.Platform + +@Hook([Platform.BUKKIT]) +class HookSayanVanish : HookVanish() { + + override fun isVanished(player: OfflinePlayer): Boolean { + if (!isHooked) { + return false + } + return player.user()?.isVanished ?: return false + } + +} \ No newline at end of file diff --git a/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/type/HookVanish.kt b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/type/HookVanish.kt new file mode 100644 index 00000000..ce81b10f --- /dev/null +++ b/project/module-compat/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/type/HookVanish.kt @@ -0,0 +1,9 @@ +package me.arasple.mc.trchat.module.internal.hook.type + +import me.arasple.mc.trchat.module.internal.hook.HookAbstract +import org.bukkit.OfflinePlayer + +abstract class HookVanish : HookAbstract() { + + abstract fun isVanished(player: OfflinePlayer): Boolean +} \ No newline at end of file diff --git a/project/module-nms/build.gradle.kts b/project/module-nms/build.gradle.kts index b028f4e5..534c4423 100644 --- a/project/module-nms/build.gradle.kts +++ b/project/module-nms/build.gradle.kts @@ -1,7 +1,7 @@ dependencies { compileOnly(project(":project:common")) // compileOnly(project(":project:module-chat")) -// compileOnly("ink.ptms.core:v12105:12105:mapped") +// compileOnly("ink.ptms.core:v12107:12107:mapped") // compileOnly("ink.ptms.core:v12005:12005:mapped") compileOnly("ink.ptms.core:v12004:12004:mapped") compileOnly("ink.ptms.core:v12002:12002:mapped") diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/impl/BukkitProxyManager.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/impl/BukkitProxyManager.kt index 308ccf35..20983c37 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/impl/BukkitProxyManager.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/impl/BukkitProxyManager.kt @@ -4,7 +4,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder import me.arasple.mc.trchat.api.ClientMessageManager import me.arasple.mc.trchat.api.ProxyMode import me.arasple.mc.trchat.module.conf.file.Settings -import me.arasple.mc.trchat.module.internal.data.PlayerData +import me.arasple.mc.trchat.module.internal.hook.isVanished import me.arasple.mc.trchat.module.internal.proxy.BukkitProxyProcessor import me.arasple.mc.trchat.module.internal.proxy.redis.RedisManager import me.arasple.mc.trchat.util.parseString @@ -39,13 +39,11 @@ object BukkitProxyManager : ClientMessageManager { override var port = 25565 - var allPlayerNames = mapOf() + var allPlayerNames = listOf>() get() = if (mode == ProxyMode.NONE) { - onlinePlayers.associate { it.name to ChatColor.stripColor(it.displayName) } + onlinePlayers.map { Triple(it.name, ChatColor.stripColor(it.displayName), it.uniqueId) } } else if (mode == ProxyMode.REDIS) { - val result = mutableMapOf() - (processor as BukkitProxyProcessor.RedisSide).allNames.values.forEach { result += it } - result + (processor as BukkitProxyProcessor.RedisSide).allNames.values.flatten() } else { field } @@ -111,12 +109,16 @@ object BukkitProxyManager : ClientMessageManager { executor.shutdownNow() } - override fun getPlayerNames(): Map { - return allPlayerNames + override fun getPlayerNames(includeVanish: Boolean): Map { + return if (includeVanish) { + allPlayerNames.associate { it.first to it.second } + } else { + allPlayerNames.filterNot { it.third.isVanished() }.associate { it.first to it.second } + } } - fun getPlayerNamesMerged(): Set { - return allPlayerNames.let { it.keys + it.values.filterNotNull() } + fun getPlayerNamesMerged(includeVanish: Boolean = false): Set { + return getPlayerNames(includeVanish).let { it.keys + it.values.filterNotNull() } } override fun getExactName(name: String): String? { @@ -168,8 +170,10 @@ object BukkitProxyManager : ClientMessageManager { fun updateNames() { sendMessage(onlinePlayers.firstOrNull(), arrayOf( "UpdateNames", - onlinePlayers.filter { it.name !in PlayerData.vanishing }.joinToString(",") { it.name + "-" + ChatColor.stripColor(it.displayName) }, - port.toString() + port.toString(), + onlinePlayers.joinToString(",") { it.name }, + onlinePlayers.joinToString(",") { ChatColor.stripColor(it.displayName)?.ifEmpty { "#" } ?: "#" }, + onlinePlayers.joinToString(",") { it.uniqueId.parseString() } )) } diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/channel/Channel.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/channel/Channel.kt index 612db45e..623befce 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/channel/Channel.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/channel/Channel.kt @@ -15,10 +15,7 @@ import org.bukkit.command.CommandSender import org.bukkit.entity.Player import taboolib.common.platform.command.PermissionDefault import taboolib.common.platform.command.command -import taboolib.common.platform.function.adaptPlayer -import taboolib.common.platform.function.console -import taboolib.common.platform.function.getProxyPlayer -import taboolib.common.platform.function.unregisterCommand +import taboolib.common.platform.function.* import taboolib.common.util.Strings import taboolib.common.util.subList import taboolib.module.chat.ComponentText @@ -58,31 +55,33 @@ open class Channel( open fun registerCommand() { if (bindings.command.isNullOrEmpty()) return - command( - name = bindings.command[0], - aliases = subList(bindings.command, 1), - description = "TrChat channel $id", - permission = "trchat.command.channel.${id.lowercase()}", - permissionDefault = PermissionDefault.TRUE - ) { - execute { sender, _, _ -> - if (sender.session.channel == this@Channel.id) { - quit(sender, setDefault = true) - } else { - join(sender, this@Channel) - } - } - dynamic("message", optional = true) { - execute { sender, _, argument -> - if (sender is Player) { - execute(sender, argument) + submit { + command( + name = bindings.command[0], + aliases = subList(bindings.command, 1), + description = "TrChat channel $id", + permission = "trchat.command.channel.${id.lowercase()}", + permissionDefault = PermissionDefault.TRUE + ) { + execute { sender, _, _ -> + if (sender.session.channel == this@Channel.id) { + quit(sender, setDefault = true) } else { - execute(sender, argument) + join(sender, this@Channel) } } - } - incorrectSender { sender, _ -> - sender.sendLang("Command-Not-Player") + dynamic("message", optional = true) { + execute { sender, _, argument -> + if (sender is Player) { + execute(sender, argument) + } else { + execute(sender, argument) + } + } + } + incorrectSender { sender, _ -> + sender.sendLang("Command-Not-Player") + } } } } @@ -237,7 +236,7 @@ open class Channel( } if (!player.hasPermission("trchat.bypass.repeat")) { val lastMessage = player.session.lastPublicMessage - if (Settings.chatSimilarity > 0 && Strings.similarDegree(lastMessage, message) > Settings.chatSimilarity) { + if (Settings.chatSimilarity > 0 && Settings.chatSimilarity <= 1 && Strings.similarDegree(lastMessage, message) >= Settings.chatSimilarity) { player.sendLang("General-Too-Similar") return false } @@ -257,7 +256,9 @@ open class Channel( } open fun unregister() { - bindings.command?.forEach { unregisterCommand(it) } + submit { + bindings.command?.forEach { unregisterCommand(it) } + } listeners.clear() } diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/channel/PrivateChannel.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/channel/PrivateChannel.kt index 40941b19..6588ea28 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/channel/PrivateChannel.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/channel/PrivateChannel.kt @@ -20,9 +20,9 @@ import org.bukkit.command.CommandSender import org.bukkit.entity.Player import taboolib.common.platform.command.PermissionDefault import taboolib.common.platform.command.command -import taboolib.common.platform.command.suggest import taboolib.common.platform.function.console import taboolib.common.platform.function.getProxyPlayer +import taboolib.common.platform.function.submit import taboolib.common.util.subList import taboolib.module.chat.ComponentText import taboolib.module.chat.Components @@ -55,41 +55,43 @@ class PrivateChannel( override fun registerCommand() { if (bindings.command.isNullOrEmpty()) return - command( - name = bindings.command[0], - aliases = subList(bindings.command, 1), - description = "TrChat channel $id", - permission = "trchat.command.channel.${id.lowercase()}", - permissionDefault = PermissionDefault.TRUE - ) { - execute { sender, _, _ -> - if (sender.session.channel == this@PrivateChannel.id) { - quit(sender, true) - } else { - sender.sendLang("Private-Message-No-Player") - } - } - dynamic("player", optional = true) { - suggest { - BukkitProxyManager.getPlayerNamesMerged().filter { it !in PlayerData.vanishing } - } - execute { sender, _, argument -> - sender.session.lastPrivateTo = BukkitProxyManager.getExactName(argument) - ?: return@execute sender.sendLang("Command-Player-Not-Exist") - join(sender, this@PrivateChannel) + submit { + command( + name = bindings.command[0], + aliases = subList(bindings.command, 1), + description = "TrChat channel $id", + permission = "trchat.command.channel.${id.lowercase()}", + permissionDefault = PermissionDefault.TRUE + ) { + execute { sender, _, _ -> + if (sender.session.channel == this@PrivateChannel.id) { + quit(sender, true) + } else { + sender.sendLang("Private-Message-No-Player") + } } - dynamic("message", optional = true) { - execute { sender, ctx, argument -> - BukkitProxyManager.getExactName(ctx["player"])?.let { - if (sender is Player) sender.session.lastPrivateTo = it - else consolePrivateTo = it - execute(sender, argument) - } ?: sender.sendLang("Command-Player-Not-Exist") + dynamic("player", optional = true) { + suggestion { sender, _ -> + BukkitProxyManager.getPlayerNamesMerged(sender.hasPermission("trchat.bypass.vanish")).toList() + } + execute { sender, _, argument -> + sender.session.lastPrivateTo = BukkitProxyManager.getExactName(argument) + ?: return@execute sender.sendLang("Command-Player-Not-Exist") + join(sender, this@PrivateChannel) + } + dynamic("message", optional = true) { + execute { sender, ctx, argument -> + BukkitProxyManager.getExactName(ctx["player"])?.let { + if (sender is Player) sender.session.lastPrivateTo = it + else consolePrivateTo = it + execute(sender, argument) + } ?: sender.sendLang("Command-Player-Not-Exist") + } } } - } - incorrectSender { sender, _ -> - sender.sendLang("Command-Not-Player") + incorrectSender { sender, _ -> + sender.sendLang("Command-Not-Player") + } } } } diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/obj/Text.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/obj/Text.kt index 43e794a0..4177d984 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/obj/Text.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/obj/Text.kt @@ -1,6 +1,6 @@ package me.arasple.mc.trchat.module.display.format.obj -import me.arasple.mc.trchat.module.internal.hook.HookPlugin +import me.arasple.mc.trchat.module.internal.hook.hookItemsAdder import me.arasple.mc.trchat.module.internal.script.Condition import me.arasple.mc.trchat.module.internal.script.kether.KetherHandler import me.arasple.mc.trchat.util.color.colorify @@ -27,7 +27,7 @@ class Text(val content: String, val condition: Condition?) { if (dynamic) { text = text.setPlaceholders(sender) } - text = HookPlugin.getItemsAdder().replaceFontImages(text, null) + text = hookItemsAdder.replaceFontImages(text, null) } text = text.replaceWithOrder(*vars).colorify() return if (isDragonCoreHooked) { diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/Mention.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/Mention.kt index 7900f76a..d2e862dc 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/Mention.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/Mention.kt @@ -5,7 +5,6 @@ import me.arasple.mc.trchat.api.impl.BukkitProxyManager import me.arasple.mc.trchat.module.conf.file.Functions import me.arasple.mc.trchat.module.display.function.Function import me.arasple.mc.trchat.module.display.function.StandardFunction -import me.arasple.mc.trchat.module.internal.data.PlayerData import me.arasple.mc.trchat.module.internal.script.Reaction import me.arasple.mc.trchat.util.CooldownType import me.arasple.mc.trchat.util.isInCooldown @@ -86,8 +85,8 @@ object Mention : Function("MENTION") { } fun getRegex(player: Player): Regex? { - val names = BukkitProxyManager.getPlayerNames().keys - .filter { (selfMention || it != player.name) && it !in PlayerData.vanishing } + val names = BukkitProxyManager.getPlayerNames(player.hasPermission("trchat.bypass.vanish")).keys + .filter { (selfMention || it != player.name) } .takeIf { it.isNotEmpty() } ?.sortedByDescending { it.length } ?.joinToString("|") { Regex.escape(it) } diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/CommandHandler.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/CommandHandler.kt index 0dba82f4..0b7b222d 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/CommandHandler.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/CommandHandler.kt @@ -68,7 +68,7 @@ object CommandHandler { val tellsimple = subCommand { dynamic("player") { suggest { - BukkitProxyManager.getPlayerNamesMerged().toList() + "*" + BukkitProxyManager.getPlayerNamesMerged(includeVanish = true).toList() + "*" } dynamic("message") { execute { sender, ctx, argument -> @@ -98,13 +98,6 @@ object CommandHandler { } } - @CommandBody(permission = "trchat.command.vanish", optional = true) - val vanish = subCommand { - execute { sender, _, _ -> - sender.data.switchVanish() - } - } - @CommandBody(permission = "trchat.command.reload", optional = true) val reload = subCommand { execute { sender, _, _ -> diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandChannel.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandChannel.kt index 0760eeae..08a6b841 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandChannel.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandChannel.kt @@ -8,6 +8,7 @@ import taboolib.common.platform.Awake import taboolib.common.platform.Platform import taboolib.common.platform.PlatformSide import taboolib.common.platform.command.command +import taboolib.common.platform.command.suggest import taboolib.expansion.createHelper import taboolib.module.lang.sendLang @@ -24,7 +25,7 @@ object CommandChannel { command("channel", listOf("chatchannel", "trchannel"), "TrChat Channel", permission = "trchat.command.channel") { literal("join") { dynamic("channel") { - suggestion { _, _ -> + suggest { Channel.channels.keys.toList() } execute { sender, _, argument -> diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandIgnore.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandIgnore.kt index 507dca0a..e2d8a4b9 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandIgnore.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandIgnore.kt @@ -2,7 +2,6 @@ package me.arasple.mc.trchat.module.internal.command.main import me.arasple.mc.trchat.api.impl.BukkitProxyManager import me.arasple.mc.trchat.module.conf.file.Settings -import me.arasple.mc.trchat.module.internal.data.PlayerData import me.arasple.mc.trchat.util.data import org.bukkit.Bukkit import org.bukkit.entity.Player @@ -12,7 +11,6 @@ import taboolib.common.platform.Platform import taboolib.common.platform.PlatformSide import taboolib.common.platform.command.bool import taboolib.common.platform.command.command -import taboolib.common.platform.command.suggest import taboolib.expansion.createHelper import taboolib.module.lang.sendLang import taboolib.platform.util.sendLang @@ -29,8 +27,8 @@ object CommandIgnore { if (Settings.conf.getStringList("Options.Disabled-Commands").contains("ignore")) return command("ignore", listOf("trignore"), permission = "trchat.command.ignore") { dynamic("player") { - suggest { - BukkitProxyManager.getPlayerNames().keys.filter { it !in PlayerData.vanishing } + suggestion { sender, _ -> + BukkitProxyManager.getPlayerNames(sender.hasPermission("trchat.bypass.vanish")).keys.toList() } execute { sender, ctx, _ -> val player = Bukkit.getOfflinePlayer(ctx["player"]) diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandMute.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandMute.kt index 3ee373ee..53ba498a 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandMute.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandMute.kt @@ -43,7 +43,7 @@ object CommandMute { } dynamic("time") { suggestUncheck { - listOf("1h", "2d", "15m") + listOf("1d", "3h", "15m", "30s") } execute { sender, ctx, _ -> mute(sender, ctx["player"], ctx["time"], "null") @@ -79,7 +79,12 @@ object CommandMute { val player = Bukkit.getPlayer(name) ?: return sender.sendLang("Command-Player-Not-Exist") val data = player.data - data.updateMuteTime(time.parseMillis()) + val millis = try { + time.parseMillis() + } catch (_: Throwable) { + return sender.sendLang("Mute-Wrong-Format", time) + } + data.updateMuteTime(millis) data.setMuteReason(reason) sender.sendLang("Mute-Muted-Player", player.name, time, reason) player.sendLang("General-Muted", muteDateFormat.format(data.muteTime), data.muteReason) diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/data/PlayerData.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/data/PlayerData.kt index 14e43e28..4029f8ec 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/data/PlayerData.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/data/PlayerData.kt @@ -17,7 +17,6 @@ import java.util.concurrent.ConcurrentHashMap class PlayerData(val player: Player) { init { - if (isVanishing) vanishing += player.name if (isSpying) spying += player.name } @@ -33,8 +32,6 @@ class PlayerData(val player: Player) { val muteReason get() = player.getDataContainer()["mute_reason"] ?: "null" - val isVanishing get() = player.getDataContainer()["vanish"].cbool - val ignored get() = player.getDataContainer()["ignored"] ?.takeIf { it.isNotBlank() } ?.split(",") @@ -68,13 +65,6 @@ class PlayerData(val player: Player) { } } - fun switchVanish(): Boolean { - player.getDataContainer()["vanish"] = !isVanishing - return isVanishing.also { - if (it) vanishing += player.name else vanishing -= player.name - } - } - fun addIgnored(uuid: UUID) { val list = player.getDataContainer()["ignored"]?.takeIf { it.isNotBlank() }?.split(",") ?: listOf() val new = list + uuid.parseString() @@ -106,9 +96,7 @@ class PlayerData(val player: Player) { @JvmField val data = ConcurrentHashMap() - val spying = mutableSetOf() - val vanishing = mutableSetOf() fun getData(player: Player): PlayerData { return data.computeIfAbsent(player.uniqueId) { diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/ext/HookPlaceholderAPI.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/ext/HookPlaceholderAPI.kt index 3182609e..ecd0aac5 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/ext/HookPlaceholderAPI.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/hook/ext/HookPlaceholderAPI.kt @@ -2,6 +2,7 @@ package me.arasple.mc.trchat.module.internal.hook.ext import me.arasple.mc.trchat.api.event.TrChatEvent import me.arasple.mc.trchat.module.internal.command.main.CommandMute +import me.arasple.mc.trchat.module.internal.hook.isVanished import me.arasple.mc.trchat.util.PAPIUtil import me.arasple.mc.trchat.util.data import me.arasple.mc.trchat.util.session @@ -48,7 +49,7 @@ object HookPlaceholderAPI : PlaceholderExpansion { "mute" -> data.isMuted "mutetime" -> CommandMute.muteDateFormat.format(data.muteTime) "mutereason" -> data.muteReason - "vanish" -> data.isVanishing + "vanish" -> player.isVanished() "ignore" -> data.hasIgnored(Bukkit.getOfflinePlayer(params[1]).uniqueId) else -> "out of case" }.toString() diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerDiscordSRV.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerDiscordSRV.kt index 21f3b080..0cfb8fa2 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerDiscordSRV.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerDiscordSRV.kt @@ -6,7 +6,7 @@ import github.scarsz.discordsrv.api.events.GameChatMessagePreProcessEvent import github.scarsz.discordsrv.dependencies.kyori.adventure.text.serializer.gson.GsonComponentSerializer import me.arasple.mc.trchat.TrChat import me.arasple.mc.trchat.module.display.format.MsgComponent -import me.arasple.mc.trchat.module.internal.hook.HookPlugin +import me.arasple.mc.trchat.module.internal.hook.hookDiscordSRV import me.arasple.mc.trchat.util.pass import me.arasple.mc.trchat.util.session import org.bukkit.entity.Player @@ -50,8 +50,8 @@ class ListenerDiscordSRV { @Awake(LifeCycle.ACTIVE) fun register() { - if (HookPlugin.getDiscordSRV().isHooked) { - HookPlugin.getDiscordSRV().registerListener(ListenerDiscordSRV()) + if (hookDiscordSRV.isHooked) { + hookDiscordSRV.registerListener(ListenerDiscordSRV()) } } } diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerPackets.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerPackets.kt index 2e86af54..fc0b1da4 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerPackets.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerPackets.kt @@ -18,7 +18,7 @@ import taboolib.module.nms.PacketSendEvent object ListenerPackets { @ConfigNode("Options.Cheat-Client-Secure-Chat", "settings.yml") - var cheatClientSecureChat = true + var cheatClientSecureChat = false private set /** diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerSignChange.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerSignChange.kt index b2abb3d9..5a062cbe 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerSignChange.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerSignChange.kt @@ -37,9 +37,12 @@ object ListenerSignChange { fun onSignChange(e: SignChangeEvent) { val p = e.player - for (index in e.lines.indices) { + var index = -1 + for (origin in e.lines) { + index++ + if (origin.isBlank()) continue if (filter) { - e.setLine(index, TrChat.api().getFilterManager().filter(e.getLine(index) ?: "", adaptPlayer(p)).filtered) + e.setLine(index, TrChat.api().getFilterManager().filter(origin, adaptPlayer(p)).filtered) } if (simple && TrChatBukkit.isPaperEnv && p.hasPermission("trchat.simple.sign")) { e.line(index, (e.getLine(index) ?: "").parseSimple().toAdventure()) diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerTabComplete.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerTabComplete.kt index 7b31f33b..d34ea062 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerTabComplete.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerTabComplete.kt @@ -16,6 +16,7 @@ import taboolib.module.configuration.ConfigNode */ @PlatformSide(Platform.BUKKIT) object ListenerTabComplete { + @ConfigNode("Options.Prevent-Tab-Complete", "settings.yml") var enabled = false private set diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/proxy/BukkitProxyProcessor.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/proxy/BukkitProxyProcessor.kt index 9987c14c..3568f0a4 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/proxy/BukkitProxyProcessor.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/proxy/BukkitProxyProcessor.kt @@ -33,6 +33,7 @@ import taboolib.platform.util.bukkitPlugin import taboolib.platform.util.deserializeToInventory import taboolib.platform.util.onlinePlayers import java.io.IOException +import java.util.* import java.util.concurrent.ExecutorService import java.util.concurrent.Future @@ -101,9 +102,11 @@ sealed interface BukkitProxyProcessor : PluginMessageListener { "UpdateAllNames" -> { BukkitProxyManager.updateNames() val names = data[1].takeIf { it != "" }?.split(",") ?: return - BukkitProxyManager.allPlayerNames = data[2].split(",").mapIndexed { index, displayName -> - names[index] to displayName.takeIf { it != "null" } - }.toMap() + val displayNames = data[2].split(",") + val uuids = data[3].split(",") + BukkitProxyManager.allPlayerNames = names.mapIndexed { index, name -> + Triple(names[index], displayNames[index].takeIf { it != "#" }, uuids[index].toUUID()) + } } "GlobalMute" -> { when (data[1]) { @@ -230,7 +233,7 @@ sealed interface BukkitProxyProcessor : PluginMessageListener { object RedisSide : BukkitProxyProcessor { - val allNames = mutableMapOf>() + val allNames = mutableMapOf>>() init { submitAsync(period = 200L) { @@ -241,9 +244,13 @@ sealed interface BukkitProxyProcessor : PluginMessageListener { override fun execute(data: Array) { when (data[0]) { "UpdateNames" -> { - val port = data[2].toInt() - val names = data[1].takeIf { it != "" }?.split(",")?.map { it.split("-", limit = 2) } ?: return - allNames[port] = names.associate { it[0] to it[1].takeIf { dn -> dn != "null" } } + val port = data[1].toInt() + val names = data[2].split(",") + val displayNames = data[3].split(",") + val uuids = data[4].split(",") + allNames[port] = names.mapIndexed { index, name -> + Triple(name, displayNames[index].takeIf { it != "#" }, uuids[index].toUUID()) + } } else -> super.execute(data) } diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/color/MessageColors.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/color/MessageColors.kt index 10136e38..8dea9f83 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/color/MessageColors.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/color/MessageColors.kt @@ -13,57 +13,70 @@ object MessageColors { const val COLOR_PERMISSION_NODE = "trchat.color." const val FORCE_CHAT_COLOR_PERMISSION_NODE = "trchat.color.force-defaultcolor." + private val STRIP_COLOR_PATTERN = Regex("&[0-9A-FK-ORX]", RegexOption.IGNORE_CASE) private val specialColors = arrayOf( "simple", "rainbow", "gradients", "hex", + "legacy", + "chat", "anvil", "sign", "book" ) @JvmOverloads - fun replaceWithPermission(sender: CommandSender, strings: List, type: Type = Type.DEFAULT): List { + fun replaceWithPermission(sender: CommandSender, strings: List, type: Type = Type.CHAT): List { return strings.map { replaceWithPermission(sender, it, type) } } @JvmOverloads - fun replaceWithPermission(sender: CommandSender, s: String, type: Type = Type.DEFAULT): String { + fun replaceWithPermission(sender: CommandSender, s: String, type: Type = Type.CHAT): String { var string = s - if (type == Type.ANVIL && sender.hasPermission("trchat.color.anvil.*")) { - return string.colorify() - } - if (type == Type.SIGN && sender.hasPermission("trchat.color.sign.*")) { - return string.colorify() - } - if (type == Type.BOOK && sender.hasPermission("trchat.color.book.*")) { - return string.colorify() - } + string = replaceWithPermission(sender, string, COLOR_PERMISSION_NODE) + string = replaceWithPermission(sender, string, type.node) + + return string + } - if (sender.hasPermission("$COLOR_PERMISSION_NODE*")) { - return string.colorify() + private fun replaceWithPermission(sender: CommandSender, s: String, node: String): String { + if (sender.hasPermission("$node*")) { + return s.colorify() } + var string = s - // 2025/6/18 https://github.com/TrPlugins/TrChat/issues/477 - if (sender.hasPermission(COLOR_PERMISSION_NODE + "rainbow")) { - string = string.parseRainbow() + // 2025/7/14 必须清除无权限的颜色,否则会被CustomColor连带处理 + string = if (sender.hasPermission(node + "rainbow")) { + string.parseRainbow() + } else { + string.replace(HexUtils.RAINBOW_PATTERN.toRegex(), "") } - if (sender.hasPermission(COLOR_PERMISSION_NODE + "gradients")) { - string = string.parseGradients() + string = if (sender.hasPermission(node + "gradients")) { + string.parseGradients() + } else { + string.replace(HexUtils.GRADIENT_PATTERN.toRegex(), "") } - if (sender.hasPermission(COLOR_PERMISSION_NODE + "hex")) { + if (sender.hasPermission(node + "hex")) { string = string.parseHex() + } else { + HexUtils.HEX_PATTERNS.forEach { string = string.replace(it.toRegex(), "") } } getColors(sender).forEach { color -> string = string.replace(color, CustomColor.get(color).color) } + string = if (sender.hasPermission(node + "legacy")) { + string.parseLegacy() + } else { + string.replace(STRIP_COLOR_PATTERN, "") + } + return string } @@ -76,7 +89,7 @@ object MessageColors { } else { null } - }.filterNot { it in specialColors } + }.filter { it !in specialColors } } fun getColors(sender: CommandSender): List { @@ -87,8 +100,10 @@ object MessageColors { return getColorsFromPermissions(sender, FORCE_CHAT_COLOR_PERMISSION_NODE) } - enum class Type { - - DEFAULT, ANVIL, SIGN, BOOK + enum class Type(val node: String) { + CHAT(COLOR_PERMISSION_NODE + "chat."), + ANVIL(COLOR_PERMISSION_NODE + "anvil."), + SIGN(COLOR_PERMISSION_NODE + "sign."), + BOOK(COLOR_PERMISSION_NODE + "book.") } } \ No newline at end of file diff --git a/project/runtime-bukkit/src/main/resources/function.yml b/project/runtime-bukkit/src/main/resources/function.yml index 77b6b78a..3cf0e7a6 100644 --- a/project/runtime-bukkit/src/main/resources/function.yml +++ b/project/runtime-bukkit/src/main/resources/function.yml @@ -56,12 +56,6 @@ General: - '[ender]' - '[enderchest]' Actions: [ ] - Image-Show: - Enabled: true - Permission: 'trchat.function.imageshow' - Cooldown: '1m' - Key: '!\[([^;]*)\]\(([a-zA-Z]+://[^\s]*)\)' - Action: [ ] Custom: # 示例 —— 网站分享 shareUrl: diff --git a/project/runtime-bukkit/src/main/resources/lang/en_US.yml b/project/runtime-bukkit/src/main/resources/lang/en_US.yml index 6f3be5e4..e66de9eb 100644 --- a/project/runtime-bukkit/src/main/resources/lang/en_US.yml +++ b/project/runtime-bukkit/src/main/resources/lang/en_US.yml @@ -229,6 +229,7 @@ Mute-Muted-Player: '&8[&3Tr&bChat&8] &7You muted {0} for {1}.Reason: {2}' Mute-Cancel-Muted-Player: '&8[&3Tr&bChat&8] &7You cancelled muting {0}.' Mute-Muted-All: '&8[&3Tr&bChat&8] &7Global muted.' Mute-Cancel-Muted-All: '&8[&3Tr&bChat&8] &7Global mute canceled.' +Mute-Wrong-Format: '&8[&3Tr&bChat&8] &7{0} is not a correct time!' Ignore-Ignored-Player: '&8[&3Tr&bChat&8] &7Ignored &f{0}''s &7messages.' Ignore-Cancel-Player: '&8[&3Tr&bChat&8] &7Restore receiving &f{0}''s &7messages.' diff --git a/project/runtime-bukkit/src/main/resources/lang/zh_CN.yml b/project/runtime-bukkit/src/main/resources/lang/zh_CN.yml index 1b142ee1..2e2c2f9d 100644 --- a/project/runtime-bukkit/src/main/resources/lang/zh_CN.yml +++ b/project/runtime-bukkit/src/main/resources/lang/zh_CN.yml @@ -232,6 +232,7 @@ Mute-Muted-Player: '&8[&3Tr&bChat&8] &7你已禁言 {0} {1}.原因: {2}' Mute-Cancel-Muted-Player: '&8[&3Tr&bChat&8] &7你已取消禁言 {0}.' Mute-Muted-All: '&8[&3Tr&bChat&8] &7全员禁言已开启.' Mute-Cancel-Muted-All: '&8[&3Tr&bChat&8] &7全员禁言已关闭.' +Mute-Wrong-Format: '&8[&3Tr&bChat&8] &7{0} 不是正确的时间!' Ignore-Ignored-Player: '&8[&3Tr&bChat&8] &7你已屏蔽 &f{0} &7的聊天.' Ignore-Cancel-Player: '&8[&3Tr&bChat&8] &7你已取消屏蔽 &f{0} &7的聊天.' diff --git a/project/runtime-bukkit/src/main/resources/settings.yml b/project/runtime-bukkit/src/main/resources/settings.yml index d614de80..fdf2282a 100644 --- a/project/runtime-bukkit/src/main/resources/settings.yml +++ b/project/runtime-bukkit/src/main/resources/settings.yml @@ -8,7 +8,7 @@ Options: Prevent-Tab-Complete: false Component-Max-Length: 32700 Always-Cancel-Chat-Event: false - Cheat-Client-Secure-Chat: true + Cheat-Client-Secure-Chat: false Use-Packets: true Disabled-Commands: [] diff --git a/project/runtime-bungee/src/main/kotlin/me/arasple/mc/trchat/api/impl/BungeeProxyManager.kt b/project/runtime-bungee/src/main/kotlin/me/arasple/mc/trchat/api/impl/BungeeProxyManager.kt index f08d70ee..dbeeff33 100644 --- a/project/runtime-bungee/src/main/kotlin/me/arasple/mc/trchat/api/impl/BungeeProxyManager.kt +++ b/project/runtime-bungee/src/main/kotlin/me/arasple/mc/trchat/api/impl/BungeeProxyManager.kt @@ -36,7 +36,7 @@ object BungeeProxyManager : ProxyMessageManager { Executors.newFixedThreadPool(8, factory) } - override val allNames = mutableMapOf>() + override val allNames = mutableMapOf>>() override fun sendMessage(recipient: Any, vararg args: String): Future<*> { if (recipient !is ServerInfo) { @@ -70,10 +70,12 @@ object BungeeProxyManager : ProxyMessageManager { @Schedule(async = true, period = 100L) override fun updateAllNames() { + val flat = allNames.values.flatten() sendMessageToAll( "UpdateAllNames", - allNames.values.joinToString(",") { it.keys.joinToString(",") }, - allNames.values.joinToString(",") { it.values.joinToString(",") } + flat.joinToString(",") { it.first }, + flat.joinToString(",") { it.second }, + flat.joinToString(",") { it.third }, ) } diff --git a/project/runtime-bungee/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerBungeeTransfer.kt b/project/runtime-bungee/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerBungeeTransfer.kt index 3a0cb2fa..53243cb0 100644 --- a/project/runtime-bungee/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerBungeeTransfer.kt +++ b/project/runtime-bungee/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerBungeeTransfer.kt @@ -58,7 +58,7 @@ object ListenerBungeeTransfer { val ports = data[5].takeIf { it != "" }?.split(";")?.map { it.toInt() } val message = try { Components.parseRaw(raw).also { it.sendTo(console()) } - } catch (e: Throwable) { + } catch (_: Throwable) { Components.text("Unable to parse raw message!") } @@ -77,8 +77,12 @@ object ListenerBungeeTransfer { } } "UpdateNames" -> { - val names = data[1].split(",").map { it.split("-", limit = 2) } - BungeeProxyManager.allNames[connection.address.port] = names.associate { it[0] to it[1].takeIf { dn -> dn != "null" } } + val names = data[2].split(",") + val displayNames = data[3].split(",") + val uuids = data[4].split(",") + BungeeProxyManager.allNames[connection.address.port] = names.mapIndexed { index, name -> + Triple(name, displayNames[index], uuids[index]) + } } } } diff --git a/project/runtime-velocity/build.gradle.kts b/project/runtime-velocity/build.gradle.kts index d1968f4a..5225c748 100644 --- a/project/runtime-velocity/build.gradle.kts +++ b/project/runtime-velocity/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile dependencies { @@ -12,8 +13,8 @@ java { } tasks.withType { - kotlinOptions { - jvmTarget = "17" + compilerOptions { + jvmTarget = JvmTarget.JVM_17 freeCompilerArgs = listOf("-Xjvm-default=all", "-Xextended-compiler-checks") } } diff --git a/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/api/impl/VelocityProxyManager.kt b/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/api/impl/VelocityProxyManager.kt index e8b2938f..606fb29f 100644 --- a/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/api/impl/VelocityProxyManager.kt +++ b/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/api/impl/VelocityProxyManager.kt @@ -42,7 +42,7 @@ object VelocityProxyManager : ProxyMessageManager { Executors.newFixedThreadPool(8, factory) } - override val allNames = mutableMapOf>() + override val allNames = mutableMapOf>>() override fun sendMessage(recipient: Any, vararg args: String): Future<*> { if (recipient !is ChannelMessageSink) { @@ -89,10 +89,12 @@ object VelocityProxyManager : ProxyMessageManager { @Schedule(async = true, period = 100L) override fun updateAllNames() { + val flat = allNames.values.flatten() sendMessageToAll( "UpdateAllNames", - allNames.values.joinToString(",") { it.keys.joinToString(",") }, - allNames.values.joinToString(",") { it.values.joinToString(",") } + flat.joinToString(",") { it.first }, + flat.joinToString(",") { it.second }, + flat.joinToString(",") { it.third }, ) } diff --git a/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerVelocityTransfer.kt b/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerVelocityTransfer.kt index 381ecae7..55071f4f 100644 --- a/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerVelocityTransfer.kt +++ b/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerVelocityTransfer.kt @@ -74,8 +74,12 @@ object ListenerVelocityTransfer { } } "UpdateNames" -> { - val names = data[1].split(",").map { it.split("-", limit = 2) } - VelocityProxyManager.allNames[connection.serverInfo.address.port] = names.associate { it[0] to it[1].takeIf { dn -> dn != "null" } } + val names = data[2].split(",") + val displayNames = data[3].split(",") + val uuids = data[4].split(",") + VelocityProxyManager.allNames[connection.serverInfo.address.port] = names.mapIndexed { index, name -> + Triple(name, displayNames[index], uuids[index]) + } } } } From 1b60fdb5637a9ba0adb0e9c7c33f51aac0979b85 Mon Sep 17 00:00:00 2001 From: YuanYuanOwO <81153017+YuanYuanOwO@users.noreply.github.com> Date: Thu, 24 Jul 2025 17:10:10 +0800 Subject: [PATCH 02/28] Update build.gradle.kts --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 54c4789e..bca67665 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -38,7 +38,7 @@ subprojects { install(Bukkit, BungeeCord, Velocity) } version { - taboolib = "6.2.3-7105e58f" + taboolib = "6.2.3-a372a91" coroutines = null // isSkipKotlin = true // isSkipKotlinRelocate = true From 0c5ef275a88e8760dc3de10db91024dfe5e38240 Mon Sep 17 00:00:00 2001 From: ItsFlicker <1812496278@qq.com> Date: Thu, 24 Jul 2025 21:18:52 +0800 Subject: [PATCH 03/28] =?UTF-8?q?[2.3.7]=201.21.8=20&=20=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=20&=20=E4=BF=AE=E5=A4=8D=20*=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BD=8E=E7=89=88=E6=9C=AC=E9=93=81=E7=A0=A7=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20*=20=E6=96=B0=E5=A2=9EKether=20mute=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C=20*=20=E6=94=AF=E6=8C=81=E7=A6=81=E8=A8=80=E4=B8=8D?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF/=E8=B7=A8=E6=9C=8D=E7=8E=A9=E5=AE=B6=20*=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=BA=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=B7=BB=E5=8A=A0=E5=86=B7=E5=8D=B4=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 2 - gradle.properties | 2 +- plugin/build.gradle.kts | 4 ++ .../kotlin/me/arasple/mc/trchat/util/Util.kt | 9 +++ .../mc/trchat/api/impl/BukkitProxyManager.kt | 2 +- .../arasple/mc/trchat/module/conf/Loader.kt | 7 ++- .../mc/trchat/module/display/ChatSession.kt | 3 +- .../module/display/format/MsgComponent.kt | 2 +- .../module/display/function/CustomFunction.kt | 11 ++++ .../mc/trchat/module/internal/TrChatBukkit.kt | 13 ++--- .../internal/command/main/CommandMute.kt | 53 ++++++++++++----- .../internal/command/main/CommandViews.kt | 2 +- .../trchat/module/internal/data/Databases.kt | 8 +-- .../trchat/module/internal/data/PlayerData.kt | 58 ++++++++++--------- .../internal/listener/ListenerAnvilChange.kt | 4 +- .../internal/listener/ListenerDiscordSRV.kt | 8 +-- .../module/internal/listener/ListenerJoin.kt | 9 +-- .../module/internal/listener/ListenerQuit.kt | 5 -- .../internal/script/kether/KetherActions.kt | 29 ++++++++-- .../me/arasple/mc/trchat/util/BukkitUtil.kt | 8 +-- .../src/main/resources/function.yml | 1 + 21 files changed, 154 insertions(+), 86 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index bca67665..5d07a85e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,8 +40,6 @@ subprojects { version { taboolib = "6.2.3-a372a91" coroutines = null -// isSkipKotlin = true -// isSkipKotlinRelocate = true } } diff --git a/gradle.properties b/gradle.properties index bc6d1399..056dc33d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=me.arasple.mc.trchat -version=2.3.6 +version=2.3.7 kotlin.incremental=true kotlin.incremental.java=true kotlin.incremental.useClasspathSnapshot=true diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 7bc9b481..61fbee6a 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -19,6 +19,10 @@ taboolib { name("Multiverse-Core").with("bukkit").loadafter(true) name("Geyser-Spigot").with("bukkit").loadafter(true) } +// version { +// isSkipKotlin = true +// isSkipKotlinRelocate = true +// } } relocate("com.eatthepath.uuid.", "${rootProject.group}.library.uuid.") // relocate("net.md_5.bungee", "net.md_5.bungee121") diff --git a/project/common/src/main/kotlin/me/arasple/mc/trchat/util/Util.kt b/project/common/src/main/kotlin/me/arasple/mc/trchat/util/Util.kt index 11c1af73..308466ed 100644 --- a/project/common/src/main/kotlin/me/arasple/mc/trchat/util/Util.kt +++ b/project/common/src/main/kotlin/me/arasple/mc/trchat/util/Util.kt @@ -11,6 +11,15 @@ private val reportedErrors = mutableListOf() val nilUUID = UUID(0, 0) val papiRegex = "(%)(.+?)(%)|(:)(.+?)(:)|(?!\\{\")((\\{)(.+?)(}))".toRegex() +fun hasClass(className: String): Boolean { + return try { + Class.forName(className) + true + } catch (_: ClassNotFoundException) { + false + } +} + fun Throwable.print(title: String, printStackTrace: Boolean = true) { console().sendMessage("§c[TrChat] §7$title") console().sendMessage("§7${javaClass.name}: $localizedMessage") diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/impl/BukkitProxyManager.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/impl/BukkitProxyManager.kt index 20983c37..af6fd119 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/impl/BukkitProxyManager.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/impl/BukkitProxyManager.kt @@ -8,8 +8,8 @@ import me.arasple.mc.trchat.module.internal.hook.isVanished import me.arasple.mc.trchat.module.internal.proxy.BukkitProxyProcessor import me.arasple.mc.trchat.module.internal.proxy.redis.RedisManager import me.arasple.mc.trchat.util.parseString +import net.md_5.bungee.api.ChatColor import org.bukkit.Bukkit -import org.bukkit.ChatColor import org.bukkit.plugin.messaging.PluginMessageRecipient import org.spigotmc.SpigotConfig import taboolib.common.platform.Platform diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/conf/Loader.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/conf/Loader.kt index de6f7c58..09754cf1 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/conf/Loader.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/conf/Loader.kt @@ -25,12 +25,14 @@ import taboolib.common.io.newFile import taboolib.common.platform.Platform import taboolib.common.platform.PlatformSide import taboolib.common.platform.ProxyCommandSender +import taboolib.common.platform.function.console import taboolib.common.platform.function.getDataFolder import taboolib.common.platform.function.releaseResourceFile import taboolib.common.util.asList import taboolib.common.util.orNull import taboolib.common.util.unsafeLazy import taboolib.common5.Coerce +import taboolib.common5.util.parseMillis import taboolib.library.configuration.ConfigurationSection import taboolib.module.configuration.util.getMap import taboolib.module.lang.sendLang @@ -196,10 +198,13 @@ object Loader { val priority = map.getInt("priority", 100) val regex = map.getString("pattern")!!.toRegex() val filterTextRegex = map.getString("text-filter")?.toRegex() + val cooldown = kotlin.runCatching { map.getString("cooldown")?.parseMillis() } + .onFailure { console().sendLang("Mute-Wrong-Format", map.getString("cooldown")!!) } + .getOrNull() val displayJson = parseJSON(map.getConfigurationSection("display")!!.toMap(), isMsg = false) val reaction = map["action"]?.let { Reaction(it.asList()) } - CustomFunction(id, condition, priority, regex, filterTextRegex, displayJson, reaction) + CustomFunction(id, condition, priority, regex, filterTextRegex, cooldown, displayJson, reaction) }.sortedBy { it.priority } Function.reload(functions) diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/ChatSession.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/ChatSession.kt index 0194774a..f5afe29f 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/ChatSession.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/ChatSession.kt @@ -8,7 +8,6 @@ import me.arasple.mc.trchat.util.color.CustomColor import me.arasple.mc.trchat.util.color.MessageColors import me.arasple.mc.trchat.util.data import org.bukkit.entity.Player -import taboolib.expansion.getDataContainer import taboolib.library.reflex.Reflex.Companion.getProperty import taboolib.module.chat.ComponentText import taboolib.module.chat.Components @@ -52,7 +51,7 @@ class ChatSession(val player: Player) { return if (forces.isNotEmpty()) { CustomColor.get(forces[0]) } else { - val selectedColor = player.getDataContainer()["color"].takeIf { it != "null" } + val selectedColor = player.data.color if (selectedColor != null && player.hasPermission(MessageColors.COLOR_PERMISSION_NODE + selectedColor)) { CustomColor.get(selectedColor) } else { diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/MsgComponent.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/MsgComponent.kt index 5d5ba8d2..6dfe3890 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/MsgComponent.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/MsgComponent.kt @@ -22,7 +22,7 @@ import taboolib.module.chat.impl.AdventureComponent */ class MsgComponent(val defaultColor: List>, style: List