支持头颅装饰商店

This commit is contained in:
小白
2022-09-10 19:21:16 +08:00
parent 717b062381
commit ce99c11707
5 changed files with 70 additions and 3 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
group=com.github.xbaimiao.shoppro group=com.github.xbaimiao.shoppro
version=1.0.1 version=1.0.2
@@ -0,0 +1,50 @@
package com.github.xbaimiao.shoppro.core.item
import com.github.xbaimiao.shoppro.core.shop.Shop
import org.bukkit.Material
import org.bukkit.inventory.ItemStack
import taboolib.library.xseries.XMaterial
import taboolib.platform.util.ItemBuilder
import java.util.*
class HeadShopItem(
override val key: Char,
headString: String,
override val price: Double,
override val limitServer: Long,
override val limitPlayer: Long,
override val name: String,
override val lore: List<String>,
override val vanilla: Boolean,
override val commands: List<String>,
override val shop: Shop,
val item: Material
) : ShopItem() {
override val material: Material = XMaterial.PLAYER_HEAD.parseMaterial()!!
val head: String
init {
head = headString.substring(5)
}
override fun vanillaItem(): ItemStack {
return taboolib.platform.util.buildItem(material) {
skullTexture = ItemBuilder.SkullTexture(head, UUID.randomUUID())
}
}
override fun equal(itemStack: ItemStack): Boolean {
return itemStack.itemMeta?.hasLore() == false && itemStack.type == item
}
override fun buildItem(): ItemStack {
return taboolib.platform.util.buildItem(material) {
this.name = this@HeadShopItem.name
this.lore.addAll(this@HeadShopItem.lore)
skullTexture = ItemBuilder.SkullTexture(head, UUID.randomUUID())
}
}
}
@@ -45,6 +45,8 @@ interface Item {
override fun hasPermission(p0: Permission) = true override fun hasPermission(p0: Permission) = true
override fun hasPermission(p0: String) = true override fun hasPermission(p0: String) = true
}, command.substring(5)) }, command.substring(5))
} else if (command == "close" || command.startsWith("[close]")) {
player.closeInventory()
} }
} }
} }
@@ -22,7 +22,6 @@ class ItemsAdderShopItem(
val custom: Int val custom: Int
init { init {
iaMaterial.split(":").let { strings -> iaMaterial.split(":").let { strings ->
material = XMaterial.matchXMaterial(strings[1]).get().parseMaterial()!! material = XMaterial.matchXMaterial(strings[1]).get().parseMaterial()!!
@@ -48,6 +48,22 @@ class ShopImpl(private val configuration: Configuration) : Shop() {
this this
) )
) )
} else if (materialString.startsWith("HEAD:")) {
items.add(
HeadShopItem(
key[0],
section.getString("$key.material")!!,
section.getDouble("$key.price"),
section.getLong("$key.limit"),
section.getLong("$key.limit-player"),
section.getString("$key.name")!!.colored(),
section.getStringList("$key.lore").colored(),
section.getBoolean("$key.vanilla", true),
section.getStringList("$key.commands"),
this,
section.getString("item")!!.parseToMaterial()
)
)
} else { } else {
items.add( items.add(
VanillaShopItem( VanillaShopItem(
@@ -67,7 +83,7 @@ class ShopImpl(private val configuration: Configuration) : Shop() {
} else { } else {
items.add( items.add(
ItemImpl( ItemImpl(
section.getString("$key.material")!!.parseToMaterial(), section.getString("$key.material")!!,
section.getStringList("$key.lore").colored(), section.getStringList("$key.lore").colored(),
section.getString("$key.name")!!.colored(), section.getString("$key.name")!!.colored(),
key[0], key[0],