From d5a5f549f7245fea816733fa2ab70e3afea7a42e Mon Sep 17 00:00:00 2001 From: xiaozhangup Date: Sun, 21 May 2023 19:53:56 +0800 Subject: [PATCH 1/2] Fix ArrayIndexOutOfBoundsException --- .../src/main/kotlin/taboolib/module/ui/type/Stored.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/module-ui/src/main/kotlin/taboolib/module/ui/type/Stored.kt b/module/module-ui/src/main/kotlin/taboolib/module/ui/type/Stored.kt index dd2972a06..e8abbae96 100644 --- a/module/module-ui/src/main/kotlin/taboolib/module/ui/type/Stored.kt +++ b/module/module-ui/src/main/kotlin/taboolib/module/ui/type/Stored.kt @@ -142,7 +142,10 @@ open class Stored(title: String) : Basic(title) { internal var writeItem: ((inventory: Inventory, itemStack: ItemStack, slot: Int) -> Unit) = { inventory, item, slot -> inventory.setItem(slot, item) } /** 读取物品回调 **/ - internal var readItem: ((inventory: Inventory, slot: Int) -> ItemStack?) = { inventory, slot -> inventory.getItem(slot) } + internal var readItem: ((inventory: Inventory, slot: Int) -> ItemStack?) = { inventory, slot -> + if (slot in 0 until inventory.size) inventory.getItem(slot) + null + } /** * 定义判定位置 From da4689f788f6946430efd580c5d23dbd1914b32e Mon Sep 17 00:00:00 2001 From: xiaozhangup Date: Sun, 21 May 2023 20:07:33 +0800 Subject: [PATCH 2/2] Fix a mistake --- .../module-ui/src/main/kotlin/taboolib/module/ui/type/Stored.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/module-ui/src/main/kotlin/taboolib/module/ui/type/Stored.kt b/module/module-ui/src/main/kotlin/taboolib/module/ui/type/Stored.kt index e8abbae96..f6d794306 100644 --- a/module/module-ui/src/main/kotlin/taboolib/module/ui/type/Stored.kt +++ b/module/module-ui/src/main/kotlin/taboolib/module/ui/type/Stored.kt @@ -144,7 +144,7 @@ open class Stored(title: String) : Basic(title) { /** 读取物品回调 **/ internal var readItem: ((inventory: Inventory, slot: Int) -> ItemStack?) = { inventory, slot -> if (slot in 0 until inventory.size) inventory.getItem(slot) - null + else null } /**