Merge pull request #5 from Exanthiax/main
Adds per-item buy/sell messages and sell-commands
This commit is contained in:
@@ -43,6 +43,12 @@ class ShopItem(
|
||||
|
||||
val commands = config.getStrings("command") + config.getStrings("commands")
|
||||
|
||||
val sellCommand = config.getStringsOrNull("sell.sell-commands")
|
||||
|
||||
val sellItemMessage = config.getStringsOrNull("sell.sell-message")
|
||||
|
||||
val buyItemMessage = config.getStringsOrNull("buy.buy-message")
|
||||
|
||||
val item = if (config.has("item")) Items.lookup(config.getString("item")) else null
|
||||
|
||||
val buyAmount = config.getIntOrNull("buy.amount") ?: 1
|
||||
@@ -253,6 +259,15 @@ class ShopItem(
|
||||
.replace("%amount%", amount.toString())
|
||||
)
|
||||
}
|
||||
if (buyItemMessage != null) {
|
||||
for (message in buyItemMessage) {
|
||||
player.sendMessage(
|
||||
message.formatEco()
|
||||
.replace("%player%", player.name)
|
||||
.replace("%amount%", amount.toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
player.profile.write(timesBoughtKey, player.profile.read(timesBoughtKey) + 1)
|
||||
|
||||
@@ -335,8 +350,27 @@ class ShopItem(
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
fun getAmountInPlayerInventory(player: Player): Int {
|
||||
if (item == null) {
|
||||
|
||||
@@ -74,6 +74,9 @@ items:
|
||||
amount: 8 # (Optional) The quick buy / default buy amount. Defaults to 1 if not specified.
|
||||
max-at-once: 16 # (Optional) The maximum amount that can be bought at once. Defaults to infinity if not specified.
|
||||
|
||||
buy-message: # (Optional) Enter messages to send to the player when the player buys this specific items. It will still send the 'bought-item/bought-multiple' from lang.yml
|
||||
- "&6Thanks for buying this specific item"
|
||||
|
||||
# Options for selling the item, see here:
|
||||
# https://plugins.auxilor.io/all-plugins/prices
|
||||
sell:
|
||||
@@ -83,6 +86,10 @@ items:
|
||||
|
||||
require: "%player_rank% > 1" # (Optional) This expression must hold true to be allowed to sell this item.
|
||||
|
||||
sell-command: # (Optional) Enter commands that should be executed when a player sells items. You can use %player% and %amount% placeholders
|
||||
- "give %player% stone %amount%"
|
||||
sell-message: # (Optional) Enter messages to send to the player when the player sells this specific items. It will still send the 'sold-item/sold-multiple' from lang.yml
|
||||
- "&6Thanks for selling this specific item"
|
||||
gui:
|
||||
column: 4 # How far left to right (1-9).
|
||||
row: 3 # How far up or down (1-6).
|
||||
|
||||
Reference in New Issue
Block a user