Add null-related annotations to the API

This commit is contained in:
filoghost 2021-05-01 18:41:01 +02:00
parent b2cd0abfe7
commit ee76d568dc
12 changed files with 52 additions and 21 deletions

View File

@ -11,6 +11,8 @@ import me.filoghost.holographicdisplays.api.line.TextLine;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
* An object made of various lines, that can be items or holograms. * An object made of various lines, that can be items or holograms.
@ -28,7 +30,8 @@ public interface Hologram {
* @return the new TextLine appended * @return the new TextLine appended
* @since 1 * @since 1
*/ */
TextLine appendTextLine(String text); @NotNull
TextLine appendTextLine(@Nullable String text);
/** /**
@ -38,7 +41,8 @@ public interface Hologram {
* @return the new ItemLine appended * @return the new ItemLine appended
* @since 1 * @since 1
*/ */
ItemLine appendItemLine(ItemStack itemStack); @NotNull
ItemLine appendItemLine(@NotNull ItemStack itemStack);
/** /**
@ -51,7 +55,8 @@ public interface Hologram {
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()) * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
* @since 1 * @since 1
*/ */
TextLine insertTextLine(int index, String text); @NotNull
TextLine insertTextLine(int index, @Nullable String text);
/** /**
@ -64,7 +69,8 @@ public interface Hologram {
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()) * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
* @since 1 * @since 1
*/ */
ItemLine insertItemLine(int index, ItemStack itemStack); @NotNull
ItemLine insertItemLine(int index, @NotNull ItemStack itemStack);
/** /**
@ -75,6 +81,7 @@ public interface Hologram {
* @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()) * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
* @since 1 * @since 1
*/ */
@NotNull
HologramLine getLine(int index); HologramLine getLine(int index);
/** /**
@ -119,7 +126,7 @@ public interface Hologram {
* @param location the new location * @param location the new location
* @since 1 * @since 1
*/ */
void teleport(Location location); void teleport(@NotNull Location location);
/** /**
@ -132,7 +139,7 @@ public interface Hologram {
* @param z the Z coordinate * @param z the Z coordinate
* @since 1 * @since 1
*/ */
void teleport(World world, double x, double y, double z); void teleport(@NotNull World world, double x, double y, double z);
/** /**
* Returns the position of the hologram. * Returns the position of the hologram.
@ -140,6 +147,7 @@ public interface Hologram {
* @return the Location of the hologram * @return the Location of the hologram
* @since 1 * @since 1
*/ */
@NotNull
Location getLocation(); Location getLocation();
/** /**
@ -175,6 +183,7 @@ public interface Hologram {
* @return the world of the hologram * @return the world of the hologram
* @since 1 * @since 1
*/ */
@NotNull
World getWorld(); World getWorld();
@ -186,6 +195,7 @@ public interface Hologram {
* @return the VisibilityManager of this hologram * @return the VisibilityManager of this hologram
* @since 1 * @since 1
*/ */
@NotNull
VisibilityManager getVisibilityManager(); VisibilityManager getVisibilityManager();

View File

@ -10,6 +10,7 @@ import me.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.Collection; import java.util.Collection;
@ -39,7 +40,8 @@ public interface HolographicDisplaysAPI {
return 1; return 1;
} }
static HolographicDisplaysAPI get(Plugin plugin) { @NotNull
static HolographicDisplaysAPI get(@NotNull Plugin plugin) {
return HolographicDisplaysAPIProvider.getImplementation().getHolographicDisplaysAPI(plugin); return HolographicDisplaysAPIProvider.getImplementation().getHolographicDisplaysAPI(plugin);
} }
@ -50,7 +52,8 @@ public interface HolographicDisplaysAPI {
* @return the created hologram * @return the created hologram
* @since 1 * @since 1
*/ */
Hologram createHologram(Location source); @NotNull
Hologram createHologram(@NotNull Location source);
/** /**
* Returns all the active holograms. A hologram is no longer active after {@link Hologram#delete()} is invoked. * Returns all the active holograms. A hologram is no longer active after {@link Hologram#delete()} is invoked.
@ -58,12 +61,13 @@ public interface HolographicDisplaysAPI {
* @return an immutable collection of active holograms * @return an immutable collection of active holograms
* @since 1 * @since 1
*/ */
@NotNull
Collection<Hologram> getHolograms(); Collection<Hologram> getHolograms();
/** /**
* @since 1 * @since 1
*/ */
void registerPlaceholder(String identifier, int refreshIntervalTicks, PlaceholderReplacer replacer); void registerPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull PlaceholderReplacer replacer);
/** /**
* Returns all the registered placeholder identifiers. * Returns all the registered placeholder identifiers.
@ -71,6 +75,7 @@ public interface HolographicDisplaysAPI {
* @return a collection of placeholder identifiers * @return a collection of placeholder identifiers
* @since 1 * @since 1
*/ */
@NotNull
Collection<String> getRegisteredPlaceholders(); Collection<String> getRegisteredPlaceholders();
/** /**
@ -79,7 +84,7 @@ public interface HolographicDisplaysAPI {
* @param identifier the identifier of the placeholder to remove * @param identifier the identifier of the placeholder to remove
* @since 1 * @since 1
*/ */
void unregisterPlaceholder(String identifier); void unregisterPlaceholder(@NotNull String identifier);
/** /**
* Resets and removes all the registered placeholders. * Resets and removes all the registered placeholders.
@ -97,7 +102,7 @@ public interface HolographicDisplaysAPI {
* @return if the entity is part of a hologram * @return if the entity is part of a hologram
* @since 1 * @since 1
*/ */
static boolean isHologramEntity(Entity entity) { static boolean isHologramEntity(@NotNull Entity entity) {
return HolographicDisplaysAPIProvider.getImplementation().isHologramEntity(entity); return HolographicDisplaysAPIProvider.getImplementation().isHologramEntity(entity);
} }

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.api; package me.filoghost.holographicdisplays.api;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/** /**
* This object is used to manage the visibility of a hologram. * This object is used to manage the visibility of a hologram.
@ -41,7 +42,7 @@ public interface VisibilityManager {
* @param player the involved player * @param player the involved player
* @since 1 * @since 1
*/ */
void showTo(Player player); void showTo(@NotNull Player player);
/** /**
* Hides the hologram to a player, overriding the value of {@link #isVisibleByDefault()}. * Hides the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
@ -50,7 +51,7 @@ public interface VisibilityManager {
* @param player the involved player * @param player the involved player
* @since 1 * @since 1
*/ */
void hideTo(Player player); void hideTo(@NotNull Player player);
/** /**
* Checks if a hologram is visible to a player. * Checks if a hologram is visible to a player.
@ -59,7 +60,7 @@ public interface VisibilityManager {
* @return if the player can see the hologram * @return if the player can see the hologram
* @since 1 * @since 1
*/ */
boolean isVisibleTo(Player player); boolean isVisibleTo(@NotNull Player player);
/** /**
* Resets the visibility to the default value. If you previously called {@link #showTo(Player)} * Resets the visibility to the default value. If you previously called {@link #showTo(Player)}
@ -69,7 +70,7 @@ public interface VisibilityManager {
* @param player the involved player * @param player the involved player
* @since 1 * @since 1
*/ */
void resetVisibility(Player player); void resetVisibility(@NotNull Player player);
/** /**
* Resets the visibility for all the players. See {@link #resetVisibility(Player)} for more details. * Resets the visibility for all the players. See {@link #resetVisibility(Player)} for more details.

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.api.handler; package me.filoghost.holographicdisplays.api.handler;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/** /**
* Interface to handle items being picked up by players. * Interface to handle items being picked up by players.
@ -19,6 +20,6 @@ public interface PickupHandler {
* @param player the player who picked up the item * @param player the player who picked up the item
* @since 1 * @since 1
*/ */
void onPickup(Player player); void onPickup(@NotNull Player player);
} }

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.api.handler; package me.filoghost.holographicdisplays.api.handler;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/** /**
* Interface to handle touch holograms. * Interface to handle touch holograms.
@ -19,6 +20,6 @@ public interface TouchHandler {
* @param player the player who interacts * @param player the player who interacts
* @since 1 * @since 1
*/ */
void onTouch(Player player); void onTouch(@NotNull Player player);
} }

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.api.line; package me.filoghost.holographicdisplays.api.line;
import me.filoghost.holographicdisplays.api.handler.PickupHandler; import me.filoghost.holographicdisplays.api.handler.PickupHandler;
import org.jetbrains.annotations.Nullable;
/** /**
* A line of a Hologram that can be picked up. * A line of a Hologram that can be picked up.
@ -20,7 +21,7 @@ public interface CollectableLine extends HologramLine {
* @param pickupHandler the new PickupHandler, can be null. * @param pickupHandler the new PickupHandler, can be null.
* @since 1 * @since 1
*/ */
void setPickupHandler(PickupHandler pickupHandler); void setPickupHandler(@Nullable PickupHandler pickupHandler);
/** /**
* Returns the current PickupHandler of this line. * Returns the current PickupHandler of this line.
@ -28,6 +29,7 @@ public interface CollectableLine extends HologramLine {
* @return the current PickupHandler, can be null. * @return the current PickupHandler, can be null.
* @since 1 * @since 1
*/ */
@Nullable
PickupHandler getPickupHandler(); PickupHandler getPickupHandler();
} }

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.api.line; package me.filoghost.holographicdisplays.api.line;
import me.filoghost.holographicdisplays.api.Hologram; import me.filoghost.holographicdisplays.api.Hologram;
import org.jetbrains.annotations.NotNull;
/** /**
* Interface to represent a line in a Hologram. * Interface to represent a line in a Hologram.
@ -20,6 +21,7 @@ public interface HologramLine {
* @return the parent Hologram. * @return the parent Hologram.
* @since 1 * @since 1
*/ */
@NotNull
Hologram getParent(); Hologram getParent();
/** /**

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.api.line; package me.filoghost.holographicdisplays.api.line;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/** /**
* @since 1 * @since 1
@ -18,6 +19,7 @@ public interface ItemLine extends CollectableLine, TouchableLine {
* @return the ItemStack if this ItemLine. * @return the ItemStack if this ItemLine.
* @since 1 * @since 1
*/ */
@NotNull
ItemStack getItemStack(); ItemStack getItemStack();
/** /**
@ -26,6 +28,6 @@ public interface ItemLine extends CollectableLine, TouchableLine {
* @param itemStack the new item, should not be null. * @param itemStack the new item, should not be null.
* @since 1 * @since 1
*/ */
void setItemStack(ItemStack itemStack); void setItemStack(@NotNull ItemStack itemStack);
} }

