Skip to content

Commit

Permalink
Merge pull request #10 from YsGqHY/master
Browse files Browse the repository at this point in the history
新增构建物品玩家参数,可解析物品中的占位符
  • Loading branch information
FxRayHughes authored Aug 15, 2024
2 parents f5c23a7 + f8a8927 commit 3a17e1b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=ink.ptms.um
version=1.0.8
taboolib_version=6.1.1-beta12
taboolib_version=6.1.1
2 changes: 1 addition & 1 deletion project/common/src/main/kotlin/ink/ptms/um/Mythic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface Mythic {
fun getItemId(itemStack: ItemStack): String?

/** 获取 MythicItem 实例并构建到 ItemStack */
fun getItemStack(name: String): ItemStack?
fun getItemStack(name: String, player: Player? = null): ItemStack?

/** 获取 MythicItem ID 列表 */
fun getItemIDList(): List<String>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package ink.ptms.um.impl4

import ink.ptms.um.*
import ink.ptms.um.Mythic
import ink.ptms.um.Skill
import io.lumine.xikage.mythicmobs.MythicMobs
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter
import io.lumine.xikage.mythicmobs.drops.DropMetadata
import io.lumine.xikage.mythicmobs.io.MythicConfig
import io.lumine.xikage.mythicmobs.io.MythicLineConfig
import io.lumine.xikage.mythicmobs.items.ItemManager
import io.lumine.xikage.mythicmobs.items.MythicItem
import io.lumine.xikage.mythicmobs.mobs.GenericCaster
import io.lumine.xikage.mythicmobs.mobs.MobManager
import io.lumine.xikage.mythicmobs.mobs.MythicMob
import io.lumine.xikage.mythicmobs.skills.SkillManager
Expand Down Expand Up @@ -62,8 +65,11 @@ internal class Mythic4 : Mythic {
return getItemList().firstOrNull { item -> itemStack.getName().equals(item.displayName, true) }?.internalName
}

override fun getItemStack(name: String): ItemStack? {
return itemManager.getItemStack(name)
override fun getItemStack(name: String, player: Player?): ItemStack? {
val target = player?.let { BukkitAdapter.adapt(it) }
val meta = target?.let { DropMetadata(GenericCaster(target), target) }
return meta?.let { itemManager.getItem(name)?.get()?.generateItemStack(it, 1)?.toBukkit() }
?: itemManager.getItemStack(name)
}

override fun getItemIDList(): List<String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package ink.ptms.um.impl5
import ink.ptms.um.Mythic
import ink.ptms.um.Skill
import io.lumine.mythic.api.MythicProvider
import io.lumine.mythic.api.mobs.GenericCaster
import io.lumine.mythic.api.mobs.MythicMob
import io.lumine.mythic.api.skills.SkillTrigger
import io.lumine.mythic.bukkit.BukkitAdapter
import io.lumine.mythic.bukkit.MythicBukkit
import io.lumine.mythic.core.config.MythicConfigImpl
import io.lumine.mythic.core.config.MythicLineConfigImpl
import io.lumine.mythic.core.drops.DropMetadataImpl
import io.lumine.mythic.core.items.MythicItem
import io.lumine.mythic.core.mobs.MobExecutor
import io.lumine.mythic.core.utils.MythicUtil
Expand All @@ -27,7 +30,7 @@ import java.util.*
import kotlin.jvm.optionals.getOrNull

/**
* universal-mythic ink.ptms.um.impl4.Mythic4
* universal-mythic ink.ptms.um.impl5.Mythic5
*
* @author 坏黑
* @since 2022/7/12 13:47
Expand All @@ -49,8 +52,11 @@ internal class Mythic5 : Mythic {
return itemStack.getItemTag()["MYTHIC_TYPE"]?.asString()
}

override fun getItemStack(name: String): ItemStack? {
return api.itemManager?.getItem(name)?.get()?.generateItemStack(1)?.toBukkit()
override fun getItemStack(name: String, player: Player?): ItemStack? {
val target = player?.let { BukkitAdapter.adapt(it) }
val meta = target?.let { DropMetadataImpl(GenericCaster(target), target) }
return meta?.let { api.itemManager?.getItem(name)?.get()?.generateItemStack(it, 1)?.toBukkit() }
?: api.itemManager?.getItem(name)?.get()?.generateItemStack(1)?.toBukkit()
}

override fun getItemIDList(): List<String> {
Expand Down

0 comments on commit 3a17e1b

Please sign in to comment.