Skip to content

Commit

Permalink
[2.2.0-beta1] 1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsFlicker committed Aug 14, 2024
1 parent d115963 commit 1d6f577
Show file tree
Hide file tree
Showing 23 changed files with 478 additions and 468 deletions.
44 changes: 38 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import io.izzel.taboolib.gradle.*
import io.izzel.taboolib.gradle.BUKKIT
import io.izzel.taboolib.gradle.BUNGEE
import io.izzel.taboolib.gradle.VELOCITY
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
id("io.izzel.taboolib") version "2.0.12"
id("io.izzel.taboolib") version "2.0.13"
id("org.jetbrains.kotlin.jvm") version "1.8.22"
}

Expand All @@ -14,20 +16,50 @@ subprojects {

taboolib {
env {
install(UNIVERSAL, DATABASE, KETHER, METRICS, NMS_UTIL)
install(EXPANSION_REDIS, EXPANSION_JAVASCRIPT, EXPANSION_PLAYER_DATABASE)
install(BUKKIT_ALL, BUNGEE, VELOCITY)
install("basic-configuration")
install(
"bukkit-hook",
"bukkit-util",
"bukkit-ui",
"bukkit-xseries"
)
install("database-sql")
install(
"minecraft-chat",
"minecraft-command-helper",
"minecraft-i18n",
"minecraft-kether",
"minecraft-metrics"
)
install(
"nms",
"nms-util"
)
install(
"database-alkaid-redis",
"database-player",
"script-javascript"
)
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)
repoTabooLib = "http://mcitd.cn:8081/repository/releases"
}
version {
taboolib = "6.1.2-beta10"
taboolib = "6.2.0-beta4-dev"
coroutines = null
// isSkipKotlin = true
// isSkipKotlinRelocate = true
}
}

