diff --git a/InventoryGUI-api/src/main/kotlin/net/projecttl/inventory/InventoryGUI.kt b/InventoryGUI-api/src/main/kotlin/net/projecttl/inventory/InventoryGUI.kt index 3cfb599..9d2eff3 100644 --- a/InventoryGUI-api/src/main/kotlin/net/projecttl/inventory/InventoryGUI.kt +++ b/InventoryGUI-api/src/main/kotlin/net/projecttl/inventory/InventoryGUI.kt @@ -51,12 +51,13 @@ object InventoryGUI { * * @param title The title of the inventory. This is the text shown at the top of the inventory. * @param slotType The Inventory's Size. Defaults to 27(3 * 9) if not set. + * @param access Allow click player's storage area. * @param init Initialize the inventory builder. Creates a default inventory if not set. * * @return The built inventory */ -fun Player.gui(title: Component, slotType: InventoryType = InventoryType.CHEST_27, init: SimpleInventoryBuilder.() -> Unit = {}): Inventory { - return SimpleInventoryBuilder(this, slotType, title).apply(init).build() +fun Player.gui(title: Component, slotType: InventoryType = InventoryType.CHEST_27, access: Boolean = true, init: SimpleInventoryBuilder.() -> Unit = {}): Inventory { + return SimpleInventoryBuilder(this, slotType, title, access).apply(init).build() } /** diff --git a/InventoryGUI-api/src/main/kotlin/net/projecttl/inventory/gui/SimpleInventoryBuilder.kt b/InventoryGUI-api/src/main/kotlin/net/projecttl/inventory/gui/SimpleInventoryBuilder.kt index a08037a..9f9e1ec 100644 --- a/InventoryGUI-api/src/main/kotlin/net/projecttl/inventory/gui/SimpleInventoryBuilder.kt +++ b/InventoryGUI-api/src/main/kotlin/net/projecttl/inventory/gui/SimpleInventoryBuilder.kt @@ -22,7 +22,8 @@ import kotlin.collections.HashMap class SimpleInventoryBuilder( override val player: Player, override val slotType: InventoryType, - override val title: Component + override val title: Component, + val access: Boolean ) : Listener, InventoryBuilder { override val slots = HashMap() val closeHandlers = ArrayList Unit>() @@ -68,6 +69,10 @@ class SimpleInventoryBuilder( if(event.view.title() == this.title) { if (inventoryIds.contains(id) && event.currentItem != null && event.view.player == player) { if (event.inventory == inventory) { + if (!access) { + event.isCancelled = true + } + for (slot in slots.entries) { if (slot.key == event.rawSlot){ event.isCancelled = true diff --git a/build.gradle.kts b/build.gradle.kts index fd7e966..a779d70 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "net.projecttl" -version = "4.5.0" +version = "4.5.1" allprojects { apply(plugin = "com.github.johnrengelman.shadow")