Skip to content

Commit 1d6f577

Browse files
committed
[2.2.0-beta1] 1.21.1
1 parent d115963 commit 1d6f577

File tree

23 files changed

+478
-468
lines changed

23 files changed

+478
-468
lines changed

build.gradle.kts

+38-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import io.izzel.taboolib.gradle.*
1+
import io.izzel.taboolib.gradle.BUKKIT
2+
import io.izzel.taboolib.gradle.BUNGEE
3+
import io.izzel.taboolib.gradle.VELOCITY
24
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
35

46
plugins {
57
java
6-
id("io.izzel.taboolib") version "2.0.12"
8+
id("io.izzel.taboolib") version "2.0.13"
79
id("org.jetbrains.kotlin.jvm") version "1.8.22"
810
}
911

@@ -14,20 +16,50 @@ subprojects {
1416

1517
taboolib {
1618
env {
17-
install(UNIVERSAL, DATABASE, KETHER, METRICS, NMS_UTIL)
18-
install(EXPANSION_REDIS, EXPANSION_JAVASCRIPT, EXPANSION_PLAYER_DATABASE)
19-
install(BUKKIT_ALL, BUNGEE, VELOCITY)
19+
install("basic-configuration")
20+
install(
21+
"bukkit-hook",
22+
"bukkit-util",
23+
"bukkit-ui",
24+
"bukkit-xseries"
25+
)
26+
install("database-sql")
27+
install(
28+
"minecraft-chat",
29+
"minecraft-command-helper",
30+
"minecraft-i18n",
31+
"minecraft-kether",
32+
"minecraft-metrics"
33+
)
34+
install(
35+
"nms",
36+
"nms-util"
37+
)
38+
install(
39+
"database-alkaid-redis",
40+
"database-player",
41+
"script-javascript"
42+
)
43+
install(BUKKIT, BUNGEE, VELOCITY)
44+
install("platform-bukkit-impl")
45+
// install(UNIVERSAL, DATABASE, KETHER, METRICS, NMS_UTIL)
46+
// install(EXPANSION_REDIS, EXPANSION_JAVASCRIPT, EXPANSION_PLAYER_DATABASE)
47+
// install(BUKKIT_ALL, BUNGEE, VELOCITY)
48+
repoTabooLib = "http://mcitd.cn:8081/repository/releases"
2049
}
2150
version {
22-
taboolib = "6.1.2-beta10"
51+
taboolib = "6.2.0-beta4-dev"
2352
coroutines = null
53+
// isSkipKotlin = true
54+
// isSkipKotlinRelocate = true
2455
}
2556
}
2657

2758
// 全局仓库
2859
repositories {
2960
mavenLocal()
3061
mavenCentral()
62+
maven("http://mcitd.cn:8081/repository/releases") { isAllowInsecureProtocol = true }
3163
maven("https://jitpack.io")
3264
maven("https://oss.sonatype.org/content/repositories/snapshots")
3365
maven("https://papermc.io/repo/repository/maven-public/")

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=me.arasple.mc.trchat
2-
version=2.1.3
2+
version=2.2.0-beta1
33
kotlin.incremental=true
44
kotlin.incremental.java=true
55
kotlin.incremental.useClasspathSnapshot=true

project/common/src/main/kotlin/me/arasple/mc/trchat/api/ChannelManager.kt

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ interface ChannelManager {
1919
* 获取聊天频道
2020
*
2121
* Bukkit -> Channel
22-
* BungeeCord/Velocity -> String
2322
*/
2423
fun getChannel(id: String): Any?
2524

project/module-nms/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
dependencies {
22
compileOnly(project(":project:common"))
3+
// compileOnly("ink.ptms.core:v12101:12101:mapped")
34
// compileOnly("ink.ptms.core:v12005:12005:mapped")
45
compileOnly("ink.ptms.core:v12004:12004:mapped")
56
compileOnly("ink.ptms.core:v12002:12002:mapped")

project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/api/impl/BukkitProxyManager.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ object BukkitProxyManager : ClientMessageManager {
6060

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

6666
override val mode: ProxyMode by unsafeLazy {

project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/conf/Loader.kt

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package me.arasple.mc.trchat.module.conf
22

33
import me.arasple.mc.trchat.api.event.TrChatReloadEvent
4-
import me.arasple.mc.trchat.api.impl.BukkitProxyManager
54
import me.arasple.mc.trchat.module.conf.file.Functions
65
import me.arasple.mc.trchat.module.display.channel.Channel
76
import me.arasple.mc.trchat.module.display.channel.PrivateChannel
@@ -36,7 +35,6 @@ import taboolib.common5.FileWatcher
3635
import taboolib.library.configuration.ConfigurationSection
3736
import taboolib.module.configuration.util.getMap
3837
import taboolib.module.lang.sendLang
39-
import taboolib.platform.util.onlinePlayers
4038
import java.io.File
4139
import kotlin.system.measureTimeMillis
4240

@@ -73,8 +71,6 @@ object Loader {
7371
Channel.channels.values.forEach { it.unregister() }
7472
Channel.channels.clear()
7573

76-
BukkitProxyManager.sendMessage(onlinePlayers.firstOrNull(), arrayOf("FetchProxyChannels"))
77-
7874
filterChannelFiles(folder).forEach {
7975
if (FileWatcher.INSTANCE.hasListener(it)) {
8076
loadChannel(it)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package me.arasple.mc.trchat.module.display.function.standard
2+
3+
import com.google.common.cache.Cache
4+
import com.google.common.cache.CacheBuilder
5+
import me.arasple.mc.trchat.api.impl.BukkitProxyManager
6+
import me.arasple.mc.trchat.module.conf.file.Functions
7+
import me.arasple.mc.trchat.module.display.function.Function
8+
import me.arasple.mc.trchat.module.display.function.StandardFunction
9+
import me.arasple.mc.trchat.module.internal.script.Reaction
10+
import me.arasple.mc.trchat.util.CooldownType
11+
import me.arasple.mc.trchat.util.getCooldownLeft
12+
import me.arasple.mc.trchat.util.passPermission
13+
import me.arasple.mc.trchat.util.updateCooldown
14+
import org.bukkit.entity.Player
15+
import org.bukkit.inventory.Inventory
16+
import org.bukkit.inventory.ItemStack
17+
import taboolib.common.io.digest
18+
import taboolib.common.platform.Platform
19+
import taboolib.common.platform.PlatformSide
20+
import taboolib.common.util.asList
21+
import taboolib.common.util.resettableLazy
22+
import taboolib.common5.util.encodeBase64
23+
import taboolib.common5.util.parseMillis
24+
import taboolib.library.xseries.XMaterial
25+
import taboolib.module.chat.ComponentText
26+
import taboolib.module.configuration.ConfigNode
27+
import taboolib.module.configuration.ConfigNodeTransfer
28+
import taboolib.module.nms.MinecraftVersion
29+
import taboolib.module.ui.buildMenu
30+
import taboolib.module.ui.type.PageableChest
31+
import taboolib.platform.util.*
32+
33+
/**
34+
* @author ItsFlicker
35+
* @since 2022/3/18 19:14
36+
*/
37+
@StandardFunction
38+
@PlatformSide(Platform.BUKKIT)
39+
object EnderChestShow : Function("ENDERCHEST") {
40+
41+
override val alias = "EnderChest-Show"
42+
43+
override val reaction by resettableLazy("functions") {
44+
Functions.conf["General.EnderChest-Show.Action"]?.let { Reaction(it.asList()) }
45+
}
46+
47+
@ConfigNode("General.EnderChest-Show.Enabled", "function.yml")
48+
var enabled = true
49+
50+
@ConfigNode("General.EnderChest-Show.Permission", "function.yml")
51+
var permission = "none"
52+
53+
@ConfigNode("General.EnderChest-Show.Cooldown", "function.yml")
54+
val cooldown = ConfigNodeTransfer<String, Long> { parseMillis() }
55+
56+
@ConfigNode("General.EnderChest-Show.Keys", "function.yml")
57+
var keys = listOf<String>()
58+
59+
val cache: Cache<String, Inventory> = CacheBuilder.newBuilder()
60+
.maximumSize(10)
61+
.build()
62+
63+
private val AIR_ITEM = buildItem(XMaterial.GRAY_STAINED_GLASS_PANE) { name = "§f" }
64+
65+
override fun createVariable(sender: Player, message: String): String {
66+
if (!enabled) {
67+
return message
68+
}
69+
var result = message
70+
keys.forEach {
71+
result = result.replaceFirst(it, "{{ENDERCHEST:${sender.name}}}", ignoreCase = true)
72+
}
73+
return result
74+
}
75+
76+
override fun parseVariable(sender: Player, arg: String): ComponentText? {
77+
return computeAndCache(sender).let {
78+
BukkitProxyManager.sendMessage(sender, arrayOf(
79+
"ForwardMessage",
80+
"EnderChestShow",
81+
MinecraftVersion.minecraftVersion,
82+
sender.name,
83+
it.first,
84+
it.second)
85+
)
86+
sender.getComponentFromLang("Function-EnderChest-Show-Format", sender.name, it.first)
87+
}
88+
}
89+
90+
override fun canUse(sender: Player): Boolean {
91+
return sender.passPermission(permission)
92+
}
93+
94+
override fun checkCooldown(sender: Player, message: String): Boolean {
95+
if (enabled && keys.any { message.contains(it, ignoreCase = true) } && !sender.hasPermission("trchat.bypass.enderchestcd")) {
96+
val enderChestCooldown = sender.getCooldownLeft(CooldownType.ENDERCHEST_SHOW)
97+
if (enderChestCooldown > 0) {
98+
sender.sendLang("Cooldowns-EnderChest-Show", enderChestCooldown / 1000)
99+
return false
100+
} else {
101+
sender.updateCooldown(CooldownType.ENDERCHEST_SHOW, cooldown.get())
102+
}
103+
}
104+
return true
105+
}
106+
107+
fun computeAndCache(sender: Player): Pair<String, String> {
108+
val inventory = sender.enderChest
109+
val sha1 = inventory.serializeToByteArray(zipped = false).encodeBase64().digest("sha-1")
110+
if (cache.getIfPresent(sha1) != null) {
111+
return sha1 to cache.getIfPresent(sha1)!!.serializeToByteArray().encodeBase64()
112+
}
113+
val menu = buildMenu<PageableChest<ItemStack>>(sender.asLangText("Function-EnderChest-Show-Title", sender.name)) {
114+
rows(3)
115+
slots((0..26).toList())
116+
elements { (0..26).map { inventory.getItem(it).replaceAir() } }
117+
onGenerate { _, element, _, _ -> element }
118+
onClick(lock = true)
119+
}
120+
cache.put(sha1, menu)
121+
return sha1 to menu.serializeToByteArray().encodeBase64()
122+
}
123+
124+
private fun ItemStack?.replaceAir() = if (isAir()) AIR_ITEM else this
125+
126+
}

0 commit comments

Comments
 (0)