From a8ec393d2b98651b6475f4d65a149fb09fce00b5 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:15:45 +0100 Subject: [PATCH 1/6] Update ShopItem.kt --- .../com/willfp/ecoshop/shop/ShopItem.kt | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt index a3b27dc..03b1e2f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt @@ -21,6 +21,7 @@ import com.willfp.ecoshop.shop.gui.BuyMenu import com.willfp.ecoshop.shop.gui.SellMenu import com.willfp.ecoshop.shop.gui.ShopItemSlot import org.bukkit.Bukkit +import org.bukkit.ChatColor import org.bukkit.Material import org.bukkit.OfflinePlayer import org.bukkit.entity.Player @@ -43,6 +44,10 @@ class ShopItem( 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 buyAmount = config.getIntOrNull("buy.amount") ?: 1 @@ -256,6 +261,7 @@ class ShopItem( } } + player.profile.write(timesBoughtKey, player.profile.read(timesBoughtKey) + 1) if (shop?.isBroadcasting == true) { @@ -337,8 +343,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) { From 93bb33ba28b910b517b67c37a96f15cba9a079d2 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:16:42 +0100 Subject: [PATCH 2/6] Update _example.yml --- .../core-plugin/src/main/resources/categories/_example.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eco-core/core-plugin/src/main/resources/categories/_example.yml b/eco-core/core-plugin/src/main/resources/categories/_example.yml index 508029a..d52c938 100644 --- a/eco-core/core-plugin/src/main/resources/categories/_example.yml +++ b/eco-core/core-plugin/src/main/resources/categories/_example.yml @@ -83,6 +83,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 + - "&" gui: column: 4 # How far left to right (1-9). row: 3 # How far up or down (1-6). From 3d28c7280e9fbc9037d68309c9f26ec839d3d791 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:17:12 +0100 Subject: [PATCH 3/6] Update _example.yml --- eco-core/core-plugin/src/main/resources/categories/_example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/resources/categories/_example.yml b/eco-core/core-plugin/src/main/resources/categories/_example.yml index d52c938..ec57e9d 100644 --- a/eco-core/core-plugin/src/main/resources/categories/_example.yml +++ b/eco-core/core-plugin/src/main/resources/categories/_example.yml @@ -86,7 +86,7 @@ items: 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 - - "&" + - "&7Thanks for selling the item!" gui: column: 4 # How far left to right (1-9). row: 3 # How far up or down (1-6). From c3ec73ff3b7e0ee4700272f1b43bedb1e2e937cb Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:30:54 +0100 Subject: [PATCH 4/6] Update _example.yml --- .../core-plugin/src/main/resources/categories/_example.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/resources/categories/_example.yml b/eco-core/core-plugin/src/main/resources/categories/_example.yml index ec57e9d..098bcd8 100644 --- a/eco-core/core-plugin/src/main/resources/categories/_example.yml +++ b/eco-core/core-plugin/src/main/resources/categories/_example.yml @@ -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: @@ -86,7 +89,7 @@ items: 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 - - "&7Thanks for selling the item!" + - "&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). From 1535bb4f609f7039b0a21dad677229ded0fcb587 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:33:57 +0100 Subject: [PATCH 5/6] Update ShopItem.kt --- .../main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt index 03b1e2f..7a0e7b2 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt @@ -48,6 +48,8 @@ class ShopItem( 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 @@ -260,7 +262,15 @@ class ShopItem( ) } } - + 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) From a30905113c64830badd4292aea5a62ca07ba91a3 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:44:26 +0100 Subject: [PATCH 6/6] Update ShopItem.kt --- .../src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt index 7a0e7b2..ad05d84 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoshop/shop/ShopItem.kt @@ -21,7 +21,6 @@ import com.willfp.ecoshop.shop.gui.BuyMenu import com.willfp.ecoshop.shop.gui.SellMenu import com.willfp.ecoshop.shop.gui.ShopItemSlot import org.bukkit.Bukkit -import org.bukkit.ChatColor import org.bukkit.Material import org.bukkit.OfflinePlayer import org.bukkit.entity.Player