Fixes a bug caused by assuming a book is in the main hand

This commit is contained in:
Kristian Knarvik 2021-09-09 03:19:17 +02:00
parent c8ac3477bd
commit 240ff0c869

View File

@ -2,6 +2,7 @@ package net.knarcraft.bookswithoutborders.command;
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
import net.knarcraft.bookswithoutborders.state.EncryptionStyle;
import net.knarcraft.bookswithoutborders.state.ItemSlot;
import net.knarcraft.bookswithoutborders.utility.EncryptionHelper;
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
import org.bukkit.command.Command;
@ -83,7 +84,8 @@ public class CommandEncrypt implements TabExecutor {
* @return <p>True if the book was encrypted successfully</p>
*/
boolean encryptBook(EncryptionStyle encryptionStyle, Player player, String key, String group) {
ItemStack encryptedBook = EncryptionHelper.encryptBook(player, true, key, encryptionStyle, group);
ItemSlot heldSlot = InventoryHelper.getHeldSlotBook(player, false, false, true, true);
ItemStack encryptedBook = EncryptionHelper.encryptBook(player, heldSlot == ItemSlot.MAIN_HAND, key, encryptionStyle, group);
if (encryptedBook != null) {
InventoryHelper.setHeldWrittenBook(player, encryptedBook);