diff --git a/build.gradle.kts b/build.gradle.kts index f46a069f..0ccd48e9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,10 +16,10 @@ subprojects { env { install(UNIVERSAL, DATABASE, KETHER, METRICS, NMS_UTIL, UI) install(EXPANSION_REDIS, EXPANSION_JAVASCRIPT, EXPANSION_PLAYER_DATABASE) - install(BUKKIT_ALL, BUNGEE, VELOCITY, "platform-bukkit-impl") + install(BUKKIT_ALL, BUNGEE, VELOCITY) } version { - taboolib = "6.1.1-beta4" + taboolib = "6.1.1-beta7" coroutines = null } } diff --git a/gradle.properties b/gradle.properties index 7ef79b3b..5db58d82 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=me.arasple.mc.trchat -version=2.0.14 +version=2.0.15 kotlin.incremental=true kotlin.incremental.java=true koltin.incremental.useClasspathSnapshot=true diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 74c7f556..b161432a 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -19,6 +19,7 @@ taboolib { } } relocate("com.eatthepath.uuid.", "${rootProject.group}.library.uuid.") + relocate("com.electronwill.nightconfig", "com.electronwill.nightconfig_3_6_7") } dependencies { diff --git a/project/common/src/main/java/me/arasple/mc/trchat/util/ServerUtil.java b/project/common/src/main/java/me/arasple/mc/trchat/util/ServerUtil.java new file mode 100644 index 00000000..235f2012 --- /dev/null +++ b/project/common/src/main/java/me/arasple/mc/trchat/util/ServerUtil.java @@ -0,0 +1,15 @@ +package me.arasple.mc.trchat.util; + +public class ServerUtil { + + public static boolean isModdedServer = false; + + static { + try { + Class.forName("catserver.server.CatServerLaunch"); + isModdedServer = true; + } catch (Throwable ignored) { + } + + } +} diff --git a/project/module-nms/src/main/kotlin/me/arasple/mc/trchat/api/nms/NMSImpl.kt b/project/module-nms/src/main/kotlin/me/arasple/mc/trchat/api/nms/NMSImpl.kt index 5817f284..cfe35552 100644 --- a/project/module-nms/src/main/kotlin/me/arasple/mc/trchat/api/nms/NMSImpl.kt +++ b/project/module-nms/src/main/kotlin/me/arasple/mc/trchat/api/nms/NMSImpl.kt @@ -1,5 +1,6 @@ package me.arasple.mc.trchat.api.nms +import me.arasple.mc.trchat.util.ServerUtil import me.arasple.mc.trchat.util.reportOnce import net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket import net.minecraft.server.v1_12_R1.ChatMessageType @@ -60,7 +61,7 @@ class NMSImpl : NMS() { } override fun sendMessage(receiver: Player, component: ComponentText, sender: UUID?) { - if (Folia.isFolia) { + if (Folia.isFolia || ServerUtil.isModdedServer) { component.sendTo(adaptPlayer(receiver)) return } diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/EnderChestShow.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/EnderChestShow.kt index a7c4f4bb..2da6fee7 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/EnderChestShow.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/EnderChestShow.kt @@ -63,15 +63,14 @@ object EnderChestShow : Function("ENDERCHEST") { private val AIR_ITEM = buildItem(XMaterial.GRAY_STAINED_GLASS_PANE) { name = "§f" } override fun createVariable(sender: Player, message: String): String { - return if (!enabled) { - message - } else { - var result = message - keys.forEach { - result = result.replaceFirst(it, "{{ENDERCHEST:${sender.name}}}", ignoreCase = true) - } - result + if (!enabled) { + return message + } + var result = message + keys.forEach { + result = result.replaceFirst(it, "{{ENDERCHEST:${sender.name}}}", ignoreCase = true) } + return result } override fun parseVariable(sender: Player, arg: String): ComponentText? { diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ImageShow.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ImageShow.kt index 49cbc65d..3ecd365b 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ImageShow.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ImageShow.kt @@ -57,14 +57,13 @@ object ImageShow : Function("IMAGE") { val tasks = mutableMapOf>() override fun createVariable(sender: Player, message: String): String { - return if (!enabled) { - message - } else { - val result = key.get().find(message) ?: return message - val description = result.groupValues[1] - val url = result.groupValues[2] - message.replaceFirst(key.get(), "{{IMAGE:$description;${url.encodeBase64()}}}") + if (!enabled) { + return message } + val result = key.get().find(message) ?: return message + val description = result.groupValues[1] + val url = result.groupValues[2] + return message.replaceFirst(key.get(), "{{IMAGE:$description;${url.encodeBase64()}}}") } override fun parseVariable(sender: Player, arg: String): ComponentText? { diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/InventoryShow.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/InventoryShow.kt index 3dfb1b37..137b6e8a 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/InventoryShow.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/InventoryShow.kt @@ -65,15 +65,14 @@ object InventoryShow : Function("INVENTORY") { private val PLACEHOLDER_ITEM = buildItem(XMaterial.WHITE_STAINED_GLASS_PANE) { name = "§f" } override fun createVariable(sender: Player, message: String): String { - return if (!enabled) { - message - } else { - var result = message - keys.forEach { - result = result.replaceFirst(it, "{{INVENTORY:${sender.name}}}", ignoreCase = true) - } - result + if (!enabled) { + return message + } + var result = message + keys.forEach { + result = result.replaceFirst(it, "{{INVENTORY:${sender.name}}}", ignoreCase = true) } + return result } override fun parseVariable(sender: Player, arg: String): ComponentText? { diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ItemShow.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ItemShow.kt index fed8ff80..8abf1dc2 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ItemShow.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ItemShow.kt @@ -38,6 +38,7 @@ import taboolib.module.nms.* import taboolib.module.ui.buildMenu import taboolib.module.ui.type.Chest import taboolib.module.ui.type.PageableChest +import taboolib.platform.Folia import taboolib.platform.util.* /** @@ -85,19 +86,18 @@ object ItemShow : Function("ITEM") { private val AIR_ITEM = buildItem(XMaterial.GRAY_STAINED_GLASS_PANE) { name = "§f" } override fun createVariable(sender: Player, message: String): String { - return if (!enabled) { - message - } else { - var result = message - keys.forEach { key -> - (1..9).forEach { - result = result.replace("$key-$it", "{{ITEM:$it}}", ignoreCase = true) - result = result.replace("$key$it", "{{ITEM:$it}}", ignoreCase = true) - } - result = result.replace(key, "{{ITEM:${sender.inventory.heldItemSlot + 1}}}", ignoreCase = true) + if (!enabled) { + return message + } + var result = message + keys.forEach { key -> + (1..9).forEach { + result = result.replace("$key-$it", "{{ITEM:$it}}", ignoreCase = true) + result = result.replace("$key$it", "{{ITEM:$it}}", ignoreCase = true) } - result + result = result.replace(key, "{{ITEM:${sender.inventory.heldItemSlot + 1}}}", ignoreCase = true) } + return result } override fun parseVariable(sender: Player, arg: String): ComponentText? { @@ -201,6 +201,9 @@ object ItemShow : Function("ITEM") { @Suppress("Deprecation") private fun ItemStack.getNameComponent(player: Player): ComponentText { + if (Folia.isFolia) { + return Components.text("Item") + } return if (originName || itemMeta?.hasDisplayName() != true) { try { if (MinecraftVersion.isHigherOrEqual(MinecraftVersion.V1_15)) { @@ -213,7 +216,11 @@ object ItemShow : Function("ITEM") { // 玄学问题 https://github.com/TrPlugins/TrChat/issues/344 Components.translation(NMS.instance.getLocaleKey(this).path) } catch (_: Throwable) { - Components.text(nmsProxy().getKey(this)) + try { + Components.text(nmsProxy().getKey(this)) + } catch (_: Throwable) { + Components.text("Item") + } } } } else { 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 0f7517ca..542867f3 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 @@ -50,16 +50,15 @@ object Mention : Function("MENTION") { val cooldown = ConfigNodeTransfer { parseMillis() } override fun createVariable(sender: Player, message: String): String { - return if (!enabled) { - message - } else { - val regex = getRegex(sender) ?: return message - val result = regex.replace(message, "{{MENTION:\$1}}") - if (result != message && !sender.hasPermission("trchat.bypass.mentioncd")) { - sender.updateCooldown(CooldownType.MENTION, cooldown.get()) - } - result + if (!enabled) { + return message } + val regex = getRegex(sender) ?: return message + val result = regex.replace(message, "{{MENTION:\$1}}") + if (result != message && !sender.hasPermission("trchat.bypass.mentioncd")) { + sender.updateCooldown(CooldownType.MENTION, cooldown.get()) + } + return result } override fun parseVariable(sender: Player, arg: String): ComponentText? { diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/MentionAll.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/MentionAll.kt index 92b15368..e473867b 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/MentionAll.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/MentionAll.kt @@ -50,15 +50,14 @@ object MentionAll : Function("MENTIONALL") { var keys = emptyList() override fun createVariable(sender: Player, message: String): String { - return if (!enabled) { - message - } else { - var result = message - keys.forEach { - result = result.replace(it, "{{MENTIONALL:${sender.name}}}") - } - result + if (!enabled) { + return message + } + var result = message + keys.forEach { + result = result.replace(it, "{{MENTIONALL:${sender.name}}}") } + return result } override fun parseVariable(sender: Player, arg: String): ComponentText? { diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/ComponentUtil.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/ComponentUtil.kt index bec0ab88..cc705246 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/ComponentUtil.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/ComponentUtil.kt @@ -11,6 +11,7 @@ import org.bukkit.inventory.meta.ItemMeta import taboolib.module.chat.ComponentText import taboolib.module.chat.component import taboolib.module.nms.getI18nName +import taboolib.platform.Folia import taboolib.platform.util.* fun String.parseSimple() = component().build { @@ -18,14 +19,17 @@ fun String.parseSimple() = component().build { } fun ComponentText.hoverItemFixed(item: ItemStack): ComponentText { + if (Folia.isFolia) { + return hoverText("Folia is unsupported! Click to view it.") + } var newItem = item.optimizeShulkerBox() newItem = NMS.instance.optimizeNBT(newItem) return try { - hoverItem(newItem) + // https://github.com/TrPlugins/TrChat/issues/363 + NMS.instance.hoverItem(this, newItem) } catch (_: Throwable) { try { - // try another method https://github.com/TrPlugins/TrChat/issues/363 - NMS.instance.hoverItem(this, newItem) + hoverItem(newItem) } catch (_: Throwable) { hoverText("Unable to display this item! Click to view it.") } diff --git a/project/runtime-bukkit/src/main/resources/filter.yml b/project/runtime-bukkit/src/main/resources/filter.yml index 76c19da3..af7fa7cf 100644 --- a/project/runtime-bukkit/src/main/resources/filter.yml +++ b/project/runtime-bukkit/src/main/resources/filter.yml @@ -10,10 +10,10 @@ Cloud-Thesaurus: - 'https://raw.githubusercontent.com/Yurinann/Filter-Thesaurus-Cloud/main/database.json' # 感谢南城提供的词库 - 'https://raw.githubusercontent.com/konsheng/Sensitive-lexicon/main/ThirdPartyCompatibleFormats/TrChat/SensitiveLexicon.json' -Local: |- - NMSL - fuck - shit +Local: + - NMSL + - fuck + - shit Ignored-Punctuations: ['!','.',',','#','$','%','&','*','(',')','|','?','/','@','"','\',';','[',']','{','}','+','~','-','_','=','^','<','>',' ',' ','!','。',',','¥','(',')','?','、','“','‘',';','【','】','——','……','《','》','\\', '`'] WhiteList: ['has been']