支持1.12.2物品附加值

This commit is contained in:
xbaimiao
2024-08-28 11:26:57 +08:00
parent ebe9bb639b
commit 3bd155d688
8 changed files with 28 additions and 10 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ taboolib {
name("xbaimiao") name("xbaimiao")
} }
val bukkitNodes = bukkitNodes as MutableMap<Any, Any> val bukkitNodes = bukkitNodes as MutableMap<Any, Any>
bukkitNodes["update-info"] = "修复提示信息错误" bukkitNodes["update-info"] = "支持1.12.2物品附加值"
} }
env { env {
install(NMS_UTIL, UI) install(NMS_UTIL, UI)
+1 -1
View File
@@ -1,2 +1,2 @@
group=com.github.xbaimiao.shoppro group=com.github.xbaimiao.shoppro
version=1.3.3-SNAPSHOT version=1.3.5-SNAPSHOT
@@ -1,6 +1,7 @@
package com.github.xbaimiao.shoppro.core.database package com.github.xbaimiao.shoppro.core.database
import com.github.xbaimiao.shoppro.core.item.Item import com.github.xbaimiao.shoppro.core.item.Item
import com.github.xbaimiao.shoppro.core.item.ShopItem
import com.github.xbaimiao.shoppro.core.item.impl.ItemsAdderShopItem import com.github.xbaimiao.shoppro.core.item.impl.ItemsAdderShopItem
import org.bukkit.entity.Player import org.bukkit.entity.Player
import taboolib.common.platform.function.submitAsync import taboolib.common.platform.function.submitAsync
@@ -55,7 +56,7 @@ abstract class SqlDatabase : Database {
private fun Item.toCacheKey(): String { private fun Item.toCacheKey(): String {
val item = this val item = this
return "${item.key}-${item.material}-${if (item is ItemsAdderShopItem) item.custom else 0}" return "${item.key}-${item.material}-${if (item is ItemsAdderShopItem) item.custom else 0}-${if (item is ShopItem) item.data else 0}"
} }
override fun getPlayerAlreadyData(player: Player, item: Item): LimitData { override fun getPlayerAlreadyData(player: Player, item: Item): LimitData {
@@ -38,6 +38,7 @@ abstract class ItemLoader {
lore = this.getStringList("lore").colored(), lore = this.getStringList("lore").colored(),
vanilla = this.getBoolean("vanilla", true), vanilla = this.getBoolean("vanilla", true),
commands = this.getStringList("commands"), commands = this.getStringList("commands"),
data = this.getInt("data"),
shop = shop, shop = shop,
script = this.getString("condition"), script = this.getString("condition"),
price = this.getDouble("price"), price = this.getDouble("price"),
@@ -52,4 +53,4 @@ abstract class ItemLoader {
) )
} }
} }
@@ -28,7 +28,8 @@ abstract class ShopItem(
private val limitPlayer: Long, private val limitPlayer: Long,
private val limitPermissionMap: Map<String, Long>, private val limitPermissionMap: Map<String, Long>,
val currency: Currency, val currency: Currency,
override val enableRight: Boolean override val enableRight: Boolean,
val data: Int,
) : Item, KetherCondition { ) : Item, KetherCondition {
constructor(itemSetting: ItemSetting) : this( constructor(itemSetting: ItemSetting) : this(
@@ -48,7 +49,8 @@ abstract class ShopItem(
itemSetting.limitPlayer, itemSetting.limitPlayer,
itemSetting.limitPermissionMap, itemSetting.limitPermissionMap,
itemSetting.currency, itemSetting.currency,
itemSetting.enableRight itemSetting.enableRight,
itemSetting.data
) )
class ItemSetting( class ItemSetting(
@@ -68,7 +70,8 @@ abstract class ShopItem(
val limitPlayer: Long, val limitPlayer: Long,
val limitPermissionMap: Map<String, Long>, val limitPermissionMap: Map<String, Long>,
var currency: Currency, var currency: Currency,
val enableRight: Boolean val enableRight: Boolean,
val data: Int,
) )
override fun isCommodity(): Boolean { override fun isCommodity(): Boolean {
@@ -126,4 +129,4 @@ abstract class ShopItem(
return item return item
} }
} }
@@ -29,10 +29,14 @@ class HeadShopItem(
override fun vanillaItem(player: Player): ItemStack { override fun vanillaItem(player: Player): ItemStack {
return com.github.xbaimiao.shoppro.util.buildItem(material) { return com.github.xbaimiao.shoppro.util.buildItem(material) {
skullTexture = com.github.xbaimiao.shoppro.util.ItemBuilder.SkullTexture(head, UUID.randomUUID()) skullTexture = com.github.xbaimiao.shoppro.util.ItemBuilder.SkullTexture(head, UUID.randomUUID())
damage = data
} }
} }
override fun equal(itemStack: ItemStack): Boolean { override fun equal(itemStack: ItemStack): Boolean {
if (data != 0 && itemStack.durability.toInt() != data) {
return false
}
return itemStack.itemMeta?.hasLore() == false && itemStack.type == item return itemStack.itemMeta?.hasLore() == false && itemStack.type == item
} }
@@ -41,6 +45,7 @@ class HeadShopItem(
this.name = this@HeadShopItem.name this.name = this@HeadShopItem.name
this.lore.addAll(this@HeadShopItem.lore) this.lore.addAll(this@HeadShopItem.lore)
skullTexture = com.github.xbaimiao.shoppro.util.ItemBuilder.SkullTexture(head, UUID.randomUUID()) skullTexture = com.github.xbaimiao.shoppro.util.ItemBuilder.SkullTexture(head, UUID.randomUUID())
damage = data
} }
} }
@@ -12,10 +12,15 @@ import taboolib.platform.util.hasLore
open class VanillaShopItem(itemSetting: ItemSetting) : ShopItem(itemSetting) { open class VanillaShopItem(itemSetting: ItemSetting) : ShopItem(itemSetting) {
override fun vanillaItem(player: Player): ItemStack { override fun vanillaItem(player: Player): ItemStack {
return com.github.xbaimiao.shoppro.util.buildItem(material) return com.github.xbaimiao.shoppro.util.buildItem(material) {
damage = data
}
} }
override fun equal(itemStack: ItemStack): Boolean { override fun equal(itemStack: ItemStack): Boolean {
if (data != 0 && itemStack.durability.toInt() != data) {
return false
}
return itemStack.type == material && !itemStack.hasLore() return itemStack.type == material && !itemStack.hasLore()
} }
@@ -23,6 +28,7 @@ open class VanillaShopItem(itemSetting: ItemSetting) : ShopItem(itemSetting) {
return com.github.xbaimiao.shoppro.util.buildItem(material) { return com.github.xbaimiao.shoppro.util.buildItem(material) {
this.name = this@VanillaShopItem.name this.name = this@VanillaShopItem.name
this.lore.addAll(this@VanillaShopItem.lore) this.lore.addAll(this@VanillaShopItem.lore)
this.damage = data
} }
} }
+3 -1
View File
@@ -25,6 +25,8 @@ items:
# 您可在 currencys 里自定义货币 # 您可在 currencys 里自定义货币
currency: points currency: points
name: '石头' name: '石头'
# data为低版本特有的 data区分material
# data: 1
# 每日限购买 # 每日限购买
limit: 5000 limit: 5000
# 每个玩家限购买 # 每个玩家限购买
@@ -120,4 +122,4 @@ items:
- '&e| &7每人限制购买: ${limit}' - '&e| &7每人限制购买: ${limit}'
- '&e| &7全服限制购买: ${allLimit}' - '&e| &7全服限制购买: ${allLimit}'
- '&e| &7您已购买: ${limit-player}' - '&e| &7您已购买: ${limit-player}'
- '&e| &7全服剩余: ${limit-server}' - '&e| &7全服剩余: ${limit-server}'