可选关闭一次性出售或购买一组
This commit is contained in:
@@ -19,6 +19,7 @@ interface Item {
|
||||
val vanilla: Boolean
|
||||
val commands: List<String>
|
||||
val shop: Shop
|
||||
val enableRight: Boolean
|
||||
|
||||
fun isCommodity(): Boolean
|
||||
fun buildItem(player: Player): ItemStack
|
||||
|
||||
@@ -47,7 +47,8 @@ abstract class ItemLoader {
|
||||
conditionIcon = this.getString("condition-icon")?.parseToMaterial(),
|
||||
conditionLore = this.getStringList("condition-lore"),
|
||||
conditionName = this.getString("condition-name"),
|
||||
limitPermissionMap = limitMap
|
||||
limitPermissionMap = limitMap,
|
||||
enableRight = this.getBoolean("right_click", true)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ abstract class ShopItem(
|
||||
val limitServer: Long,
|
||||
private val limitPlayer: Long,
|
||||
private val limitPermissionMap: Map<String, Long>,
|
||||
val currency: Currency
|
||||
val currency: Currency,
|
||||
override val enableRight: Boolean
|
||||
) : Item, KetherCondition {
|
||||
|
||||
constructor(itemSetting: ItemSetting) : this(
|
||||
@@ -46,7 +47,8 @@ abstract class ShopItem(
|
||||
itemSetting.limitServer,
|
||||
itemSetting.limitPlayer,
|
||||
itemSetting.limitPermissionMap,
|
||||
itemSetting.currency
|
||||
itemSetting.currency,
|
||||
itemSetting.enableRight
|
||||
)
|
||||
|
||||
class ItemSetting(
|
||||
@@ -65,7 +67,8 @@ abstract class ShopItem(
|
||||
val limitServer: Long,
|
||||
val limitPlayer: Long,
|
||||
val limitPermissionMap: Map<String, Long>,
|
||||
var currency: Currency
|
||||
var currency: Currency,
|
||||
val enableRight: Boolean
|
||||
)
|
||||
|
||||
override fun isCommodity(): Boolean {
|
||||
|
||||
@@ -21,7 +21,8 @@ class ItemImpl(
|
||||
override val key: Char,
|
||||
override val vanilla: Boolean,
|
||||
override val commands: List<String>,
|
||||
override val shop: Shop
|
||||
override val shop: Shop,
|
||||
override val enableRight: Boolean
|
||||
) : Item {
|
||||
|
||||
override lateinit var material: Material
|
||||
@@ -82,7 +83,8 @@ class ItemImpl(
|
||||
char,
|
||||
section.getBoolean("vanilla", true),
|
||||
section.getStringList("commands"),
|
||||
shop
|
||||
shop,
|
||||
section.getBoolean("right_click", true)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ import com.github.xbaimiao.shoppro.core.item.KetherCondition
|
||||
import com.github.xbaimiao.shoppro.core.item.ShopItem
|
||||
import com.github.xbaimiao.shoppro.util.Util.howManyItems
|
||||
import com.github.xbaimiao.shoppro.util.Util.replacePapi
|
||||
import io.lumine.xikage.mythicmobs.utils.adventure.text.minimessage.MiniMessage
|
||||
import io.lumine.xikage.mythicmobs.utils.adventure.text.minimessage.MiniMessageImpl
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.configuration.Configuration
|
||||
import org.bukkit.entity.Player
|
||||
@@ -110,7 +108,7 @@ class ShopImpl(private val configuration: Configuration) : Shop() {
|
||||
}
|
||||
val amount = when (event.clickEvent().click) {
|
||||
org.bukkit.event.inventory.ClickType.LEFT -> 1
|
||||
org.bukkit.event.inventory.ClickType.RIGHT -> 64
|
||||
org.bukkit.event.inventory.ClickType.RIGHT -> if (item.enableRight) 64 else 1
|
||||
else -> return@onClick
|
||||
}
|
||||
checkBuyLimit(amount, item, player)
|
||||
@@ -124,32 +122,19 @@ class ShopImpl(private val configuration: Configuration) : Shop() {
|
||||
if (event.clickType != ClickType.CLICK) {
|
||||
return@onClick
|
||||
}
|
||||
val amount : Int
|
||||
if (configuration.getBoolean("items.${item.key}.right_click")){
|
||||
amount = when (event.clickEvent().click) {
|
||||
org.bukkit.event.inventory.ClickType.LEFT -> 1
|
||||
org.bukkit.event.inventory.ClickType.RIGHT -> 64
|
||||
org.bukkit.event.inventory.ClickType.SHIFT_RIGHT -> {
|
||||
player.inventory.howManyItems {
|
||||
item.equal(it)
|
||||
}
|
||||
val amount = when (event.clickEvent().click) {
|
||||
org.bukkit.event.inventory.ClickType.LEFT -> 1
|
||||
org.bukkit.event.inventory.ClickType.RIGHT -> if (item.enableRight) 64 else 1
|
||||
org.bukkit.event.inventory.ClickType.SHIFT_RIGHT -> {
|
||||
player.inventory.howManyItems {
|
||||
item.equal(it)
|
||||
}
|
||||
|
||||
else -> return@onClick
|
||||
}
|
||||
}else{
|
||||
amount = when (event.clickEvent().click) {
|
||||
org.bukkit.event.inventory.ClickType.LEFT -> 1
|
||||
org.bukkit.event.inventory.ClickType.SHIFT_RIGHT -> {
|
||||
player.inventory.howManyItems {
|
||||
item.equal(it)
|
||||
}
|
||||
}
|
||||
|
||||
else -> return@onClick
|
||||
}
|
||||
else -> return@onClick
|
||||
}
|
||||
|
||||
|
||||
checkSellLimit(amount, item, player)
|
||||
event.currentItem?.let {
|
||||
event.clickEvent().inventory.setItem(event.rawSlot, item.update(player))
|
||||
|
||||
Reference in New Issue
Block a user