fix sell bug

master
ALI Hamza 2020-04-18 07:02:00 +07:00
parent b39672a256
commit 72458bceb1
No known key found for this signature in database
GPG Key ID: BCA8A46C87798C4C
2 changed files with 10 additions and 10 deletions

@ -237,7 +237,7 @@ fun clickInventory(e: InventoryClickEvent, pe: PurchaseEvent) {
fun executeSell(item: ItemStack, howMany: Int, singleCost: Double, p: Player, op: OfflinePlayer) {
val name = if (item.itemMeta.hasDisplayName()) item.itemMeta.displayName else item.type.prettyName()
if (howMany <= 0) {
if (howMany <= 0 || p containing item < howMany) {
p.msg(GlobalConfig.messages.sellNotEnough.replace("%NAME%", name))
return
}

@ -4,16 +4,16 @@ import org.bukkit.Material
import org.bukkit.inventory.ItemStack
object PurchaseItems {
fun paneStack(damage: Int, name: String): ItemStack {
return ItemStack(Material.STAINED_GLASS_PANE, 1, damage.toShort()).apply {
fun paneStack(damage: Int, name: String, amount: Int = 1): ItemStack {
return ItemStack(Material.STAINED_GLASS, amount, damage.toShort()).apply {
itemMeta = itemMeta.apply {
displayName = name.c
}
}
}
fun blockStack(damage: Int, name: String): ItemStack {
return ItemStack(Material.STAINED_GLASS, 1, damage.toShort()).apply {
fun blockStack(damage: Int, name: String, amount: Int = 1): ItemStack {
return ItemStack(Material.STAINED_GLASS, amount, damage.toShort()).apply {
itemMeta = itemMeta.apply {
displayName = name.c
}
@ -27,12 +27,12 @@ object PurchaseItems {
var msgs = GlobalConfig.messages
val set1 = paneStack(14, msgs.set1)
val sub10 = paneStack(14, msgs.sub10)
val sub1 = paneStack(14, msgs.sub1)
val sub10 = paneStack(14, msgs.sub10, 10)
val sub1 = paneStack(14, msgs.sub1, 1)
val add1 = paneStack(5, msgs.add1)
val add10 = paneStack(5, msgs.add10)
val set64 = paneStack(5, msgs.set64)
val add1 = paneStack(5, msgs.add1, 1)
val add10 = paneStack(5, msgs.add10, 10)
val set64 = paneStack(5, msgs.set64, 64)
val sellConfirm = blockStack(5, msgs.sellConfirm)
val sellAll = blockStack(5, msgs.sellAll)