diff --git a/src/main/java/ch/njol/skript/aliases/ItemType.java b/src/main/java/ch/njol/skript/aliases/ItemType.java index c7c18fb42ff..39ce6d21962 100644 --- a/src/main/java/ch/njol/skript/aliases/ItemType.java +++ b/src/main/java/ch/njol/skript/aliases/ItemType.java @@ -1415,8 +1415,8 @@ public Material getMaterial() { } /** - * @return A random block material this ItemType represents. {@link Material#AIR} will be returned if no block - * material exists. + * @return A random block material this ItemType represents. + * @throws IllegalStateException If {@link #hasBlock()} is false. */ public Material getBlockMaterial() { List blockItemDatas = new ArrayList<>(); @@ -1426,7 +1426,7 @@ public Material getBlockMaterial() { } if (blockItemDatas.isEmpty()) throw new IllegalStateException("This ItemType does not represent a material. " + - "ItemData#hasBlock() should return true before invoking this method."); + "ItemType#hasBlock() should return true before invoking this method."); return blockItemDatas.get(random.nextInt(blockItemDatas.size())).getType(); } diff --git a/src/main/java/ch/njol/skript/util/ColorRGB.java b/src/main/java/ch/njol/skript/util/ColorRGB.java index 7b3c99f328c..141f753f701 100644 --- a/src/main/java/ch/njol/skript/util/ColorRGB.java +++ b/src/main/java/ch/njol/skript/util/ColorRGB.java @@ -8,6 +8,7 @@ import org.bukkit.DyeColor; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.NotSerializableException; @@ -17,12 +18,12 @@ public class ColorRGB implements Color { + private static final boolean HAS_ARGB = Skript.methodExists(org.bukkit.Color.class, "getAlpha"); private static final Pattern RGB_PATTERN = Pattern.compile("(?>rgb|RGB) (\\d+), (\\d+), (\\d+)"); private org.bukkit.Color bukkit; - @Nullable - private DyeColor dye; + private @Nullable DyeColor dye; /** * Subject to being private in the future. Use {@link #fromRGB(int, int, int)} @@ -48,7 +49,6 @@ public ColorRGB(org.bukkit.Color bukkit) { this.bukkit = bukkit; } - private static final boolean HAS_ARGB = Skript.methodExists(org.bukkit.Color.class, "getAlpha"); /** * Returns a ColorRGB object from the provided arguments. Versions lower than 1.19 will not support alpha values. * @@ -59,7 +59,7 @@ public ColorRGB(org.bukkit.Color bukkit) { * @return ColorRGB */ @Contract("_,_,_,_ -> new") - public static ColorRGB fromRGBA(int red, int green, int blue, int alpha) { + public static @NotNull ColorRGB fromRGBA(int red, int green, int blue, int alpha) { org.bukkit.Color bukkit; if (HAS_ARGB) { bukkit = org.bukkit.Color.fromARGB(alpha, red, green, blue); @@ -78,7 +78,7 @@ public static ColorRGB fromRGBA(int red, int green, int blue, int alpha) { * @return ColorRGB */ @Contract("_,_,_ -> new") - public static ColorRGB fromRGB(int red, int green, int blue) { + public static @NotNull ColorRGB fromRGB(int red, int green, int blue) { return new ColorRGB(red, green, blue); } @@ -89,7 +89,7 @@ public static ColorRGB fromRGB(int red, int green, int blue) { * @return ColorRGB */ @Contract("_ -> new") - public static ColorRGB fromBukkitColor(org.bukkit.Color bukkit) { + public static @NotNull ColorRGB fromBukkitColor(org.bukkit.Color bukkit) { return new ColorRGB(bukkit); } @@ -99,8 +99,7 @@ public org.bukkit.Color asBukkitColor() { } @Override - @Nullable - public DyeColor asDyeColor() { + public @Nullable DyeColor asDyeColor() { return dye; } @@ -112,8 +111,7 @@ public String getName() { return "rgb " + rgb; } - @Nullable - public static ColorRGB fromString(String string) { + public static @Nullable ColorRGB fromString(String string) { Matcher matcher = RGB_PATTERN.matcher(string); if (!matcher.matches()) return null; diff --git a/src/main/java/org/skriptlang/skript/bukkit/displays/generic/ExprDisplayViewRange.java b/src/main/java/org/skriptlang/skript/bukkit/displays/generic/ExprDisplayViewRange.java index f6216ff9283..0775fb4f1fd 100644 --- a/src/main/java/org/skriptlang/skript/bukkit/displays/generic/ExprDisplayViewRange.java +++ b/src/main/java/org/skriptlang/skript/bukkit/displays/generic/ExprDisplayViewRange.java @@ -51,6 +51,8 @@ public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { case ADD: for (Display display : displays) { float value = Math.max(0F, display.getViewRange() + change); + if (Float.isInfinite(value)) + continue; display.setViewRange(value); } break;