SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -2,6 +2,8 @@ package org.bukkit.map;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a bitmap font drawable to a map.
|
||||
@@ -19,7 +21,7 @@ public class MapFont {
|
||||
* @param sprite The CharacterSprite to set.
|
||||
* @throws IllegalStateException if this font is static.
|
||||
*/
|
||||
public void setChar(char ch, CharacterSprite sprite) {
|
||||
public void setChar(char ch, @NotNull CharacterSprite sprite) {
|
||||
if (!malleable) {
|
||||
throw new IllegalStateException("this font is not malleable");
|
||||
}
|
||||
@@ -37,6 +39,7 @@ public class MapFont {
|
||||
* @return The CharacterSprite associated with the character, or null if
|
||||
* there is none.
|
||||
*/
|
||||
@Nullable
|
||||
public CharacterSprite getChar(char ch) {
|
||||
return chars.get(ch);
|
||||
}
|
||||
@@ -48,7 +51,7 @@ public class MapFont {
|
||||
* @param text The text.
|
||||
* @return The width in pixels.
|
||||
*/
|
||||
public int getWidth(String text) {
|
||||
public int getWidth(@NotNull String text) {
|
||||
if (!isValid(text)) {
|
||||
throw new IllegalArgumentException("text contains invalid characters");
|
||||
}
|
||||
@@ -84,7 +87,7 @@ public class MapFont {
|
||||
* @return True if the string contains only defined characters, false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isValid(String text) {
|
||||
public boolean isValid(@NotNull String text) {
|
||||
for (int i = 0; i < text.length(); ++i) {
|
||||
char ch = text.charAt(i);
|
||||
if (ch == ChatColor.COLOR_CHAR || ch == '\n') continue;
|
||||
@@ -102,7 +105,7 @@ public class MapFont {
|
||||
private final int height;
|
||||
private final boolean[] data;
|
||||
|
||||
public CharacterSprite(int width, int height, boolean[] data) {
|
||||
public CharacterSprite(int width, int height, @NotNull boolean[] data) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.data = data;
|
||||
|
||||
Reference in New Issue
Block a user