SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.Set;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Event triggered for server broadcast messages such as from
|
||||
@@ -16,7 +17,7 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
|
||||
private final Set<CommandSender> recipients;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public BroadcastMessageEvent(String message, Set<CommandSender> recipients) {
|
||||
public BroadcastMessageEvent(@NotNull String message, @NotNull Set<CommandSender> recipients) {
|
||||
this.message = message;
|
||||
this.recipients = recipients;
|
||||
}
|
||||
@@ -26,6 +27,7 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
|
||||
*
|
||||
* @return Message to broadcast
|
||||
*/
|
||||
@NotNull
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
@@ -35,7 +37,7 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
|
||||
*
|
||||
* @param message New message to broadcast
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
public void setMessage(@NotNull String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@@ -52,6 +54,7 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
|
||||
*
|
||||
* @return All CommandSenders who will see this chat message
|
||||
*/
|
||||
@NotNull
|
||||
public Set<CommandSender> getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
@@ -66,11 +69,13 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.event.server;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a map is initialized.
|
||||
@@ -10,7 +11,7 @@ public class MapInitializeEvent extends ServerEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final MapView mapView;
|
||||
|
||||
public MapInitializeEvent(final MapView mapView) {
|
||||
public MapInitializeEvent(@NotNull final MapView mapView) {
|
||||
this.mapView = mapView;
|
||||
}
|
||||
|
||||
@@ -19,15 +20,18 @@ public class MapInitializeEvent extends ServerEvent {
|
||||
*
|
||||
* @return Map for this event
|
||||
*/
|
||||
@NotNull
|
||||
public MapView getMap() {
|
||||
return mapView;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.event.server;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a plugin is disabled.
|
||||
@@ -9,15 +10,17 @@ import org.bukkit.plugin.Plugin;
|
||||
public class PluginDisableEvent extends PluginEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public PluginDisableEvent(final Plugin plugin) {
|
||||
public PluginDisableEvent(@NotNull final Plugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.event.server;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a plugin is enabled.
|
||||
@@ -9,15 +10,17 @@ import org.bukkit.plugin.Plugin;
|
||||
public class PluginEnableEvent extends PluginEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public PluginEnableEvent(final Plugin plugin) {
|
||||
public PluginEnableEvent(@NotNull final Plugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.event.server;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Used for plugin enable and disable events
|
||||
@@ -8,7 +9,7 @@ import org.bukkit.plugin.Plugin;
|
||||
public abstract class PluginEvent extends ServerEvent {
|
||||
private final Plugin plugin;
|
||||
|
||||
public PluginEvent(final Plugin plugin) {
|
||||
public PluginEvent(@NotNull final Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -17,6 +18,7 @@ public abstract class PluginEvent extends ServerEvent {
|
||||
*
|
||||
* @return Plugin for this event
|
||||
*/
|
||||
@NotNull
|
||||
public Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.event.server;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event is called when a command is received over RCON. See the javadocs
|
||||
@@ -10,15 +11,17 @@ import org.bukkit.event.HandlerList;
|
||||
public class RemoteServerCommandEvent extends ServerCommandEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public RemoteServerCommandEvent(final CommandSender sender, final String command) {
|
||||
public RemoteServerCommandEvent(@NotNull final CommandSender sender, @NotNull final String command) {
|
||||
super(sender, command);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.bukkit.event.server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event is called when a command is run by a non-player. It is
|
||||
@@ -44,7 +45,7 @@ public class ServerCommandEvent extends ServerEvent implements Cancellable {
|
||||
private final CommandSender sender;
|
||||
private boolean cancel = false;
|
||||
|
||||
public ServerCommandEvent(final CommandSender sender, final String command) {
|
||||
public ServerCommandEvent(@NotNull final CommandSender sender, @NotNull final String command) {
|
||||
this.command = command;
|
||||
this.sender = sender;
|
||||
}
|
||||
@@ -55,6 +56,7 @@ public class ServerCommandEvent extends ServerEvent implements Cancellable {
|
||||
*
|
||||
* @return Command the user is attempting to execute
|
||||
*/
|
||||
@NotNull
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
@@ -64,7 +66,7 @@ public class ServerCommandEvent extends ServerEvent implements Cancellable {
|
||||
*
|
||||
* @param message New message that the server will execute
|
||||
*/
|
||||
public void setCommand(String message) {
|
||||
public void setCommand(@NotNull String message) {
|
||||
this.command = message;
|
||||
}
|
||||
|
||||
@@ -73,15 +75,18 @@ public class ServerCommandEvent extends ServerEvent implements Cancellable {
|
||||
*
|
||||
* @return The sender
|
||||
*/
|
||||
@NotNull
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@ import java.net.InetAddress;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.UndefinedNullability;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a server list ping is coming in. Displayed players can be
|
||||
@@ -20,7 +22,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
||||
private final int numPlayers;
|
||||
private int maxPlayers;
|
||||
|
||||
public ServerListPingEvent(final InetAddress address, final String motd, final int numPlayers, final int maxPlayers) {
|
||||
public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int numPlayers, final int maxPlayers) {
|
||||
Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
|
||||
this.address = address;
|
||||
this.motd = motd;
|
||||
@@ -37,7 +39,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
||||
* @param motd the message of the day
|
||||
* @param maxPlayers the max number of players
|
||||
*/
|
||||
protected ServerListPingEvent(final InetAddress address, final String motd, final int maxPlayers) {
|
||||
protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int maxPlayers) {
|
||||
this.numPlayers = MAGIC_PLAYER_COUNT;
|
||||
this.address = address;
|
||||
this.motd = motd;
|
||||
@@ -49,6 +51,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
||||
*
|
||||
* @return the address
|
||||
*/
|
||||
@NotNull
|
||||
public InetAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
@@ -58,6 +61,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
||||
*
|
||||
* @return the message of the day
|
||||
*/
|
||||
@NotNull
|
||||
public String getMotd() {
|
||||
return motd;
|
||||
}
|
||||
@@ -67,7 +71,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
||||
*
|
||||
* @param motd the message of the day
|
||||
*/
|
||||
public void setMotd(String motd) {
|
||||
public void setMotd(@NotNull String motd) {
|
||||
this.motd = motd;
|
||||
}
|
||||
|
||||
@@ -115,15 +119,17 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
||||
* @throws UnsupportedOperationException if the caller of this event does
|
||||
* not support setting the server icon
|
||||
*/
|
||||
public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException {
|
||||
public void setServerIcon(@UndefinedNullability("implementation dependent") CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
@@ -139,6 +145,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
||||
* @throws UnsupportedOperationException if the caller of this event does
|
||||
* not support removing players
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<Player> iterator() throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.event.server;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event is called when either the server startup or reload has completed.
|
||||
@@ -22,7 +23,7 @@ public class ServerLoadEvent extends ServerEvent {
|
||||
*
|
||||
* @param type the context in which the server was loaded
|
||||
*/
|
||||
public ServerLoadEvent(LoadType type) {
|
||||
public ServerLoadEvent(@NotNull LoadType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -31,15 +32,18 @@ public class ServerLoadEvent extends ServerEvent {
|
||||
*
|
||||
* @return the context in which the server was loaded
|
||||
*/
|
||||
@NotNull
|
||||
public LoadType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.event.server;
|
||||
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event relating to a registered service. This is called in a {@link
|
||||
@@ -9,10 +10,11 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
public abstract class ServiceEvent extends ServerEvent {
|
||||
private final RegisteredServiceProvider<?> provider;
|
||||
|
||||
public ServiceEvent(final RegisteredServiceProvider<?> provider) {
|
||||
public ServiceEvent(@NotNull final RegisteredServiceProvider<?> provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RegisteredServiceProvider<?> getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.event.server;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event is called when a service is registered.
|
||||
@@ -12,15 +13,17 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
public class ServiceRegisterEvent extends ServiceEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public ServiceRegisterEvent(RegisteredServiceProvider<?> registeredProvider) {
|
||||
public ServiceRegisterEvent(@NotNull RegisteredServiceProvider<?> registeredProvider) {
|
||||
super(registeredProvider);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.event.server;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event is called when a service is unregistered.
|
||||
@@ -12,15 +13,17 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
public class ServiceUnregisterEvent extends ServiceEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public ServiceUnregisterEvent(RegisteredServiceProvider<?> serviceProvider) {
|
||||
public ServiceUnregisterEvent(@NotNull RegisteredServiceProvider<?> serviceProvider) {
|
||||
super(serviceProvider);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a {@link CommandSender} of any description (ie: player or
|
||||
@@ -27,7 +28,7 @@ public class TabCompleteEvent extends Event implements Cancellable {
|
||||
private List<String> completions;
|
||||
private boolean cancelled;
|
||||
|
||||
public TabCompleteEvent(CommandSender sender, String buffer, List<String> completions) {
|
||||
public TabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, @NotNull List<String> completions) {
|
||||
Validate.notNull(sender, "sender");
|
||||
Validate.notNull(buffer, "buffer");
|
||||
Validate.notNull(completions, "completions");
|
||||
@@ -42,6 +43,7 @@ public class TabCompleteEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return the {@link CommandSender} instance
|
||||
*/
|
||||
@NotNull
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
@@ -51,6 +53,7 @@ public class TabCompleteEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return command buffer, as entered
|
||||
*/
|
||||
@NotNull
|
||||
public String getBuffer() {
|
||||
return buffer;
|
||||
}
|
||||
@@ -61,6 +64,7 @@ public class TabCompleteEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return a list of offered completions
|
||||
*/
|
||||
@NotNull
|
||||
public List<String> getCompletions() {
|
||||
return completions;
|
||||
}
|
||||
@@ -70,7 +74,7 @@ public class TabCompleteEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @param completions the new completions
|
||||
*/
|
||||
public void setCompletions(List<String> completions) {
|
||||
public void setCompletions(@NotNull List<String> completions) {
|
||||
Validate.notNull(completions);
|
||||
this.completions = completions;
|
||||
}
|
||||
@@ -85,11 +89,13 @@ public class TabCompleteEvent extends Event implements Cancellable {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user