Merge branch 'main' into global_and_limit_placeholders

This commit is contained in:
Will FP
2023-04-30 20:24:24 +01:00
committed by GitHub
5 changed files with 55 additions and 9 deletions

View File

@@ -10,6 +10,8 @@ import com.willfp.ecoshop.commands.CommandEcoShop
import com.willfp.ecoshop.commands.CommandSell
import com.willfp.ecoshop.config.UsermadeConfig
import com.willfp.ecoshop.integration.EcoShopAdapter
import com.willfp.ecoshop.shop.Shops
import com.willfp.ecoshop.shop.gui.SellGUI
import org.bukkit.event.Listener
import java.io.File
import java.util.zip.ZipFile
@@ -24,6 +26,13 @@ class EcoShopPlugin : EcoPlugin() {
override fun handleEnable() {
copyConfigs("categories")
copyConfigs("shops")
Shops.update(this)
SellGUI.update(this)
}
override fun handleReload() {
Shops.update(this)
SellGUI.update(this)
}
private fun copyConfigs(directory: String) {

View File

@@ -41,7 +41,13 @@ class ShopItem(
) {
val id = config.getString("id")
val commands = config.getStringsOrNull("command")
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
@@ -262,11 +268,18 @@ class ShopItem(
queue.push()
}
if (commands != null) {
for (command in commands) {
Bukkit.dispatchCommand(
Bukkit.getConsoleSender(),
command.replace("%player%", player.name)
for (command in commands) {
Bukkit.dispatchCommand(
Bukkit.getConsoleSender(),
command.replace("%player%", player.name)
.replace("%amount%", amount.toString())
)
}
if (buyItemMessage != null) {
for (message in buyItemMessage) {
player.sendMessage(
message.formatEco()
.replace("%player%", player.name)
.replace("%amount%", amount.toString())
)
}
@@ -354,8 +367,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) {

View File

@@ -30,7 +30,6 @@ object Shops {
return ImmutableList.copyOf(BY_ID.values)
}
@ConfigUpdater
@JvmStatic
fun update(plugin: EcoShopPlugin) {
ShopCategories.update(plugin)

View File

@@ -18,7 +18,6 @@ object SellGUI {
private lateinit var menu: Menu
@JvmStatic
@ConfigUpdater
fun update(plugin: EcoShopPlugin) {
val rows = plugin.configYml.getInt("sell-gui.rows")

View File

@@ -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).