diff --git a/build.gradle.kts b/build.gradle.kts index ae5340b2..82cfc7d4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,7 +19,7 @@ subprojects { install(BUKKIT_ALL, BUNGEE, VELOCITY) } version { - taboolib = "6.1.1" + taboolib = "6.1.2-beta4" coroutines = null } } diff --git a/gradle.properties b/gradle.properties index f8e1000d..e7351dca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=me.arasple.mc.trchat -version=2.1.1 +version=2.1.2 kotlin.incremental=true kotlin.incremental.java=true kotlin.incremental.useClasspathSnapshot=true diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 5ffe6f23..862b2ba5 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -16,6 +16,7 @@ taboolib { name("ItemsAdder").with("bukkit").optional(true) name("Nova").with("bukkit").optional(true) name("Multiverse-Core").with("bukkit").loadafter(true) + name("Geyser-Spigot").with("bukkit").loadafter(true) } } relocate("com.eatthepath.uuid.", "${rootProject.group}.library.uuid.") diff --git a/project/module-compat/build.gradle.kts b/project/module-compat/build.gradle.kts index 96aecd07..ff9d04c5 100644 --- a/project/module-compat/build.gradle.kts +++ b/project/module-compat/build.gradle.kts @@ -5,7 +5,7 @@ repositories { dependencies { compileOnly(project(":project:common")) - compileOnly("ink.ptms.core:v12004:12004:universal") + compileOnly("ink.ptms.core:v12005:12005:universal") compileOnly("com.discordsrv:discordsrv:1.26.0") { isTransitive = false } compileOnly("com.willfp:eco:6.35.1") { isTransitive = false } diff --git a/project/module-nms/build.gradle.kts b/project/module-nms/build.gradle.kts index 780f90b2..6c7700a3 100644 --- a/project/module-nms/build.gradle.kts +++ b/project/module-nms/build.gradle.kts @@ -1,5 +1,6 @@ dependencies { compileOnly(project(":project:common")) +// compileOnly("ink.ptms.core:v12005:12005:mapped") compileOnly("ink.ptms.core:v12004:12004:mapped") compileOnly("ink.ptms.core:v12002:12002:mapped") compileOnly("ink.ptms.core:v11903:11903:mapped") diff --git a/project/runtime-bukkit/build.gradle.kts b/project/runtime-bukkit/build.gradle.kts index c5c5ae5f..10fd47f2 100644 --- a/project/runtime-bukkit/build.gradle.kts +++ b/project/runtime-bukkit/build.gradle.kts @@ -7,7 +7,7 @@ dependencies { compileOnly(project(":project:module-adventure")) compileOnly(project(":project:module-compat")) compileOnly(project(":project:module-nms")) - compileOnly("ink.ptms.core:v12004:12004:universal") + compileOnly("ink.ptms.core:v12005:12005:universal") compileOnly("net.md-5:bungeecord-api:1.20-R0.1-SNAPSHOT") compileOnly(fileTree(rootDir.resolve("libs"))) diff --git a/project/runtime-bukkit/src/main/java/me/arasple/mc/trchat/util/color/HexUtils.java b/project/runtime-bukkit/src/main/java/me/arasple/mc/trchat/util/color/HexUtils.java index 5e36d118..cffcb4ed 100644 --- a/project/runtime-bukkit/src/main/java/me/arasple/mc/trchat/util/color/HexUtils.java +++ b/project/runtime-bukkit/src/main/java/me/arasple/mc/trchat/util/color/HexUtils.java @@ -206,15 +206,17 @@ public static String parseGradients(String message) { } public static String parseHex(String message) { - if (BukkitUtilKt.isDragonCoreHooked()) - return message; - String parsed = message; for (Pattern pattern : HEX_PATTERNS) { Matcher matcher = pattern.matcher(parsed); while (matcher.find()) { - String color = translateHex(cleanHex(matcher.group())).toString(); + String color; + if (BukkitUtilKt.isDragonCoreHooked()) { + color = 'ยง' + cleanHex(matcher.group()); + } else { + color = translateHex(cleanHex(matcher.group())).toString(); + } String before = parsed.substring(0, matcher.start()); String after = parsed.substring(matcher.end()); parsed = before + color + after; diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/event/TrChatMentionEvent.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/event/TrChatMentionEvent.kt new file mode 100644 index 00000000..609d839a --- /dev/null +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/event/TrChatMentionEvent.kt @@ -0,0 +1,14 @@ +package me.arasple.mc.trchat.api.event + +import org.bukkit.entity.Player +import taboolib.platform.type.BukkitProxyEvent + +class TrChatMentionEvent( + val sender: Player, + val receiver: String +) : BukkitProxyEvent() { + + override val allowCancelled: Boolean + get() = true + +} \ No newline at end of file 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 b531c70e..8f49358f 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 @@ -148,7 +148,7 @@ object Loader { val condition = map["condition"]?.toString()?.toCondition() val priority = Coerce.asInteger(map["priority"]).orNull() ?: 100 val prefix = parseGroups(map["prefix"] as LinkedHashMap<*, *>) - val msg = parseMsg(map["msg"] as LinkedHashMap<*, *>) + val msg = parseGroup(map["msg"], isMsg = true) val suffix = parseGroups(map["suffix"] as? LinkedHashMap<*, *>) Format(condition, priority, prefix, msg, suffix) }.sortedBy { it.priority } @@ -156,13 +156,13 @@ object Loader { val condition = map["condition"]?.toString()?.toCondition() val priority = Coerce.asInteger(map["priority"]).orNull() ?: 100 val prefix = parseGroups(map["prefix"] as LinkedHashMap<*, *>) - val msg = parseMsg(map["msg"] as LinkedHashMap<*, *>) + val msg = parseGroup(map["msg"], isMsg = true) val suffix = parseGroups(map["suffix"] as? LinkedHashMap<*, *>) Format(condition, priority, prefix, msg, suffix) }.sortedBy { it.priority } val console = conf.getMapList("Console").map { map -> val prefix = parseGroups(map["prefix"] as LinkedHashMap<*, *>) - val msg = parseMsg(map["msg"] as LinkedHashMap<*, *>) + val msg = parseGroup(map["msg"], isMsg = true) val suffix = parseGroups(map["suffix"] as? LinkedHashMap<*, *>) Format(null, 100, prefix, msg, suffix) } @@ -173,13 +173,13 @@ object Loader { val condition = map["condition"]?.toString()?.toCondition() val priority = Coerce.asInteger(map["priority"]).orNull() ?: 100 val prefix = parseGroups(map["prefix"] as LinkedHashMap<*, *>) - val msg = parseMsg(map["msg"] as LinkedHashMap<*, *>) + val msg = parseGroup(map["msg"], isMsg = true) val suffix = parseGroups(map["suffix"] as? LinkedHashMap<*, *>) Format(condition, priority, prefix, msg, suffix) }.sortedBy { it.priority } val console = conf.getMapList("Console").map { map -> val prefix = parseGroups(map["prefix"] as LinkedHashMap<*, *>) - val msg = parseMsg(map["msg"] as LinkedHashMap<*, *>) + val msg = parseGroup(map["msg"], isMsg = true) val suffix = parseGroups(map["suffix"] as? LinkedHashMap<*, *>) Format(null, 100, prefix, msg, suffix) } @@ -200,7 +200,7 @@ object Loader { val priority = map.getInt("priority", 100) val regex = map.getString("pattern")!!.toRegex() val filterTextRegex = map.getString("text-filter")?.toRegex() - val displayJson = parseJSON(map.getConfigurationSection("display")!!.toMap()) + 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) @@ -209,44 +209,29 @@ object Loader { Function.reload(functions) } - private fun parseGroups(map: LinkedHashMap<*, *>?): Map> { - map ?: return emptyMap() - return map.map { (id, content) -> - id as String - when (content) { - is Map<*, *> -> { - val condition = content["condition"]?.toString()?.toCondition() - id to listOf(Group(condition, 100, parseJSON(content))) - } - is List<*> -> { - id to content.map { - it as LinkedHashMap<*, *> - val condition = it["condition"]?.toString()?.toCondition() - val priority = Coerce.asInteger(map["priority"]).orNull() ?: 100 - Group(condition, priority, parseJSON(it)) - }.sortedBy { it.priority } - } - else -> error("Unexpected group: $content") - } - }.toMap() + private fun parseGroups(map: LinkedHashMap<*, *>?, isMsg: Boolean = false): Map> { + return map?.map { (id, content) -> (id as String) to parseGroup(content, isMsg) }?.toMap() ?: emptyMap() } - private fun parseJSON(content: Map<*, *>): JsonComponent { - val text = Property.serialize(content["text"] ?: "null").map { Text(it.first, it.second.getCondition()) } - val style = mutableListOf() - style += content["hover"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Hover.Text(it) } - style += content["suggest"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Click.Suggest(it) } - style += content["command"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Click.Command(it) } - style += content["url"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Click.Url(it) } - style += content["copy"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Click.Copy(it) } - style += content["file"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Click.File(it) } - style += content["insertion"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Insertion(it) } - style += content["font"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Font(it) } - return JsonComponent(text, style.filterNotNull()) + private fun parseGroup(content: Any?, isMsg: Boolean = false): List { + return when (content) { + is Map<*, *> -> { + val condition = content["condition"]?.toString()?.toCondition() + listOf(Group(condition, 100, parseJSON(content, isMsg))) + } + is List<*> -> { + content.map { + it as LinkedHashMap<*, *> + val condition = it["condition"]?.toString()?.toCondition() + val priority = Coerce.asInteger(it["priority"]).orNull() ?: 100 + Group(condition, priority, parseJSON(it, isMsg)) + }.sortedBy { it.priority } + } + else -> error("Unexpected group: $content") + } } - private fun parseMsg(content: Map<*, *>): MsgComponent { - val defaultColor = content["default-color"]!!.serialize().map { CustomColor.get(it.first) to it.second.getCondition() } + private fun parseJSON(content: Map<*, *>, isMsg: Boolean = false): JsonComponent { val style = mutableListOf() style += content["hover"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Hover.Text(it) } style += content["suggest"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Click.Suggest(it) } @@ -256,7 +241,13 @@ object Loader { style += content["file"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Click.File(it) } style += content["insertion"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Insertion(it) } style += content["font"]?.serialize()?.map { it.first to it.second.getCondition() }?.let { Style.Font(it) } - return MsgComponent(defaultColor, style.filterNotNull()) + return if (isMsg) { + val defaultColor = content["default-color"]!!.serialize().map { CustomColor.get(it.first) to it.second.getCondition() } + MsgComponent(defaultColor, style.filterNotNull()) + } else { + val text = Property.serialize(content["text"] ?: "null").map { Text(it.first, it.second.getCondition()) } + JsonComponent(text, style.filterNotNull()) + } } private fun filterChannelFiles(file: File): List { 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 79b0896a..1d63c271 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 @@ -6,6 +6,7 @@ import me.arasple.mc.trchat.api.impl.BukkitProxyManager import me.arasple.mc.trchat.module.conf.file.Settings import me.arasple.mc.trchat.module.display.channel.obj.* import me.arasple.mc.trchat.module.display.format.Format +import me.arasple.mc.trchat.module.display.format.MsgComponent import me.arasple.mc.trchat.module.display.function.Function import me.arasple.mc.trchat.module.internal.data.ChatLogs import me.arasple.mc.trchat.module.internal.service.Metrics @@ -105,7 +106,7 @@ open class Channel( consoleFormat.firstOrNull()?.let { format -> format.prefix.forEach { prefix -> component.append(prefix.value[0].content.toTextComponent(sender)) } - component.append(format.msg.createComponent(sender, message, settings.disabledFunctions)) + component.append((format.msg[0].content as MsgComponent).createComponent(sender, message, settings.disabledFunctions)) format.suffix.forEach { suffix -> component.append(suffix.value[0].content.toTextComponent(sender)) } } ?: return ChannelExecuteResult(failedReason = ChannelExecuteResult.FailReason.NO_FORMAT) @@ -147,7 +148,9 @@ open class Channel( format.prefix .mapNotNull { prefix -> prefix.value.firstOrNull { it.condition.pass(player) }?.content?.toTextComponent(player) } .forEach { prefix -> component.append(prefix) } - component.append(format.msg.createComponent(player, msg, settings.disabledFunctions)) + format.msg.firstOrNull { it.condition.pass(player) } + ?.let { component.append((it.content as MsgComponent).createComponent(player, msg, settings.disabledFunctions)) } + ?: return ChannelExecuteResult(failedReason = ChannelExecuteResult.FailReason.NO_FORMAT) format.suffix .mapNotNull { suffix -> suffix.value.firstOrNull { it.condition.pass(player) }?.content?.toTextComponent(player) } .forEach { suffix -> component.append(suffix) } 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 f5c4dd01..48c30769 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 @@ -7,6 +7,7 @@ import me.arasple.mc.trchat.module.display.channel.obj.ChannelEvents import me.arasple.mc.trchat.module.display.channel.obj.ChannelExecuteResult import me.arasple.mc.trchat.module.display.channel.obj.ChannelSettings import me.arasple.mc.trchat.module.display.format.Format +import me.arasple.mc.trchat.module.display.format.MsgComponent import me.arasple.mc.trchat.module.internal.command.main.CommandReply import me.arasple.mc.trchat.module.internal.data.ChatLogs import me.arasple.mc.trchat.module.internal.data.PlayerData @@ -23,7 +24,6 @@ import taboolib.common.platform.command.suggest import taboolib.common.platform.function.console import taboolib.common.platform.function.getProxyPlayer import taboolib.common.util.subList -import taboolib.module.chat.ComponentText import taboolib.module.chat.Components import taboolib.module.lang.sendLang import taboolib.platform.util.onlinePlayers @@ -105,7 +105,9 @@ class PrivateChannel( format.prefix .mapNotNull { prefix -> prefix.value.firstOrNull { it.condition.pass(toPlayer) }?.content?.toTextComponent(toPlayer) } .forEach { prefix -> component.append(prefix) } - component.append(format.msg.createComponent(toPlayer, message, settings.disabledFunctions)) + format.msg.firstOrNull { it.condition.pass(toPlayer) } + ?.let { component.append((it.content as MsgComponent).createComponent(toPlayer, message, settings.disabledFunctions)) } + ?: return ChannelExecuteResult(failedReason = ChannelExecuteResult.FailReason.NO_FORMAT) format.suffix .mapNotNull { suffix -> suffix.value.firstOrNull { it.condition.pass(toPlayer) }?.content?.toTextComponent(toPlayer) } .forEach { suffix -> component.append(suffix) } @@ -114,7 +116,7 @@ class PrivateChannel( consoleFormat.firstOrNull()?.let { format -> format.prefix.forEach { prefix -> component.append(prefix.value[0].content.toTextComponent(sender)) } - component.append(format.msg.createComponent(sender, message, settings.disabledFunctions)) + component.append((format.msg[0].content as MsgComponent).createComponent(sender, message, settings.disabledFunctions)) format.suffix.forEach { suffix -> component.append(suffix.value[0].content.toTextComponent(sender)) } } ?: return ChannelExecuteResult(failedReason = ChannelExecuteResult.FailReason.NO_FORMAT) @@ -159,13 +161,15 @@ class PrivateChannel( ?: return ChannelExecuteResult(failedReason = ChannelExecuteResult.FailReason.EVENT) val send = Components.empty() - var msgComponent: ComponentText? = null + val msgComponent = Components.empty() sender.firstOrNull { it.condition.pass(player) }?.let { format -> format.prefix .mapNotNull { prefix -> prefix.value.firstOrNull { it.condition.pass(player) }?.content?.toTextComponent(player) } .forEach { prefix -> send.append(prefix) } - msgComponent = format.msg.createComponent(player, msg, settings.disabledFunctions) - send.append(msgComponent!!) + format.msg.firstOrNull { it.condition.pass(player) } + ?.let { msgComponent.append((it.content as MsgComponent).createComponent(player, msg, settings.disabledFunctions)) } + ?: return ChannelExecuteResult(failedReason = ChannelExecuteResult.FailReason.NO_FORMAT) + send.append(msgComponent) format.suffix .mapNotNull { suffix -> suffix.value.firstOrNull { it.condition.pass(player) }?.content?.toTextComponent(player) } .forEach { suffix -> send.append(suffix) } @@ -176,7 +180,7 @@ class PrivateChannel( format.prefix .mapNotNull { prefix -> prefix.value.firstOrNull { it.condition.pass(player) }?.content?.toTextComponent(player) } .forEach { prefix -> receive.append(prefix) } - receive.append(msgComponent!!) + receive.append(msgComponent) format.suffix .mapNotNull { suffix -> suffix.value.firstOrNull { it.condition.pass(player) }?.content?.toTextComponent(player) } .forEach { suffix -> receive.append(suffix) } @@ -194,9 +198,9 @@ class PrivateChannel( PlayerData.spying.forEach { Bukkit.getPlayer(it) - ?.sendLang("Private-Message-Spy-Format", player.name, to, msgComponent!!.toLegacyText()) + ?.sendLang("Private-Message-Spy-Format", player.name, to, msgComponent.toLegacyText()) } - console().sendLang("Private-Message-Spy-Format", player.name, to, msgComponent!!.toLegacyText()) + console().sendLang("Private-Message-Spy-Format", player.name, to, msgComponent.toLegacyText()) CommandReply.lastMessageFrom[to] = player.name ChatLogs.logPrivate(player.name, to, message) diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/Format.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/Format.kt index 9116f7aa..0f80a207 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/Format.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/format/Format.kt @@ -10,6 +10,6 @@ class Format( val condition: Condition?, val priority: Int, val prefix: Map>, - val msg: MsgComponent, + val msg: List, val suffix: Map> ) \ No newline at end of file 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 89b7fb8b..c0bb2f2c 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 @@ -4,13 +4,16 @@ import me.arasple.mc.trchat.module.internal.hook.HookPlugin 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 +import me.arasple.mc.trchat.util.isDragonCoreHooked import me.arasple.mc.trchat.util.papiRegex import me.arasple.mc.trchat.util.setPlaceholders +import net.md_5.bungee.api.chat.TextComponent import org.bukkit.command.CommandSender import org.bukkit.entity.Player import taboolib.common.util.replaceWithOrder import taboolib.module.chat.ComponentText import taboolib.module.chat.Components +import taboolib.module.chat.impl.DefaultComponent /** * @author ItsFlicker @@ -28,6 +31,10 @@ class Text(val content: String, val condition: Condition?) { } text = HookPlugin.getItemsAdder().replaceFontImages(text, null) } - return Components.text(text.replaceWithOrder(*vars).colorify()) + return if (isDragonCoreHooked) { + DefaultComponent(listOf(TextComponent(text.replaceWithOrder(*vars).colorify()))) + } else { + Components.text(text.replaceWithOrder(*vars).colorify()) + } } } \ No newline at end of file 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 542867f3..7900f76a 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 @@ -1,5 +1,6 @@ package me.arasple.mc.trchat.module.display.function.standard +import me.arasple.mc.trchat.api.event.TrChatMentionEvent 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 @@ -54,7 +55,14 @@ object Mention : Function("MENTION") { return message } val regex = getRegex(sender) ?: return message - val result = regex.replace(message, "{{MENTION:\$1}}") + val result = message.replace(regex) { + val name = it.groupValues[1] + if (TrChatMentionEvent(sender, name).call()) { + "{{MENTION:$name}}" + } else { + it.value + } + } if (result != message && !sender.hasPermission("trchat.bypass.mentioncd")) { sender.updateCooldown(CooldownType.MENTION, cooldown.get()) } diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatBukkit.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatBukkit.kt index 4ee08026..0bc72f52 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatBukkit.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatBukkit.kt @@ -52,7 +52,7 @@ object TrChatBukkit : Plugin() { } override fun onEnable() { - if (!Settings.usePackets || Folia.isFolia) { + if (!Settings.usePackets || Folia.isFolia || Bukkit.getPluginManager().isPluginEnabled("Geyser-Spigot")) { disablePacketListener() } BukkitProxyManager.processor 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 e96d641e..21f3b080 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 @@ -5,6 +5,7 @@ import github.scarsz.discordsrv.api.events.DiscordGuildMessagePreBroadcastEvent 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.util.pass import me.arasple.mc.trchat.util.session @@ -23,9 +24,10 @@ class ListenerDiscordSRV { val channel = player.session.lastChannel ?: return if (channel.settings.sendToDiscord) { val message = TrChat.api().getFilterManager().filter(e.message, adaptPlayer(player)).filtered - val component = channel.formats - .firstOrNull { it.condition.pass(player) } - ?.msg?.createComponent(player, message, channel.settings.disabledFunctions) + val component = (channel.formats + .firstOrNull { it.condition.pass(player) }?.msg + ?.firstOrNull { it.condition.pass(player) }?.content as? MsgComponent) + ?.createComponent(player, message, channel.settings.disabledFunctions) ?: return e.messageComponent = GsonComponentSerializer.gson().deserialize(component.toRawMessage()) if (channel.settings.discordChannel.isNotEmpty()) { diff --git a/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatVelocity.kt b/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatVelocity.kt index 188b3cc4..7816af85 100644 --- a/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatVelocity.kt +++ b/project/runtime-velocity/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatVelocity.kt @@ -38,7 +38,8 @@ object TrChatVelocity : Plugin() { suggest { listOf("on", "off") } - execute { _, _, argument -> + execute { sender, _, argument -> + if (!sender.hasPermission("trchatv.muteallservers")) return@execute VelocityProxyManager.sendMessageToAll("GlobalMute", argument) } }