From 3bd155d688449b9f2b68519320f8fb0e1b51980c Mon Sep 17 00:00:00 2001 From: xbaimiao <3104026189@qq.com> Date: Wed, 28 Aug 2024 11:26:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=811.12.2=E7=89=A9=E5=93=81?= =?UTF-8?q?=E9=99=84=E5=8A=A0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 2 +- gradle.properties | 2 +- .../xbaimiao/shoppro/core/database/SqlDatabase.kt | 3 ++- .../github/xbaimiao/shoppro/core/item/ItemLoader.kt | 3 ++- .../com/github/xbaimiao/shoppro/core/item/ShopItem.kt | 11 +++++++---- .../xbaimiao/shoppro/core/item/impl/HeadShopItem.kt | 5 +++++ .../shoppro/core/item/impl/VanillaShopItem.kt | 8 +++++++- src/main/resources/shops/limit-buy.yml | 4 +++- 8 files changed, 28 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b90b84f..6544221 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,7 +20,7 @@ taboolib { name("xbaimiao") } val bukkitNodes = bukkitNodes as MutableMap - bukkitNodes["update-info"] = "修复提示信息错误" + bukkitNodes["update-info"] = "支持1.12.2物品附加值" } env { install(NMS_UTIL, UI) diff --git a/gradle.properties b/gradle.properties index 0b21834..27ddfcb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=com.github.xbaimiao.shoppro -version=1.3.3-SNAPSHOT +version=1.3.5-SNAPSHOT diff --git a/src/main/kotlin/com/github/xbaimiao/shoppro/core/database/SqlDatabase.kt b/src/main/kotlin/com/github/xbaimiao/shoppro/core/database/SqlDatabase.kt index 9f665f0..982965e 100644 --- a/src/main/kotlin/com/github/xbaimiao/shoppro/core/database/SqlDatabase.kt +++ b/src/main/kotlin/com/github/xbaimiao/shoppro/core/database/SqlDatabase.kt @@ -1,6 +1,7 @@ package com.github.xbaimiao.shoppro.core.database 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 org.bukkit.entity.Player import taboolib.common.platform.function.submitAsync @@ -55,7 +56,7 @@ abstract class SqlDatabase : Database { private fun Item.toCacheKey(): String { 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 { diff --git a/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/ItemLoader.kt b/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/ItemLoader.kt index 32f537a..f5ee467 100644 --- a/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/ItemLoader.kt +++ b/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/ItemLoader.kt @@ -38,6 +38,7 @@ abstract class ItemLoader { lore = this.getStringList("lore").colored(), vanilla = this.getBoolean("vanilla", true), commands = this.getStringList("commands"), + data = this.getInt("data"), shop = shop, script = this.getString("condition"), price = this.getDouble("price"), @@ -52,4 +53,4 @@ abstract class ItemLoader { ) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/ShopItem.kt b/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/ShopItem.kt index 921e628..6ccc029 100644 --- a/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/ShopItem.kt +++ b/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/ShopItem.kt @@ -28,7 +28,8 @@ abstract class ShopItem( private val limitPlayer: Long, private val limitPermissionMap: Map, val currency: Currency, - override val enableRight: Boolean + override val enableRight: Boolean, + val data: Int, ) : Item, KetherCondition { constructor(itemSetting: ItemSetting) : this( @@ -48,7 +49,8 @@ abstract class ShopItem( itemSetting.limitPlayer, itemSetting.limitPermissionMap, itemSetting.currency, - itemSetting.enableRight + itemSetting.enableRight, + itemSetting.data ) class ItemSetting( @@ -68,7 +70,8 @@ abstract class ShopItem( val limitPlayer: Long, val limitPermissionMap: Map, var currency: Currency, - val enableRight: Boolean + val enableRight: Boolean, + val data: Int, ) override fun isCommodity(): Boolean { @@ -126,4 +129,4 @@ abstract class ShopItem( return item } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/impl/HeadShopItem.kt b/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/impl/HeadShopItem.kt index d9d7109..876bc87 100644 --- a/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/impl/HeadShopItem.kt +++ b/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/impl/HeadShopItem.kt @@ -29,10 +29,14 @@ class HeadShopItem( override fun vanillaItem(player: Player): ItemStack { return com.github.xbaimiao.shoppro.util.buildItem(material) { skullTexture = com.github.xbaimiao.shoppro.util.ItemBuilder.SkullTexture(head, UUID.randomUUID()) + damage = data } } override fun equal(itemStack: ItemStack): Boolean { + if (data != 0 && itemStack.durability.toInt() != data) { + return false + } return itemStack.itemMeta?.hasLore() == false && itemStack.type == item } @@ -41,6 +45,7 @@ class HeadShopItem( this.name = this@HeadShopItem.name this.lore.addAll(this@HeadShopItem.lore) skullTexture = com.github.xbaimiao.shoppro.util.ItemBuilder.SkullTexture(head, UUID.randomUUID()) + damage = data } } diff --git a/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/impl/VanillaShopItem.kt b/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/impl/VanillaShopItem.kt index 7edf813..dc10673 100644 --- a/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/impl/VanillaShopItem.kt +++ b/src/main/kotlin/com/github/xbaimiao/shoppro/core/item/impl/VanillaShopItem.kt @@ -12,10 +12,15 @@ import taboolib.platform.util.hasLore open class VanillaShopItem(itemSetting: ItemSetting) : ShopItem(itemSetting) { 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 { + if (data != 0 && itemStack.durability.toInt() != data) { + return false + } 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) { this.name = this@VanillaShopItem.name this.lore.addAll(this@VanillaShopItem.lore) + this.damage = data } } diff --git a/src/main/resources/shops/limit-buy.yml b/src/main/resources/shops/limit-buy.yml index d718ff8..e0f421b 100644 --- a/src/main/resources/shops/limit-buy.yml +++ b/src/main/resources/shops/limit-buy.yml @@ -25,6 +25,8 @@ items: # 您可在 currencys 里自定义货币 currency: points name: '石头' + # data为低版本特有的 data区分material +# data: 1 # 每日限购买 limit: 5000 # 每个玩家限购买 @@ -120,4 +122,4 @@ items: - '&e| &7每人限制购买: ${limit}' - '&e| &7全服限制购买: ${allLimit}' - '&e| &7您已购买: ${limit-player}' - - '&e| &7全服剩余: ${limit-server}' \ No newline at end of file + - '&e| &7全服剩余: ${limit-server}'