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
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/zh_bug_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ body:
| Server software: xxxx
| Java version: xxxx

| TabooLib: x.x.x
| TrMenu: x.x.x
Installed Plugins:
· XXXXXX - x.x.x
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ subprojects {
PtcObject
)
repoTabooLib = "https://repo.aeoliancloud.com/repository/releases"
// repoTabooLib = project.repositories.mavenLocal().url.toString()
disableOnSkippedVersion = false
}
version {
taboolib = "6.2.3-c573ce52"
taboolib = "6.2.3-d4a5f0ea"
coroutines = null
}
}
Expand Down
6 changes: 6 additions & 0 deletions common/src/main/kotlin/trplugins/menu/util/EvalResult.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package trplugins.menu.util

import taboolib.common5.cint

/**
* @author Arasple
* @date 2021/1/31 11:53
Expand All @@ -19,6 +21,10 @@ value class EvalResult(val any: Any? = null) {
return any.toString()
}

fun asInt(def: Int = 0): Int {
return any?.cint ?: def
}

companion object {

val TRUE = EvalResult(true)
Expand Down
10 changes: 10 additions & 0 deletions common/src/main/kotlin/trplugins/menu/util/conf/Property.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ enum class Property(val default: String, val regex: Regex) {
*/
ICON_DISPLAY_LORE("lore", "(display)?-?lores?"),

/**
* 菜单图标显示 - 物品损伤值
*/
ICON_DISPLAY_DATA("data", "(display)?-?data"),

