From b2a485e34ddf7fedc019d3566509ae860676b380 Mon Sep 17 00:00:00 2001 From: ItsFlicker <1812496278@qq.com> Date: Sat, 7 Sep 2024 23:19:16 +0800 Subject: [PATCH] [2.2.0-beta2] 1.21.1 --- build.gradle.kts | 18 ++- gradle.properties | 2 +- .../module/display/function/Function.kt | 5 +- .../display/function/standard/ImageShow.kt | 107 ------------------ .../internal/command/main/CommandViews.kt | 20 ---- 5 files changed, 15 insertions(+), 137 deletions(-) delete mode 100644 project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ImageShow.kt diff --git a/build.gradle.kts b/build.gradle.kts index c0209606..1ce8e8df 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,7 +21,10 @@ subprojects { "bukkit-hook", "bukkit-util", "bukkit-ui", - "bukkit-xseries" + "bukkit-ui-legacy", + "bukkit-ui-modern", + "bukkit-xseries", + "bukkit-xseries-item" ) install("database-sql") install( @@ -33,7 +36,12 @@ subprojects { ) install( "nms", - "nms-util" + "nms-util", + "nms-util-stable", + "nms-util-unstable", + "nms-util-tag", + "nms-util-tag-12005", + "nms-util-tag-legacy", ) install( "database-alkaid-redis", @@ -42,13 +50,11 @@ subprojects { ) install(BUKKIT, BUNGEE, VELOCITY) install("platform-bukkit-impl") -// install(UNIVERSAL, DATABASE, KETHER, METRICS, NMS_UTIL) -// install(EXPANSION_REDIS, EXPANSION_JAVASCRIPT, EXPANSION_PLAYER_DATABASE) -// install(BUKKIT_ALL, BUNGEE, VELOCITY) + forceDownloadInDev = false repoTabooLib = "http://mcitd.cn:8081/repository/releases" } version { - taboolib = "6.2.0-beta4-dev" + taboolib = "6.2.0-beta5-dev" coroutines = null // isSkipKotlin = true // isSkipKotlinRelocate = true diff --git a/gradle.properties b/gradle.properties index 141f92b9..de5b6df9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=me.arasple.mc.trchat -version=2.2.0-beta1 +version=2.2.0-beta2 kotlin.incremental=true kotlin.incremental.java=true kotlin.incremental.useClasspathSnapshot=true diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/Function.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/Function.kt index 781a2803..e919709a 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/Function.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/Function.kt @@ -3,7 +3,6 @@ package me.arasple.mc.trchat.module.display.function import me.arasple.mc.trchat.api.event.TrChatReloadEvent import me.arasple.mc.trchat.module.internal.script.Reaction import org.bukkit.entity.Player -import taboolib.common.io.getInstance import taboolib.common.io.runningClassesWithoutLibrary import taboolib.common.platform.ProxyCommandSender import taboolib.common.platform.ProxyPlayer @@ -39,8 +38,8 @@ abstract class Function(val id: String) { fun reload(customFunctions: List) { functions.clear() functions.addAll(runningClassesWithoutLibrary - .filter { it.isAnnotationPresent(StandardFunction::class.java) } - .mapNotNull { it.getInstance()?.get() as? Function } + .filter { it.hasAnnotation(StandardFunction::class.java) } + .mapNotNull { it.getInstance() as? Function } ) functions.addAll(customFunctions) TrChatReloadEvent.Function(functions).call() 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 deleted file mode 100644 index 3ecd365b..00000000 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ImageShow.kt +++ /dev/null @@ -1,107 +0,0 @@ -package me.arasple.mc.trchat.module.display.function.standard - -import com.google.common.cache.Cache -import com.google.common.cache.CacheBuilder -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.script.Reaction -import me.arasple.mc.trchat.util.CooldownType -import me.arasple.mc.trchat.util.getCooldownLeft -import me.arasple.mc.trchat.util.passPermission -import me.arasple.mc.trchat.util.updateCooldown -import org.bukkit.entity.Player -import taboolib.common.platform.Platform -import taboolib.common.platform.PlatformSide -import taboolib.common.util.asList -import taboolib.common.util.resettableLazy -import taboolib.common5.util.decodeBase64 -import taboolib.common5.util.encodeBase64 -import taboolib.common5.util.parseMillis -import taboolib.module.chat.ComponentText -import taboolib.module.configuration.ConfigNode -import taboolib.module.configuration.ConfigNodeTransfer -import taboolib.module.nms.NMSMap -import taboolib.module.nms.buildMap -import taboolib.platform.util.sendLang -import java.net.URL -import java.util.concurrent.CompletableFuture - -/** - * @author ItsFlicker - * @since 2022/3/12 19:14 - */ -@StandardFunction -@PlatformSide(Platform.BUKKIT) -object ImageShow : Function("IMAGE") { - - override val alias = "Image-Show" - - override val reaction by resettableLazy("functions") { - Functions.conf["General.Image-Show.Action"]?.let { Reaction(it.asList()) } - } - - @ConfigNode("General.Image-Show.Enabled", "function.yml") - var enabled = false - - @ConfigNode("General.Image-Show.Permission", "function.yml") - var permission = "none" - - @ConfigNode("General.Image-Show.Cooldown", "function.yml") - val cooldown = ConfigNodeTransfer { parseMillis() } - - @ConfigNode("General.Image-Show.Key", "function.yml") - val key = ConfigNodeTransfer { Regex(this) } - - val cache: Cache = CacheBuilder.newBuilder().maximumSize(40).build() - val tasks = mutableMapOf>() - - override fun createVariable(sender: Player, message: String): String { - 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? { - val args = arg.split(";", limit = 2) - val description = args[0] - val url = args[1].decodeBase64().decodeToString() - computeAndCache(url) - return sender.getComponentFromLang("Function-Image-Show-Format", description, args[1]) - } - - override fun canUse(sender: Player): Boolean { - return sender.passPermission(permission) - } - - override fun checkCooldown(sender: Player, message: String): Boolean { - if (enabled && message.contains(key.get()) && !sender.hasPermission("trchat.bypass.imagecd")) { - val imageCooldown = sender.getCooldownLeft(CooldownType.IMAGE_SHOW) - if (imageCooldown > 0) { - sender.sendLang("Cooldowns-Image-Show", imageCooldown / 1000) - return false - } else { - sender.updateCooldown(CooldownType.IMAGE_SHOW, cooldown.get()) - } - } - return true - } - - fun computeAndCache(url: String) { - if (url !in tasks) { - tasks[url] = buildMap(URL(url)) { - name = "Image" - }.whenCompleteAsync { map, e -> - if (e == null && map != null) { - cache.put(url, map) - tasks -= url - } - } - } - } - -} \ No newline at end of file diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandViews.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandViews.kt index fea890bc..95020416 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandViews.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/command/main/CommandViews.kt @@ -2,7 +2,6 @@ package me.arasple.mc.trchat.module.internal.command.main import me.arasple.mc.trchat.module.conf.file.Settings import me.arasple.mc.trchat.module.display.function.standard.EnderChestShow -import me.arasple.mc.trchat.module.display.function.standard.ImageShow import me.arasple.mc.trchat.module.display.function.standard.InventoryShow import me.arasple.mc.trchat.module.display.function.standard.ItemShow import org.bukkit.entity.Player @@ -12,7 +11,6 @@ import taboolib.common.platform.Platform import taboolib.common.platform.PlatformSide import taboolib.common.platform.command.PermissionDefault import taboolib.common.platform.command.command -import taboolib.common5.util.decodeBase64 import taboolib.expansion.createHelper import taboolib.module.lang.sendLang import taboolib.platform.util.sendLang @@ -78,23 +76,5 @@ object CommandViews { createHelper() } } - command("view-image", permissionDefault = PermissionDefault.TRUE) { - dynamic("image") { - execute { sender, _, argument -> - val url = argument.decodeBase64().decodeToString() - ImageShow.cache.getIfPresent(url)?.sendTo(sender) - ?: kotlin.run { - ImageShow.computeAndCache(url) - sender.sendLang("Function-Image-Show-Unavailable") - } - } - } - incorrectSender { sender, _ -> - sender.sendLang("Command-Not-Player") - } - incorrectCommand { _, _, _, _ -> - createHelper() - } - } } } \ No newline at end of file