View File

@ -5,6 +5,8 @@
*/ */
package me.filoghost.holographicdisplays.api.line; package me.filoghost.holographicdisplays.api.line;
import org.jetbrains.annotations.Nullable;
/** /**
* @since 1 * @since 1
*/ */
@ -16,6 +18,7 @@ public interface TextLine extends TouchableLine {
* @return the current text of this line. * @return the current text of this line.
* @since 1 * @since 1
*/ */
@Nullable
String getText(); String getText();
/** /**
@ -24,6 +27,6 @@ public interface TextLine extends TouchableLine {
* @param text the new text of this line. * @param text the new text of this line.
* @since 1 * @since 1
*/ */
void setText(String text); void setText(@Nullable String text);
} }

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.api.line; package me.filoghost.holographicdisplays.api.line;
import me.filoghost.holographicdisplays.api.handler.TouchHandler; import me.filoghost.holographicdisplays.api.handler.TouchHandler;
import org.jetbrains.annotations.Nullable;
/** /**
* A line of a Hologram that can be touched (right click). * A line of a Hologram that can be touched (right click).
@ -20,7 +21,7 @@ public interface TouchableLine extends HologramLine {
* @param touchHandler the new TouchHandler, can be null. * @param touchHandler the new TouchHandler, can be null.
* @since 1 * @since 1
*/ */
void setTouchHandler(TouchHandler touchHandler); void setTouchHandler(@Nullable TouchHandler touchHandler);
/** /**
* Returns the current TouchHandler of this line. * Returns the current TouchHandler of this line.
@ -28,6 +29,7 @@ public interface TouchableLine extends HologramLine {
* @return the current TouchHandler, can be null. * @return the current TouchHandler, can be null.
* @since 1 * @since 1
*/ */
@Nullable
TouchHandler getTouchHandler(); TouchHandler getTouchHandler();
} }

View File

@ -15,6 +15,7 @@ public interface PlaceholderFactory {
/** /**
* @since 1 * @since 1
*/ */
@Nullable
Placeholder getPlaceholder(@Nullable String argument); Placeholder getPlaceholder(@Nullable String argument);
} }

View File

@ -25,6 +25,7 @@ public interface PlaceholderReplacer {
* @return the placeholder replacement * @return the placeholder replacement
* @since 1 * @since 1
*/ */
@Nullable
String getReplacement(@Nullable String argument); String getReplacement(@Nullable String argument);
} }