Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.
Open

Error #398

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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# [Invero](http://invero.trixey.cc/) is available, this is the inventory gui for bukkit of emerging。 TrMenu will be deprecated.
## TrMenu was deprecated the 25/03/2023

TrMenu is now working on 1.20.1

# I'm trying to maintain TrMenu alive, please open an issue if you have any suggestions / bugs

---
## (Deprecated) TrMenu

![](https://attachment.mcbbs.net/data/myattachment/forum/202108/17/142921rll20j5kie5kzk1f.gif)
![](https://img.shields.io/github/last-commit/Arasple/TrMenu?logo=artstation&style=for-the-badge&color=9266CC)![](https://img.shields.io/github/issues/InsinuateProjects/TrMenu?style=for-the-badge&logo=slashdot)![](https://img.shields.io/github/release/Arasple/TrMenu?style=for-the-badge&color=00C58E&logo=ionic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package trplugins.menu.api.action
import taboolib.common.io.runningClasses
import taboolib.common.platform.ProxyPlayer
import taboolib.common.platform.function.submit
import taboolib.common.reflect.Reflex.Companion.invokeConstructor
import taboolib.library.reflex.Reflex.Companion.invokeConstructor
import trplugins.menu.api.action.base.ActionBase
import trplugins.menu.api.action.base.ActionEntry
import trplugins.menu.api.action.impl.logic.Break
Expand Down Expand Up @@ -33,7 +33,7 @@ class ActionHandle(
register(*runningClasses.toTypedArray())
}

fun register(vararg classes: Class<*>) {
private fun register(vararg classes: Class<*>) {
classes.forEach { `class` ->
if (Modifier.isAbstract(`class`.modifiers)) return@forEach
if (`class`.superclass != ActionBase::class.java) return@forEach
Expand All @@ -54,7 +54,7 @@ class ActionHandle(
}
}

fun unregister(vararg names: String) {
private fun unregister(vararg names: String) {
return unregister(*names.map { getRegisteredAction(it) }.toTypedArray())
}

Expand All @@ -65,7 +65,7 @@ class ActionHandle(
fun getRegisteredAction(key: String): ActionBase =
registries.find { key.lowercase() == it.lowerName || it.regex.matches(key.lowercase()) } ?: defaultAction

val defaultAction by lazy { registries.find { it.name.equals(default, true) }!! }
private val defaultAction by lazy { registries.find { it.name.equals(default, true) }!! }

fun runAction(player: ProxyPlayer, actions: List<String>) {
runAction(player, ActionEntry.of(this, actions))
Expand Down
4 changes: 2 additions & 2 deletions api/receptacle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ repositories {
dependencies {
compileOnly(project(":common"))
compileOnly("ink.ptms:nms-all:1.0.0")
compileOnly("ink.ptms.core:v11900:11900-minimize:universal")
compileOnly("ink.ptms.core:v11900:11900-minimize:mapped")
compileOnly("ink.ptms.core:v11903:11903-minimize:mapped")
compileOnly("ink.ptms.core:v11903:11903-minimize:universal")
compileOnly("org.geysermc.floodgate:api:2.2.0-SNAPSHOT")
compileOnly(fileTree("libs"))
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id("org.gradle.java")
id("org.gradle.maven-publish")
kotlin("jvm") version "1.8.0" apply false
id("io.izzel.taboolib") version "1.55" apply false
id("io.izzel.taboolib") version "1.56" apply false
}

description = "Modern & Advanced Menu-Plugin for Minecraft Servers"
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/kotlin/trplugins/menu/util/net/PasteGG.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package trplugins.menu.util.net

import taboolib.common.Isolated
import taboolib.common.env.DependencyDownloader
import taboolib.common.env.IO
import trplugins.menu.util.parseJson
import java.net.HttpURLConnection
import java.net.URL
Expand Down Expand Up @@ -70,7 +71,7 @@ object PasteGG {
con.doInput = true
con.doOutput = true
con.outputStream.also { it.write(json.toByteArray(StandardCharsets.UTF_8)) }
val source = DependencyDownloader.readFully(con.inputStream, StandardCharsets.UTF_8).parseJson().asJsonObject
val source = IO.readFully(con.inputStream, StandardCharsets.UTF_8).parseJson().asJsonObject

success.invoke(source.toString())
} catch (e: Throwable) {
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/kotlin/trplugins/menu/util/net/Paster.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package trplugins.menu.util.net

import taboolib.common.env.DependencyDownloader
import taboolib.common.env.IO
import taboolib.common.platform.ProxyCommandSender
import taboolib.common.platform.function.submit
import taboolib.module.lang.sendLang
Expand Down Expand Up @@ -35,7 +36,7 @@ object Paster {
con.doInput = true
con.doOutput = true
con.outputStream.also { it.write(content.toByteArray(StandardCharsets.UTF_8)) }
val source = DependencyDownloader.readFully(con.inputStream, StandardCharsets.UTF_8).parseJson().asJsonObject
val source = IO.readFully(con.inputStream, StandardCharsets.UTF_8).parseJson().asJsonObject
url(URL + source.get("key").asString)
} catch (e: Throwable) {
e.printStackTrace()
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=me.arasple.mc.trmenu
version=3.1.19
taboolibVersion=6.0.10-98
version=3.1.22
taboolibVersion=6.0.12-13
3 changes: 0 additions & 3 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ dependencies {
// Libraries
compileOnly("org.apache.commons:commons-lang3:3.12.0")
compileOnly("com.electronwill.night-config:core:3.6.5")
compileOnly("cc.trixey.invero:framework-common:1.0.0")
compileOnly("cc.trixey.invero:framework-bukkit:1.0.0")
// compileOnly("cc.trixey.invero:framework-core:1.0.0")

// Server Core
compileOnly("ink.ptms.core:v11903:11903-minimize:mapped")
Expand Down
25 changes: 9 additions & 16 deletions plugin/src/main/kotlin/trplugins/menu/api/TrMenuAPI.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package trplugins.menu.api

import org.bukkit.command.CommandMap
import trplugins.menu.module.display.Menu
import trplugins.menu.module.internal.data.Metadata
import trplugins.menu.util.EvalResult
import trplugins.menu.module.internal.service.Performance
import taboolib.library.kether.LocalizedException
import org.bukkit.entity.Player
import taboolib.common.platform.function.adaptPlayer
import taboolib.common.platform.function.onlinePlayers
import taboolib.common.platform.function.pluginId
import taboolib.library.kether.LocalizedException
import taboolib.module.kether.KetherShell
import taboolib.module.kether.KetherShell.eval
import taboolib.module.kether.ScriptContext
import taboolib.module.kether.ScriptOptions
import trplugins.menu.module.display.Menu
import trplugins.menu.module.internal.data.Metadata
import trplugins.menu.module.internal.service.Performance
import trplugins.menu.util.EvalResult
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
Expand All @@ -36,14 +36,7 @@ object TrMenuAPI {
fun eval(player: Player, script: String): CompletableFuture<Any?> {
Performance.check("Handler:Script:Evaluation") {
return try {
KetherShell.eval(script, namespace = listOf("trmenu")) {
sender = adaptPlayer(player)
rootFrame().variables().run {
Metadata.getMeta(player).data.forEach { (key, value) ->
set(key, value.toString())
}
}
}
eval(script, ScriptOptions.builder().namespace(namespace = listOf("trmenu")).sender(adaptPlayer(player)).build())
} catch (e: LocalizedException) {
println("§c[TrMenu] §8Unexpected exception while parsing kether shell:")
e.localizedMessage.split("\n").forEach {
Expand Down
17 changes: 9 additions & 8 deletions plugin/src/main/kotlin/trplugins/menu/module/conf/Loader.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package trplugins.menu.module.conf

import trplugins.menu.util.concurrent.TaskConcurrent
import trplugins.menu.TrMenu
import trplugins.menu.api.TrMenuAPI
import trplugins.menu.api.event.MenuOpenEvent
import trplugins.menu.module.conf.prop.SerialzeResult
import trplugins.menu.module.display.Menu
import trplugins.menu.util.file.FileListener
import org.bukkit.Bukkit
import org.bukkit.command.CommandSender
import taboolib.common.platform.function.console
import taboolib.common.platform.function.releaseResourceFile
import taboolib.module.lang.sendLang
import taboolib.platform.util.sendLang
import trplugins.menu.TrMenu
import trplugins.menu.api.TrMenuAPI
import trplugins.menu.api.event.MenuOpenEvent
import trplugins.menu.module.conf.prop.SerialzeResult
import trplugins.menu.module.display.Menu
import trplugins.menu.util.concurrent.TaskConcurrent
import trplugins.menu.util.file.FileListener
import java.io.File

/**
Expand Down Expand Up @@ -121,7 +121,8 @@ object Loader {
* 监听菜单
*/
internal fun listen(file: File) {
if (!FileListener.isListening(file)) {
val isListening = runCatching { !FileListener.isListening(file) }.getOrElse { true }
if (!isListening) {
FileListener.listener(file) {
val start = System.currentTimeMillis()
val reload = try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ object MenuSerializer : ISerializer {
* Func Ⅴ. 载入图标显示部分
*/
private val loadIconProperty: (String, IconProperty?, Configuration?, Configuration?, Configuration?, Int) -> IconProperty =
{ id, def, it, display, action, order ->
{ _, def, it, display, action, order ->
val name = Property.ICON_DISPLAY_NAME.ofStringList(display)
val texture = Property.ICON_DISPLAY_MATERIAL.ofStringList(display)
val lore = Property.ICON_DISPLAY_LORE.ofLists(display)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Meta(
}

fun nbt(session: MenuSession, itemStack: ItemStack): ItemMeta? {
if (nbt != null && !nbt.isEmpty()) {
val nbt = if (isNBTDynamic) ItemTag.fromLegacyJson(session.parse(nbt.toJson())) else nbt
if (!nbt.isNullOrEmpty()) {
val nbt = if (isNBTDynamic) ItemTag.fromJson(session.parse(nbt.toJson())) else nbt
val tag = ItemTag()
tag.putAll(itemStack.getItemTag())
tag.putAll(nbt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package trplugins.menu.module.display.texture

import org.bukkit.Material
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.LeatherArmorMeta
import org.bukkit.inventory.meta.SkullMeta
import taboolib.common.util.Strings.similarDegree
import taboolib.library.xseries.XMaterial
import taboolib.module.nms.MinecraftVersion
import taboolib.platform.util.buildItem
import trplugins.menu.api.menu.ITexture
import trplugins.menu.module.display.MenuSession
import trplugins.menu.module.internal.hook.HookPlugin
Expand All @@ -9,15 +17,6 @@ import trplugins.menu.module.internal.item.ItemSource
import trplugins.menu.util.Regexs
import trplugins.menu.util.bukkit.Heads
import trplugins.menu.util.bukkit.ItemHelper
import org.bukkit.Material
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.LeatherArmorMeta
import org.bukkit.inventory.meta.SkullMeta
import taboolib.common.reflect.Reflex.Companion.invokeMethod
import taboolib.common.util.Strings.similarDegree
import taboolib.library.xseries.XMaterial
import taboolib.module.nms.MinecraftVersion
import taboolib.platform.util.buildItem

/**
* @author Arasple
Expand Down Expand Up @@ -146,48 +145,20 @@ class Texture(

private fun parseMaterial(material: String): ItemStack {
val split = material.split(":", limit = 2)
val data = split.getOrNull(1)?.toIntOrNull() ?: 0
val id = split[0].toIntOrNull() ?: split[0].uppercase().replace("[ _]".toRegex(), "_")


val item = try {
buildItem(XMaterial.matchXMaterial(FALL_BACK)) {
if (id is Int) {
try {
this.material = Material::class.java.invokeMethod<Material>(
"getMaterial",
id.toInt(),
fixed = true
)!!
this.damage = data
} catch (t: Throwable) {
t.printStackTrace()
XMaterial.matchXMaterial(id, -1).let {
if (it.isPresent) {
setMaterial(it.get())
this.damage = data
} else {
XMaterial.STONE
}
}
}
/* XMaterial.matchXMaterial(id, (-1).toByte()).let {
if (it.isPresent) {
setMaterial(it.get())
this.damage = data
} else {
XMaterial.STONE
}
}*/
} else {
val name = id.toString()
this.material = Material.getMaterial(name)!!
}
val name = id.toString()
this.material = Material.getMaterial(name)!!
}
} catch (e: Throwable) {
runCatching { XMaterial.values().find { it.name.equals(id.toString(), true) }
?: XMaterial.values().find { it -> it.legacy.any { it == id.toString() } }
?: XMaterial.values().maxByOrNull { similarDegree(id.toString(), it.name) } }.getOrNull()?.parseItem()
runCatching {
XMaterial.values().find { it.name.equals(id.toString(), true) }
?: XMaterial.values().find { it -> it.legacy.any { it == id.toString() } }
?: XMaterial.values().maxByOrNull { similarDegree(id.toString(), it.name) }
}.getOrNull()?.parseItem()
?: FALL_BACK
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ object HookPlugin {
return get(HookHeadDatabase::class.java)
}

fun getOraxen(): HookOraxen {
return get(HookOraxen::class.java)
}

fun getPlayerPoints(): HookPlayerPoints {
return get(HookPlayerPoints::class.java)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ object ItemSource {
else HookPlugin[HookSkulls::class.java].getSkull(id)
}
"JAVASCRIPT", "JS" -> JavaScriptAgent.eval(session, id).asItemStack()
"ORAXEN" -> HookPlugin.getOraxen().getItem(id)
"ITEMSADDER", "IA" -> HookPlugin.getItemsAdder().getItem(id)
"ZAPHKIEL", "ZL" -> HookPlugin.getZaphkiel().getItem(id)
else -> CustomItemSourceEvent(name, id, session).also { it.call() }.source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import trplugins.menu.TrMenu
import org.bukkit.event.player.PlayerJoinEvent
import taboolib.common.LifeCycle
import taboolib.common.env.DependencyDownloader
import taboolib.common.env.IO
import taboolib.common.platform.*
import taboolib.common.platform.event.EventPriority
import taboolib.common.platform.event.SubscribeEvent
Expand Down Expand Up @@ -48,7 +49,7 @@ object Updater {
try {
URL(API_URL).openStream().use { inputStream ->
BufferedInputStream(inputStream).use { bufferedInputStream ->
read = DependencyDownloader.readFully(bufferedInputStream, StandardCharsets.UTF_8)
read = IO.readFully(bufferedInputStream, StandardCharsets.UTF_8)
val json = JsonParser().parse(read) as JsonObject
val latestVersion = json.get("tag_name").asDouble
if (latestVersion > CURRENT_VERSION) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object ItemHelper {
builder.patterns.clear()
builder.patterns.addAll(string.split(",").let {
val patterns = mutableListOf<Pattern>()
it.forEach {
it.forEach { it ->
val type = it.split(" ")
if (type.size == 1) {
builder.finishing = {
Expand Down Expand Up @@ -109,7 +109,11 @@ object ItemHelper {
itemStack?.amount = it.asInt
}
val meta = parse["meta"]
return if (meta != null) itemStack.also { ItemTag.fromLegacyJson(meta.toString()).saveTo(it) }
return if (meta != null) itemStack.also {
if (it != null) {
ItemTag.fromLegacyJson(meta.toString()).saveTo(it)
}
}
else itemStack
}
return null
Expand Down