SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -4,6 +4,8 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a {@link Command} belonging to a plugin
|
||||
@@ -13,7 +15,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
|
||||
private CommandExecutor executor;
|
||||
private TabCompleter completer;
|
||||
|
||||
protected PluginCommand(String name, Plugin owner) {
|
||||
protected PluginCommand(@NotNull String name, @NotNull Plugin owner) {
|
||||
super(name);
|
||||
this.executor = owner;
|
||||
this.owningPlugin = owner;
|
||||
@@ -29,7 +31,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
|
||||
* @return true if the command was successful, otherwise false
|
||||
*/
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
boolean success = false;
|
||||
|
||||
if (!owningPlugin.isEnabled()) {
|
||||
@@ -60,7 +62,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
|
||||
*
|
||||
* @param executor New executor to run
|
||||
*/
|
||||
public void setExecutor(CommandExecutor executor) {
|
||||
public void setExecutor(@Nullable CommandExecutor executor) {
|
||||
this.executor = executor == null ? owningPlugin : executor;
|
||||
}
|
||||
|
||||
@@ -69,6 +71,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
|
||||
*
|
||||
* @return CommandExecutor object linked to this command
|
||||
*/
|
||||
@NotNull
|
||||
public CommandExecutor getExecutor() {
|
||||
return executor;
|
||||
}
|
||||
@@ -81,7 +84,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
|
||||
*
|
||||
* @param completer New tab completer
|
||||
*/
|
||||
public void setTabCompleter(TabCompleter completer) {
|
||||
public void setTabCompleter(@Nullable TabCompleter completer) {
|
||||
this.completer = completer;
|
||||
}
|
||||
|
||||
@@ -90,6 +93,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
|
||||
*
|
||||
* @return TabCompleter object linked to this command
|
||||
*/
|
||||
@Nullable
|
||||
public TabCompleter getTabCompleter() {
|
||||
return completer;
|
||||
}
|
||||
@@ -99,6 +103,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
|
||||
*
|
||||
* @return Plugin that owns this command
|
||||
*/
|
||||
@NotNull
|
||||
public Plugin getPlugin() {
|
||||
return owningPlugin;
|
||||
}
|
||||
@@ -120,8 +125,9 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
|
||||
* exception during the process of tab-completing.
|
||||
* @throws IllegalArgumentException if sender, alias, or args is null
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public java.util.List<String> tabComplete(CommandSender sender, String alias, String[] args) throws CommandException, IllegalArgumentException {
|
||||
public java.util.List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws CommandException, IllegalArgumentException {
|
||||
Validate.notNull(sender, "Sender cannot be null");
|
||||
Validate.notNull(args, "Arguments cannot be null");
|
||||
Validate.notNull(alias, "Alias cannot be null");
|
||||
|
||||
Reference in New Issue
Block a user