|
|
@ -71,9 +71,9 @@ class MainConfig(file: File) : ConfigFile(file) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class ShopConfig(val name: String, file: File) : ConfigFile(file) {
|
|
|
|
class ShopConfig(val name: String, file: File) : ConfigFile(file) {
|
|
|
|
open class Block(val item: ItemStack)
|
|
|
|
open class Block(open val item: ItemStack, open val buy: Double)
|
|
|
|
class Item(item: ItemStack, val raw: ItemStack, val buy: Double, val sell: Double) : Block(item)
|
|
|
|
data class Item(override val item: ItemStack, val raw: ItemStack, override val buy: Double, val sell: Double) : Block(item, buy)
|
|
|
|
class Command(item: ItemStack, val asPlayer: Boolean, val commands: List<String>) : Block(item)
|
|
|
|
data class Command(override val item: ItemStack, override val buy: Double, val asPlayer: Boolean, val commands: List<String>) : Block(item, buy)
|
|
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
init {
|
|
|
|
run {
|
|
|
|
run {
|
|
|
@ -108,16 +108,25 @@ class ShopConfig(val name: String, file: File) : ConfigFile(file) {
|
|
|
|
|
|
|
|
|
|
|
|
val buy = it.getDouble("buyPrice", -1.0)
|
|
|
|
val buy = it.getDouble("buyPrice", -1.0)
|
|
|
|
val sell = it.getDouble("sellPrice", -1.0)
|
|
|
|
val sell = it.getDouble("sellPrice", -1.0)
|
|
|
|
|
|
|
|
val additional =
|
|
|
|
|
|
|
|
when {
|
|
|
|
|
|
|
|
buy > 0 && sell > 0 -> GlobalConfig.messages.buyAndSell
|
|
|
|
|
|
|
|
buy > 0 -> GlobalConfig.messages.buyOnly
|
|
|
|
|
|
|
|
sell > 0 -> GlobalConfig.messages.sellOnly
|
|
|
|
|
|
|
|
else -> ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val item = it.getConfigurationSection("item").asItem(buy, sell)
|
|
|
|
val item = it.getConfigurationSection("item").asItem(buy, sell)
|
|
|
|
|
|
|
|
|
|
|
|
when (type) {
|
|
|
|
when (type) {
|
|
|
|
"command" -> Command(
|
|
|
|
"command" -> Command(
|
|
|
|
it.getConfigurationSection("item").asItem(),
|
|
|
|
it.getConfigurationSection("item").asItem(buy),
|
|
|
|
|
|
|
|
buy,
|
|
|
|
it.getBoolean("asplayer"),
|
|
|
|
it.getBoolean("asplayer"),
|
|
|
|
it.getStringList("commands")
|
|
|
|
it.getStringList("commands")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
"item" -> Item(
|
|
|
|
"item" -> Item(
|
|
|
|
item.addLore(GlobalConfig.messages.itemLore),
|
|
|
|
item.addLore(additional),
|
|
|
|
it.getConfigurationSection("item").asItem(),
|
|
|
|
it.getConfigurationSection("item").asItem(),
|
|
|
|
buy,
|
|
|
|
buy,
|
|
|
|
sell
|
|
|
|
sell
|
|
|
@ -133,10 +142,10 @@ class ShopConfig(val name: String, file: File) : ConfigFile(file) {
|
|
|
|
val inventory: Inventory
|
|
|
|
val inventory: Inventory
|
|
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
init {
|
|
|
|
inventory = makeInventory(size, title, menuRow, blocks, 1)
|
|
|
|
inventory = makeInventory(size, title, menuRow, blocks, 1, pages)
|
|
|
|
inventories += inventory
|
|
|
|
inventories += inventory
|
|
|
|
for (i in 2..pages) {
|
|
|
|
for (i in 2..pages) {
|
|
|
|
inventories += makeInventory(size, title, menuRow, blocks, i)
|
|
|
|
inventories += makeInventory(size, title, menuRow, blocks, i, pages)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|