Update ShopItem.kt
This commit is contained in:
@@ -21,6 +21,7 @@ import com.willfp.ecoshop.shop.gui.BuyMenu
|
|||||||
import com.willfp.ecoshop.shop.gui.SellMenu
|
import com.willfp.ecoshop.shop.gui.SellMenu
|
||||||
import com.willfp.ecoshop.shop.gui.ShopItemSlot
|
import com.willfp.ecoshop.shop.gui.ShopItemSlot
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.ChatColor
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
import org.bukkit.OfflinePlayer
|
import org.bukkit.OfflinePlayer
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
@@ -43,6 +44,10 @@ class ShopItem(
|
|||||||
|
|
||||||
val commands = config.getStringsOrNull("command")
|
val commands = config.getStringsOrNull("command")
|
||||||
|
|
||||||
|
val sellCommand = config.getStringsOrNull("sell.sell-commands")
|
||||||
|
|
||||||
|
val sellItemMessage = config.getStringsOrNull("sell.sell-message")
|
||||||
|
|
||||||
val item = if (config.has("item")) Items.lookup(config.getString("item")) else null
|
val item = if (config.has("item")) Items.lookup(config.getString("item")) else null
|
||||||
|
|
||||||
val buyAmount = config.getIntOrNull("buy.amount") ?: 1
|
val buyAmount = config.getIntOrNull("buy.amount") ?: 1
|
||||||
@@ -256,6 +261,7 @@ class ShopItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
player.profile.write(timesBoughtKey, player.profile.read(timesBoughtKey) + 1)
|
player.profile.write(timesBoughtKey, player.profile.read(timesBoughtKey) + 1)
|
||||||
|
|
||||||
if (shop?.isBroadcasting == true) {
|
if (shop?.isBroadcasting == true) {
|
||||||
@@ -337,8 +343,27 @@ class ShopItem(
|
|||||||
|
|
||||||
shop?.sellSound?.playTo(player)
|
shop?.sellSound?.playTo(player)
|
||||||
|
|
||||||
|
if (sellCommand != null) {
|
||||||
|
for (command in sellCommand) {
|
||||||
|
Bukkit.dispatchCommand(
|
||||||
|
Bukkit.getConsoleSender(),
|
||||||
|
command.replace("%player%", player.name)
|
||||||
|
.replace("%amount%", amountSold.toString())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sellItemMessage != null) {
|
||||||
|
for (message in sellItemMessage) {
|
||||||
|
player.sendMessage(
|
||||||
|
message.formatEco()
|
||||||
|
.replace("%player%", player.name)
|
||||||
|
.replace("%amount%", amountSold.toString())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return amountSold
|
return amountSold
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAmountInPlayerInventory(player: Player): Int {
|
fun getAmountInPlayerInventory(player: Player): Int {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user