diff --git a/src/main/java/net/knarcraft/bookswithoutborders/state/HoldingItemState.java b/src/main/java/net/knarcraft/bookswithoutborders/state/HoldingItemState.java deleted file mode 100644 index d645fe2..0000000 --- a/src/main/java/net/knarcraft/bookswithoutborders/state/HoldingItemState.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.knarcraft.bookswithoutborders.state; - -/** - * This enum represents the different states of a player holding a given item - */ -public enum HoldingItemState { - - /** - * The player is holding one item in each hand - */ - BOTH_HANDS, - - /** - * The player is holding one item in their main hand - */ - MAIN_HAND, - - /** - * The player is holding one item in their off hand - */ - OFF_HAND, - - /** - * The player is not holding any items - */ - NONE - -} diff --git a/src/main/java/net/knarcraft/bookswithoutborders/utility/InventoryHelper.java b/src/main/java/net/knarcraft/bookswithoutborders/utility/InventoryHelper.java index 8795246..8338a0a 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/utility/InventoryHelper.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/utility/InventoryHelper.java @@ -49,35 +49,22 @@ public class InventoryHelper { } /** - * Performs checks to validate that a player contains exactly one written - * + * Performs checks to validate that a player contains exactly one written book * @param player
The player to validate
* @param noBookMessageThe message to display if the player is not holding a book
* @param twoBooksMessageThe message to display if the player is holding one book in each hand
- * @returnFalse if the player is holding exactly one written book
- */ - public static boolean notHoldingOneWrittenBookCheck(Player player, String noBookMessage, String twoBooksMessage) { - return notHoldingOneBookCheck(player, noBookMessage, twoBooksMessage, true); - } - - /** - * Performs checks to validate that a player contains exactly one book - * @param playerThe player to validate
- * @param noBookMessageThe message to display if the player is not holding a book
- * @param twoBooksMessageThe message to display if the player is holding one book in each hand
- * @param writtenWhether to require a written/signed book as opposed to a writable/unsigned book
* @returnFalse if the player is holding exactly one book
*/ - private static boolean notHoldingOneBookCheck(Player player, String noBookMessage, String twoBooksMessage, boolean written) { + public static boolean notHoldingOneWrittenBookCheck(Player player, String noBookMessage, String twoBooksMessage) { BookHoldingState holdingState = getBookHoldingState(player); - if (holdingState == BookHoldingState.NONE) { + if (holdingState == BookHoldingState.NONE || holdingState == BookHoldingState.UNSIGNED_BOTH_HANDS || + holdingState == BookHoldingState.UNSIGNED_MAIN_HAND || holdingState == BookHoldingState.UNSIGNED_OFF_HAND) { BooksWithoutBorders.sendErrorMessage(player, noBookMessage); return true; } - if ((written && holdingState == BookHoldingState.SIGNED_BOTH_HANDS) || - (!written && holdingState == BookHoldingState.UNSIGNED_BOTH_HANDS)) { + if (holdingState == BookHoldingState.SIGNED_BOTH_HANDS) { BooksWithoutBorders.sendErrorMessage(player, twoBooksMessage); return true; } @@ -85,29 +72,6 @@ public class InventoryHelper { return false; } - /** - * Check whether the player is holding one book - * - * @param playerThe player possibly holding a book
- * @param signedBookWhether to look for signed or unsigned books
- * @returnTrue if the player is holding one book
- */ - public static boolean isHoldingBook(Player player, boolean signedBook) { - BookHoldingState holdingState = getBookHoldingState(player); - - if (holdingState == BookHoldingState.SIGNED_MAIN_HAND_UNSIGNED_OFF_HAND || - holdingState == BookHoldingState.UNSIGNED_MAIN_HAND_SIGNED_OFF_HAND) { - return true; - } - if (signedBook) { - return holdingState == BookHoldingState.SIGNED_MAIN_HAND || - holdingState == BookHoldingState.SIGNED_OFF_HAND; - } else { - return holdingState == BookHoldingState.UNSIGNED_MAIN_HAND || - holdingState == BookHoldingState.UNSIGNED_OFF_HAND; - } - } - /** * Gets the slot of the player's held book * @param playerThe player holding the book