Removes some unused code
This commit is contained in:
parent
6c897b4ddf
commit
8520a4818b
@ -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
|
|
||||||
|
|
||||||
}
|
|
@ -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 <p>The player to validate</p>
|
* @param player <p>The player to validate</p>
|
||||||
* @param noBookMessage <p>The message to display if the player is not holding a book</p>
|
* @param noBookMessage <p>The message to display if the player is not holding a book</p>
|
||||||
* @param twoBooksMessage <p>The message to display if the player is holding one book in each hand</p>
|
* @param twoBooksMessage <p>The message to display if the player is holding one book in each hand</p>
|
||||||
* @return <p>False if the player is holding exactly one written book</p>
|
|
||||||
*/
|
|
||||||
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 player <p>The player to validate</p>
|
|
||||||
* @param noBookMessage <p>The message to display if the player is not holding a book</p>
|
|
||||||
* @param twoBooksMessage <p>The message to display if the player is holding one book in each hand</p>
|
|
||||||
* @param written <p>Whether to require a written/signed book as opposed to a writable/unsigned book</p>
|
|
||||||
* @return <p>False if the player is holding exactly one book</p>
|
* @return <p>False if the player is holding exactly one book</p>
|
||||||
*/
|
*/
|
||||||
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);
|
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);
|
BooksWithoutBorders.sendErrorMessage(player, noBookMessage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((written && holdingState == BookHoldingState.SIGNED_BOTH_HANDS) ||
|
if (holdingState == BookHoldingState.SIGNED_BOTH_HANDS) {
|
||||||
(!written && holdingState == BookHoldingState.UNSIGNED_BOTH_HANDS)) {
|
|
||||||
BooksWithoutBorders.sendErrorMessage(player, twoBooksMessage);
|
BooksWithoutBorders.sendErrorMessage(player, twoBooksMessage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -85,29 +72,6 @@ public class InventoryHelper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether the player is holding one book
|
|
||||||
*
|
|
||||||
* @param player <p>The player possibly holding a book</p>
|
|
||||||
* @param signedBook <p>Whether to look for signed or unsigned books</p>
|
|
||||||
* @return <p>True if the player is holding one book</p>
|
|
||||||
*/
|
|
||||||
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
|
* Gets the slot of the player's held book
|
||||||
* @param player <p>The player holding the book</p>
|
* @param player <p>The player holding the book</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user