Merge branch 'main' into global_and_limit_placeholders
This commit is contained in:
@@ -10,6 +10,8 @@ import com.willfp.ecoshop.commands.CommandEcoShop
|
|||||||
import com.willfp.ecoshop.commands.CommandSell
|
import com.willfp.ecoshop.commands.CommandSell
|
||||||
import com.willfp.ecoshop.config.UsermadeConfig
|
import com.willfp.ecoshop.config.UsermadeConfig
|
||||||
import com.willfp.ecoshop.integration.EcoShopAdapter
|
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 org.bukkit.event.Listener
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
@@ -24,6 +26,13 @@ class EcoShopPlugin : EcoPlugin() {
|
|||||||
override fun handleEnable() {
|
override fun handleEnable() {
|
||||||
copyConfigs("categories")
|
copyConfigs("categories")
|
||||||
copyConfigs("shops")
|
copyConfigs("shops")
|
||||||
|
Shops.update(this)
|
||||||
|
SellGUI.update(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleReload() {
|
||||||
|
Shops.update(this)
|
||||||
|
SellGUI.update(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun copyConfigs(directory: String) {
|
private fun copyConfigs(directory: String) {
|
||||||
|
|||||||
@@ -41,7 +41,13 @@ class ShopItem(
|
|||||||
) {
|
) {
|
||||||
val id = config.getString("id")
|
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
|
val item = if (config.has("item")) Items.lookup(config.getString("item")) else null
|
||||||
|
|
||||||
@@ -262,11 +268,18 @@ class ShopItem(
|
|||||||
queue.push()
|
queue.push()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commands != null) {
|
for (command in commands) {
|
||||||
for (command in commands) {
|
Bukkit.dispatchCommand(
|
||||||
Bukkit.dispatchCommand(
|
Bukkit.getConsoleSender(),
|
||||||
Bukkit.getConsoleSender(),
|
command.replace("%player%", player.name)
|
||||||
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())
|
.replace("%amount%", amount.toString())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -354,8 +367,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) {
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ object Shops {
|
|||||||
return ImmutableList.copyOf(BY_ID.values)
|
return ImmutableList.copyOf(BY_ID.values)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigUpdater
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun update(plugin: EcoShopPlugin) {
|
fun update(plugin: EcoShopPlugin) {
|
||||||
ShopCategories.update(plugin)
|
ShopCategories.update(plugin)
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ object SellGUI {
|
|||||||
private lateinit var menu: Menu
|
private lateinit var menu: Menu
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ConfigUpdater
|
|
||||||
fun update(plugin: EcoShopPlugin) {
|
fun update(plugin: EcoShopPlugin) {
|
||||||
val rows = plugin.configYml.getInt("sell-gui.rows")
|
val rows = plugin.configYml.getInt("sell-gui.rows")
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ items:
|
|||||||
amount: 8 # (Optional) The quick buy / default buy amount. Defaults to 1 if not specified.
|
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.
|
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:
|
# Options for selling the item, see here:
|
||||||
# https://plugins.auxilor.io/all-plugins/prices
|
# https://plugins.auxilor.io/all-plugins/prices
|
||||||
sell:
|
sell:
|
||||||
@@ -83,6 +86,10 @@ items:
|
|||||||
|
|
||||||
require: "%player_rank% > 1" # (Optional) This expression must hold true to be allowed to sell this item.
|
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:
|
gui:
|
||||||
column: 4 # How far left to right (1-9).
|
column: 4 # How far left to right (1-9).
|
||||||
row: 3 # How far up or down (1-6).
|
row: 3 # How far up or down (1-6).
|
||||||
|
|||||||
Reference in New Issue
Block a user