Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ subprojects {
disableOnSkippedVersion = false
}
version {
taboolib = "6.2.4-8d51195"
taboolib = "6.2.4-e6c8347"
coroutines = null
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=me.arasple.mc.trmenu
version=3.9.17
version=3.9.19
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import taboolib.common.platform.function.submitAsync
import taboolib.common.platform.service.PlatformExecutor
import taboolib.common.util.replaceWithOrder
import taboolib.library.reflex.Reflex.Companion.getProperty
import taboolib.module.chat.colored
import taboolib.module.lang.Language
import taboolib.platform.compat.replacePlaceholder
import trplugins.menu.api.event.MenuCloseEvent
Expand All @@ -15,8 +14,7 @@ import trplugins.menu.module.display.icon.Icon
import trplugins.menu.module.display.icon.IconProperty
import trplugins.menu.module.display.layout.Layout
import trplugins.menu.module.internal.script.FunctionParser
import trplugins.menu.util.parseGradients
import trplugins.menu.util.parseRainbow
import trplugins.menu.util.colorify
import java.util.UUID
import java.util.concurrent.ConcurrentHashMap

Expand Down Expand Up @@ -144,10 +142,10 @@ class MenuSession(
}
}
val content =
(if (preColor) funced else funced.colored().parseRainbow().parseGradients()).replaceWithOrder(*arguments).replaceWithOrder(*implicitArguments)
(if (preColor) funced else funced.colorify()).replaceWithOrder(*arguments).replaceWithOrder(*implicitArguments)
val papi = content.replacePlaceholder(placeholderPlayer)

return if (preColor) papi else papi.colored().parseRainbow().parseGradients()
return if (preColor) papi else papi.colorify()
}

fun parse(string: List<String>): List<String> {
Expand Down Expand Up @@ -320,4 +318,4 @@ fun Player.session(): MenuSession {
}
fun ProxyPlayer.session(): MenuSession {
return cast<Player>().session()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package trplugins.menu.module.display
import me.clip.placeholderapi.PlaceholderAPI
import org.bukkit.Bukkit
import taboolib.common.platform.function.pluginId
import taboolib.module.chat.colored
import trplugins.menu.TrMenu
import trplugins.menu.api.reaction.Reactions
import trplugins.menu.api.receptacle.MenuTaskData
import trplugins.menu.module.internal.script.js.ScriptFunction
import trplugins.menu.util.Cooldown
import trplugins.menu.util.colorify
import trplugins.menu.util.bukkit.ItemMatcher
import trplugins.menu.util.collections.CycleList

Expand Down Expand Up @@ -40,8 +40,8 @@ class MenuSettings(
companion object {

val PRE_COLOR get() = TrMenu.SETTINGS.getBoolean("Menu.Icon.Item.Pre-Color")
val DEFAULT_NAME_COLOR get() = (TrMenu.SETTINGS.getString("Menu.Icon.Item.Default-Name-Color") ?: "&7").colored()
val DEFAULT_LORE_COLOR get() = (TrMenu.SETTINGS.getString("Menu.Icon.Item.Default-Lore-Color") ?: "&7").colored()
val DEFAULT_NAME_COLOR get() = (TrMenu.SETTINGS.getString("Menu.Icon.Item.Default-Name-Color") ?: "&7").colorify()
val DEFAULT_LORE_COLOR get() = (TrMenu.SETTINGS.getString("Menu.Icon.Item.Default-Lore-Color") ?: "&7").colorify()

}

Expand Down Expand Up @@ -119,4 +119,4 @@ class MenuSettings(
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@ object RegisterCommands {
}

fun load() {
submit {
registered.removeIf {
unregisterCommand(it)
true
}

}
val unregisterList = registered.toList()
unregisterList.forEach { unregisterCommand(it) }
registered.clear()

TrMenu.SETTINGS.getConfigurationSection("RegisterCommands")?.let { it ->
val section = TrMenu.SETTINGS.getConfigurationSection("RegisterCommands")
section?.let { it ->
for (main in it.getKeys(false)) {
val section = it.getConfigurationSection(main) ?: continue
val argument = section.getConfigurationSection("arguments")
Expand Down Expand Up @@ -81,9 +78,11 @@ object RegisterCommands {
// 延迟同步命令到所有在线玩家,避免与 Paper 异步命令发送线程冲突
// Paper 的 sendAsync 会在异步线程遍历命令树,直接调用 updateCommands 可能触发 ConcurrentModificationException
submit(delay = 1) {
try {
Bukkit.getOnlinePlayers().forEach { it.updateCommands() }
} catch (_: Throwable) {}
val players = Bukkit.getOnlinePlayers()
if (players.isEmpty()) {
return@submit
}
players.forEach { it.updateCommands() }
}
}
}
}
11 changes: 10 additions & 1 deletion plugin/src/main/kotlin/trplugins/menu/util/Hex.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ object Hex {
Pattern.compile("<(?<type>rainbow|r)(#(?<speed>\\d+))?(:(?<saturation>\\d*\\.?\\d+))?(:(?<brightness>\\d*\\.?\\d+))?(:(?<loop>l|L|loop))?>")
private val GRADIENT_PATTERN =
Pattern.compile("<(?<type>gradient|g)(#(?<speed>\\d+))?(?<hex>(:#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})){2,})(:(?<loop>l|L|loop))?>")
private val LEGACY_HEX_PATTERN =
Pattern.compile("&\\{#([A-Fa-f0-9]){6}}") // &{#FFFFFF}
private val HEX_PATTERNS = listOf(
Pattern.compile("<#([A-Fa-f0-9]){6}>"), // <#FFFFFF>
Pattern.compile("\\{#([A-Fa-f0-9]){6}}"), // {#FFFFFF}
Expand Down Expand Up @@ -70,8 +72,9 @@ object Hex {
* @param message The message
* @return A color-replaced message
*/
private fun colorify(message: String): String {
internal fun colorify(message: String): String {
var parsed = message
parsed = normalizeLegacyHex(parsed)
parsed = parseRainbow(parsed)
parsed = parseGradients(parsed)
parsed = parseHex(parsed)
Expand Down Expand Up @@ -222,6 +225,11 @@ object Hex {
return ChatColor.translateAlternateColorCodes('&', message)
}

private fun normalizeLegacyHex(message: String): String {
val matcher = LEGACY_HEX_PATTERN.matcher(message)
return if (matcher.find()) matcher.replaceAll("&#\$1") else message
}

/**
* Returns the index before the color changes
*
Expand Down Expand Up @@ -422,5 +430,6 @@ object Hex {
}
}

fun String.colorify() = Hex.colorify(this)
fun String.parseRainbow() = Hex.parseRainbow(this)
fun String.parseGradients() = Hex.parseGradients(this)