diff --git a/build.gradle.kts b/build.gradle.kts index df044fa..5bce97d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,9 +3,9 @@ import java.net.URL plugins { `java-library` `maven-publish` - id("io.izzel.taboolib") version "1.51" - id("org.jetbrains.kotlin.jvm") version "1.6.10" - id("org.jetbrains.dokka") version "1.6.10" + id("io.izzel.taboolib") version "1.56" + id("org.jetbrains.kotlin.jvm") version "1.7.20" + id("org.jetbrains.dokka") version "1.7.20" } @@ -71,7 +71,7 @@ taboolib { install("platform-bukkit") install("module-nms") classifier = null - version = "6.0.10-38" + version = "6.0.12-34" } repositories { @@ -82,8 +82,12 @@ repositories { dependencies { dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.6.10") - compileOnly("com.google.code.gson:gson:2.9.0") + compileOnly("ink.ptms:nms-all:1.0.0") + compileOnly("ink.ptms.core:v11900:11900:mapped") + compileOnly("ink.ptms.core:v11900:11900:universal") + compileOnly("ink.ptms.core:v11200:11200") + compileOnly("io.lumine:Mythic-Dist:5.0.3") compileOnly("com.github.LoneDev6:api-itemsadder:3.0.0") @@ -128,4 +132,4 @@ publishing { groupId = project.group.toString() } } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index e0217cd..65d617f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=com.skillw.itemsystem -version=1.0.4 \ No newline at end of file +version=2.0.0 diff --git a/libs/AttributeSystem-1.4.4-gamma-code.jar b/libs/AttributeSystem-1.4.4-gamma-code.jar deleted file mode 100644 index 93a4c61..0000000 Binary files a/libs/AttributeSystem-1.4.4-gamma-code.jar and /dev/null differ diff --git a/libs/AttributeSystem-2.1.0-gamma-7-api.jar b/libs/AttributeSystem-2.1.0-gamma-7-api.jar new file mode 100644 index 0000000..0bbf671 Binary files /dev/null and b/libs/AttributeSystem-2.1.0-gamma-7-api.jar differ diff --git a/libs/BuffSystem-1.1.3-code.jar b/libs/BuffSystem-1.1.3-code.jar deleted file mode 100644 index e010a72..0000000 Binary files a/libs/BuffSystem-1.1.3-code.jar and /dev/null differ diff --git a/libs/BuffSystem-1.2.0-alpha-3-api.jar b/libs/BuffSystem-1.2.0-alpha-3-api.jar new file mode 100644 index 0000000..af070fe Binary files /dev/null and b/libs/BuffSystem-1.2.0-alpha-3-api.jar differ diff --git a/libs/Pouvoir-1.6.0-A-api.jar b/libs/Pouvoir-1.6.0-A-api.jar deleted file mode 100644 index dde723e..0000000 Binary files a/libs/Pouvoir-1.6.0-A-api.jar and /dev/null differ diff --git a/libs/Pouvoir-1.6.5-4-api.jar b/libs/Pouvoir-1.6.5-4-api.jar new file mode 100644 index 0000000..68d129c Binary files /dev/null and b/libs/Pouvoir-1.6.5-4-api.jar differ diff --git a/src/main/kotlin/com/skillw/itemsystem/ItemSystem.kt b/src/main/kotlin/com/skillw/itemsystem/ItemSystem.kt index 25e70cd..885a5eb 100644 --- a/src/main/kotlin/com/skillw/itemsystem/ItemSystem.kt +++ b/src/main/kotlin/com/skillw/itemsystem/ItemSystem.kt @@ -2,16 +2,14 @@ package com.skillw.itemsystem import com.skillw.itemsystem.api.manager.* import com.skillw.itemsystem.internal.manager.ISConfig -import com.skillw.pouvoir.api.annotation.PouManager import com.skillw.pouvoir.api.manager.ManagerData import com.skillw.pouvoir.api.plugin.SubPouvoir -import com.skillw.pouvoir.api.thread.BasicThreadFactory +import com.skillw.pouvoir.api.plugin.annotation.PouManager import org.bukkit.plugin.java.JavaPlugin import taboolib.common.platform.Plugin import taboolib.module.configuration.Config import taboolib.module.configuration.ConfigFile import taboolib.platform.BukkitPlugin -import java.util.concurrent.ScheduledThreadPoolExecutor object ItemSystem : Plugin(), SubPouvoir { @@ -74,4 +72,4 @@ object ItemSystem : Plugin(), SubPouvoir { disable() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/action/ActionType.kt b/src/main/kotlin/com/skillw/itemsystem/api/action/ActionType.kt index de760f1..e7fffef 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/action/ActionType.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/action/ActionType.kt @@ -1,11 +1,11 @@ package com.skillw.itemsystem.api.action import com.skillw.itemsystem.ItemSystem -import com.skillw.pouvoir.api.able.Registrable +import com.skillw.pouvoir.api.plugin.map.component.Registrable class ActionType(override val key: String) : Registrable { override fun register() { ItemSystem.actionTypeManager.register(this) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/builder/BaseItemBuilder.kt b/src/main/kotlin/com/skillw/itemsystem/api/builder/BaseItemBuilder.kt index ef98e44..4105b38 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/builder/BaseItemBuilder.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/builder/BaseItemBuilder.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.api.builder import com.skillw.itemsystem.internal.core.builder.ProcessData import com.skillw.itemsystem.internal.core.meta.data.MetaData -import com.skillw.pouvoir.api.able.Registrable +import com.skillw.pouvoir.api.plugin.map.component.Registrable import org.bukkit.configuration.serialization.ConfigurationSerializable import org.bukkit.entity.LivingEntity import org.bukkit.inventory.ItemStack @@ -34,4 +34,4 @@ abstract class BaseItemBuilder(override val key: String) : Registrable, */ abstract fun build(entity: LivingEntity? = null, processData: ProcessData = ProcessData(entity)): ItemStack -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/builder/IProcessData.kt b/src/main/kotlin/com/skillw/itemsystem/api/builder/IProcessData.kt index 065e9e7..9f4c3f9 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/builder/IProcessData.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/builder/IProcessData.kt @@ -50,4 +50,4 @@ interface IProcessData { * @return 结果 */ fun result(receiver: ProcessData.() -> Unit): ItemStack -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/event/ItemBuildEvent.kt b/src/main/kotlin/com/skillw/itemsystem/api/event/ItemBuildEvent.kt index 258329a..64d789b 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/event/ItemBuildEvent.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/event/ItemBuildEvent.kt @@ -20,7 +20,7 @@ class ItemBuildEvent { * @property data 过程数据 * @property entity 实体 */ - class Post(val builder: BaseItemBuilder, val data: ProcessData, val entity: LivingEntity?) : BukkitProxyEvent() + class Pre(val builder: BaseItemBuilder, val data: ProcessData, val entity: LivingEntity?) : BukkitProxyEvent() /** * 构建物品中,Meta已经运行完毕,下一步就是构建物品 @@ -38,7 +38,7 @@ class ItemBuildEvent { * @property itemStack 结果物品 * @property entity 实体 */ - class After( + class Post( val builder: BaseItemBuilder, val data: ProcessData, var itemStack: ItemStack, @@ -58,4 +58,4 @@ class ItemBuildEvent { var itemStack: ItemStack, val entity: LivingEntity, ) : BukkitProxyEvent() -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/glow/GlowColor.kt b/src/main/kotlin/com/skillw/itemsystem/api/glow/GlowColor.kt index 0c023fc..070ff99 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/glow/GlowColor.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/glow/GlowColor.kt @@ -1,8 +1,8 @@ package com.skillw.itemsystem.api.glow import com.skillw.itemsystem.util.nms.NMS -import com.skillw.pouvoir.api.able.Registrable -import com.skillw.pouvoir.api.map.KeyMap +import com.skillw.pouvoir.api.plugin.map.KeyMap +import com.skillw.pouvoir.api.plugin.map.component.Registrable import org.bukkit.ChatColor import org.bukkit.entity.Entity import org.bukkit.entity.Player @@ -76,4 +76,4 @@ class GlowColor(override val key: ChatColor) : Registrable { override fun register() { glowColors.register(this) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/manager/ActionTypeManager.kt b/src/main/kotlin/com/skillw/itemsystem/api/manager/ActionTypeManager.kt index ea1ea85..bd263bb 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/manager/ActionTypeManager.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/manager/ActionTypeManager.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.api.manager import com.skillw.itemsystem.api.action.ActionType import com.skillw.pouvoir.api.manager.Manager -import com.skillw.pouvoir.api.map.LowerKeyMap +import com.skillw.pouvoir.api.plugin.map.LowerKeyMap import org.bukkit.entity.LivingEntity import org.bukkit.inventory.ItemStack @@ -28,4 +28,4 @@ abstract class ActionTypeManager : Manager, LowerKeyMap() { itemStack: ItemStack, receiver: MutableMap.() -> Unit, ) -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/manager/GlobalManager.kt b/src/main/kotlin/com/skillw/itemsystem/api/manager/GlobalManager.kt index c38adda..76538dd 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/manager/GlobalManager.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/manager/GlobalManager.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.api.manager import com.skillw.itemsystem.internal.core.meta.data.MetaData import com.skillw.pouvoir.api.manager.Manager -import com.skillw.pouvoir.api.map.BaseMap +import com.skillw.pouvoir.api.plugin.map.BaseMap /** * @className GlobalManager @@ -12,4 +12,4 @@ import com.skillw.pouvoir.api.map.BaseMap * @author Glom * @date 2022/8/7 7:20 Copyright 2022 user. All rights reserved. */ -abstract class GlobalManager : Manager, BaseMap() \ No newline at end of file +abstract class GlobalManager : Manager, BaseMap() diff --git a/src/main/kotlin/com/skillw/itemsystem/api/manager/ItemBuilderManager.kt b/src/main/kotlin/com/skillw/itemsystem/api/manager/ItemBuilderManager.kt index 3adcff1..57ddc95 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/manager/ItemBuilderManager.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/manager/ItemBuilderManager.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.api.manager import com.skillw.itemsystem.api.builder.BaseItemBuilder import com.skillw.pouvoir.api.manager.Manager -import com.skillw.pouvoir.api.map.KeyMap +import com.skillw.pouvoir.api.plugin.map.KeyMap import org.bukkit.configuration.ConfigurationSection import java.io.File @@ -18,4 +18,4 @@ abstract class ItemBuilderManager : Manager, KeyMap() { /** 物品构造器的Yaml文件 */ abstract val files: Set abstract val loading: MutableSet -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/manager/MetaManager.kt b/src/main/kotlin/com/skillw/itemsystem/api/manager/MetaManager.kt index 58b8db1..0fdc6b2 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/manager/MetaManager.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/manager/MetaManager.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.api.manager import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.pouvoir.api.manager.Manager -import com.skillw.pouvoir.api.map.KeyMap +import com.skillw.pouvoir.api.plugin.map.KeyMap /** * @className MetaManager @@ -14,4 +14,4 @@ import com.skillw.pouvoir.api.map.KeyMap */ abstract class MetaManager : Manager, KeyMap() { abstract val sortedMetas: List -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/manager/OptionManager.kt b/src/main/kotlin/com/skillw/itemsystem/api/manager/OptionManager.kt index 147432c..be74476 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/manager/OptionManager.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/manager/OptionManager.kt @@ -3,9 +3,10 @@ package com.skillw.itemsystem.api.manager import com.skillw.itemsystem.ItemSystem import com.skillw.itemsystem.api.builder.BaseItemBuilder import com.skillw.itemsystem.api.option.BaseOption +import com.skillw.itemsystem.internal.core.option.OptionType import com.skillw.pouvoir.api.manager.Manager -import com.skillw.pouvoir.api.map.KeyMap import com.skillw.pouvoir.api.plugin.SubPouvoir +import com.skillw.pouvoir.api.plugin.map.KeyMap import org.bukkit.configuration.ConfigurationSection /** @@ -17,6 +18,7 @@ import org.bukkit.configuration.ConfigurationSection * @date 2022/10/7 19:39 Copyright 2022 user. All rights reserved. */ object OptionManager : Manager, KeyMap() { + private fun readResolve(): Any = OptionManager override val key: String = "OptionManager" override val priority: Int = 1 override val subPouvoir: SubPouvoir = ItemSystem @@ -26,4 +28,9 @@ object OptionManager : Manager, KeyMap() { it.init(section, builder) } } -} \ No newline at end of file + + override fun onReload() { + OptionType.types.clear() + } + +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/manager/VarTypeManager.kt b/src/main/kotlin/com/skillw/itemsystem/api/manager/VarTypeManager.kt index 63ca89d..7cc74da 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/manager/VarTypeManager.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/manager/VarTypeManager.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.api.manager import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.vartype.VariableType import com.skillw.pouvoir.api.manager.Manager -import com.skillw.pouvoir.api.map.KeyMap +import com.skillw.pouvoir.api.plugin.map.KeyMap import java.util.function.Supplier /** @@ -25,4 +25,4 @@ abstract class VarTypeManager : Manager, KeyMap() { * @return */ abstract fun createVar(memory: Memory): Supplier? -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/meta/BaseMeta.kt b/src/main/kotlin/com/skillw/itemsystem/api/meta/BaseMeta.kt index 2b1ca3f..6bb0f27 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/meta/BaseMeta.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/meta/BaseMeta.kt @@ -5,7 +5,7 @@ import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.internal.core.builder.ProcessData import com.skillw.itemsystem.internal.core.meta.data.MetaData -import com.skillw.pouvoir.api.able.Registrable +import com.skillw.pouvoir.api.plugin.map.component.Registrable /** * @className BaseMeta @@ -55,4 +55,4 @@ abstract class BaseMeta(override val key: String) : Registrable, Compara override fun register() { ItemSystem.metaManager.register(this) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/meta/data/IMetaData.kt b/src/main/kotlin/com/skillw/itemsystem/api/meta/data/IMetaData.kt index 435c304..d68c2c2 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/meta/data/IMetaData.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/meta/data/IMetaData.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.api.meta.data import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.internal.core.meta.data.MetaData -import com.skillw.pouvoir.api.able.Keyable +import com.skillw.pouvoir.api.plugin.map.component.Keyable import org.bukkit.configuration.serialization.ConfigurationSerializable /** @@ -19,4 +19,4 @@ interface IMetaData : Keyable, ConfigurationSerializable { * @return 元数据 */ fun clone(): MetaData -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/meta/data/Memory.kt b/src/main/kotlin/com/skillw/itemsystem/api/meta/data/Memory.kt index 81dd149..0301dba 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/meta/data/Memory.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/meta/data/Memory.kt @@ -262,7 +262,7 @@ data class Memory(val metaData: MetaData, val processData: ProcessData) : IMetaD * @return */ internal fun getAny(key: String, processData: ProcessData): Any? { - return (metaData.get(key) ?: processData[key]) + return (metaData[key] ?: processData[key]) } /** @@ -273,7 +273,7 @@ data class Memory(val metaData: MetaData, val processData: ProcessData) : IMetaD * @return */ internal fun getList(key: String, processData: ProcessData): List? { - return ((metaData.get(key) ?: processData[key]) as? List?)?.map { it.analysis() } + return ((metaData[key] ?: processData[key]) as? List?)?.map { it.analysis() } } /** @@ -284,7 +284,7 @@ data class Memory(val metaData: MetaData, val processData: ProcessData) : IMetaD * @return */ internal fun getShort(key: String, processData: ProcessData): Short? { - return Coerce.toShort((metaData.get(key) ?: processData[key] ?: return null).analysis()) + return Coerce.toShort((metaData[key] ?: processData[key] ?: return null).analysis()) } /** @@ -295,7 +295,7 @@ data class Memory(val metaData: MetaData, val processData: ProcessData) : IMetaD * @return */ internal fun getByte(key: String, processData: ProcessData): Byte? { - return Coerce.toByte((metaData.get(key) ?: processData[key] ?: return null).analysis()) + return Coerce.toByte((metaData[key] ?: processData[key] ?: return null).analysis()) } /** @@ -306,7 +306,7 @@ data class Memory(val metaData: MetaData, val processData: ProcessData) : IMetaD * @return */ internal fun getBoolean(key: String, processData: ProcessData): Boolean? { - return Coerce.toBoolean((metaData.get(key) ?: processData[key] ?: return null).analysis()) + return Coerce.toBoolean((metaData[key] ?: processData[key] ?: return null).analysis()) } /** @@ -317,7 +317,7 @@ data class Memory(val metaData: MetaData, val processData: ProcessData) : IMetaD * @return */ internal fun getDouble(key: String, processData: ProcessData): Double? { - return Coerce.toDouble((metaData.get(key) ?: processData[key] ?: return null).analysis()) + return Coerce.toDouble((metaData[key] ?: processData[key] ?: return null).analysis()) } /** @@ -328,7 +328,7 @@ data class Memory(val metaData: MetaData, val processData: ProcessData) : IMetaD * @return */ internal fun getFloat(key: String, processData: ProcessData): Float? { - return Coerce.toFloat((metaData.get(key) ?: processData[key] ?: return null).analysis()) + return Coerce.toFloat((metaData[key] ?: processData[key] ?: return null).analysis()) } /** @@ -339,7 +339,7 @@ data class Memory(val metaData: MetaData, val processData: ProcessData) : IMetaD * @return */ internal fun getLong(key: String, processData: ProcessData): Long? { - return Coerce.toLong((metaData.get(key) ?: processData[key] ?: return null).analysis()) + return Coerce.toLong((metaData[key] ?: processData[key] ?: return null).analysis()) } /** @@ -350,7 +350,7 @@ data class Memory(val metaData: MetaData, val processData: ProcessData) : IMetaD * @return */ internal fun getInt(key: String, processData: ProcessData): Int? { - return Coerce.toInteger((metaData.get(key) ?: processData[key] ?: return null).analysis()) + return Coerce.toInteger((metaData[key] ?: processData[key] ?: return null).analysis()) } /** @@ -361,6 +361,6 @@ data class Memory(val metaData: MetaData, val processData: ProcessData) : IMetaD * @return */ internal fun getString(key: String, processData: ProcessData): String? { - return (metaData.get(key) ?: processData[key] ?: return null).analysis().toString() + return (metaData[key] ?: processData[key] ?: return null).analysis().toString() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/option/BaseOption.kt b/src/main/kotlin/com/skillw/itemsystem/api/option/BaseOption.kt index f905071..29a88e5 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/option/BaseOption.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/option/BaseOption.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.api.option import com.skillw.itemsystem.ItemSystem.optionManager import com.skillw.itemsystem.api.builder.BaseItemBuilder -import com.skillw.pouvoir.api.able.Registrable +import com.skillw.pouvoir.api.plugin.map.component.Registrable import org.bukkit.configuration.ConfigurationSection /** @@ -40,4 +40,4 @@ abstract class BaseOption(override val key: String) : Registrable { optionManager.register(key, this) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/api/vartype/VariableType.kt b/src/main/kotlin/com/skillw/itemsystem/api/vartype/VariableType.kt index 34bce5c..a7273d5 100644 --- a/src/main/kotlin/com/skillw/itemsystem/api/vartype/VariableType.kt +++ b/src/main/kotlin/com/skillw/itemsystem/api/vartype/VariableType.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.api.vartype import com.skillw.itemsystem.ItemSystem import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.able.Registrable +import com.skillw.pouvoir.api.plugin.map.component.Registrable /** * @className VariableType @@ -25,4 +25,4 @@ abstract class VariableType(override val key: String, vararg val alias: String) override fun register() { ItemSystem.varTypeManager.register(this) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/command/ISCommand.kt b/src/main/kotlin/com/skillw/itemsystem/internal/command/ISCommand.kt index 0f773ae..3be071e 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/command/ISCommand.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/command/ISCommand.kt @@ -2,9 +2,9 @@ package com.skillw.itemsystem.internal.command import com.skillw.itemsystem.ItemSystem import com.skillw.itemsystem.internal.command.sub.* -import com.skillw.pouvoir.util.PlayerUtils.soundClick -import com.skillw.pouvoir.util.PlayerUtils.soundFail -import com.skillw.pouvoir.util.PlayerUtils.soundSuccess +import com.skillw.pouvoir.util.soundClick +import com.skillw.pouvoir.util.soundFail +import com.skillw.pouvoir.util.soundSuccess import org.bukkit.command.CommandSender import org.bukkit.entity.Player import taboolib.common.platform.ProxyCommandSender @@ -88,4 +88,4 @@ object ISCommand { @CommandBody(permission = "is.command.rebuild") val rebuild = ItemRebuildCommand.rebuild -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemListCommand.kt b/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemListCommand.kt index affb5bd..ead5fbb 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemListCommand.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemListCommand.kt @@ -7,7 +7,7 @@ import com.skillw.itemsystem.internal.core.option.OptionType.type import com.skillw.itemsystem.internal.manager.ISConfig import com.skillw.itemsystem.util.ItemUtils.displayClone import com.skillw.itemsystem.util.ItemUtils.displayItem -import com.skillw.pouvoir.util.StringUtils.replacement +import com.skillw.pouvoir.util.replacement import org.bukkit.entity.Player import taboolib.common.platform.ProxyCommandSender import taboolib.common.platform.ProxyPlayer @@ -138,4 +138,4 @@ object ItemListCommand { sender.performCommand("item list all 1") } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemProductCommand.kt b/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemProductCommand.kt index 7f9cd31..14d6aad 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemProductCommand.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemProductCommand.kt @@ -12,7 +12,7 @@ import com.skillw.itemsystem.internal.feature.effect.RandomItemEffect import com.skillw.itemsystem.internal.feature.product.ProductData import com.skillw.itemsystem.util.ItemUtils.displayClone import com.skillw.itemsystem.util.ItemUtils.displayItem -import com.skillw.pouvoir.util.PlayerUtils.soundFinish +import com.skillw.pouvoir.util.soundFinish import org.bukkit.Bukkit import org.bukkit.Location import org.bukkit.entity.Player @@ -294,4 +294,4 @@ object ItemProductCommand { } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemRebuildCommand.kt b/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemRebuildCommand.kt index 9712b69..90dbe56 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemRebuildCommand.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemRebuildCommand.kt @@ -6,8 +6,8 @@ import com.skillw.itemsystem.internal.feature.ItemUpdater.updateItem import com.skillw.itemsystem.util.GsonUtils.parseToMap import com.skillw.itemsystem.util.ItemUtils.displayClone import com.skillw.itemsystem.util.ItemUtils.displayItem -import com.skillw.pouvoir.util.PlayerUtils.soundFinish -import com.skillw.pouvoir.util.PlayerUtils.soundSuccess +import com.skillw.pouvoir.util.soundFinish +import com.skillw.pouvoir.util.soundSuccess import org.bukkit.Bukkit import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -133,4 +133,4 @@ object ItemRebuildCommand { ) .sendTo(this) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemSaveCommand.kt b/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemSaveCommand.kt index 21d3092..77c5380 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemSaveCommand.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/command/sub/ItemSaveCommand.kt @@ -4,9 +4,9 @@ import com.skillw.itemsystem.ItemSystem import com.skillw.itemsystem.internal.core.builder.ItemBuilder import com.skillw.itemsystem.util.ItemUtils.displayClone import com.skillw.itemsystem.util.ItemUtils.displayItem -import com.skillw.pouvoir.util.PlayerUtils.soundClick -import com.skillw.pouvoir.util.PlayerUtils.soundFail -import com.skillw.pouvoir.util.PlayerUtils.soundSuccess +import com.skillw.pouvoir.util.soundClick +import com.skillw.pouvoir.util.soundFail +import com.skillw.pouvoir.util.soundSuccess import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack import taboolib.common.io.newFile @@ -20,7 +20,6 @@ import taboolib.module.configuration.Configuration import taboolib.module.configuration.Type import taboolib.module.lang.asLangText import taboolib.module.nms.getName - import taboolib.platform.util.isAir import taboolib.platform.util.sendLang @@ -98,4 +97,4 @@ object ItemSaveCommand { ) .sendTo(this) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/builder/ItemBuilder.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/builder/ItemBuilder.kt index 222db27..6f82e7e 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/builder/ItemBuilder.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/builder/ItemBuilder.kt @@ -37,7 +37,7 @@ class ItemBuilder(key: String) : BaseItemBuilder(key) { name = console().asLangText("command-list-abstract-item") }.build() } - val pre = ItemBuildEvent.Post(this, processData, entity) + val pre = ItemBuildEvent.Pre(this, processData, entity) pre.call() var data = pre.data return mirrorNow("product") { @@ -63,7 +63,7 @@ class ItemBuilder(key: String) : BaseItemBuilder(key) { }) } }.also { - ItemBuildEvent.After(this, data, it, entity).call() + ItemBuildEvent.Post(this, data, it, entity).call() } } } @@ -145,4 +145,4 @@ class ItemBuilder(key: String) : BaseItemBuilder(key) { override fun hashCode(): Int { return process.hashCode() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/builder/ProcessData.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/builder/ProcessData.kt index e6b280a..096c34b 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/builder/ProcessData.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/builder/ProcessData.kt @@ -1,17 +1,19 @@ package com.skillw.itemsystem.internal.core.builder +import com.skillw.asahi.api.AsahiAPI.analysis +import com.skillw.asahi.api.AsahiAPI.asahi +import com.skillw.asahi.api.member.context.AsahiContext +import com.skillw.asahi.api.member.namespace.NamespaceContainer +import com.skillw.asahi.api.member.namespace.NamespaceHolder import com.skillw.itemsystem.api.builder.IProcessData -import com.skillw.pouvoir.api.PouvoirAPI.analysis -import com.skillw.pouvoir.api.PouvoirAPI.eval -import com.skillw.pouvoir.api.function.context.IContext -import com.skillw.pouvoir.internal.core.function.context.SimpleContext -import com.skillw.pouvoir.util.TypeUtils.cast +import com.skillw.pouvoir.util.cast import org.bukkit.entity.LivingEntity import org.bukkit.inventory.ItemStack import taboolib.library.xseries.XMaterial import taboolib.module.nms.ItemTag import taboolib.module.nms.getItemTag import taboolib.platform.util.ItemBuilder +import java.util.concurrent.ConcurrentHashMap /** * @className ProcessData @@ -19,15 +21,21 @@ import taboolib.platform.util.ItemBuilder * @author Glom * @date 2022/8/7 7:30 Copyright 2022 user. All rights reserved. */ -class ProcessData(override val entity: LivingEntity? = null, val context: IContext = SimpleContext()) : - IContext by context, IProcessData { +class ProcessData( + override val entity: LivingEntity? = null, val context: AsahiContext = AsahiContext.create(ConcurrentHashMap()) +) : AsahiContext by context, IProcessData, NamespaceHolder { + + override val namespaces = NamespaceContainer() + override val builder = ItemBuilder(XMaterial.STONE) override val nbt = ItemTag() override val savingKeys = HashSet() // MM Hook init { + namespaces.addNamespaces("bukkit", "item_system") entity?.let { context["entity"] = it } + this["data"] = this } constructor(entity: LivingEntity? = null, receiver: ProcessData.() -> Unit) : this(entity) { @@ -35,10 +43,7 @@ class ProcessData(override val entity: LivingEntity? = null, val context: IConte } override fun String.eval(): Any { - return this.eval( - namespaces = arrayOf("common", "item_system"), - context = this@ProcessData - ) + return asahi(this@ProcessData, *namespaceNames()) } private fun List<*>.analysis(): List { diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/action/MetaAction.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/action/MetaAction.kt index f49571b..3b4fd6d 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/action/MetaAction.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/action/MetaAction.kt @@ -4,7 +4,7 @@ import com.skillw.itemsystem.ItemSystem import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.meta.data.Memory.Companion.get -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import taboolib.common.platform.function.warning import taboolib.module.nms.ItemTag import taboolib.module.nms.ItemTagData @@ -38,4 +38,4 @@ object MetaAction : BaseMeta("action") { } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaDamage.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaDamage.kt index 89788f3..92cc563 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaDamage.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaDamage.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister @AutoRegister object MetaDamage : BaseMeta("damage") { @@ -20,4 +20,4 @@ object MetaDamage : BaseMeta("damage") { return data.builder.damage } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaDisplay.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaDisplay.kt index bba23f5..2a57f40 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaDisplay.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaDisplay.kt @@ -3,8 +3,8 @@ package com.skillw.itemsystem.internal.core.meta.bukkit import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.util.ColorUtils.decolored +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister +import com.skillw.pouvoir.util.script.ColorUtil.decolored import taboolib.module.chat.colored import taboolib.module.nms.getName @@ -25,4 +25,4 @@ object MetaDisplay : BaseMeta("display") { return (data.builder.name ?: data.itemStack.getName()).decolored() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaEnchantments.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaEnchantments.kt index d59af68..eb5425d 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaEnchantments.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaEnchantments.kt @@ -4,7 +4,7 @@ import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.meta.data.Memory.Companion.get -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.enchantments.Enchantment import taboolib.common.platform.function.warning import taboolib.common5.Coerce @@ -40,4 +40,4 @@ object MetaEnchantments : BaseMeta("enchantments") { return mapOf("enchantments" to data.builder.enchants.mapKeys { XEnchantment.matchXEnchantment(it.key).name }) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaFlags.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaFlags.kt index 003e89e..8deaed3 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaFlags.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaFlags.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.inventory.ItemFlag import taboolib.common5.Coerce @@ -27,4 +27,4 @@ object MetaFlags : BaseMeta("flags") { return data.builder.flags.map { it.name } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaGlowColor.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaGlowColor.kt index 32f490b..ed372d3 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaGlowColor.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaGlowColor.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.ChatColor import taboolib.common.platform.function.warning import taboolib.common5.Coerce @@ -31,4 +31,4 @@ object MetaGlowColor : BaseMeta("glow-color") { return data.itemTag.removeDeep("ITEM_SYSTEM.glow-color")?.unsafeData() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaLore.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaLore.kt index 71dbb0f..f273283 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaLore.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaLore.kt @@ -3,8 +3,8 @@ package com.skillw.itemsystem.internal.core.meta.bukkit import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.util.ColorUtils.decolored +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister +import com.skillw.pouvoir.util.script.ColorUtil.decolored import taboolib.module.chat.colored @AutoRegister @@ -31,4 +31,4 @@ object MetaLore : BaseMeta("lore") { override fun loadData(data: ItemData): Any { return data.builder.lore.decolored() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaMaterial.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaMaterial.kt index d7ed6c4..b820c6a 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaMaterial.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaMaterial.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import com.skillw.pouvoir.taboolib.library.xseries.XMaterial import org.bukkit.Material @@ -24,4 +24,4 @@ object MetaMaterial : BaseMeta("material") { return XMaterial.matchXMaterial(data.itemStack).name } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaModelData.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaModelData.kt index 01cf11a..a08ea9d 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaModelData.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaModelData.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister @AutoRegister object MetaModelData : BaseMeta("data") { @@ -22,4 +22,4 @@ object MetaModelData : BaseMeta("data") { return data.builder.customModelData } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaNBT.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaNBT.kt index 9c5a14f..3ee2652 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaNBT.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaNBT.kt @@ -5,9 +5,9 @@ import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.meta.data.Memory.Companion.get import com.skillw.itemsystem.util.NBTUtils.toMutableMap -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.util.TypeUtils.valuesToTypeString -import taboolib.module.nms.ItemTag +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister +import com.skillw.pouvoir.util.valuesToTypeString +import taboolib.module.nms.ItemTagData @AutoRegister object MetaNBT : BaseMeta("nbt") { @@ -17,7 +17,7 @@ object MetaNBT : BaseMeta("nbt") { override fun invoke(memory: Memory) { with(memory) { val map = memory.get>("nbt").analysis() - nbt.putAll(ItemTag.toNBT(map).asCompound()) + nbt.putAll(ItemTagData.toNBT(map).asCompound()) } } @@ -35,4 +35,4 @@ object MetaNBT : BaseMeta("nbt") { } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaShiny.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaShiny.kt index 972a4de..ade9832 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaShiny.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaShiny.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister @AutoRegister object MetaShiny : BaseMeta("shiny") { @@ -17,4 +17,4 @@ object MetaShiny : BaseMeta("shiny") { } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaUnbreakable.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaUnbreakable.kt index bea9de1..f961e04 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaUnbreakable.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaUnbreakable.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister @AutoRegister object MetaUnbreakable : BaseMeta("unbreakable") { @@ -22,4 +22,4 @@ object MetaUnbreakable : BaseMeta("unbreakable") { return data.builder.isUnbreakable } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaUnique.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaUnique.kt index 8e81cbf..2359aaf 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaUnique.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/MetaUnique.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.meta.data.Memory.Companion.get -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import java.util.* @AutoRegister @@ -16,4 +16,4 @@ object MetaUnique : BaseMeta("unique") { } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/egg/MetaSpawnType.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/egg/MetaSpawnType.kt index 6a1bd4a..3a0a204 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/egg/MetaSpawnType.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/egg/MetaSpawnType.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit.egg import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.entity.EntityType import taboolib.common5.Coerce @@ -23,4 +23,4 @@ object MetaSpawnType : BaseMeta("spawn-type") { return data.builder.spawnType?.name } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/flag/MetaPattern.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/flag/MetaPattern.kt index c1cc6b5..efae33f 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/flag/MetaPattern.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/flag/MetaPattern.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit.flag import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.DyeColor import org.bukkit.block.banner.Pattern import org.bukkit.block.banner.PatternType @@ -40,4 +40,4 @@ object MetaPattern : BaseMeta("pattern") { return patterns.run { if (isEmpty()) null else this } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/interact/MetaCanBePlaced.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/interact/MetaCanBePlaced.kt index 9f53328..9aeac32 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/interact/MetaCanBePlaced.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/interact/MetaCanBePlaced.kt @@ -9,7 +9,7 @@ import com.skillw.itemsystem.internal.feature.ItemDrop import com.skillw.itemsystem.internal.feature.ItemDrop.drop import com.skillw.itemsystem.internal.feature.block.BlockData import com.skillw.itemsystem.util.NBTUtils.obj -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.Location import org.bukkit.event.block.BlockBreakEvent import org.bukkit.event.block.BlockPlaceEvent @@ -35,7 +35,7 @@ object MetaCanBePlaced : BaseMeta("can-be-placed") { } @SubscribeEvent - fun build(event: ItemBuildEvent.After) { + fun build(event: ItemBuildEvent.Post) { event.itemStack.apply { setItemTag(getTag().also { it["ITEM_SYSTEM"]?.asCompound()?.putIfAbsent("ITEM_SYSTEM.can-be-placed", ItemTagData("true")) @@ -72,4 +72,4 @@ object MetaCanBePlaced : BaseMeta("can-be-placed") { } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/interact/MetaCanCraft.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/interact/MetaCanCraft.kt index df54091..2a03a2c 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/interact/MetaCanCraft.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/interact/MetaCanCraft.kt @@ -7,7 +7,7 @@ import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.internal.feature.ItemCache.getTag import com.skillw.itemsystem.util.NBTUtils.obj -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.event.inventory.CraftItemEvent import taboolib.common.platform.event.SubscribeEvent import taboolib.module.nms.ItemTagData @@ -31,7 +31,7 @@ object MetaCanCraft : BaseMeta("can-craft") { } @SubscribeEvent - fun build(event: ItemBuildEvent.After) { + fun build(event: ItemBuildEvent.Post) { event.itemStack.apply { setItemTag(getTag().also { it["ITEM_SYSTEM"]?.asCompound()?.putIfAbsent("ITEM_SYSTEM.can-craft", ItemTagData("false")) @@ -49,4 +49,4 @@ object MetaCanCraft : BaseMeta("can-craft") { } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/leather/MetaColor.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/leather/MetaColor.kt index 8243e1e..7c686e6 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/leather/MetaColor.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/leather/MetaColor.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit.leather import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.Color import taboolib.common5.Coerce @@ -27,4 +27,4 @@ object MetaColor : BaseMeta("color") { return data.builder.color?.run { "$red,$green,$blue" } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/potion/MetaPotion.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/potion/MetaPotion.kt index 44f1d68..5e31ab9 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/potion/MetaPotion.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/potion/MetaPotion.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit.potion import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.potion.PotionData import org.bukkit.potion.PotionType import taboolib.library.xseries.XPotion @@ -32,4 +32,4 @@ object MetaPotion : BaseMeta("potion") { ) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/skull/MetaSkullOwner.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/skull/MetaSkullOwner.kt index ba0107f..e64176e 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/skull/MetaSkullOwner.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/skull/MetaSkullOwner.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.bukkit.skull import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister @AutoRegister object MetaSkullOwner : BaseMeta("skull-owner") { @@ -22,4 +22,4 @@ object MetaSkullOwner : BaseMeta("skull-owner") { return data.builder.skullOwner } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/skull/MetaSkullTexture.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/skull/MetaSkullTexture.kt index e406d1f..e4c72c7 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/skull/MetaSkullTexture.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/bukkit/skull/MetaSkullTexture.kt @@ -4,7 +4,7 @@ import com.skillw.itemsystem.api.builder.ItemData import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.meta.data.Memory.Companion.get -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import taboolib.platform.util.ItemBuilder import java.util.* @@ -28,4 +28,4 @@ object MetaSkullTexture : BaseMeta("skull-texture") { return mapOf("skull-texture" to linkedMapOf("texture" to skull.textures, "uuid" to skull.uuid.toString())) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/data/MetaData.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/data/MetaData.kt index 0f432c1..112d11b 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/data/MetaData.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/data/MetaData.kt @@ -5,7 +5,7 @@ import com.skillw.itemsystem.ItemSystem.metaManager import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.IMetaData import com.skillw.itemsystem.internal.core.meta.define.MetaDefine -import com.skillw.pouvoir.api.map.BaseMap +import com.skillw.pouvoir.api.plugin.map.BaseMap /** @@ -40,7 +40,7 @@ class MetaData(override val key: BaseMeta) : BaseMap(), IMetaData { } override fun serialize(): MutableMap { - return map + return toMutableMap() } @@ -58,6 +58,6 @@ class MetaData(override val key: BaseMeta) : BaseMap(), IMetaData { } override fun hashCode(): Int { - return key.hashCode() + map.hashCode() + return key.hashCode() + toMutableMap().hashCode() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/define/MetaDefine.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/define/MetaDefine.kt index b459860..2e885b5 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/define/MetaDefine.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/define/MetaDefine.kt @@ -3,7 +3,7 @@ package com.skillw.itemsystem.internal.core.meta.define import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.internal.manager.VarTypeManagerImpl.createVar -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister @AutoRegister object MetaDefine : BaseMeta("define") { @@ -22,4 +22,4 @@ object MetaDefine : BaseMeta("define") { } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/eval/MetaRun.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/eval/MetaRun.kt index 0d83393..5f0e5b1 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/eval/MetaRun.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/eval/MetaRun.kt @@ -2,13 +2,13 @@ package com.skillw.itemsystem.internal.core.meta.eval import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister @AutoRegister object MetaRun : BaseMeta("run") { override fun invoke(memory: Memory) { with(memory) { - metaData.get("run").toString().eval() + metaData["run"].toString().eval() } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/eval/MetaScript.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/eval/MetaScript.kt index 4ca8e8d..0de998d 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/eval/MetaScript.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/meta/eval/MetaScript.kt @@ -3,13 +3,16 @@ package com.skillw.itemsystem.internal.core.meta.eval import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.pouvoir.Pouvoir.scriptManager -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister @AutoRegister object MetaScript : BaseMeta("script") { override fun invoke(memory: Memory) { with(memory) { - scriptManager.evalJs(metaData.map["script"].toString(), mapOf("data" to memory.processData)) + scriptManager.evalJs( + metaData["script"].toString(), + mapOf("data" to memory.processData) + ) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionAbstract.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionAbstract.kt index 6d8156e..062cca5 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionAbstract.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionAbstract.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.internal.core.option import com.skillw.itemsystem.api.builder.BaseItemBuilder import com.skillw.itemsystem.api.option.BaseOption -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.configuration.ConfigurationSection @AutoRegister @@ -13,4 +13,4 @@ object OptionAbstract : BaseOption("abstract") { val BaseItemBuilder.abstract: Boolean get() = options["abstract"] as Boolean -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionAutoUpdate.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionAutoUpdate.kt index 3559445..2985361 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionAutoUpdate.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionAutoUpdate.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.internal.core.option import com.skillw.itemsystem.api.builder.BaseItemBuilder import com.skillw.itemsystem.api.option.BaseOption -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.configuration.ConfigurationSection @AutoRegister @@ -13,4 +13,4 @@ object OptionAutoUpdate : BaseOption("auto-update") { val BaseItemBuilder.autoUpdate: Boolean get() = options["auto-update"].toString().toBoolean() -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionLockedLore.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionLockedLore.kt index fa02b09..b183ae2 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionLockedLore.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionLockedLore.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.internal.core.option import com.skillw.itemsystem.api.builder.BaseItemBuilder import com.skillw.itemsystem.api.option.BaseOption -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.configuration.ConfigurationSection @AutoRegister @@ -13,4 +13,4 @@ object OptionLockedLore : BaseOption("locked-lore") { val BaseItemBuilder.lockedLore: Boolean get() = options["locked-lore"] as Boolean -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionLockedNBTKeys.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionLockedNBTKeys.kt index 0bd4630..11d10a5 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionLockedNBTKeys.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionLockedNBTKeys.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.internal.core.option import com.skillw.itemsystem.api.builder.BaseItemBuilder import com.skillw.itemsystem.api.option.BaseOption -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.configuration.ConfigurationSection @AutoRegister @@ -13,4 +13,4 @@ object OptionLockedNBTKeys : BaseOption("locked-nbt-keys") { val BaseItemBuilder.lockedNBT: List get() = options["locked-nbt-keys"] as List -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionType.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionType.kt index 432aed3..713854a 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionType.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/option/OptionType.kt @@ -1,19 +1,13 @@ package com.skillw.itemsystem.internal.core.option -import com.skillw.itemsystem.ItemSystem import com.skillw.itemsystem.api.builder.BaseItemBuilder import com.skillw.itemsystem.api.option.BaseOption -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.event.ManagerTime -import com.skillw.pouvoir.api.manager.Manager.Companion.addExec +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import org.bukkit.configuration.ConfigurationSection @AutoRegister object OptionType : BaseOption("type") { val types: HashSet by lazy { - ItemSystem.optionManager.addExec("type-clear", ManagerTime.BEFORE_RELOAD) { - OptionType.types.clear() - } HashSet() } @@ -26,4 +20,4 @@ object OptionType : BaseOption("type") { val BaseItemBuilder.type: String get() = options["type"]?.toString() ?: "default" -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeMap.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeMap.kt index b741c3b..e269217 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeMap.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeMap.kt @@ -1,13 +1,13 @@ package com.skillw.itemsystem.internal.core.vartype +import com.skillw.asahi.api.member.context.AsahiContext import com.skillw.itemsystem.ItemSystem import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.vartype.VariableType import com.skillw.itemsystem.internal.core.builder.ProcessData import com.skillw.itemsystem.internal.core.meta.data.MetaData import com.skillw.itemsystem.internal.core.meta.define.MetaDefine -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.internal.core.function.context.SimpleContext +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import java.util.function.Supplier @@ -18,18 +18,17 @@ object VarTypeMap : VariableType("map") { @Suppress("UNCHECKED_CAST") override fun createVar(memory: Memory): Any { with(memory) { - val context = SimpleContext() + val context = AsahiContext.create() val mapData = ProcessData(entity, context) context.apply { - putAll(memory.metaData.map - .filterKeys { it !in ignoreKeys }.mapValues { - val value = it.value - if (value !is Map<*, *>) return@mapValues value - value as Map - if (!value.containsKey("type")) return@mapValues value - val metaData = MetaData(MetaDefine).apply { putAll(value);put("key", it.key) } - ItemSystem.varTypeManager.createVar(Memory(metaData, mapData)) ?: value - }) + putAll(memory.metaData.filterKeys { it !in ignoreKeys }.mapValues { + val value = it.value + if (value !is Map<*, *>) return@mapValues value + value as Map + if (!value.containsKey("type")) return@mapValues value + val metaData = MetaData(MetaDefine).apply { putAll(value);put("key", it.key) } + ItemSystem.varTypeManager.createVar(Memory(metaData, mapData)) ?: value + }) } return object : MutableMap by mapData { override fun get(key: String): Any? { @@ -43,4 +42,4 @@ object VarTypeMap : VariableType("map") { } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeNumber.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeNumber.kt index 1df350c..e28029d 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeNumber.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeNumber.kt @@ -2,8 +2,8 @@ package com.skillw.itemsystem.internal.core.vartype import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.vartype.VariableType -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.util.NumberUtils.format +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister +import com.skillw.pouvoir.util.format import java.lang.Double.max import java.lang.Double.min @@ -19,4 +19,4 @@ object VarTypeNumber : VariableType("number", "num") { return max(min(number, max), min).format(format) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeRandom.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeRandom.kt index e3b6209..a809102 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeRandom.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeRandom.kt @@ -2,8 +2,8 @@ package com.skillw.itemsystem.internal.core.vartype import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.vartype.VariableType -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.util.NumberUtils.randomInt +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister +import com.skillw.pouvoir.util.randomInt import taboolib.common5.Coerce @@ -17,4 +17,4 @@ object VarTypeRandom : VariableType("random") { } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeStrings.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeStrings.kt index 6504765..4f5c81d 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeStrings.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeStrings.kt @@ -2,8 +2,7 @@ package com.skillw.itemsystem.internal.core.vartype import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.vartype.VariableType -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.util.StringUtils.toList +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import taboolib.common5.Coerce import java.util.* @@ -13,7 +12,7 @@ object VarTypeStrings : VariableType("strings", "string", "str") { private fun Any?.toStrList(): List { return if (this is String) - this.toList() + this.toStrList() else Coerce.toListOf(this, String::class.java) } @@ -56,4 +55,4 @@ object VarTypeStrings : VariableType("strings", "string", "str") { } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeWeight.kt b/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeWeight.kt index 3b1aa4d..bc2aff3 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeWeight.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/core/vartype/VarTypeWeight.kt @@ -1,9 +1,9 @@ package com.skillw.itemsystem.internal.core.vartype +import com.skillw.asahi.api.AsahiAPI.asahi import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.vartype.VariableType -import com.skillw.pouvoir.api.PouvoirAPI.eval -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import taboolib.common5.Coerce import taboolib.common5.RandomList @@ -22,10 +22,10 @@ object VarTypeWeight : VariableType("weight") { } return weights.random().run { if (this is String && startsWith("eval::")) { - return this.substring(4).eval(context = processData) + return this.substring(4).asahi(context = processData) } else analysis() } ?: "Empty Weight" } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/ItemDynamic.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/ItemDynamic.kt index bb81c79..53a3e66 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/ItemDynamic.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/ItemDynamic.kt @@ -1,18 +1,14 @@ package com.skillw.itemsystem.internal.feature +import com.skillw.asahi.api.AsahiAPI.asahi +import com.skillw.asahi.api.member.context.AsahiContext import com.skillw.itemsystem.internal.core.builder.ProcessData import com.skillw.itemsystem.internal.feature.ItemCache.cacheLore import com.skillw.itemsystem.internal.feature.ItemCache.getTag import com.skillw.itemsystem.internal.manager.ISConfig -import com.skillw.pouvoir.api.PouvoirAPI.eval -import com.skillw.pouvoir.api.event.ManagerTime -import com.skillw.pouvoir.api.function.context.IContext -import com.skillw.pouvoir.api.function.parser.Parser -import com.skillw.pouvoir.api.manager.Manager.Companion.addExec -import com.skillw.pouvoir.internal.core.function.context.SimpleContext -import com.skillw.pouvoir.util.ColorUtils.decolored -import com.skillw.pouvoir.util.StringUtils.toList +import com.skillw.pouvoir.util.script.ColorUtil.decolored +import com.skillw.pouvoir.util.toObjList import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -25,21 +21,18 @@ import taboolib.module.nms.getItemTag import java.util.regex.Pattern object ItemDynamic { - private var dynamicPattern: Pattern = Pattern.compile("\\{}") + internal var dynamicPattern: Pattern = Pattern.compile("\\{}") @Awake(LifeCycle.ACTIVE) fun addFunc() { dynamicPattern = Pattern.compile("\\{${ISConfig.unknownDynamic}(?\\d)}") - ISConfig.addExec("dynamic-pattern-update", ManagerTime.RELOAD) { - dynamicPattern = Pattern.compile("\\{${ISConfig.unknownDynamic}(?\\d)}") - } } private fun String.dynamic(itemStack: ItemStack, entity: LivingEntity): String { val matcher = dynamicPattern.matcher(this.decolored()) if (!matcher.find()) return this val buffer = StringBuffer() - val context = SimpleContext().apply { + val context = AsahiContext.create().apply { put("item", itemStack) put("entity", entity) if (entity is Player) @@ -48,9 +41,9 @@ object ItemDynamic { do { val index = matcher.group("index") val content = itemStack.getContent(index) - val replaced = content?.eval( - namespaces = arrayOf("item_system", "common"), - context = context + val replaced = content?.asahi( + context = context, + namespaces = arrayOf("common", "lang", "bukkit", "item_system") ).toString() matcher.appendReplacement( buffer, @@ -69,7 +62,7 @@ object ItemDynamic { val newLore = ArrayList() display = display?.dynamic(this, entity) originLore.forEach { line -> - newLore.addAll(line.dynamic(this, entity).toList()) + newLore.addAll(line.dynamic(this, entity).toObjList()) } meta.setDisplayName(display) meta.lore = newLore @@ -84,8 +77,8 @@ object ItemDynamic { return data[index]?.asString() } - internal fun Parser.addDynamic(content: String): String { - val dynamicData = (context as ProcessData).nbt + internal fun AsahiContext.addDynamic(content: String): String { + val dynamicData = (get("data") as ProcessData).nbt .getOrPut("ITEM_SYSTEM") { ItemTag() }.asCompound() .getOrPut("DYNAMIC_DATA") { ItemTag() }.asCompound() val index = nextIndex().toString() @@ -94,11 +87,11 @@ object ItemDynamic { return "{$name}" } - private val IContext.dynamicIndexNow + private val AsahiContext.dynamicIndexNow get() = getOrPut(INDEX_KEY) { 0 } as Int - private fun IContext.nextIndex(): Int { + private fun AsahiContext.nextIndex(): Int { return (dynamicIndexNow + 1).also { put(INDEX_KEY, it) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/action/ItemAction.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/action/ItemAction.kt index 2bede0a..4aa5bf4 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/action/ItemAction.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/action/ItemAction.kt @@ -1,12 +1,12 @@ package com.skillw.itemsystem.internal.feature.action +import com.skillw.asahi.api.AsahiAPI.asahi +import com.skillw.asahi.api.member.context.AsahiContext import com.skillw.itemsystem.api.action.ActionType import com.skillw.itemsystem.internal.feature.ItemCache.getTag import com.skillw.pouvoir.Pouvoir.scriptManager -import com.skillw.pouvoir.api.PouvoirAPI.eval -import com.skillw.pouvoir.api.map.BaseMap -import com.skillw.pouvoir.internal.core.function.context.SimpleContext -import com.skillw.pouvoir.util.MapUtils.put +import com.skillw.pouvoir.api.plugin.map.BaseMap +import com.skillw.pouvoir.util.put import org.bukkit.entity.LivingEntity import org.bukkit.inventory.ItemStack import taboolib.common.platform.function.submit @@ -40,9 +40,10 @@ internal object ItemAction { scriptManager.evalJs(substring(10), arguments = argumentsMap) else if (startsWith("js_invoke::")) scriptManager.invoke(substring(11), arguments = argumentsMap) - else eval( - arrayOf("common"), - context = SimpleContext().apply { putAll(argumentsMap); }) + else asahi( + context = AsahiContext.create().apply { putAll(argumentsMap); }, + namespaces = arrayOf("common", "lang", "bukkit") + ) } } } @@ -57,4 +58,4 @@ internal object ItemAction { } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/block/BlockData.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/block/BlockData.kt index e3626ee..946ac5d 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/block/BlockData.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/block/BlockData.kt @@ -4,9 +4,9 @@ import com.skillw.itemsystem.api.ItemAPI import com.skillw.itemsystem.internal.feature.ItemCache.getTag import com.skillw.itemsystem.util.GsonUtils.parseToMap import com.skillw.itemsystem.util.NBTUtils.obj -import com.skillw.pouvoir.util.FileUtils.loadYaml -import com.skillw.pouvoir.util.FileUtils.toMap -import com.skillw.pouvoir.util.GsonUtils.encodeJson +import com.skillw.pouvoir.util.encodeJson +import com.skillw.pouvoir.util.loadYaml +import com.skillw.pouvoir.util.toMap import org.bukkit.Bukkit import org.bukkit.Location import org.bukkit.entity.Player @@ -24,8 +24,8 @@ object BlockData { fun push(location: Location, item: ItemStack) { val nbt = item.getTag() - val key = nbt.getDeep("ITEM_SYSTEM.key").asString() - val data = nbt.getDeep("ITEM_SYSTEM.data").obj() + val key = nbt.getDeep("ITEM_SYSTEM.key")!!.asString() + val data = nbt.getDeep("ITEM_SYSTEM.data")!!.obj() blockData[location] = mapOf("item_key" to key, "data" to data) } @@ -84,4 +84,4 @@ object BlockData { save() } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/annotation/Meta.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/annotation/Meta.kt similarity index 90% rename from src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/annotation/Meta.kt rename to src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/annotation/Meta.kt index f42c26a..d045821 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/annotation/Meta.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/annotation/Meta.kt @@ -1,4 +1,4 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.annotation +package com.skillw.itemsystem.internal.feature.compat.asahi.annotation import com.skillw.itemsystem.ItemSystem import com.skillw.itemsystem.api.builder.ItemData @@ -6,10 +6,10 @@ import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.internal.manager.ISConfig import com.skillw.pouvoir.Pouvoir -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import com.skillw.pouvoir.api.script.annotation.ScriptAnnotation import com.skillw.pouvoir.api.script.annotation.ScriptAnnotationData -import com.skillw.pouvoir.util.StringUtils.toArgs +import com.skillw.pouvoir.util.toArgs import taboolib.common.platform.function.console import taboolib.module.lang.sendLang @@ -42,4 +42,4 @@ object Meta : ScriptAnnotation("Meta", fileAnnotation = true) { ItemSystem.metaManager.remove(key) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/annotation/VarType.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/annotation/VarType.kt similarity index 88% rename from src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/annotation/VarType.kt rename to src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/annotation/VarType.kt index 8d3c45b..ba096fd 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/annotation/VarType.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/annotation/VarType.kt @@ -1,14 +1,14 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.annotation +package com.skillw.itemsystem.internal.feature.compat.asahi.annotation import com.skillw.itemsystem.ItemSystem import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.vartype.VariableType import com.skillw.itemsystem.internal.manager.ISConfig import com.skillw.pouvoir.Pouvoir -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import com.skillw.pouvoir.api.script.annotation.ScriptAnnotation import com.skillw.pouvoir.api.script.annotation.ScriptAnnotationData -import com.skillw.pouvoir.util.StringUtils.toArgs +import com.skillw.pouvoir.util.toArgs import taboolib.common.platform.function.console import taboolib.module.lang.sendLang @@ -36,4 +36,4 @@ object VarType : ScriptAnnotation("VarType", fileAnnotation = true) { ItemSystem.varTypeManager.remove(key) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/action/ActionItem.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/infix/InfixItem.kt similarity index 62% rename from src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/action/ActionItem.kt rename to src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/infix/InfixItem.kt index 2713786..cbf6757 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/action/ActionItem.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/infix/InfixItem.kt @@ -1,14 +1,14 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.action +package com.skillw.itemsystem.internal.feature.compat.asahi.infix +import com.skillw.asahi.api.annotation.AsahiInfix +import com.skillw.asahi.api.member.context.InfixContext +import com.skillw.asahi.api.member.parser.infix.namespacing.BaseInfix import com.skillw.itemsystem.api.ItemAPI import com.skillw.itemsystem.internal.feature.ItemCache.getTag import com.skillw.itemsystem.internal.feature.ItemDrop import com.skillw.itemsystem.internal.feature.ItemDrop.drop import com.skillw.itemsystem.internal.feature.ItemUpdater.updateItem -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.function.action.PouAction -import com.skillw.pouvoir.api.function.parser.Parser import org.bukkit.Location import org.bukkit.Material import org.bukkit.entity.Player @@ -20,52 +20,53 @@ import taboolib.module.nms.ItemTag import taboolib.module.nms.getName import kotlin.math.max -@AutoRegister -object ActionItem : PouAction(ItemStack::class.java) { - private fun Parser.getPlayer() = context["player"] as? Player? ?: error("No player found, please define 'player' !") +@AsahiInfix +object InfixItem : BaseInfix(ItemStack::class.java) { + private fun InfixContext.getPlayer() = + context["player"] as? Player? ?: error("No player found, please define 'player' !") init { - addExec("drop") { obj -> - except("at") + infix("drop") { obj -> + expect("at") val loc = parse() val player = getPlayer() obj.drop(loc, ItemDrop.DropData(player)) } - addExec("clone") { obj -> + infix("clone") { obj -> obj.clone() } - addExec("amount") { obj -> - if (except("to")) { + infix("amount") { obj -> + if (expect("to")) { obj.amount = parse() } obj.amount } - addExec("name") { obj -> - if (except("to")) { + infix("name") { obj -> + if (expect("to")) { val meta = obj.itemMeta meta.setDisplayName(parseString().colored()) obj.itemMeta = meta - return@addExec true + return@infix true } val player = getPlayer() obj.getName(player) } - addExec("lore") { obj -> - if (except("to")) { + infix("lore") { obj -> + if (expect("to")) { val meta = obj.itemMeta meta.lore = parseList().map { it.toString().colored() } obj.itemMeta = meta - return@addExec true + return@infix true } obj.itemMeta.lore } - addExec("type") { obj -> - if (except("to")) { + infix("material") { obj -> + if (expect("to")) { obj.type = parseString().let { it.parseToXMaterial().parseMaterial() ?: Coerce.toEnum( it, @@ -73,71 +74,71 @@ object ActionItem : PouAction(ItemStack::class.java) { Material.STONE ) } - return@addExec true + return@infix true } obj.type } - addExec("cooldown") { obj -> + infix("cooldown") { obj -> val player = getPlayer() - if (except("to")) { + if (expect("to")) { player.setCooldown(obj.type, parseInt()) - true + return@infix true } player.getCooldown(obj.type) } - addExec("damage") { obj -> - if (except("to")) { + infix("damage") { obj -> + if (expect("to")) { obj.durability = parse() - return@addExec true + return@infix true } obj.durability } - addExec("maxDurability") { obj -> + infix("maxDurability") { obj -> obj.type.maxDurability } - addExec("nbt") { obj -> - if (except("to")) { + infix("nbt") { obj -> + if (expect("to")) { parse().saveTo(obj) - return@addExec true + return@infix true } obj.getTag() } - addExec("repair") { obj -> + infix("repair") { obj -> val amount = parseShort() obj.durability = (max(0, obj.durability - amount)).toShort() true } - addExec("consume") { obj -> + infix("consume") { obj -> obj.amount-- } - addExec("build") { obj -> + infix("build") { obj -> val player = getPlayer() val key = parseString() val data = HashMap() - if (except("with")) { - data.putAll(parseMap()) + if (expect("with")) { + data.putAll(parse>()) } - return@addExec ItemAPI.productItem(key, player) { + return@infix ItemAPI.productItem(key, player) { it.putAll(data) } } - addExec("rebuild") { obj -> + infix("rebuild") { obj -> val player = getPlayer() var variables = setOf("all") var data: Map = HashMap() - if (except("with")) { + if (expect("with")) { variables = parseList().map { it.toString() }.toSet() - data = parseMap().mapKeys { it.toString() } + data = parse>().mapKeys { it.toString() } } obj.updateItem(player, variables, data) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/action/ActionTag.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/infix/InfixTag.kt similarity index 68% rename from src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/action/ActionTag.kt rename to src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/infix/InfixTag.kt index d395d5c..2b97c84 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/action/ActionTag.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/infix/InfixTag.kt @@ -1,8 +1,8 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.action +package com.skillw.itemsystem.internal.feature.compat.asahi.infix +import com.skillw.asahi.api.annotation.AsahiInfix +import com.skillw.asahi.api.member.parser.infix.namespacing.BaseInfix import com.skillw.itemsystem.util.NBTUtils.obj -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.function.action.PouAction import org.bukkit.inventory.ItemStack import taboolib.module.nms.ItemTag import taboolib.module.nms.ItemTagData @@ -13,34 +13,34 @@ import taboolib.module.nms.ItemTagData * @author Glom * @date 2022/8/19 10:58 Copyright 2022 user. All rights reserved. */ -@AutoRegister -object ActionTag : PouAction(ItemTag::class.java) { +@AsahiInfix +object InfixTag : BaseInfix(ItemTag::class.java) { init { - addExec("get") { tag -> + infix("get") { tag -> val key = parseString() key.run { if (contains(".")) tag.getDeep(key) else tag[key] }?.obj() } - addExec("put") { tag -> + infix("put") { tag -> val key = parseString() - except("to") + expect("to") val value = ItemTagData.toNBT(parseAny()) key.run { if (contains(".")) tag.putDeep(key, value) else tag.put(key, value) }?.obj() } - addExec("remove") { tag -> + infix("remove") { tag -> val key = parseString() key.run { if (contains(".")) tag.removeDeep(key) else tag.remove(key) }?.obj() } - addExec("has") { tag -> + infix("has") { tag -> val key = parseString() key.run { if (contains(".")) tag.getDeep(key) != null else tag.containsKey(key) } } - addExec("saveTo") { tag -> + infix("saveTo") { tag -> val item = parse() tag.saveTo(item) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixDynamic.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixDynamic.kt new file mode 100644 index 0000000..6f46da5 --- /dev/null +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixDynamic.kt @@ -0,0 +1,13 @@ +package com.skillw.itemsystem.internal.feature.compat.asahi.prefix + +import com.skillw.asahi.api.annotation.AsahiPrefix +import com.skillw.asahi.api.prefixParser +import com.skillw.itemsystem.internal.feature.ItemDynamic.addDynamic + +@AsahiPrefix(["dynamic"], "item_system") +private fun dynamic() = prefixParser { + val script = splitTill("{", "}") + result { + addDynamic(script[0]) + } +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixItem.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixItem.kt new file mode 100644 index 0000000..5ee2f19 --- /dev/null +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixItem.kt @@ -0,0 +1,15 @@ +package com.skillw.itemsystem.internal.feature.compat.asahi.prefix + +import com.skillw.asahi.api.annotation.AsahiPrefix +import com.skillw.asahi.api.prefixParser +import com.skillw.asahi.api.quest +import org.bukkit.Material +import org.bukkit.inventory.ItemStack + +@AsahiPrefix(["item"], "common") +private fun item() = prefixParser { + val material = quest() + result { + ItemStack(material.get()) + } +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixMythicSkill.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixMythicSkill.kt new file mode 100644 index 0000000..97a35e3 --- /dev/null +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixMythicSkill.kt @@ -0,0 +1,17 @@ +package com.skillw.itemsystem.internal.feature.compat.asahi.prefix + +import com.skillw.asahi.api.annotation.AsahiPrefix +import com.skillw.asahi.api.prefixParser +import com.skillw.asahi.api.quester +import ink.ptms.um.Mythic +import org.bukkit.entity.LivingEntity + +@AsahiPrefix(["mmskill"], "common") +private fun mmskill() = prefixParser { + val skillKey = questString() + val power = if (expect("with")) questFloat() else quester { 1.0f } + result { + val caster = (this["entity"] ?: this["player"]) as? LivingEntity? ?: return@result false + Mythic.API.castSkill(caster, skillKey.get(), null, power = power.get()) + } +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixOverride.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixOverride.kt new file mode 100644 index 0000000..f8d8a77 --- /dev/null +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixOverride.kt @@ -0,0 +1,18 @@ +package com.skillw.itemsystem.internal.feature.compat.asahi.prefix + +import com.skillw.asahi.api.annotation.AsahiPrefix +import com.skillw.asahi.api.prefixParser +import com.skillw.itemsystem.internal.core.builder.ProcessData + +@AsahiPrefix(["override"], "item_system") +private fun override() = prefixParser { + val key = questString() + expect("=", "to") + val value = questAny() + result { + val data = get("data") as? ProcessData ?: return@result "Error Context" + this[key.get()] = value.get() + data.savingKeys.add(key.get()) + value.get() + } +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixPapi.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixPapi.kt new file mode 100644 index 0000000..cb182dc --- /dev/null +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixPapi.kt @@ -0,0 +1,15 @@ +package com.skillw.itemsystem.internal.feature.compat.asahi.prefix + +import com.skillw.asahi.api.annotation.AsahiPrefix +import com.skillw.asahi.api.prefixParser +import com.skillw.pouvoir.api.PouvoirAPI.placeholder +import org.bukkit.entity.LivingEntity + +@AsahiPrefix(["papi"], "item_system") +private fun papi() = prefixParser { + val str = questString() + result { + val entity = this["entity"] as? LivingEntity? ?: return@result str.get() + str.get().placeholder(entity) + } +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixSave.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixSave.kt new file mode 100644 index 0000000..9e8ebd3 --- /dev/null +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixSave.kt @@ -0,0 +1,16 @@ +package com.skillw.itemsystem.internal.feature.compat.asahi.prefix + +import com.skillw.asahi.api.annotation.AsahiPrefix +import com.skillw.asahi.api.prefixParser +import com.skillw.itemsystem.internal.core.builder.ProcessData + +@AsahiPrefix(["save"], "item_system") +private fun save() = prefixParser { + result { + val data = get("data") as? ProcessData ?: return@result "Error Context" + if (peek() == "[") { + return@result questList().get().onEach { data.savingKeys.add(it.toString()) } + } + return@result questString().get().also { data.savingKeys.add(it) } + } +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixSyncNBT.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixSyncNBT.kt new file mode 100644 index 0000000..1e75659 --- /dev/null +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixSyncNBT.kt @@ -0,0 +1,14 @@ +package com.skillw.itemsystem.internal.feature.compat.asahi.prefix + +import com.skillw.asahi.api.annotation.AsahiPrefix +import com.skillw.asahi.api.prefixParser +import com.skillw.itemsystem.internal.feature.ItemDynamic.addDynamic + +@AsahiPrefix(["syncNBT"], "common") +private fun syncNBT() = prefixParser { + val nbt = questString() + result { + val content = "&item nbt get '${nbt.get()}'" + return@result addDynamic(content) + } +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixVar.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixVar.kt new file mode 100644 index 0000000..f0abc6f --- /dev/null +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/asahi/prefix/PrefixVar.kt @@ -0,0 +1,19 @@ +package com.skillw.itemsystem.internal.feature.compat.asahi.prefix + +import com.skillw.asahi.api.annotation.AsahiPrefix +import com.skillw.asahi.api.prefixParser +import com.skillw.itemsystem.internal.core.builder.ProcessData + +@AsahiPrefix(["var", "let", "const"], "item_system") +private fun let() = prefixParser { + val key = next() + expect("=", "to") + val value = questAny() + result { + val data = get("data") as? ProcessData ?: return@result "Error Context" + if (containsKey(key)) return@result this[key] + this[key] = value.get() + data.savingKeys.add(key) + value.get() + } +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/attsystem/AttributesMeta.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/attsystem/AttributesMeta.kt index b5aef8e..75adb94 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/attsystem/AttributesMeta.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/attsystem/AttributesMeta.kt @@ -5,15 +5,16 @@ import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.meta.data.Memory.Companion.get import com.skillw.itemsystem.util.NBTUtils.toMutableMap -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import taboolib.module.nms.ItemTag +import taboolib.module.nms.ItemTagData @AutoRegister(test = "com.skillw.attsystem.AttributeSystem") object AttributesMeta : BaseMeta("attributes") { override fun invoke(memory: Memory) { with(memory) { val map = memory.get>("attributes").analysis() - nbt.getOrPut("ATTRIBUTE_DATA") { ItemTag() }.asCompound().putAll(ItemTag.toNBT(map).asCompound()) + nbt.getOrPut("ATTRIBUTE_DATA") { ItemTag() }.asCompound().putAll(ItemTagData.toNBT(map).asCompound()) } } @@ -25,4 +26,4 @@ object AttributesMeta : BaseMeta("attributes") { ) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/attsystem/ConditionsMeta.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/attsystem/ConditionsMeta.kt index 4ffc40e..8c3d2b6 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/attsystem/ConditionsMeta.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/attsystem/ConditionsMeta.kt @@ -5,15 +5,16 @@ import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.meta.data.Memory.Companion.get import com.skillw.itemsystem.util.NBTUtils.toMutableMap -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import taboolib.module.nms.ItemTag +import taboolib.module.nms.ItemTagData @AutoRegister(test = "com.skillw.attsystem.AttributeSystem") object ConditionsMeta : BaseMeta("conditions") { override fun invoke(memory: Memory) { with(memory) { val map = memory.get>("conditions").analysis() - nbt.getOrPut("CONDITION_DATA") { ItemTag() }.asCompound().putAll(ItemTag.toNBT(map).asCompound()) + nbt.getOrPut("CONDITION_DATA") { ItemTag() }.asCompound().putAll(ItemTagData.toNBT(map).asCompound()) } } @@ -23,4 +24,4 @@ object ConditionsMeta : BaseMeta("conditions") { return mapOf("conditions" to conditions) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/buffsystem/BuffsMeta.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/buffsystem/BuffsMeta.kt index a45592f..d4839f1 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/buffsystem/BuffsMeta.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/buffsystem/BuffsMeta.kt @@ -9,13 +9,14 @@ import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory import com.skillw.itemsystem.api.meta.data.Memory.Companion.get import com.skillw.itemsystem.util.NBTUtils.toMutableMap -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.map.BaseMap -import com.skillw.pouvoir.util.MapUtils.put +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.map.BaseMap +import com.skillw.pouvoir.util.put import org.bukkit.entity.LivingEntity import taboolib.common.platform.event.OptionalEvent import taboolib.common.platform.event.SubscribeEvent import taboolib.module.nms.ItemTag +import taboolib.module.nms.ItemTagData import taboolib.module.nms.getItemTag import taboolib.platform.util.isAir import java.util.* @@ -30,7 +31,7 @@ object BuffsMeta : BaseMeta("buffs") { val buffs = get>("buffs") buffs.forEach { (key, data) -> if (!buffManager.containsKey(key)) return@forEach - nbt.getOrPut(BUFF_KEY) { ItemTag() }.asCompound()[key] = ItemTag.toNBT(data) + nbt.getOrPut(BUFF_KEY) { ItemTag() }.asCompound()[key] = ItemTagData.toNBT(data) } } } @@ -47,11 +48,11 @@ object BuffsMeta : BaseMeta("buffs") { @SubscribeEvent(bind = "com.skillw.attsystem.api.event.EquipmentUpdateEvent\$After") fun e(optional: OptionalEvent) { - val event = optional.get() + val event = optional.get() val entity = event.entity if (entity !is LivingEntity) return val sets = HashSet() - event.compound.values.forEach inner@{ + event.data.values.forEach inner@{ it.values.forEach { item -> if (item.isAir()) return@forEach tags.getOrPut(item.hashCode()) { item.getItemTag() }[BUFF_KEY]?.asCompound() @@ -71,10 +72,10 @@ object BuffsMeta : BaseMeta("buffs") { data[entity.uniqueId]?.forEach { if (!sets.contains(it)) { BuffSystem.buffDataManager.removeBuff(entity, it) - data.get(entity.uniqueId)!!.remove(it) + data[entity.uniqueId]!!.remove(it) } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/mythicmobs/MobListener.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/mythicmobs/MobListener.kt index dde1c5c..8ba305c 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/mythicmobs/MobListener.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/mythicmobs/MobListener.kt @@ -1,9 +1,9 @@ package com.skillw.itemsystem.internal.feature.compat.mythicmobs +import com.skillw.asahi.api.AsahiAPI.analysis import com.skillw.itemsystem.internal.feature.ItemDrop import com.skillw.itemsystem.internal.feature.compat.mythicmobs.MobUtils.drop import com.skillw.itemsystem.internal.feature.compat.mythicmobs.MobUtils.equip -import com.skillw.pouvoir.api.PouvoirAPI.analysis import ink.ptms.um.event.MobDeathEvent import ink.ptms.um.event.MobSpawnEvent import org.bukkit.entity.LivingEntity @@ -37,4 +37,4 @@ object MobListener { ) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/mythicmobs/meta/MetaDropSkill.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/mythicmobs/meta/MetaDropSkill.kt index 35b24c8..982f119 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/mythicmobs/meta/MetaDropSkill.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/mythicmobs/meta/MetaDropSkill.kt @@ -2,7 +2,7 @@ package com.skillw.itemsystem.internal.feature.compat.mythicmobs.meta import com.skillw.itemsystem.api.meta.BaseMeta import com.skillw.itemsystem.api.meta.data.Memory -import com.skillw.pouvoir.api.annotation.AutoRegister +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister import taboolib.module.nms.ItemTagData @AutoRegister @@ -14,4 +14,4 @@ object MetaDropSkill : BaseMeta("drop-skills") { } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionDef.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionDef.kt deleted file mode 100644 index 2441a75..0000000 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionDef.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.function - -import com.skillw.itemsystem.internal.core.builder.ProcessData -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.function.PouFunction -import com.skillw.pouvoir.api.function.parser.Parser - -@AutoRegister -object FunctionDef : PouFunction("def", "var", "let", "const", namespace = "item_system") { - override fun execute(parser: Parser): Any? { - with(parser) { - if (context !is ProcessData) return "Error Context" - val key = next() ?: return null - if (context.containsKey(key)) return context[key] - except("=", "to") - val value = parseAny() - context[key] = value - (context as ProcessData).savingKeys.add(key) - return value - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionDynamic.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionDynamic.kt deleted file mode 100644 index aa6fa2c..0000000 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionDynamic.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.function - -import com.skillw.itemsystem.internal.core.builder.ProcessData -import com.skillw.itemsystem.internal.feature.ItemDynamic.addDynamic -import com.skillw.itemsystem.internal.manager.ISConfig.unknownDynamic -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.function.PouFunction -import com.skillw.pouvoir.api.function.context.IContext -import com.skillw.pouvoir.api.function.parser.Parser -import taboolib.module.nms.ItemTag -import taboolib.module.nms.ItemTagData - -@AutoRegister -object FunctionDynamic : PouFunction("dynamic", namespace = "item_system") { - - override fun execute(parser: Parser): String = parser.run{ return addDynamic(splitTill("{", "}")) } - - - -} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionItem.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionItem.kt deleted file mode 100644 index 7e09a4d..0000000 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionItem.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.function - -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.function.PouFunction -import com.skillw.pouvoir.api.function.parser.Parser -import org.bukkit.Material -import org.bukkit.inventory.ItemStack - -@AutoRegister -object FunctionItem : PouFunction("item", namespace = "common") { - override fun execute(parser: Parser): ItemStack { - with(parser) { - return ItemStack(parse()) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionMythicSkill.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionMythicSkill.kt deleted file mode 100644 index 84983e4..0000000 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionMythicSkill.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.function - -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.function.PouFunction -import com.skillw.pouvoir.api.function.parser.Parser -import ink.ptms.um.Mythic -import org.bukkit.entity.LivingEntity - -@AutoRegister -object FunctionMythicSkill : PouFunction("mmskill", namespace = "common") { - override fun execute(parser: Parser): Boolean { - with(parser) { - val skillKey = parseString() - var power = 1.0f - if (except("with")) { - power = parseFloat() - } - val caster = (context["entity"] ?: context["player"]) as? LivingEntity? ?: return false - return Mythic.API.castSkill(caster, skillKey, null, power = power) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionOverride.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionOverride.kt deleted file mode 100644 index 994b957..0000000 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionOverride.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.function - -import com.skillw.itemsystem.internal.core.builder.ProcessData -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.function.PouFunction -import com.skillw.pouvoir.api.function.parser.Parser - -@AutoRegister -object FunctionOverride : PouFunction("override", namespace = "item_system") { - override fun execute(parser: Parser): Any { - with(parser) { - if (context !is ProcessData) return "Error Context" - val key = parseString() - except("=", "to") - val value = parseAny() - context[key] = value - (context as ProcessData).savingKeys.add(key) - return value - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionPapi.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionPapi.kt deleted file mode 100644 index 31f6c25..0000000 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionPapi.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.function - -import com.skillw.pouvoir.api.PouvoirAPI.placeholder -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.function.PouFunction -import com.skillw.pouvoir.api.function.parser.Parser -import org.bukkit.entity.LivingEntity - -@AutoRegister -object FunctionPapi : PouFunction("papi", namespace = "item_system") { - - override fun execute(parser: Parser): String { - with(parser) { - val str = parseString() - val entity = context["entity"] as? LivingEntity? ?: return str - return str.placeholder(entity) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionSave.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionSave.kt deleted file mode 100644 index d99233e..0000000 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionSave.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.function - -import com.skillw.itemsystem.internal.core.builder.ProcessData -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.function.PouFunction -import com.skillw.pouvoir.api.function.parser.Parser - -@AutoRegister -object FunctionSave : PouFunction("save", namespace = "item_system") { - override fun execute(parser: Parser): Any { - with(parser) { - if (context !is ProcessData) return "Error Context" - val processData = context as ProcessData - if (peek() == "[") { - return parseList().onEach { processData.savingKeys.add(it.toString()) } - } - return parseString().also { processData.savingKeys.add(it) } - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionSyncNBT.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionSyncNBT.kt deleted file mode 100644 index 92eb390..0000000 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/compat/pouvoir/function/FunctionSyncNBT.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.skillw.itemsystem.internal.feature.compat.pouvoir.function - -import com.skillw.itemsystem.internal.feature.ItemDynamic.addDynamic -import com.skillw.pouvoir.api.annotation.AutoRegister -import com.skillw.pouvoir.api.function.PouFunction -import com.skillw.pouvoir.api.function.parser.Parser - -@AutoRegister -object FunctionSyncNBT : PouFunction("syncNBT", namespace = "item_system") { - - override fun execute(parser: Parser): String { - with(parser) { - val nbt = parseString() - val content = "&item nbt get '${nbt}'" - return addDynamic(content) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/effect/RandomItemEffect.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/effect/RandomItemEffect.kt index cc631da..030363d 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/effect/RandomItemEffect.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/effect/RandomItemEffect.kt @@ -7,9 +7,9 @@ import taboolib.common.platform.sendTo import taboolib.common.util.Location import taboolib.common.util.Vector import taboolib.common.util.random -import taboolib.module.effect.Arc import taboolib.module.effect.ParticleObj import taboolib.module.effect.ParticleSpawner +import taboolib.module.effect.shape.Arc import taboolib.platform.util.toProxyLocation import java.util.* @@ -52,4 +52,4 @@ class RandomItemEffect(val origin: Location) { private val particles = setOf(ProxyParticle.REDSTONE) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/listener/GlowListener.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/listener/GlowListener.kt index c724b1d..4f04df3 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/listener/GlowListener.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/listener/GlowListener.kt @@ -44,4 +44,4 @@ private object GlowListener { if (sync) submit { glowDrop() } else glowDrop() } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/feature/product/DemandData.kt b/src/main/kotlin/com/skillw/itemsystem/internal/feature/product/DemandData.kt index f8e0db5..2716186 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/feature/product/DemandData.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/feature/product/DemandData.kt @@ -1,8 +1,8 @@ package com.skillw.itemsystem.internal.feature.product import com.skillw.itemsystem.util.GsonUtils.parseToMap -import com.skillw.pouvoir.util.CalculationUtils.calculate -import com.skillw.pouvoir.util.CalculationUtils.calculateDouble +import com.skillw.pouvoir.util.calculate +import com.skillw.pouvoir.util.calculateDouble import org.bukkit.entity.LivingEntity import taboolib.common.util.random import taboolib.common5.Coerce @@ -31,4 +31,4 @@ data class DemandData( } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/manager/ActionTypeManagerImpl.kt b/src/main/kotlin/com/skillw/itemsystem/internal/manager/ActionTypeManagerImpl.kt index 45be56c..3279019 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/manager/ActionTypeManagerImpl.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/manager/ActionTypeManagerImpl.kt @@ -11,6 +11,8 @@ import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ActionTypeManagerImpl : ActionTypeManager() { + private fun readResolve(): Any = ActionTypeManagerImpl + override val key: String = "ActionTypeManager" override val priority: Int = 2 override val subPouvoir: SubPouvoir = ItemSystem @@ -41,4 +43,4 @@ object ActionTypeManagerImpl : ActionTypeManager() { override fun onReload() { clearCooldwon() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/manager/GlobalManagerImpl.kt b/src/main/kotlin/com/skillw/itemsystem/internal/manager/GlobalManagerImpl.kt index 4a08825..3980d86 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/manager/GlobalManagerImpl.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/manager/GlobalManagerImpl.kt @@ -6,16 +6,18 @@ import com.skillw.itemsystem.api.manager.GlobalManager import com.skillw.itemsystem.internal.core.meta.data.MetaData import com.skillw.itemsystem.util.FileWatcher.unwatch import com.skillw.itemsystem.util.FileWatcher.watch -import com.skillw.pouvoir.api.map.BaseMap import com.skillw.pouvoir.api.plugin.SubPouvoir -import com.skillw.pouvoir.util.FileUtils.listSubFiles -import com.skillw.pouvoir.util.FileUtils.loadYaml -import com.skillw.pouvoir.util.FileUtils.toMap +import com.skillw.pouvoir.api.plugin.map.BaseMap +import com.skillw.pouvoir.util.listSubFiles +import com.skillw.pouvoir.util.loadYaml +import com.skillw.pouvoir.util.toMap import org.bukkit.configuration.ConfigurationSection import taboolib.common.platform.function.getDataFolder import java.io.File object GlobalManagerImpl : GlobalManager() { + private fun readResolve(): Any = GlobalManagerImpl + override val key: String = "GlobalManager" override val priority: Int = 2 override val subPouvoir: SubPouvoir = ItemSystem @@ -53,4 +55,4 @@ object GlobalManagerImpl : GlobalManager() { .filter { it.extension == "yml" } .forEach { it.watch(this::fileReload); reload(it) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/manager/ISConfig.kt b/src/main/kotlin/com/skillw/itemsystem/internal/manager/ISConfig.kt index 05ac99d..a876dd7 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/manager/ISConfig.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/manager/ISConfig.kt @@ -3,9 +3,10 @@ package com.skillw.itemsystem.internal.manager import com.skillw.itemsystem.ItemSystem import com.skillw.itemsystem.api.ItemAPI import com.skillw.itemsystem.internal.feature.ItemCache.getTag +import com.skillw.itemsystem.internal.feature.ItemDynamic import com.skillw.pouvoir.Pouvoir import com.skillw.pouvoir.api.manager.ConfigManager -import com.skillw.pouvoir.util.ClassUtils.static +import com.skillw.pouvoir.util.static import org.bukkit.inventory.ItemStack import taboolib.common.platform.Platform import taboolib.common.platform.function.console @@ -17,8 +18,11 @@ import taboolib.module.nms.ItemTag import taboolib.platform.BukkitPlugin import java.io.File import java.util.function.Function +import java.util.regex.Pattern object ISConfig : ConfigManager(ItemSystem) { + private fun readResolve(): Any = ISConfig + override val priority = 0 val debug @@ -41,12 +45,10 @@ object ISConfig : ConfigManager(ItemSystem) { ) createIfNotExists("items", "action.yml", "example.yml", "gem.yml") createIfNotExists("global", "global.yml") - Metrics(16051, BukkitPlugin.getInstance().description.version, Platform.BUKKIT).run { - - } + Metrics(16051, BukkitPlugin.getInstance().description.version, Platform.BUKKIT) Pouvoir.scriptEngineManager.globalVariables.also { it["ItemAPI"] = ItemAPI::class.java.static() - it["getTag"] = Function{ item -> + it["getTag"] = Function { item -> return@Function item.getTag() } } @@ -59,6 +61,7 @@ object ISConfig : ConfigManager(ItemSystem) { override fun subReload() { Pouvoir.scriptManager.addScriptDir(File(getDataFolder(), "scripts")) unknownDynamic = console().asLangText("unknown-dynamic").colored() + ItemDynamic.dynamicPattern = Pattern.compile("\\{$unknownDynamic(?\\d)}") } @JvmStatic @@ -68,4 +71,4 @@ object ISConfig : ConfigManager(ItemSystem) { } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/manager/ItemBuilderManagerImpl.kt b/src/main/kotlin/com/skillw/itemsystem/internal/manager/ItemBuilderManagerImpl.kt index 7230585..588d207 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/manager/ItemBuilderManagerImpl.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/manager/ItemBuilderManagerImpl.kt @@ -5,16 +5,18 @@ import com.skillw.itemsystem.api.manager.ItemBuilderManager import com.skillw.itemsystem.internal.core.builder.ItemBuilder import com.skillw.itemsystem.util.FileWatcher.unwatch import com.skillw.itemsystem.util.FileWatcher.watch -import com.skillw.pouvoir.api.map.BaseMap import com.skillw.pouvoir.api.plugin.SubPouvoir -import com.skillw.pouvoir.util.FileUtils.listSubFiles -import com.skillw.pouvoir.util.FileUtils.loadYaml -import com.skillw.pouvoir.util.MapUtils.put +import com.skillw.pouvoir.api.plugin.map.BaseMap +import com.skillw.pouvoir.util.listSubFiles +import com.skillw.pouvoir.util.loadYaml +import com.skillw.pouvoir.util.put import org.bukkit.configuration.ConfigurationSection import taboolib.common.platform.function.getDataFolder import java.io.File object ItemBuilderManagerImpl : ItemBuilderManager() { + private fun readResolve(): Any = ItemBuilderManagerImpl + override val files: Set get() = items.keys override val key: String = "ItemBuilderManager" @@ -39,7 +41,7 @@ object ItemBuilderManagerImpl : ItemBuilderManager() { .filter { it.extension == "yml" } .forEach { it.watch { reload() } - items.put(it, HashSet()) + items[it] = HashSet() } reload() } @@ -63,4 +65,4 @@ object ItemBuilderManagerImpl : ItemBuilderManager() { } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/manager/MetaManagerImpl.kt b/src/main/kotlin/com/skillw/itemsystem/internal/manager/MetaManagerImpl.kt index ca4c461..1f55e73 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/manager/MetaManagerImpl.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/manager/MetaManagerImpl.kt @@ -7,6 +7,8 @@ import com.skillw.pouvoir.api.plugin.SubPouvoir import java.util.* object MetaManagerImpl : MetaManager() { + private fun readResolve(): Any = MetaManagerImpl + override val key: String = "MetaManager" override val priority: Int = 1 override val subPouvoir: SubPouvoir = ItemSystem @@ -18,4 +20,4 @@ object MetaManagerImpl : MetaManager() { super.register(value) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/skillw/itemsystem/internal/manager/VarTypeManagerImpl.kt b/src/main/kotlin/com/skillw/itemsystem/internal/manager/VarTypeManagerImpl.kt index be82092..cf02948 100644 --- a/src/main/kotlin/com/skillw/itemsystem/internal/manager/VarTypeManagerImpl.kt +++ b/src/main/kotlin/com/skillw/itemsystem/internal/manager/VarTypeManagerImpl.kt @@ -8,16 +8,18 @@ import com.skillw.pouvoir.api.plugin.SubPouvoir import java.util.function.Supplier object VarTypeManagerImpl : VarTypeManager() { + private fun readResolve(): Any = VarTypeManagerImpl + override val key: String = "VarTypeManager" override val priority: Int = 0 override val subPouvoir: SubPouvoir = ItemSystem - override fun register(key: String, value: VariableType) { + override fun register(key: String, value: VariableType): VariableType? { value.alias.forEach { super.register(it, value) } - super.register(key, value) + return super.register(key, value) } override fun createVar(memory: Memory): Supplier? { @@ -31,4 +33,4 @@ object VarTypeManagerImpl : VarTypeManager() { } } } -} \ No newline at end of file +} diff --git a/src/main/resources/items/example.yml b/src/main/resources/items/example.yml index 7a4aa59..c582142 100644 --- a/src/main/resources/items/example.yml +++ b/src/main/resources/items/example.yml @@ -85,8 +85,8 @@ ExampleItem: - global: default-prefixes #下面这段是声明前缀相关的变量 - run: |- - def 前缀颜色 = &randomColor - def prefix = &default-prefixes get &quality + var 前缀颜色 = &randomColor + var prefix = &default-prefixes get &quality set 前缀 = join [ &前缀颜色 &prefix ] #处理后缀相关 @@ -96,17 +96,17 @@ ExampleItem: - global: suffix-effects #下面这段是声明后缀相关的变量 - run: |- - def suffix to &default-suffixes - def 后缀颜色 = &randomColor + var suffix to &default-suffixes + var 后缀颜色 = &randomColor + + set 后缀 to join [ &后缀颜色 &suffix ] + set 后缀效果 to join { &suffix-effects get &suffix } by '\\n' - set 后缀 to join [ &后缀颜色 &suffix ] - set 后缀效果 to join &suffix-effects get &suffix by '\n' #处理强度相关 #声明强度相关的变量 - run: |- - def 强度 = random 0 to 1 + var 强度 = random 0 to 1 set 强度展示 = format calculate '{&强度} * 100' '#.##' - set 强度条 = createBar [ empty to '&8|' , fill to '&a|' , length to 20 , percent to &强度 ] #计算总评分 转为整数 - run: "set 总评分 to type int calculate ' { &品质评分 } * {&强度} '" @@ -144,18 +144,17 @@ ExampleItem: - "" - "&f&m─&7&m─────────&f&m─&f其它&f&m─&7&m─────────&f&m─" - "" - - "&f>> &7<&8{syncNBT 'gem.0.name'}&7>" - - "&f>> &7<&8{syncNBT 'gem.1.name'}&7>" - - "&f>> &7<&8{syncNBT 'gem.2.name'}&7>" + - "&f>> &7<&8{ syncNBT 'gem.0.name' }&7>" + - "&f>> &7<&8{ syncNBT 'gem.1.name' }&7>" + - "&f>> &7<&8{ syncNBT 'gem.2.name' }&7>" - "" - "&f&m─&7&m─────────&f&m─&f锻造信息&f&m─&7&m─────────&f&m─" - "" - - "&f>> &e强度: {&强度条} &8[{&强度展示}&8]" - - "&f>> &e创建时间: &7{ papi '%pou_run_time.js::getTime%' }" + - "&f>> &e强度: {&强度展示}" - "" - "&f&m─&7&m─────────&f&m─&f其它&f&m─&7&m─────────&f&m─" - "" - - "&f>> &e耐久: &7[&8{syncNBT '耐久.当前耐久'}&f/&8{syncNBT '耐久.总耐久'}&7]" + - "&f>> &e耐久: &7[&8{ syncNBT '耐久.当前耐久' }&f/&8{ syncNBT '耐久.总耐久' }&7]" - "" - "" #NBT diff --git a/src/main/resources/items/gem.yml b/src/main/resources/items/gem.yml index 50f707e..aa9d496 100644 --- a/src/main/resources/items/gem.yml +++ b/src/main/resources/items/gem.yml @@ -33,10 +33,10 @@ BaseGem: - material: "{&材质}" - glow-color: "{&品质颜色}" - run: |- - def name to '模板' - def attributes to '无' + var name to '模板' + var attributes to '无' set 名字 to &name - set 属性 to join &attributes by '\n' + set 属性 to join &attributes by '\\n' - display: "{&品质颜色}{&名字}宝石" - lore: - "&f&m─&7&m─────────&f&m─&f介绍&f&m─&7&m─────────&f&m─" @@ -59,7 +59,7 @@ BaseGem: type: build sync: true run: |- - set attKey to analysis 'gem-{&unique}' + set attKey to inline "gem-{&unique}" set gemAtt to attr readLore &item attr addItemAttr &item &attKey &gemAtt - action: