Cleanup and maintenance

Updates Spigot version
Removes MockBukkit and related tests, as it makes updating a hassle
Bumps API version to 1.20
Removes legacy sign updating
This commit is contained in:
2025-07-26 20:21:35 +02:00
parent 932dae0182
commit a861591fec
8 changed files with 6 additions and 420 deletions

View File

@@ -1,6 +1,5 @@
package net.knarcraft.stargate.utility;
import net.knarcraft.stargate.Stargate;
import org.bukkit.DyeColor;
import org.bukkit.block.Sign;
import org.bukkit.block.sign.Side;
@@ -12,8 +11,6 @@ import org.jetbrains.annotations.Nullable;
*/
public final class SignHelper {
private static final boolean HAS_SIGN_SIDES = hasSignSides();
private SignHelper() {
}
@@ -26,13 +23,7 @@ public final class SignHelper {
*/
@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();
}
return sign.getSide(Side.FRONT).getLines();
}
/**
@@ -43,13 +34,7 @@ public final class SignHelper {
*/
@Nullable
public static DyeColor getDye(@NotNull Sign sign) {
if (HAS_SIGN_SIDES) {
return sign.getSide(Side.FRONT).getColor();
} else {
// Note: This is depreciated, but is currently necessary for pre-1.19.4 support
//noinspection deprecation
return sign.getColor();
}
return sign.getSide(Side.FRONT).getColor();
}
/**
@@ -60,29 +45,7 @@ public final class SignHelper {
* @param text <p>The text to set</p>
*/
public static void setSignLine(@NotNull Sign sign, int line, @NotNull String text) {
if (HAS_SIGN_SIDES) {
sign.getSide(Side.FRONT).setLine(line, text);
} else {
// Note: This is depreciated, but is currently necessary for pre-1.19.4 support
//noinspection deprecation
sign.setLine(line, text);
}
}
/**
* Checks whether the running version differentiates between the front or back of a sign
*
* @return <p>True if the server supports sign side differentiation</p>
*/
private static boolean hasSignSides() {
try {
Class<?> aClass = Class.forName("org.bukkit.block.Sign");
aClass.getMethod("getSide", Side.class);
return true;
} catch (ClassNotFoundException | NoSuchMethodException ignored) {
Stargate.debug("SignHelper::hasSignSides", "Detected legacy Spigot");
return false;
}
sign.getSide(Side.FRONT).setLine(line, text);
}
}