Uses optional legacy method when getting sign lines

This commit is contained in:
2024-06-01 20:13:20 +02:00
parent 2c98103db0
commit f77ead15c4
3 changed files with 20 additions and 3 deletions

View File

@@ -13,7 +13,6 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.block.sign.Side;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -184,7 +183,8 @@ public class PortalSignDrawer {
*/
private void updateSign(@NotNull Sign sign, @NotNull String[] lines) {
boolean updateNecessary = false;
String[] oldLines = sign.getSide(Side.FRONT).getLines();
String[] oldLines = SignHelper.getLines(sign);
for (int i = 0; i < 4; i++) {
if (!oldLines[i].equals(lines[i])) {
updateNecessary = true;

View File

@@ -17,6 +17,23 @@ public final class SignHelper {
}
/**
* Gets the lines of the given sign
*
* @param sign <p>The sign to get lines from</p>
* @return <p>The lines of the sign</p>
*/
@NotNull
public static String[] getLines(@NotNull Sign sign) {
if (HAS_SIGN_SIDES) {
return sign.getSide(Side.FRONT).getLines();
} else {
// Note: This is depreciated, but is currently necessary for pre-1.19.4 support
//noinspection deprecation
return sign.getLines();
}
}
/**
* Gets the dye color of the given sign
*