}
}
private void equipBook (Player player, ItemStack book) {
ItemStack currItem = player.getItemInHand();
Inventory inv = player.getInventory();
int emptySpot = inv.firstEmpty();
// if player isn't holding anything
if (currItem == null || currItem.getType() == Material.AIR) {
player.setItemInHand(book);
return;
}
// drop it if inventory has no empty slots
emptySpot = inv.firstEmpty();
dB.log("emptySpot: " + emptySpot);
if (emptySpot == -1) {
player.getWorld().dropItem(player.getLocation(), book);
dB.log("Player's inventory is full, dropped book.");
}
// move current held item to empty spot, set item in hand to the book
else {
inv.setItem(emptySpot, currItem);
player.setItemInHand(book);
dB.log("...added book to player hand, moved original item");
}
}