尝试支持ItemsAdder贴图
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.github.xbaimiao.shoppro.core.item
|
||||
|
||||
import com.github.xbaimiao.shoppro.core.shop.Shop
|
||||
import me.clip.placeholderapi.PlaceholderAPI
|
||||
import com.github.xbaimiao.shoppro.util.Util.replacePapi
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
@@ -28,7 +28,7 @@ open class ItemImpl(
|
||||
val item = buildItem().modifyLore {
|
||||
val newLore = ArrayList<String>()
|
||||
for (line in this) {
|
||||
newLore.add(PlaceholderAPI.setPlaceholders(player, line))
|
||||
newLore.add(line.replacePapi(player))
|
||||
}
|
||||
this.clear()
|
||||
this.addAll(newLore)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.github.xbaimiao.shoppro.core.item
|
||||
|
||||
import com.github.xbaimiao.shoppro.ShopPro
|
||||
import com.github.xbaimiao.shoppro.Util.format
|
||||
import com.github.xbaimiao.shoppro.Util.howManyItems
|
||||
import com.github.xbaimiao.shoppro.core.shop.Shop
|
||||
import me.clip.placeholderapi.PlaceholderAPI
|
||||
import com.github.xbaimiao.shoppro.util.Util.format
|
||||
import com.github.xbaimiao.shoppro.util.Util.howManyItems
|
||||
import com.github.xbaimiao.shoppro.util.Util.replacePapi
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import taboolib.platform.util.modifyLore
|
||||
@@ -55,7 +55,7 @@ abstract class ShopItem : Item {
|
||||
} * price).format()
|
||||
newLine = newLine.replace("\${priceAll}", priceAll.toString())
|
||||
}
|
||||
newLore.add(PlaceholderAPI.setPlaceholders(player, newLine))
|
||||
newLore.add(newLine.replacePapi(player))
|
||||
}
|
||||
this.clear()
|
||||
this.addAll(newLore)
|
||||
|
||||
@@ -15,7 +15,7 @@ abstract class Shop {
|
||||
|
||||
}
|
||||
|
||||
abstract fun getTitle(): String
|
||||
abstract fun getTitle(player: Player): String
|
||||
|
||||
abstract fun getType(): ShopType
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.github.xbaimiao.shoppro.core.shop
|
||||
|
||||
import com.github.xbaimiao.shoppro.ShopPro
|
||||
import com.github.xbaimiao.shoppro.Util.howManyItems
|
||||
import com.github.xbaimiao.shoppro.api.ShopProBuyEvent
|
||||
import com.github.xbaimiao.shoppro.api.ShopProSellEvent
|
||||
import com.github.xbaimiao.shoppro.core.database.LimitData
|
||||
import com.github.xbaimiao.shoppro.core.item.*
|
||||
import com.github.xbaimiao.shoppro.util.Util.howManyItems
|
||||
import com.github.xbaimiao.shoppro.util.Util.replacePapi
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.configuration.Configuration
|
||||
import org.bukkit.entity.Player
|
||||
@@ -77,8 +78,8 @@ class ShopImpl(private val configuration: Configuration) : Shop() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTitle(): String {
|
||||
return configuration.getString("title")!!.colored()
|
||||
override fun getTitle(player: Player): String {
|
||||
return configuration.getString("title")!!.colored().replacePapi(player)
|
||||
}
|
||||
|
||||
override fun getType(): ShopType {
|
||||
@@ -90,7 +91,7 @@ class ShopImpl(private val configuration: Configuration) : Shop() {
|
||||
}
|
||||
|
||||
override fun open(player: Player) {
|
||||
player.openMenu<Basic>(getTitle()) {
|
||||
player.openMenu<Basic>(getTitle(player)) {
|
||||
rows(slots.size)
|
||||
slots = ArrayList<List<Char>>().also { it.addAll(this@ShopImpl.slots) }
|
||||
onClick {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.github.xbaimiao.shoppro.core.vault
|
||||
|
||||
import com.github.xbaimiao.shoppro.Util.format
|
||||
import com.github.xbaimiao.shoppro.util.Util.format
|
||||
import org.bukkit.entity.Player
|
||||
import taboolib.platform.compat.VaultService
|
||||
|
||||
|
||||
+13
-1
@@ -1,5 +1,8 @@
|
||||
package com.github.xbaimiao.shoppro
|
||||
package com.github.xbaimiao.shoppro.util
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.Inventory
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import taboolib.platform.util.isNotAir
|
||||
@@ -7,6 +10,8 @@ import java.text.DecimalFormat
|
||||
|
||||
object Util {
|
||||
|
||||
private val hasPapi by lazy { Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null }
|
||||
|
||||
fun Double.format(): Double {
|
||||
val df = DecimalFormat("#0.00")
|
||||
return df.format(this).toDouble()
|
||||
@@ -24,4 +29,11 @@ object Util {
|
||||
return amount
|
||||
}
|
||||
|
||||
fun String.replacePapi(player: Player): String {
|
||||
if (hasPapi) {
|
||||
return PlaceholderAPI.setPlaceholders(player, this)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user