diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 190e67d19..57a7fc882 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -268,53 +268,27 @@ abstract class MatteryMenu @JvmOverloads protected constructor( // This method receive Player interactor and slot_index where Shift + Right click occurred // It shall return item stack that got moved override fun quickMoveStack(ply: Player, slotIndex: Int): ItemStack { - if (storageSlots.isEmpty()) { + if (storageSlots.isEmpty() || !slots[slotIndex].hasItem() || !slots[slotIndex].mayPickup(ply)) { return ItemStack.EMPTY } - var moveToPlayer: Boolean? = null - if (storageSlots.any { it.index == slotIndex }) { - moveToPlayer = true + val copy = slots[slotIndex].item.copy() + + if (moveItemStackTo(slots[slotIndex], _playerInventorySlots)) + return copy + else + return ItemStack.EMPTY + } else if (_playerInventorySlots.any { it.index == slotIndex }) { + val copy = slots[slotIndex].item.copy() + + if (moveItemStackTo(slots[slotIndex], storageSlots)) + return copy + else + return ItemStack.EMPTY } - if (moveToPlayer == null && _playerInventorySlots.any { it.index == slotIndex }) { - moveToPlayer = false - } - - if (moveToPlayer == null) { - return ItemStack.EMPTY - } - - var moved = ItemStack.EMPTY - val initialSlot = slots[slotIndex] - - if (initialSlot.hasItem()) { - if (!initialSlot.mayPickup(ply)) { - return moved - } - - val initialItem = initialSlot.item - moved = initialItem.copy() - - if (moveToPlayer) { - if (!moveItemStackTo(initialItem, _playerInventorySlots)) { - return ItemStack.EMPTY - } - } else { - if (!moveItemStackTo(initialItem, storageSlots)) { - return ItemStack.EMPTY - } - } - - if (initialItem.isEmpty) { - initialSlot.set(ItemStack.EMPTY) - } else { - initialSlot.setChanged() - } - } - - return moved + return ItemStack.EMPTY } fun quickMoveToInventory(stack: ItemStack, simulate: Boolean): ItemStack {