/**
* 菜单图标显示 - 物品数量
*/
Expand Down Expand Up @@ -243,6 +248,11 @@ enum class Property(val default: String, val regex: Regex) {
*/
ICON_DISPLAY_HIDE_TOOLTIP("hide_tooltip", "hide_?tool(tip)?"),

/**
* 菜单图标 - Unbreakable
*/
ICON_DISPLAY_UNBREAKABLE("unbreakable", "unbreak(able)?"),

/**
* 菜单图标 - 子图标
*/
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.8.9
version=3.9.7
2 changes: 2 additions & 0 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ dependencies {
compileOnly("org.apache.commons:commons-lang3:3.17.0")

// Server Core
compileOnly("ink.ptms.core:v12005:12005-minimize:mapped")
compileOnly("ink.ptms.core:v12005:12005-minimize:universal")
compileOnly("ink.ptms.core:v12002:12002-minimize:mapped")
compileOnly("ink.ptms.core:v12002:12002-minimize:universal")
compileOnly("ink.ptms.core:v11904:11904-minimize:mapped")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,12 @@ object MenuSerializer : ISerializer {
val hideTooltip = if (inherit.contains(Property.ICON_DISPLAY_HIDE_TOOLTIP)) {
def!!.display.meta.hideTooltip
} else Property.ICON_DISPLAY_HIDE_TOOLTIP.ofString(display, "false")
val unbreakable = if (inherit.contains(Property.ICON_DISPLAY_UNBREAKABLE)) {
def!!.display.meta.unbreakable
} else Property.ICON_DISPLAY_UNBREAKABLE.ofString(display, "false")
val data = if (inherit.contains(Property.ICON_DISPLAY_DATA)) {
def!!.display.meta.data
} else Property.ICON_DISPLAY_DATA.ofString(display, "")

// only for the subIcon
val priority = Property.PRIORITY.ofInt(it, order)
Expand Down Expand Up @@ -396,7 +402,7 @@ object MenuSerializer : ISerializer {
if (def != null && inherit.contains(Property.ICON_DISPLAY_LORE) && lore.isEmpty()) def.display.lore
else CycleList(lore.map { Lore(line(it)) }),
// 图标附加属性
Meta(amount, shiny, flags, nbt, tooltipStyle, itemModel, hideTooltip)
Meta(amount, shiny, flags, nbt, tooltipStyle, itemModel, hideTooltip, unbreakable, data)
)

// i18n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ open class Item(
meta.tooltipStyle(session, this)
meta.itemModel(session, this)
meta.hideTooltip(session, this)
meta.unbreakable(session, this)
meta.data(session, this)

if (meta.hasAmount()) this.amount = meta.amount(session)
}
Expand Down Expand Up @@ -132,7 +134,7 @@ open class Item(
else {
val current = cache[session.id]
try {
val new = buildItem(current!!) { name = parsedName(session) }
val new = buildItem(current!!) { parsedName(session)?.let { name = it } }
cache[session.id] = new
} catch (t: Throwable) {
t.stackTrace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ class Meta(
val tooltip: String?,
val itemModel: String?,
val hideTooltip: String,
val unbreakable: String,
val data: String,
) {

private val isAmountDynamic = amount.toIntOrNull() == null
private val isShinyDynamic = !shiny.matches(Regexs.BOOLEAN)
private val isHideTooltipDynamic = !hideTooltip.matches(Regexs.BOOLEAN)
private val isNBTDynamic = nbt != null && Regexs.containsPlaceholder(nbt.toJsonSimplified())
private val isUnbreakableDynamic = !unbreakable.matches(Regexs.BOOLEAN)
private val isDataDynamic = data.toIntOrNull() == null
val isDynamic = isAmountDynamic || isNBTDynamic || isShinyDynamic || isHideTooltipDynamic

fun amount(session: MenuSession): Int {
Expand Down Expand Up @@ -82,9 +86,23 @@ class Meta(
}

fun hideTooltip(session: MenuSession, builder: ItemBuilder) {
if ((hideTooltip.toBoolean()) || (isHideTooltipDynamic && session.placeholderPlayer.evalScript(hideTooltip).asBoolean())) {
if (hideTooltip.toBoolean() || (isHideTooltipDynamic && session.placeholderPlayer.evalScript(hideTooltip).asBoolean())) {
builder.isHideTooltip = true
}
}

fun unbreakable(session: MenuSession, builder: ItemBuilder) {
if (unbreakable.toBoolean() || (isUnbreakableDynamic && session.placeholderPlayer.evalScript(unbreakable).asBoolean())) {
builder.isUnbreakable = true
}
}

fun data(session: MenuSession, builder: ItemBuilder) {
if (data.isEmpty()) {
return
}
val evalData = session.parse(amount).toIntOrNull() ?: session.placeholderPlayer.evalScript(data).asInt(0)
builder.damage = evalData
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package trplugins.menu.module.internal.command.impl
import org.bukkit.Bukkit
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import taboolib.common.io.newFile
import taboolib.common.platform.command.subCommand
import taboolib.common.platform.function.adaptCommandSender
import taboolib.common.platform.function.getDataFolder
import taboolib.common.platform.function.pluginVersion
import taboolib.common.platform.function.submit
import taboolib.module.chat.HexColor
import taboolib.platform.util.sendLang
import trplugins.menu.TrMenu
import trplugins.menu.api.TrMenuAPI
import trplugins.menu.module.display.Menu
Expand Down Expand Up @@ -84,27 +86,44 @@ object CommandDebug : CommandExpression {
val dump = buildString {
append("TrMenu Dump Information (Date: ${Time.formatDate()})\n\n")
append("| Server OS: ${properties["os.name"]} ${properties["os.arch"]} ${properties["os.version"]}\n")
append("| Server software: ${Bukkit.getServer().version} (${Bukkit.getServer().bukkitVersion})\n")
append("| Java version: ${System.getProperty("java.version")}\n\n")
append("| Server software: ${Bukkit.getName()} - ${Bukkit.getServer().version} (${Bukkit.getServer().bukkitVersion})\n")
append("| Java version: ${getJavaVendorDetailed()}\n\n")
append("| TrMenu: ${pluginVersion}\n")
// append(" ${description.getString("built-time")} by ${description.getString("built-by")})\n\n")
append("Installed Plugins: \n")
Bukkit.getPluginManager().plugins.sortedBy { it.name }.forEach { plugin ->
var file: File? = null
try {
Class.forName("org.bukkit.plugin.java.JavaPlugin").also { it ->
file = it.getMethod("getFile").also { it.isAccessible = true }.invoke(plugin) as File
}
} catch (t: Throwable) {
t.stackTrace
}
val size = (file?.length() ?: 0) / 1024
append("· ${plugin.name} - ${plugin.description.version} ($size KB)\n")
append("· ${plugin.name} - ${plugin.description.version}\n")
}
}
val fileName = "dump-info-${System.currentTimeMillis()}.log"
val file = newFile(getDataFolder(), "debug/$fileName")
file.writeText(dump)
sender.sendLang("Dump-Info-Created", file.absolutePath)
Paster.paste(adaptCommandSender(sender), dump)
}

private fun getJavaVendorDetailed(): String {
val vendor = System.getProperty("java.vendor") ?: "Unknown"
val version = System.getProperty("java.version") ?: "?"
val runtimeName = System.getProperty("java.runtime.name") ?: ""
val runtimeVersion = System.getProperty("java.runtime.version") ?: ""

return buildString {
append(vendor)
append(" (")
append(runtimeName)
if (runtimeVersion.isNotBlank()) {
append(" ")
append(runtimeVersion)
} else {
append(" v")
append(version)
}
append(")")
}
}


/**
* 服务器信息查看
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ object ItemHelper {
if (type.size == 1) {
builder.finishing = {
try {
(it.itemMeta as? BannerMeta)?.baseColor = DyeColor.valueOf(type[0].uppercase())
(it.itemMeta as? BannerMeta)?.addPattern(Pattern(DyeColor.valueOf(type[0].uppercase()), PatternType.BASE))
} catch (e: Exception) {
(it.itemMeta as? BannerMeta)?.baseColor = DyeColor.BLACK
(it.itemMeta as? BannerMeta)?.addPattern(Pattern(DyeColor.BLACK, PatternType.BASE))
}
}
} else if (type.size == 2) {
Expand Down
3 changes: 2 additions & 1 deletion plugin/src/main/resources/lang/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@ Command-Convert-Unknown-Type: '&8[&3Tr&bMenu&8] &7Unknown type &b{0} &7.'
Command-Convert-Type-Already: '&8[&3Tr&bMenu&8] &7The type of menu &6{0} &7 is already &b{1} &7.'
Command-Convert-Converted: '&8[&3Tr&bMenu&8] &7Typecast menu &6{0} &7 to &b{1}&7.'
Command-Data-Get: '&8[&3Tr&bMenu&8] &7Get &6{1} &7data &6{2} &7for player &6{0} &7: &f{3}.'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &cInvalid modify type.'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &cInvalid modify type.'
Dump-Info-Created: '&8[&3Tr&bMenu&8] &7File Created: &f{0}'
3 changes: 2 additions & 1 deletion plugin/src/main/resources/lang/ru_RU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ Command-Convert-Unknown-Type: '&8[&3Tr&bMenu&8] &7Неизвестный вид
Command-Convert-Type-Already: '&8[&3Tr&bMenu&8] &7Вид меню &6{0} &7 находится &b{1} &7.'
Command-Convert-Converted: '&8[&3Tr&bMenu&8] &7Типичное меню от &6{0} &7 до &b{1}&7.'
Command-Data-Get: '&8[&3Tr&bMenu&8] &7Получение &6{1} &7данных &6{2} &7для &7игрока &6{0}&7: &f{3}'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &cInvalid modify type.'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &cInvalid modify type.'
Dump-Info-Created: '&8[&3Tr&bMenu&8] &7File Created: &f{0}'
1 change: 1 addition & 0 deletions plugin/src/main/resources/lang/uk_UA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,4 @@ Menu-Loader-Loading: '&8[&3Tr&bMenu&8] &6ПОТІК &8| &3Завантаженн
Command-Data-Get: '&8[&3Tr&bMenu&8] &7Отримати дані про &6{1} &7гравців &6{0} {2} &7: &f{3}'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &cInvalid modify type.'
Command-Data-Description: 'Modify & get data'
Dump-Info-Created: '&8[&3Tr&bMenu&8] &7File Created: &f{0}'
3 changes: 2 additions & 1 deletion plugin/src/main/resources/lang/vi_VN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@ Command-Convert-Unknown-Type: '&8[&3Tr&bMenu&8] &7Unknown type &b{0} &7.'
Command-Convert-Type-Already: '&8[&3Tr&bMenu&8] &7The type of menu &6{0} &7 is already &b{1} &7.'
Command-Convert-Converted: '&8[&3Tr&bMenu&8] &7Typecast menu &6{0} &7 to &b{1}&7.'
Command-Data-Get: '&8[&3Tr&bMenu&8] &7Nhận &6{1} &7dữ liệu &6{2} &7của người chơi &6{0}&7: &f{3}'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &cInvalid modify type.'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &cInvalid modify type.'
Dump-Info-Created: '&8[&3Tr&bMenu&8] &7File Created: &f{0}'
3 changes: 2 additions & 1 deletion plugin/src/main/resources/lang/zh_CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ Command-Convert-Unknown-Type: '&8[&3Tr&bMenu&8] &7未知类型 &b{0} &7.'
Command-Convert-Type-Already: '&8[&3Tr&bMenu&8] &7菜单 &6{0} &7的类型已经是 &b{1} &7了.'
Command-Convert-Converted: '&8[&3Tr&bMenu&8] &7已将菜单 &6{0} &7的类型转换为 &b{1}&7.'
Command-Data-Get: '&8[&3Tr&bMenu&8] &7获取玩家 &6{0} &7的 &6{1} &7数据 &6{2} &7: &f{3}'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &c无效的修改类型'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &c无效的修改类型'
Dump-Info-Created: '&8[&3Tr&bMenu&8] &7已创建文件: &f{0}'
3 changes: 2 additions & 1 deletion plugin/src/main/resources/lang/zh_HK.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@ Command-Convert-Unknown-Type: '&8[&3Tr&bMenu&8] &7未知類型 &b{0} &7.'
Command-Convert-Type-Already: '&8[&3Tr&bMenu&8] &7菜單 &6{0} &7的類型已經是 &b{1} &7了.'
Command-Convert-Converted: '&8[&3Tr&bMenu&8] &7已將菜單 &6{0} &7的類型轉換為 &b{1}&7.'
Command-Data-Get: '&8[&3Tr&bMenu&8] &7獲取玩家 &6{0} &7的 &6{1} &7數據 &6{2} &7: &f{3}'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &c無效的修改類型'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &c無效的修改類型'
Dump-Info-Created: '&8[&3Tr&bMenu&8] &7已創建文件: &f{0}'
3 changes: 2 additions & 1 deletion plugin/src/main/resources/lang/zh_TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ Command-Convert-Unknown-Type: '&8[&3Tr&bMenu&8] &7未知類型 &b{0} &7.'
Command-Convert-Type-Already: '&8[&3Tr&bMenu&8] &7菜單 &6{0} &7的類型已經是 &b{1} &7了.'
Command-Convert-Converted: '&8[&3Tr&bMenu&8] &7已將菜單 &6{0} &7的類型轉換為 &b{1}&7.'
Command-Data-Get: '&8[&3Tr&bMenu&8] &7獲取玩家 &6{0} &7的 &6{1} &7數據 &6{2} &7: &f{3}'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &c無效的修改類型'
Command-Data-Invalid-Modify: '&8[&3Tr&bMenu&8] &c無效的修改類型'
Dump-Info-Created: '&8[&3Tr&bMenu&8] &7已創建文件: &f{0}'