SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -8,6 +8,9 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Handles all plugin management from the Server
|
||||
@@ -21,7 +24,7 @@ public interface PluginManager {
|
||||
* @throws IllegalArgumentException Thrown when the given Class is not a
|
||||
* valid PluginLoader
|
||||
*/
|
||||
public void registerInterface(Class<? extends PluginLoader> loader) throws IllegalArgumentException;
|
||||
public void registerInterface(@NotNull Class<? extends PluginLoader> loader) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Checks if the given plugin is loaded and returns it when applicable
|
||||
@@ -31,13 +34,15 @@ public interface PluginManager {
|
||||
* @param name Name of the plugin to check
|
||||
* @return Plugin if it exists, otherwise null
|
||||
*/
|
||||
public Plugin getPlugin(String name);
|
||||
@Nullable
|
||||
public Plugin getPlugin(@NotNull String name);
|
||||
|
||||
/**
|
||||
* Gets a list of all currently loaded plugins
|
||||
*
|
||||
* @return Array of Plugins
|
||||
*/
|
||||
@NotNull
|
||||
public Plugin[] getPlugins();
|
||||
|
||||
/**
|
||||
@@ -48,7 +53,7 @@ public interface PluginManager {
|
||||
* @param name Name of the plugin to check
|
||||
* @return true if the plugin is enabled, otherwise false
|
||||
*/
|
||||
public boolean isPluginEnabled(String name);
|
||||
public boolean isPluginEnabled(@NotNull String name);
|
||||
|
||||
/**
|
||||
* Checks if the given plugin is enabled or not
|
||||
@@ -56,7 +61,8 @@ public interface PluginManager {
|
||||
* @param plugin Plugin to check
|
||||
* @return true if the plugin is enabled, otherwise false
|
||||
*/
|
||||
public boolean isPluginEnabled(Plugin plugin);
|
||||
@Contract("null -> false")
|
||||
public boolean isPluginEnabled(@Nullable Plugin plugin);
|
||||
|
||||
/**
|
||||
* Loads the plugin in the specified file
|
||||
@@ -72,7 +78,8 @@ public interface PluginManager {
|
||||
* @throws UnknownDependencyException If a required dependency could not
|
||||
* be resolved
|
||||
*/
|
||||
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException;
|
||||
@Nullable
|
||||
public Plugin loadPlugin(@NotNull File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException;
|
||||
|
||||
/**
|
||||
* Loads the plugins contained within the specified directory
|
||||
@@ -80,7 +87,8 @@ public interface PluginManager {
|
||||
* @param directory Directory to check for plugins
|
||||
* @return A list of all plugins loaded
|
||||
*/
|
||||
public Plugin[] loadPlugins(File directory);
|
||||
@NotNull
|
||||
public Plugin[] loadPlugins(@NotNull File directory);
|
||||
|
||||
/**
|
||||
* Disables all the loaded plugins
|
||||
@@ -102,7 +110,7 @@ public interface PluginManager {
|
||||
* <i>Note: This is best-effort basis, and should not be used to test
|
||||
* synchronized state. This is an indicator for flawed flow logic.</i>
|
||||
*/
|
||||
public void callEvent(Event event) throws IllegalStateException;
|
||||
public void callEvent(@NotNull Event event) throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Registers all the events in the given listener class
|
||||
@@ -110,7 +118,7 @@ public interface PluginManager {
|
||||
* @param listener Listener to register
|
||||
* @param plugin Plugin to register
|
||||
*/
|
||||
public void registerEvents(Listener listener, Plugin plugin);
|
||||
public void registerEvents(@NotNull Listener listener, @NotNull Plugin plugin);
|
||||
|
||||
/**
|
||||
* Registers the specified executor to the given event class
|
||||
@@ -121,7 +129,7 @@ public interface PluginManager {
|
||||
* @param executor EventExecutor to register
|
||||
* @param plugin Plugin to register
|
||||
*/
|
||||
public void registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin);
|
||||
public void registerEvent(@NotNull Class<? extends Event> event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin);
|
||||
|
||||
/**
|
||||
* Registers the specified executor to the given event class
|
||||
@@ -133,7 +141,7 @@ public interface PluginManager {
|
||||
* @param plugin Plugin to register
|
||||
* @param ignoreCancelled Whether to pass cancelled events or not
|
||||
*/
|
||||
public void registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin, boolean ignoreCancelled);
|
||||
public void registerEvent(@NotNull Class<? extends Event> event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin, boolean ignoreCancelled);
|
||||
|
||||
/**
|
||||
* Enables the specified plugin
|
||||
@@ -143,7 +151,7 @@ public interface PluginManager {
|
||||
*
|
||||
* @param plugin Plugin to enable
|
||||
*/
|
||||
public void enablePlugin(Plugin plugin);
|
||||
public void enablePlugin(@NotNull Plugin plugin);
|
||||
|
||||
/**
|
||||
* Disables the specified plugin
|
||||
@@ -152,7 +160,7 @@ public interface PluginManager {
|
||||
*
|
||||
* @param plugin Plugin to disable
|
||||
*/
|
||||
public void disablePlugin(Plugin plugin);
|
||||
public void disablePlugin(@NotNull Plugin plugin);
|
||||
|
||||
/**
|
||||
* Gets a {@link Permission} from its fully qualified name
|
||||
@@ -160,7 +168,8 @@ public interface PluginManager {
|
||||
* @param name Name of the permission
|
||||
* @return Permission, or null if none
|
||||
*/
|
||||
public Permission getPermission(String name);
|
||||
@Nullable
|
||||
public Permission getPermission(@NotNull String name);
|
||||
|
||||
/**
|
||||
* Adds a {@link Permission} to this plugin manager.
|
||||
@@ -172,7 +181,7 @@ public interface PluginManager {
|
||||
* @throws IllegalArgumentException Thrown when a permission with the same
|
||||
* name already exists
|
||||
*/
|
||||
public void addPermission(Permission perm);
|
||||
public void addPermission(@NotNull Permission perm);
|
||||
|
||||
/**
|
||||
* Removes a {@link Permission} registration from this plugin manager.
|
||||
@@ -185,7 +194,7 @@ public interface PluginManager {
|
||||
*
|
||||
* @param perm Permission to remove
|
||||
*/
|
||||
public void removePermission(Permission perm);
|
||||
public void removePermission(@NotNull Permission perm);
|
||||
|
||||
/**
|
||||
* Removes a {@link Permission} registration from this plugin manager.
|
||||
@@ -198,7 +207,7 @@ public interface PluginManager {
|
||||
*
|
||||
* @param name Permission to remove
|
||||
*/
|
||||
public void removePermission(String name);
|
||||
public void removePermission(@NotNull String name);
|
||||
|
||||
/**
|
||||
* Gets the default permissions for the given op status
|
||||
@@ -206,6 +215,7 @@ public interface PluginManager {
|
||||
* @param op Which set of default permissions to get
|
||||
* @return The default permissions
|
||||
*/
|
||||
@NotNull
|
||||
public Set<Permission> getDefaultPermissions(boolean op);
|
||||
|
||||
/**
|
||||
@@ -216,7 +226,7 @@ public interface PluginManager {
|
||||
*
|
||||
* @param perm Permission to recalculate
|
||||
*/
|
||||
public void recalculatePermissionDefaults(Permission perm);
|
||||
public void recalculatePermissionDefaults(@NotNull Permission perm);
|
||||
|
||||
/**
|
||||
* Subscribes the given Permissible for information about the requested
|
||||
@@ -228,7 +238,7 @@ public interface PluginManager {
|
||||
* @param permission Permission to subscribe to
|
||||
* @param permissible Permissible subscribing
|
||||
*/
|
||||
public void subscribeToPermission(String permission, Permissible permissible);
|
||||
public void subscribeToPermission(@NotNull String permission, @NotNull Permissible permissible);
|
||||
|
||||
/**
|
||||
* Unsubscribes the given Permissible for information about the requested
|
||||
@@ -237,7 +247,7 @@ public interface PluginManager {
|
||||
* @param permission Permission to unsubscribe from
|
||||
* @param permissible Permissible subscribing
|
||||
*/
|
||||
public void unsubscribeFromPermission(String permission, Permissible permissible);
|
||||
public void unsubscribeFromPermission(@NotNull String permission, @NotNull Permissible permissible);
|
||||
|
||||
/**
|
||||
* Gets a set containing all subscribed {@link Permissible}s to the given
|
||||
@@ -246,7 +256,8 @@ public interface PluginManager {
|
||||
* @param permission Permission to query for
|
||||
* @return Set containing all subscribed permissions
|
||||
*/
|
||||
public Set<Permissible> getPermissionSubscriptions(String permission);
|
||||
@NotNull
|
||||
public Set<Permissible> getPermissionSubscriptions(@NotNull String permission);
|
||||
|
||||
/**
|
||||
* Subscribes to the given Default permissions by operator status
|
||||
@@ -257,7 +268,7 @@ public interface PluginManager {
|
||||
* @param op Default list to subscribe to
|
||||
* @param permissible Permissible subscribing
|
||||
*/
|
||||
public void subscribeToDefaultPerms(boolean op, Permissible permissible);
|
||||
public void subscribeToDefaultPerms(boolean op, @NotNull Permissible permissible);
|
||||
|
||||
/**
|
||||
* Unsubscribes from the given Default permissions by operator status
|
||||
@@ -265,7 +276,7 @@ public interface PluginManager {
|
||||
* @param op Default list to unsubscribe from
|
||||
* @param permissible Permissible subscribing
|
||||
*/
|
||||
public void unsubscribeFromDefaultPerms(boolean op, Permissible permissible);
|
||||
public void unsubscribeFromDefaultPerms(boolean op, @NotNull Permissible permissible);
|
||||
|
||||
/**
|
||||
* Gets a set containing all subscribed {@link Permissible}s to the given
|
||||
@@ -274,6 +285,7 @@ public interface PluginManager {
|
||||
* @param op Default list to query for
|
||||
* @return Set containing all subscribed permissions
|
||||
*/
|
||||
@NotNull
|
||||
public Set<Permissible> getDefaultPermSubscriptions(boolean op);
|
||||
|
||||
/**
|
||||
@@ -283,6 +295,7 @@ public interface PluginManager {
|
||||
*
|
||||
* @return Set containing all current registered permissions
|
||||
*/
|
||||
@NotNull
|
||||
public Set<Permission> getPermissions();
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user