SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
package org.bukkit.map;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
@ -15,11 +18,12 @@ public final class MapPalette {
|
||||
// Internal mechanisms
|
||||
private MapPalette() {}
|
||||
|
||||
@NotNull
|
||||
private static Color c(int r, int g, int b) {
|
||||
return new Color(r, g, b);
|
||||
}
|
||||
|
||||
private static double getDistance(Color c1, Color c2) {
|
||||
private static double getDistance(@NotNull Color c1, @NotNull Color c2) {
|
||||
double rmean = (c1.getRed() + c2.getRed()) / 2.0;
|
||||
double r = c1.getRed() - c2.getRed();
|
||||
double g = c1.getGreen() - c2.getGreen();
|
||||
@ -30,6 +34,7 @@ public final class MapPalette {
|
||||
return weightR * r * r + weightG * g * g + weightB * b * b;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static final Color[] colors = {
|
||||
c(0, 0, 0), c(0, 0, 0), c(0, 0, 0), c(0, 0, 0),
|
||||
c(89, 125, 39), c(109, 153, 48), c(127, 178, 56), c(67, 94, 29),
|
||||
@ -163,7 +168,8 @@ public final class MapPalette {
|
||||
* @param image The image to resize.
|
||||
* @return The resized image.
|
||||
*/
|
||||
public static BufferedImage resizeImage(Image image) {
|
||||
@NotNull
|
||||
public static BufferedImage resizeImage(@Nullable Image image) {
|
||||
BufferedImage result = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D graphics = result.createGraphics();
|
||||
graphics.drawImage(image, 0, 0, 128, 128, null);
|
||||
@ -179,7 +185,8 @@ public final class MapPalette {
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public static byte[] imageToBytes(Image image) {
|
||||
@NotNull
|
||||
public static byte[] imageToBytes(@NotNull Image image) {
|
||||
BufferedImage temp = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D graphics = temp.createGraphics();
|
||||
graphics.drawImage(image, 0, 0, null);
|
||||
@ -219,7 +226,7 @@ public final class MapPalette {
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public static byte matchColor(Color color) {
|
||||
public static byte matchColor(@NotNull Color color) {
|
||||
if (color.getAlpha() < 128) return 0;
|
||||
|
||||
int index = 0;
|
||||
@ -245,6 +252,7 @@ public final class MapPalette {
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public static Color getColor(byte index) {
|
||||
if ((index > -49 && index < 0) || index > 127) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
|
||||
Reference in New Issue
Block a user