diff --git a/compile.sh b/compile.sh new file mode 100644 index 0000000..fa081f9 --- /dev/null +++ b/compile.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +./gradlew shadowJar + +mv build/libs/ShopReborn-1.0-SNAPSHOT.jar ~/Desktop/CodeRelated/server/plugins/ \ No newline at end of file diff --git a/src/main/kotlin/pw.hamzantal.shopreborn/ClickListeners.kt b/src/main/kotlin/pw.hamzantal.shopreborn/ClickListeners.kt index e7c4efd..5fb3864 100644 --- a/src/main/kotlin/pw.hamzantal.shopreborn/ClickListeners.kt +++ b/src/main/kotlin/pw.hamzantal.shopreborn/ClickListeners.kt @@ -1,6 +1,6 @@ package pw.hamzantal.shopreborn -import hazae41.minecraft.kutils.bukkit.msg +import org.bukkit.entity.Player import org.bukkit.event.inventory.InventoryClickEvent fun baseListener(e: InventoryClickEvent) { @@ -8,14 +8,17 @@ fun baseListener(e: InventoryClickEvent) { mainClick(e) return } - - } fun mainClick(e: InventoryClickEvent) { - val main = Configurations.main - e.isCancelled = true; + e.isCancelled = true if (e.rawSlot > e.inventory.size) return - e.whoClicked.msg(e.rawSlot.toString()) + val main = Configurations.main + val p = e.whoClicked as Player + + val block = main.blocks.firstOrNull { it.slot == e.slot } ?: return + block.commands.forEach { + p.performCommand(it) + } } \ No newline at end of file diff --git a/src/main/kotlin/pw.hamzantal.shopreborn/Configuration.kt b/src/main/kotlin/pw.hamzantal.shopreborn/Configuration.kt index 568a98b..114f167 100644 --- a/src/main/kotlin/pw.hamzantal.shopreborn/Configuration.kt +++ b/src/main/kotlin/pw.hamzantal.shopreborn/Configuration.kt @@ -5,6 +5,7 @@ import hazae41.minecraft.kutils.bukkit.keys import org.bukkit.Bukkit import org.bukkit.Material import org.bukkit.configuration.ConfigurationSection +import org.bukkit.inventory.Inventory import org.bukkit.inventory.ItemStack import java.io.File @@ -18,35 +19,35 @@ class MainConfig(file: File) : ConfigFile(file) { var shops by section("shops") - var size by int("startGUI.size") - var title by string("startGUI.title") + var size by int("shopGUI.size") + var title by string("shopGUI.title") var blocksRaw by section("shopGUI.blocks") val blocks = blocksRaw?.keys ?.map { blocksRaw!!.getConfigurationSection(it) } ?.map { Block( - it.asItem(), + it.getConfigurationSection("item").asItem(), it.getInt("slot"), it.getStringList("commands") ) } ?: listOf() - val inventory by lazy { - val inv = Bukkit.createInventory(null, size, title.c) + val inventory: Inventory = Bukkit.createInventory(null, size, title.c).apply { blocks.forEach { - inv.setItem(it.slot, it.item) + println(it) + setItem(it.slot, it.item) } - inv } } fun ConfigurationSection.asItem(): ItemStack { val material = Material.valueOf(getString("material").toUpperCase()) val item = ItemStack(material, getInt("quantity", 1), getInt("data", 0).toShort()) - item.itemMeta.apply { - displayName = getString("name", "") + + item.itemMeta = item.itemMeta.apply { + displayName = getString("name", "").c lore = getStringList("lore").map { it.c } } return item diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e7dd47a..5e65eae 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,7 +2,7 @@ shops: blocks: "blocks.yml" -startGUI: +shopGUI: size: 18 title: "&2Select a shop" blocks: