More SignSide APIs because damn is writing code annoying
Signed-off-by: Irmo van den Berge <irmo.vandenberge@ziggo.nl>
This commit is contained in:
1 parent
3e04ed35f2
commit
de8950595b
1 file changed
+41
@@ -25,10 +25,16 @@ public enum SignSide {
|
||||
*/
|
||||
BACK(SignHandle::getBackLines, SignHandle::getBackLine, SignHandle::setBackLine, CommonCapabilities.HAS_SIGN_BACK_TEXT);
|
||||
|
||||
static {
|
||||
FRONT.opposite = BACK;
|
||||
BACK.opposite = FRONT;
|
||||
}
|
||||
|
||||
private final Function<SignHandle, String[]> allLinesGetter;
|
||||
private final LineGetterFunc lineGetter;
|
||||
private final LineSetterFunc lineSetter;
|
||||
private final boolean supported;
|
||||
private SignSide opposite;
|
||||
|
||||
SignSide(Function<SignHandle, String[]> allLinesGetter,
|
||||
LineGetterFunc lineGetter,
|
||||
@@ -41,6 +47,15 @@ public enum SignSide {
|
||||
this.supported = supported;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the opposite side
|
||||
*
|
||||
* @return opposite side
|
||||
*/
|
||||
public SignSide opposite() {
|
||||
return opposite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether this side is supported on the current version of the server
|
||||
*
|
||||
@@ -90,6 +105,32 @@ public enum SignSide {
|
||||
return facing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the FRONT-assigned value out of two values which are this side,
|
||||
* or the opposite of this side.
|
||||
*
|
||||
* @param selfSideValue Value assigned to this side
|
||||
* @param oppositeSideValue Value assigned to the {@link #opposite()} side
|
||||
* @return Front value
|
||||
* @param <T> Value Type
|
||||
*/
|
||||
public <T> T selectFront(T selfSideValue, T oppositeSideValue) {
|
||||
return (this == FRONT) ? selfSideValue : oppositeSideValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the BACK-assigned value out of two values which are this side,
|
||||
* or the opposite of this side.
|
||||
*
|
||||
* @param selfSideValue Value assigned to this side
|
||||
* @param oppositeSideValue Value assigned to the {@link #opposite()} side
|
||||
* @return Back value
|
||||
* @param <T> Value Type
|
||||
*/
|
||||
public <T> T selectBack(T selfSideValue, T oppositeSideValue) {
|
||||
return (this == BACK) ? selfSideValue : oppositeSideValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the lines put on this side of the sign.
|
||||
* Returns an array of empty lines for the back side on Minecraft versions
|
||||
|
||||
Reference in new issue
Block a user