支持头颅装饰商店
This commit is contained in:
@@ -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: String) = true
|
||||
}, command.substring(5))
|
||||
} else if (command == "close" || command.startsWith("[close]")) {
|
||||
player.closeInventory()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ class ItemsAdderShopItem(
|
||||
|
||||
val custom: Int
|
||||
|
||||
|
||||
init {
|
||||
iaMaterial.split(":").let { strings ->
|
||||
material = XMaterial.matchXMaterial(strings[1]).get().parseMaterial()!!
|
||||
|
||||
@@ -48,6 +48,22 @@ class ShopImpl(private val configuration: Configuration) : Shop() {
|
||||
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 {
|
||||
items.add(
|
||||
VanillaShopItem(
|
||||
@@ -67,7 +83,7 @@ class ShopImpl(private val configuration: Configuration) : Shop() {
|
||||
} else {
|
||||
items.add(
|
||||
ItemImpl(
|
||||
section.getString("$key.material")!!.parseToMaterial(),
|
||||
section.getString("$key.material")!!,
|
||||
section.getStringList("$key.lore").colored(),
|
||||
section.getString("$key.name")!!.colored(),
|
||||
key[0],
|
||||
|
||||
Reference in New Issue
Block a user