// 全局仓库
repositories {
mavenLocal()
mavenCentral()
maven("http://mcitd.cn:8081/repository/releases") { isAllowInsecureProtocol = true }
maven("https://jitpack.io")
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://papermc.io/repo/repository/maven-public/")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=me.arasple.mc.trchat
version=2.1.3
version=2.2.0-beta1
kotlin.incremental=true
kotlin.incremental.java=true
kotlin.incremental.useClasspathSnapshot=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ interface ChannelManager {
* 获取聊天频道
*
* Bukkit -> Channel
* BungeeCord/Velocity -> String
*/
fun getChannel(id: String): Any?

Expand Down
1 change: 1 addition & 0 deletions project/module-nms/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dependencies {
compileOnly(project(":project:common"))
// compileOnly("ink.ptms.core:v12101:12101:mapped")
// compileOnly("ink.ptms.core:v12005:12005:mapped")
compileOnly("ink.ptms.core:v12004:12004:mapped")
compileOnly("ink.ptms.core:v12002:12002:mapped")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object BukkitProxyManager : ClientMessageManager {

override val executor: ExecutorService by unsafeLazy {
val factory = ThreadFactoryBuilder().setNameFormat("TrChat PluginMessage Processing Thread #%d").build()
Executors.newFixedThreadPool(4, factory)
Executors.newFixedThreadPool(8, factory)
}

override val mode: ProxyMode by unsafeLazy {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.arasple.mc.trchat.module.conf

import me.arasple.mc.trchat.api.event.TrChatReloadEvent
import me.arasple.mc.trchat.api.impl.BukkitProxyManager
import me.arasple.mc.trchat.module.conf.file.Functions
import me.arasple.mc.trchat.module.display.channel.Channel
import me.arasple.mc.trchat.module.display.channel.PrivateChannel
Expand Down Expand Up @@ -36,7 +35,6 @@ import taboolib.common5.FileWatcher
import taboolib.library.configuration.ConfigurationSection
import taboolib.module.configuration.util.getMap
import taboolib.module.lang.sendLang
import taboolib.platform.util.onlinePlayers
import java.io.File
import kotlin.system.measureTimeMillis

Expand Down Expand Up @@ -73,8 +71,6 @@ object Loader {
Channel.channels.values.forEach { it.unregister() }
Channel.channels.clear()

BukkitProxyManager.sendMessage(onlinePlayers.firstOrNull(), arrayOf("FetchProxyChannels"))

filterChannelFiles(folder).forEach {
if (FileWatcher.INSTANCE.hasListener(it)) {
loadChannel(it)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
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.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.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 org.bukkit.inventory.Inventory
import org.bukkit.inventory.ItemStack
import taboolib.common.io.digest
import taboolib.common.platform.Platform
import taboolib.common.platform.PlatformSide
import taboolib.common.util.asList
import taboolib.common.util.resettableLazy
import taboolib.common5.util.encodeBase64
import taboolib.common5.util.parseMillis
import taboolib.library.xseries.XMaterial
import taboolib.module.chat.ComponentText
import taboolib.module.configuration.ConfigNode
import taboolib.module.configuration.ConfigNodeTransfer
import taboolib.module.nms.MinecraftVersion
import taboolib.module.ui.buildMenu
import taboolib.module.ui.type.PageableChest
import taboolib.platform.util.*

/**
* @author ItsFlicker
* @since 2022/3/18 19:14
*/
@StandardFunction
@PlatformSide(Platform.BUKKIT)
object EnderChestShow : Function("ENDERCHEST") {

override val alias = "EnderChest-Show"

override val reaction by resettableLazy("functions") {
Functions.conf["General.EnderChest-Show.Action"]?.let { Reaction(it.asList()) }
}

@ConfigNode("General.EnderChest-Show.Enabled", "function.yml")
var enabled = true

@ConfigNode("General.EnderChest-Show.Permission", "function.yml")
var permission = "none"

@ConfigNode("General.EnderChest-Show.Cooldown", "function.yml")
val cooldown = ConfigNodeTransfer<String, Long> { parseMillis() }

@ConfigNode("General.EnderChest-Show.Keys", "function.yml")
var keys = listOf<String>()

val cache: Cache<String, Inventory> = CacheBuilder.newBuilder()
.maximumSize(10)
.build()

private val AIR_ITEM = buildItem(XMaterial.GRAY_STAINED_GLASS_PANE) { name = "§f" }

override fun createVariable(sender: Player, message: String): String {
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? {
return computeAndCache(sender).let {
BukkitProxyManager.sendMessage(sender, arrayOf(
"ForwardMessage",
"EnderChestShow",
MinecraftVersion.minecraftVersion,
sender.name,
it.first,
it.second)
)
sender.getComponentFromLang("Function-EnderChest-Show-Format", sender.name, it.first)
}
}

override fun canUse(sender: Player): Boolean {
return sender.passPermission(permission)
}

override fun checkCooldown(sender: Player, message: String): Boolean {
if (enabled && keys.any { message.contains(it, ignoreCase = true) } && !sender.hasPermission("trchat.bypass.enderchestcd")) {
val enderChestCooldown = sender.getCooldownLeft(CooldownType.ENDERCHEST_SHOW)
if (enderChestCooldown > 0) {
sender.sendLang("Cooldowns-EnderChest-Show", enderChestCooldown / 1000)
return false
} else {
sender.updateCooldown(CooldownType.ENDERCHEST_SHOW, cooldown.get())
}
}
return true
}

fun computeAndCache(sender: Player): Pair<String, String> {
val inventory = sender.enderChest
val sha1 = inventory.serializeToByteArray(zipped = false).encodeBase64().digest("sha-1")
if (cache.getIfPresent(sha1) != null) {
return sha1 to cache.getIfPresent(sha1)!!.serializeToByteArray().encodeBase64()
}
val menu = buildMenu<PageableChest<ItemStack>>(sender.asLangText("Function-EnderChest-Show-Title", sender.name)) {
rows(3)
slots((0..26).toList())
elements { (0..26).map { inventory.getItem(it).replaceAir() } }
onGenerate { _, element, _, _ -> element }
onClick(lock = true)
}
cache.put(sha1, menu)
return sha1 to menu.serializeToByteArray().encodeBase64()
}

private fun ItemStack?.replaceAir() = if (isAir()) AIR_ITEM else this

}
Loading

0 comments on commit 1d6f577

Please sign in to comment.