SPIGOT-2540: Add nullability annotations to entire Bukkit API

By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
Bukkit/Spigot
2019-03-13 17:42:57 +11:00
parent e069a80fd8
commit 416c865476
565 changed files with 5372 additions and 2008 deletions

View File

@@ -6,6 +6,7 @@ import java.util.Set;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* This event will sometimes fire synchronously, depending on how it was
@@ -38,7 +39,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable {
* @param players the players to receive the message. This may be a lazy
* or unmodifiable collection.
*/
public AsyncPlayerChatEvent(final boolean async, final Player who, final String message, final Set<Player> players) {
public AsyncPlayerChatEvent(final boolean async, @NotNull final Player who, @NotNull final String message, @NotNull final Set<Player> players) {
super(who, async);
this.message = message;
recipients = players;
@@ -50,6 +51,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable {
*
* @return Message the player is attempting to send
*/
@NotNull
public String getMessage() {
return message;
}
@@ -60,7 +62,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable {
*
* @param message New message that the player will send
*/
public void setMessage(String message) {
public void setMessage(@NotNull String message) {
this.message = message;
}
@@ -74,6 +76,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable {
* @return {@link String#format(String, Object...)} compatible format
* string
*/
@NotNull
public String getFormat() {
return format;
}
@@ -92,7 +95,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable {
* @throws NullPointerException if format is null
* @see String#format(String, Object...)
*/
public void setFormat(final String format) throws IllegalFormatException, NullPointerException {
public void setFormat(@NotNull final String format) throws IllegalFormatException, NullPointerException {
// Oh for a better way to do this!
try {
String.format(format, player, message);
@@ -117,6 +120,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable {
*
* @return All Players who will see this chat message
*/
@NotNull
public Set<Player> getRecipients() {
return recipients;
}
@@ -129,11 +133,13 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Stores details for players attempting to log in.
@@ -20,11 +21,11 @@ public class AsyncPlayerPreLoginEvent extends Event {
private final UUID uniqueId;
@Deprecated
public AsyncPlayerPreLoginEvent(final String name, final InetAddress ipAddress) {
public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress) {
this(name, ipAddress, null);
}
public AsyncPlayerPreLoginEvent(final String name, final InetAddress ipAddress, final UUID uniqueId) {
public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId) {
super(true);
this.result = Result.ALLOWED;
this.message = "";
@@ -38,6 +39,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
*
* @return Current Result of the login
*/
@NotNull
public Result getLoginResult() {
return result;
}
@@ -51,6 +53,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
* @see #getLoginResult()
*/
@Deprecated
@NotNull
public PlayerPreLoginEvent.Result getResult() {
return result == null ? null : result.old();
}
@@ -60,7 +63,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
*
* @param result New result to set
*/
public void setLoginResult(final Result result) {
public void setLoginResult(@NotNull final Result result) {
this.result = result;
}
@@ -73,7 +76,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
* @see #setLoginResult(Result)
*/
@Deprecated
public void setResult(final PlayerPreLoginEvent.Result result) {
public void setResult(@NotNull final PlayerPreLoginEvent.Result result) {
this.result = result == null ? null : Result.valueOf(result.name());
}
@@ -83,6 +86,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
*
* @return Current kick message
*/
@NotNull
public String getKickMessage() {
return message;
}
@@ -92,7 +96,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
*
* @param message New kick message
*/
public void setKickMessage(final String message) {
public void setKickMessage(@NotNull final String message) {
this.message = message;
}
@@ -110,7 +114,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
* @param result New result for disallowing the player
* @param message Kick message to display to the user
*/
public void disallow(final Result result, final String message) {
public void disallow(@NotNull final Result result, @NotNull final String message) {
this.result = result;
this.message = message;
}
@@ -125,7 +129,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
* @see #disallow(Result, String)
*/
@Deprecated
public void disallow(final PlayerPreLoginEvent.Result result, final String message) {
public void disallow(@NotNull final PlayerPreLoginEvent.Result result, @NotNull final String message) {
this.result = result == null ? null : Result.valueOf(result.name());
this.message = message;
}
@@ -135,6 +139,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
*
* @return the player's name
*/
@NotNull
public String getName() {
return name;
}
@@ -144,6 +149,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
*
* @return The IP address
*/
@NotNull
public InetAddress getAddress() {
return ipAddress;
}
@@ -153,15 +159,18 @@ public class AsyncPlayerPreLoginEvent extends Event {
*
* @return The unique ID
*/
@NotNull
public UUID getUniqueId() {
return uniqueId;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
@@ -194,6 +203,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
KICK_OTHER;
@Deprecated
@NotNull
private PlayerPreLoginEvent.Result old() {
return PlayerPreLoginEvent.Result.valueOf(name());
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.Achievement;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player earns an achievement.
@@ -37,6 +38,7 @@ public class PlayerAchievementAwardedEvent extends PlayerEvent implements Cancel
this.isCancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.advancement.Advancement;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player has completed all criteria in an advancement.
@@ -13,7 +14,7 @@ public class PlayerAdvancementDoneEvent extends PlayerEvent {
//
private final Advancement advancement;
public PlayerAdvancementDoneEvent(Player who, Advancement advancement) {
public PlayerAdvancementDoneEvent(@NotNull Player who, @NotNull Advancement advancement) {
super(who);
this.advancement = advancement;
}
@@ -23,15 +24,18 @@ public class PlayerAdvancementDoneEvent extends PlayerEvent {
*
* @return completed advancement
*/
@NotNull
public Advancement getAdvancement() {
return advancement;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Represents a player animation event
@@ -17,7 +18,7 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable {
*
* @param player The player instance
*/
public PlayerAnimationEvent(final Player player) {
public PlayerAnimationEvent(@NotNull final Player player) {
super(player);
// Only supported animation type for now:
@@ -29,6 +30,7 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable {
*
* @return the animation type
*/
@NotNull
public PlayerAnimationType getAnimationType() {
return animationType;
}
@@ -41,11 +43,13 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable {
this.isCancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.ArmorStand;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player interacts with an armor stand and will either swap, retrieve or place an item.
@@ -17,7 +18,7 @@ public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent {
private final ItemStack armorStandItem;
private final EquipmentSlot slot;
public PlayerArmorStandManipulateEvent(final Player who, final ArmorStand clickedEntity, final ItemStack playerItem, final ItemStack armorStandItem, final EquipmentSlot slot) {
public PlayerArmorStandManipulateEvent(@NotNull final Player who, @NotNull final ArmorStand clickedEntity, @NotNull final ItemStack playerItem, @NotNull final ItemStack armorStandItem, @NotNull final EquipmentSlot slot) {
super(who, clickedEntity);
this.playerItem = playerItem;
this.armorStandItem = armorStandItem;
@@ -33,6 +34,7 @@ public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent {
* In the case that the event is cancelled the original items will remain the same.
* @return the item held by the player.
*/
@NotNull
public ItemStack getPlayerItem() {
return this.playerItem;
}
@@ -46,6 +48,7 @@ public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent {
* In the case that the event is cancelled the original items will remain the same.
* @return the item held by the armor stand.
*/
@NotNull
public ItemStack getArmorStandItem() {
return this.armorStandItem;
}
@@ -55,20 +58,24 @@ public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent {
*
* @return the index of the item obtained or placed of the armor stand.
*/
@NotNull
public EquipmentSlot getSlot() {
return this.slot;
}
@NotNull
@Override
public ArmorStand getRightClicked() {
return (ArmorStand) this.clickedEntity;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* This event is fired when the player is almost about to enter the bed.
@@ -51,14 +52,14 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable {
private final BedEnterResult bedEnterResult;
private Result useBed = Result.DEFAULT;
public PlayerBedEnterEvent(Player who, Block bed, BedEnterResult bedEnterResult) {
public PlayerBedEnterEvent(@NotNull Player who, @NotNull Block bed, @NotNull BedEnterResult bedEnterResult) {
super(who);
this.bed = bed;
this.bedEnterResult = bedEnterResult;
}
@Deprecated
public PlayerBedEnterEvent(Player who, Block bed) {
public PlayerBedEnterEvent(@NotNull Player who, @NotNull Block bed) {
this(who, bed, BedEnterResult.OK);
}
@@ -67,6 +68,7 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable {
*
* @return the bed enter result representing the default outcome of this event
*/
@NotNull
public BedEnterResult getBedEnterResult() {
return bedEnterResult;
}
@@ -80,6 +82,7 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable {
* @return the action to take with the interacted bed
* @see #setUseBed(org.bukkit.event.Event.Result)
*/
@NotNull
public Result useBed() {
return useBed;
}
@@ -99,7 +102,7 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable {
* @param useBed the action to take with the interacted bed
* @see #useBed()
*/
public void setUseBed(Result useBed) {
public void setUseBed(@NotNull Result useBed) {
this.useBed = useBed;
}
@@ -139,15 +142,18 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable {
*
* @return the bed block involved in this event
*/
@NotNull
public Block getBed() {
return bed;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* This event is fired when the player is leaving a bed.
@@ -13,7 +14,7 @@ public class PlayerBedLeaveEvent extends PlayerEvent {
private final Block bed;
private boolean setBedSpawn;
public PlayerBedLeaveEvent(final Player who, final Block bed, boolean setBedSpawn) {
public PlayerBedLeaveEvent(@NotNull final Player who, @NotNull final Block bed, boolean setBedSpawn) {
super(who);
this.bed = bed;
this.setBedSpawn = setBedSpawn;
@@ -24,6 +25,7 @@ public class PlayerBedLeaveEvent extends PlayerEvent {
*
* @return the bed block involved in this event
*/
@NotNull
public Block getBed() {
return bed;
}
@@ -60,11 +62,13 @@ public class PlayerBedLeaveEvent extends PlayerEvent {
this.setBedSpawn = setBedSpawn;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -6,6 +6,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player empties a bucket
@@ -13,15 +14,17 @@ import org.bukkit.inventory.ItemStack;
public class PlayerBucketEmptyEvent extends PlayerBucketEvent {
private static final HandlerList handlers = new HandlerList();
public PlayerBucketEmptyEvent(final Player who, final Block blockClicked, final BlockFace blockFace, final Material bucket, final ItemStack itemInHand) {
public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) {
super(who, blockClicked, blockFace, bucket, itemInHand);
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -6,6 +6,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a player interacts with a Bucket
@@ -17,7 +19,7 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab
private final BlockFace blockFace;
private final Material bucket;
public PlayerBucketEvent(final Player who, final Block blockClicked, final BlockFace blockFace, final Material bucket, final ItemStack itemInHand) {
public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) {
super(who);
this.blockClicked = blockClicked;
this.blockFace = blockFace;
@@ -30,6 +32,7 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab
*
* @return the used bucket
*/
@NotNull
public Material getBucket() {
return bucket;
}
@@ -37,8 +40,9 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab
/**
* Get the resulting item in hand after the bucket event
*
* @return Itemstack hold in hand after the event.
* @return ItemStack hold in hand after the event.
*/
@Nullable
public ItemStack getItemStack() {
return itemStack;
}
@@ -46,9 +50,9 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab
/**
* Set the item in hand after the event
*
* @param itemStack the new held itemstack after the bucket event.
* @param itemStack the new held ItemStack after the bucket event.
*/
public void setItemStack(ItemStack itemStack) {
public void setItemStack(@Nullable ItemStack itemStack) {
this.itemStack = itemStack;
}
@@ -57,6 +61,7 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab
*
* @return the clicked block
*/
@NotNull
public Block getBlockClicked() {
return blockClicked;
}
@@ -66,6 +71,7 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab
*
* @return the clicked face
*/
@NotNull
public BlockFace getBlockFace() {
return blockFace;
}

View File

@@ -6,6 +6,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player fills a bucket
@@ -13,15 +14,17 @@ import org.bukkit.inventory.ItemStack;
public class PlayerBucketFillEvent extends PlayerBucketEvent {
private static final HandlerList handlers = new HandlerList();
public PlayerBucketFillEvent(final Player who, final Block blockClicked, final BlockFace blockFace, final Material bucket, final ItemStack itemInHand) {
public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) {
super(who, blockClicked, blockFace, bucket, itemInHand);
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.MainHand;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player changes their main hand in the client settings.
@@ -13,7 +14,7 @@ public class PlayerChangedMainHandEvent extends PlayerEvent {
//
private final MainHand mainHand;
public PlayerChangedMainHandEvent(Player who, MainHand mainHand) {
public PlayerChangedMainHandEvent(@NotNull Player who, @NotNull MainHand mainHand) {
super(who);
this.mainHand = mainHand;
}
@@ -24,15 +25,18 @@ public class PlayerChangedMainHandEvent extends PlayerEvent {
*
* @return the new {@link MainHand} of the player
*/
@NotNull
public MainHand getMainHand() {
return mainHand;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player switches to another world.
@@ -11,7 +12,7 @@ public class PlayerChangedWorldEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final World from;
public PlayerChangedWorldEvent(final Player player, final World from) {
public PlayerChangedWorldEvent(@NotNull final Player player, @NotNull final World from) {
super(player);
this.from = from;
}
@@ -21,15 +22,18 @@ public class PlayerChangedWorldEvent extends PlayerEvent {
*
* @return player's previous world
*/
@NotNull
public World getFrom() {
return from;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* This event is called after a player registers or unregisters a new plugin
@@ -11,20 +12,23 @@ public abstract class PlayerChannelEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final String channel;
public PlayerChannelEvent(final Player player, final String channel) {
public PlayerChannelEvent(@NotNull final Player player, @NotNull final String channel) {
super(player);
this.channel = channel;
}
@NotNull
public final String getChannel() {
return channel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -8,6 +8,7 @@ import org.bukkit.Warning;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Holds information for player chat and commands
@@ -28,14 +29,14 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable {
private String format;
private final Set<Player> recipients;
public PlayerChatEvent(final Player player, final String message) {
public PlayerChatEvent(@NotNull final Player player, @NotNull final String message) {
super(player);
this.message = message;
this.format = "<%1$s> %2$s";
this.recipients = new HashSet<Player>(player.getServer().getOnlinePlayers());
}
public PlayerChatEvent(final Player player, final String message, final String format, final Set<Player> recipients) {
public PlayerChatEvent(@NotNull final Player player, @NotNull final String message, @NotNull final String format, @NotNull final Set<Player> recipients) {
super(player);
this.message = message;
this.format = format;
@@ -55,6 +56,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable {
*
* @return Message the player is attempting to send
*/
@NotNull
public String getMessage() {
return message;
}
@@ -64,7 +66,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable {
*
* @param message New message that the player will send
*/
public void setMessage(String message) {
public void setMessage(@NotNull String message) {
this.message = message;
}
@@ -74,7 +76,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable {
*
* @param player New player which this event will execute as
*/
public void setPlayer(final Player player) {
public void setPlayer(@NotNull final Player player) {
Validate.notNull(player, "Player cannot be null");
this.player = player;
}
@@ -84,6 +86,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable {
*
* @return String.Format compatible format string
*/
@NotNull
public String getFormat() {
return format;
}
@@ -93,7 +96,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable {
*
* @param format String.Format compatible format string
*/
public void setFormat(final String format) {
public void setFormat(@NotNull final String format) {
// Oh for a better way to do this!
try {
String.format(format, player, message);
@@ -110,15 +113,18 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable {
*
* @return All Players who will see this chat message
*/
@NotNull
public Set<Player> getRecipients() {
return recipients;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -6,6 +6,7 @@ import org.apache.commons.lang.Validate;
import org.bukkit.Warning;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player attempts to tab-complete a chat message.
@@ -20,7 +21,7 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent {
private final String lastToken;
private final Collection<String> completions;
public PlayerChatTabCompleteEvent(final Player who, final String message, final Collection<String> completions) {
public PlayerChatTabCompleteEvent(@NotNull final Player who, @NotNull final String message, @NotNull final Collection<String> completions) {
super(who);
Validate.notNull(message, "Message cannot be null");
Validate.notNull(completions, "Completions cannot be null");
@@ -39,6 +40,7 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent {
*
* @return the chat message
*/
@NotNull
public String getChatMessage() {
return message;
}
@@ -51,6 +53,7 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent {
*
* @return The last token for the chat message
*/
@NotNull
public String getLastToken() {
return lastToken;
}
@@ -60,15 +63,18 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent {
*
* @return the current completions
*/
@NotNull
public Collection<String> getTabCompletions() {
return completions;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -7,6 +7,7 @@ import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* This event is called whenever a player runs a command (by placing a slash
@@ -51,13 +52,13 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell
private String message;
private final Set<Player> recipients;
public PlayerCommandPreprocessEvent(final Player player, final String message) {
public PlayerCommandPreprocessEvent(@NotNull final Player player, @NotNull final String message) {
super(player);
this.recipients = new HashSet<Player>(player.getServer().getOnlinePlayers());
this.message = message;
}
public PlayerCommandPreprocessEvent(final Player player, final String message, final Set<Player> recipients) {
public PlayerCommandPreprocessEvent(@NotNull final Player player, @NotNull final String message, @NotNull final Set<Player> recipients) {
super(player);
this.recipients = recipients;
this.message = message;
@@ -79,6 +80,7 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell
*
* @return Message the player is attempting to send
*/
@NotNull
public String getMessage() {
return message;
}
@@ -92,7 +94,7 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell
* @param command New message that the player will send
* @throws IllegalArgumentException if command is null or empty
*/
public void setMessage(String command) throws IllegalArgumentException {
public void setMessage(@NotNull String command) throws IllegalArgumentException {
Validate.notNull(command, "Command cannot be null");
Validate.notEmpty(command, "Command cannot be empty");
this.message = command;
@@ -104,7 +106,7 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell
* @param player New player which this event will execute as
* @throws IllegalArgumentException if the player provided is null
*/
public void setPlayer(final Player player) throws IllegalArgumentException {
public void setPlayer(@NotNull final Player player) throws IllegalArgumentException {
Validate.notNull(player, "Player cannot be null");
this.player = player;
}
@@ -123,16 +125,19 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell
* guarantee to the effect of viewing or modifying the set.
* @return All Players who will see this chat message
*/
@NotNull
@Deprecated
public Set<Player> getRecipients() {
return recipients;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import java.util.Collection;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* This event is called when the list of available server commands is sent to
@@ -18,7 +19,7 @@ public class PlayerCommandSendEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final Collection<String> commands;
public PlayerCommandSendEvent(final Player player, final Collection<String> commands) {
public PlayerCommandSendEvent(@NotNull final Player player, @NotNull final Collection<String> commands) {
super(player);
this.commands = commands;
}
@@ -31,15 +32,18 @@ public class PlayerCommandSendEvent extends PlayerEvent {
*
* @return collection of all commands
*/
@NotNull
public Collection<String> getCommands() {
return commands;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when a player drops an item from their inventory
@@ -13,7 +14,7 @@ public class PlayerDropItemEvent extends PlayerEvent implements Cancellable {
private final Item drop;
private boolean cancel = false;
public PlayerDropItemEvent(final Player player, final Item drop) {
public PlayerDropItemEvent(@NotNull final Player player, @NotNull final Item drop) {
super(player);
this.drop = drop;
}
@@ -23,6 +24,7 @@ public class PlayerDropItemEvent extends PlayerEvent implements Cancellable {
*
* @return ItemDrop created by the player
*/
@NotNull
public Item getItemDrop() {
return drop;
}
@@ -35,11 +37,13 @@ public class PlayerDropItemEvent extends PlayerEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.meta.BookMeta;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player edits or signs a book and quill item. If the event is
@@ -20,7 +21,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable {
private boolean isSigning;
private boolean cancel;
public PlayerEditBookEvent(Player who, int slot, BookMeta previousBookMeta, BookMeta newBookMeta, boolean isSigning) {
public PlayerEditBookEvent(@NotNull Player who, int slot, @NotNull BookMeta previousBookMeta, @NotNull BookMeta newBookMeta, boolean isSigning) {
super(who);
Validate.isTrue(slot >= -1 && slot <= 8, "Slot must be in range (-1)-8 inclusive");
@@ -44,6 +45,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable {
*
* @return the book meta currently on the book
*/
@NotNull
public BookMeta getPreviousBookMeta() {
return previousBookMeta.clone();
}
@@ -57,6 +59,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable {
*
* @return the book meta that the player is attempting to add
*/
@NotNull
public BookMeta getNewBookMeta() {
return newBookMeta.clone();
}
@@ -82,7 +85,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable {
* @param newBookMeta new book meta
* @throws IllegalArgumentException if the new book meta is null
*/
public void setNewBookMeta(BookMeta newBookMeta) throws IllegalArgumentException {
public void setNewBookMeta(@NotNull BookMeta newBookMeta) throws IllegalArgumentException {
Validate.notNull(newBookMeta, "New book meta must not be null");
Bukkit.getItemFactory().equals(newBookMeta, null);
this.newBookMeta = newBookMeta.clone();
@@ -108,11 +111,13 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable {
isSigning = signing;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.entity.Egg;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player throws an egg and it might hatch
@@ -15,7 +16,7 @@ public class PlayerEggThrowEvent extends PlayerEvent {
private EntityType hatchType;
private byte numHatches;
public PlayerEggThrowEvent(final Player player, final Egg egg, final boolean hatching, final byte numHatches, final EntityType hatchingType) {
public PlayerEggThrowEvent(@NotNull final Player player, @NotNull final Egg egg, final boolean hatching, final byte numHatches, @NotNull final EntityType hatchingType) {
super(player);
this.egg = egg;
this.hatching = hatching;
@@ -28,6 +29,7 @@ public class PlayerEggThrowEvent extends PlayerEvent {
*
* @return the egg involved in this event
*/
@NotNull
public Egg getEgg() {
return egg;
}
@@ -57,6 +59,7 @@ public class PlayerEggThrowEvent extends PlayerEvent {
*
* @return The type of the mob being hatched by the egg
*/
@NotNull
public EntityType getHatchingType() {
return hatchType;
}
@@ -66,7 +69,7 @@ public class PlayerEggThrowEvent extends PlayerEvent {
*
* @param hatchType The type of the mob being hatched by the egg
*/
public void setHatchingType(EntityType hatchType) {
public void setHatchingType(@NotNull EntityType hatchType) {
if(!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!");
this.hatchType = hatchType;
}
@@ -98,11 +101,13 @@ public class PlayerEggThrowEvent extends PlayerEvent {
this.numHatches = numHatches;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Represents a player related event
@@ -9,11 +10,11 @@ import org.bukkit.event.Event;
public abstract class PlayerEvent extends Event {
protected Player player;
public PlayerEvent(final Player who) {
public PlayerEvent(@NotNull final Player who) {
player = who;
}
PlayerEvent(final Player who, boolean async) {
PlayerEvent(@NotNull final Player who, boolean async) {
super(async);
player = who;
@@ -24,6 +25,7 @@ public abstract class PlayerEvent extends Event {
*
* @return Player who is involved in this event
*/
@NotNull
public final Player getPlayer() {
return player;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a players experience changes naturally
@@ -10,7 +11,7 @@ public class PlayerExpChangeEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private int exp;
public PlayerExpChangeEvent(final Player player, final int expAmount) {
public PlayerExpChangeEvent(@NotNull final Player player, final int expAmount) {
super(player);
exp = expAmount;
}
@@ -33,11 +34,13 @@ public class PlayerExpChangeEvent extends PlayerEvent {
exp = amount;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,8 @@ import org.bukkit.event.Cancellable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FishHook;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Thrown when a player is fishing
@@ -17,7 +19,7 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable {
private final State state;
private final FishHook hookEntity;
public PlayerFishEvent(final Player player, final Entity entity, final FishHook hookEntity, final State state) {
public PlayerFishEvent(@NotNull final Player player, @Nullable final Entity entity, @NotNull final FishHook hookEntity, @NotNull final State state) {
super(player);
this.entity = entity;
this.hookEntity = hookEntity;
@@ -33,6 +35,7 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable {
* @return Entity caught by the player, Entity if fishing, and null if
* bobber has gotten stuck in the ground or nothing has been caught
*/
@Nullable
public Entity getCaught() {
return entity;
}
@@ -42,6 +45,7 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable {
*
* @return the entity representing the fishing hook/bobber.
*/
@NotNull
public FishHook getHook() {
return hookEntity;
}
@@ -83,15 +87,18 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable {
*
* @return A State detailing the state of the fishing
*/
@NotNull
public State getState() {
return state;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when the GameMode of the player is changed.
@@ -13,7 +14,7 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl
private boolean cancelled;
private final GameMode newGameMode;
public PlayerGameModeChangeEvent(final Player player, final GameMode newGameMode) {
public PlayerGameModeChangeEvent(@NotNull final Player player, @NotNull final GameMode newGameMode) {
super(player);
this.newGameMode = newGameMode;
}
@@ -31,15 +32,18 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl
*
* @return player's new GameMode
*/
@NotNull
public GameMode getNewGameMode() {
return newGameMode;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
/**
* Represents an event that is called when a player right clicks an entity that
@@ -17,24 +18,27 @@ public class PlayerInteractAtEntityEvent extends PlayerInteractEntityEvent {
private static final HandlerList handlers = new HandlerList();
private final Vector position;
public PlayerInteractAtEntityEvent(Player who, Entity clickedEntity, Vector position) {
public PlayerInteractAtEntityEvent(@NotNull Player who, @NotNull Entity clickedEntity, @NotNull Vector position) {
this(who, clickedEntity, position, EquipmentSlot.HAND);
}
public PlayerInteractAtEntityEvent(Player who, Entity clickedEntity, Vector position, EquipmentSlot hand) {
public PlayerInteractAtEntityEvent(@NotNull Player who, @NotNull Entity clickedEntity, @NotNull Vector position, @NotNull EquipmentSlot hand) {
super(who, clickedEntity, hand);
this.position = position;
}
@NotNull
public Vector getClickedPosition() {
return position.clone();
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.EquipmentSlot;
import org.jetbrains.annotations.NotNull;
/**
* Represents an event that is called when a player right clicks an entity.
@@ -15,11 +16,11 @@ public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellabl
boolean cancelled = false;
private EquipmentSlot hand;
public PlayerInteractEntityEvent(final Player who, final Entity clickedEntity) {
public PlayerInteractEntityEvent(@NotNull final Player who, @NotNull final Entity clickedEntity) {
this(who, clickedEntity, EquipmentSlot.HAND);
}
public PlayerInteractEntityEvent(final Player who, final Entity clickedEntity, final EquipmentSlot hand) {
public PlayerInteractEntityEvent(@NotNull final Player who, @NotNull final Entity clickedEntity, @NotNull final EquipmentSlot hand) {
super(who);
this.clickedEntity = clickedEntity;
this.hand = hand;
@@ -34,10 +35,11 @@ public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellabl
}
/**
* Gets the entity that was rightclicked by the player.
* Gets the entity that was right-clicked by the player.
*
* @return entity right clicked by player
*/
@NotNull
public Entity getRightClicked() {
return this.clickedEntity;
}
@@ -47,15 +49,18 @@ public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellabl
*
* @return the hand used to interact
*/
@NotNull
public EquipmentSlot getHand() {
return hand;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -10,6 +10,8 @@ import org.bukkit.event.Cancellable;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents an event that is called when a player interacts with an object or
@@ -33,11 +35,11 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
private Result useItemInHand;
private EquipmentSlot hand;
public PlayerInteractEvent(final Player who, final Action action, final ItemStack item, final Block clickedBlock, final BlockFace clickedFace) {
public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace) {
this(who, action, item, clickedBlock, clickedFace, EquipmentSlot.HAND);
}
public PlayerInteractEvent(final Player who, final Action action, final ItemStack item, final Block clickedBlock, final BlockFace clickedFace, final EquipmentSlot hand) {
public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace, @Nullable final EquipmentSlot hand) {
super(who);
this.action = action;
this.item = item;
@@ -54,6 +56,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
*
* @return Action returns the type of interaction
*/
@NotNull
public Action getAction() {
return action;
}
@@ -88,6 +91,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
*
* @return ItemStack the item used
*/
@Nullable
public ItemStack getItem() {
return this.item;
}
@@ -98,6 +102,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
*
* @return Material the material of the item used
*/
@NotNull
public Material getMaterial() {
if (!hasItem()) {
return Material.AIR;
@@ -143,6 +148,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
*
* @return Block returns the block clicked with this item.
*/
@Nullable
public Block getClickedBlock() {
return blockClicked;
}
@@ -152,6 +158,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
*
* @return BlockFace returns the face of the block that was clicked
*/
@NotNull
public BlockFace getBlockFace() {
return blockFace;
}
@@ -163,6 +170,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
*
* @return the action to take with the interacted block
*/
@NotNull
public Result useInteractedBlock() {
return useClickedBlock;
}
@@ -170,7 +178,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
/**
* @param useInteractedBlock the action to take with the interacted block
*/
public void setUseInteractedBlock(Result useInteractedBlock) {
public void setUseInteractedBlock(@NotNull Result useInteractedBlock) {
this.useClickedBlock = useInteractedBlock;
}
@@ -182,6 +190,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
*
* @return the action to take with the item in hand
*/
@NotNull
public Result useItemInHand() {
return useItemInHand;
}
@@ -189,7 +198,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
/**
* @param useItemInHand the action to take with the item in hand
*/
public void setUseItemInHand(Result useItemInHand) {
public void setUseItemInHand(@NotNull Result useItemInHand) {
this.useItemInHand = useItemInHand;
}
@@ -199,15 +208,18 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
*
* @return the hand used to interact. May be null.
*/
@Nullable
public EquipmentSlot getHand() {
return hand;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Fired when a player's item breaks (such as a shovel or flint and steel).
@@ -14,7 +15,7 @@ public class PlayerItemBreakEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final ItemStack brokenItem;
public PlayerItemBreakEvent(final Player player, final ItemStack brokenItem) {
public PlayerItemBreakEvent(@NotNull final Player player, @NotNull final ItemStack brokenItem) {
super(player);
this.brokenItem = brokenItem;
}
@@ -24,15 +25,18 @@ public class PlayerItemBreakEvent extends PlayerEvent {
*
* @return The broken item
*/
@NotNull
public ItemStack getBrokenItem() {
return brokenItem;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This event will fire when a player is finishing consuming an item (food,
@@ -25,7 +27,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
* @param player the player consuming
* @param item the ItemStack being consumed
*/
public PlayerItemConsumeEvent(final Player player, final ItemStack item) {
public PlayerItemConsumeEvent(@NotNull final Player player, @NotNull final ItemStack item) {
super(player);
this.item = item;
@@ -38,6 +40,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
*
* @return an ItemStack for the item being consumed
*/
@NotNull
public ItemStack getItem() {
return item.clone();
}
@@ -47,7 +50,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
*
* @param item the item being consumed
*/
public void setItem(ItemStack item) {
public void setItem(@Nullable ItemStack item) {
if (item == null) {
this.item = new ItemStack(Material.AIR);
} else {
@@ -63,11 +66,13 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
this.isCancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when an item used by the player takes durability damage as a result of
@@ -16,7 +17,7 @@ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable {
private int damage;
private boolean cancelled = false;
public PlayerItemDamageEvent(Player player, ItemStack what, int damage) {
public PlayerItemDamageEvent(@NotNull Player player, @NotNull ItemStack what, int damage) {
super(player);
this.item = what;
this.damage = damage;
@@ -27,6 +28,7 @@ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable {
*
* @return the item
*/
@NotNull
public ItemStack getItem() {
return item;
}
@@ -54,11 +56,13 @@ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Fired when a player changes their currently held item
@@ -13,7 +14,7 @@ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable {
private final int previous;
private final int current;
public PlayerItemHeldEvent(final Player player, final int previous, final int current) {
public PlayerItemHeldEvent(@NotNull final Player player, final int previous, final int current) {
super(player);
this.previous = previous;
this.current = current;
@@ -45,11 +46,13 @@ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Represents when a player has an item repaired via the Mending enchantment.
@@ -21,7 +22,7 @@ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable {
private int repairAmount;
private boolean cancelled;
public PlayerItemMendEvent(Player who, ItemStack item, ExperienceOrb experienceOrb, int repairAmount) {
public PlayerItemMendEvent(@NotNull Player who, @NotNull ItemStack item, @NotNull ExperienceOrb experienceOrb, int repairAmount) {
super(who);
this.item = item;
this.experienceOrb = experienceOrb;
@@ -35,6 +36,7 @@ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable {
*
* @return the item to be repaired
*/
@NotNull
public ItemStack getItem() {
return item;
}
@@ -44,6 +46,7 @@ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable {
*
* @return the experience orb
*/
@NotNull
public ExperienceOrb getExperienceOrb() {
return experienceOrb;
}
@@ -81,11 +84,13 @@ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable {
this.cancelled = cancelled;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player joins a server
@@ -10,7 +11,7 @@ public class PlayerJoinEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private String joinMessage;
public PlayerJoinEvent(final Player playerJoined, final String joinMessage) {
public PlayerJoinEvent(@NotNull final Player playerJoined, @NotNull final String joinMessage) {
super(playerJoined);
this.joinMessage = joinMessage;
}
@@ -20,6 +21,7 @@ public class PlayerJoinEvent extends PlayerEvent {
*
* @return string join message
*/
@NotNull
public String getJoinMessage() {
return joinMessage;
}
@@ -29,15 +31,17 @@ public class PlayerJoinEvent extends PlayerEvent {
*
* @param joinMessage join message
*/
public void setJoinMessage(String joinMessage) {
public void setJoinMessage(@NotNull String joinMessage) {
this.joinMessage = joinMessage;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player gets kicked from the server
@@ -13,7 +14,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {
private String kickReason;
private Boolean cancel;
public PlayerKickEvent(final Player playerKicked, final String kickReason, final String leaveMessage) {
public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final String kickReason, @NotNull final String leaveMessage) {
super(playerKicked);
this.kickReason = kickReason;
this.leaveMessage = leaveMessage;
@@ -25,6 +26,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {
*
* @return string kick reason
*/
@NotNull
public String getReason() {
return kickReason;
}
@@ -34,6 +36,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {
*
* @return string kick reason
*/
@NotNull
public String getLeaveMessage() {
return leaveMessage;
}
@@ -51,7 +54,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {
*
* @param kickReason kick reason
*/
public void setReason(String kickReason) {
public void setReason(@NotNull String kickReason) {
this.kickReason = kickReason;
}
@@ -60,15 +63,17 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {
*
* @param leaveMessage leave message
*/
public void setLeaveMessage(String leaveMessage) {
public void setLeaveMessage(@NotNull String leaveMessage) {
this.leaveMessage = leaveMessage;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a players level changes
@@ -11,7 +12,7 @@ public class PlayerLevelChangeEvent extends PlayerEvent {
private final int oldLevel;
private final int newLevel;
public PlayerLevelChangeEvent(final Player player, final int oldLevel, final int newLevel) {
public PlayerLevelChangeEvent(@NotNull final Player player, final int oldLevel, final int newLevel) {
super(player);
this.oldLevel = oldLevel;
this.newLevel = newLevel;
@@ -35,11 +36,13 @@ public class PlayerLevelChangeEvent extends PlayerEvent {
return newLevel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player changes their locale in the client settings.
@@ -12,7 +13,7 @@ public class PlayerLocaleChangeEvent extends PlayerEvent {
//
private final String locale;
public PlayerLocaleChangeEvent(Player who, String locale) {
public PlayerLocaleChangeEvent(@NotNull Player who, @NotNull String locale) {
super(who);
this.locale = locale;
}
@@ -22,15 +23,18 @@ public class PlayerLocaleChangeEvent extends PlayerEvent {
*
* @return the player's new locale
*/
@NotNull
public String getLocale() {
return locale;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import java.net.InetAddress;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Stores details for players attempting to log in.
@@ -28,7 +29,7 @@ public class PlayerLoginEvent extends PlayerEvent {
* @param address The address the player used to connect, provided for
* timing issues
*/
public PlayerLoginEvent(final Player player, final String hostname, final InetAddress address) {
public PlayerLoginEvent(@NotNull final Player player, @NotNull final String hostname, @NotNull final InetAddress address) {
super(player);
this.hostname = hostname;
this.address = address;
@@ -44,7 +45,7 @@ public class PlayerLoginEvent extends PlayerEvent {
* @param result The result status for this event
* @param message The message to be displayed if result denies login
*/
public PlayerLoginEvent(final Player player, String hostname, final InetAddress address, final Result result, final String message) {
public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final String message) {
this(player, hostname, address);
this.result = result;
this.message = message;
@@ -55,6 +56,7 @@ public class PlayerLoginEvent extends PlayerEvent {
*
* @return Current Result of the login
*/
@NotNull
public Result getResult() {
return result;
}
@@ -64,7 +66,7 @@ public class PlayerLoginEvent extends PlayerEvent {
*
* @param result New result to set
*/
public void setResult(final Result result) {
public void setResult(@NotNull final Result result) {
this.result = result;
}
@@ -74,6 +76,7 @@ public class PlayerLoginEvent extends PlayerEvent {
*
* @return Current kick message
*/
@NotNull
public String getKickMessage() {
return message;
}
@@ -83,7 +86,7 @@ public class PlayerLoginEvent extends PlayerEvent {
*
* @param message New kick message
*/
public void setKickMessage(final String message) {
public void setKickMessage(@NotNull final String message) {
this.message = message;
}
@@ -93,6 +96,7 @@ public class PlayerLoginEvent extends PlayerEvent {
*
* @return The hostname
*/
@NotNull
public String getHostname() {
return hostname;
}
@@ -111,7 +115,7 @@ public class PlayerLoginEvent extends PlayerEvent {
* @param result New result for disallowing the player
* @param message Kick message to display to the user
*/
public void disallow(final Result result, final String message) {
public void disallow(@NotNull final Result result, @NotNull final String message) {
this.result = result;
this.message = message;
}
@@ -124,15 +128,18 @@ public class PlayerLoginEvent extends PlayerEvent {
* @return The address for this player. For legacy compatibility, this may
* be null.
*/
@NotNull
public InetAddress getAddress() {
return address;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,8 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Holds information for player movement events
@@ -15,7 +17,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
private Location from;
private Location to;
public PlayerMoveEvent(final Player player, final Location from, final Location to) {
public PlayerMoveEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) {
super(player);
this.from = from;
this.to = to;
@@ -54,6 +56,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
*
* @return Location the player moved from
*/
@NotNull
public Location getFrom() {
return from;
}
@@ -63,7 +66,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
*
* @param from New location to mark as the players previous location
*/
public void setFrom(Location from) {
public void setFrom(@NotNull Location from) {
validateLocation(from);
this.from = from;
}
@@ -73,6 +76,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
*
* @return Location the player moved to
*/
@Nullable
public Location getTo() {
return to;
}
@@ -82,21 +86,23 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
*
* @param to New Location this player will move to
*/
public void setTo(Location to) {
public void setTo(@NotNull Location to) {
validateLocation(to);
this.to = to;
}
private void validateLocation(Location loc) {
private void validateLocation(@NotNull Location loc) {
Preconditions.checkArgument(loc != null, "Cannot use null location!");
Preconditions.checkArgument(loc.getWorld() != null, "Cannot use null location with null world!");
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when a player picks up an arrow from the ground.
@@ -11,7 +12,7 @@ public class PlayerPickupArrowEvent extends PlayerPickupItemEvent {
private final Arrow arrow;
public PlayerPickupArrowEvent(final Player player, final Item item, final Arrow arrow) {
public PlayerPickupArrowEvent(@NotNull final Player player, @NotNull final Item item, @NotNull final Arrow arrow) {
super(player, item, 0);
this.arrow = arrow;
}
@@ -21,6 +22,7 @@ public class PlayerPickupArrowEvent extends PlayerPickupItemEvent {
*
* @return The arrow being picked up
*/
@NotNull
public Arrow getArrow() {
return arrow;
}

View File

@@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when a player picks an item up from the ground
@@ -19,7 +20,7 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
private boolean cancel = false;
private final int remaining;
public PlayerPickupItemEvent(final Player player, final Item item, final int remaining) {
public PlayerPickupItemEvent(@NotNull final Player player, @NotNull final Item item, final int remaining) {
super(player);
this.item = item;
this.remaining = remaining;
@@ -30,6 +31,7 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
*
* @return Item
*/
@NotNull
public Item getItem() {
return item;
}
@@ -51,11 +53,13 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,8 @@ import org.bukkit.Location;
import org.bukkit.TravelAgent;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a player is about to teleport because it is in contact with a
@@ -16,12 +18,12 @@ public class PlayerPortalEvent extends PlayerTeleportEvent {
protected boolean useTravelAgent = true;
protected TravelAgent travelAgent;
public PlayerPortalEvent(final Player player, final Location from, final Location to, final TravelAgent pta) {
public PlayerPortalEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TravelAgent pta) {
super(player, from, to);
this.travelAgent = pta;
}
public PlayerPortalEvent(Player player, Location from, Location to, TravelAgent pta, TeleportCause cause) {
public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TravelAgent pta, @NotNull TeleportCause cause) {
super(player, from, to, cause);
this.travelAgent = pta;
}
@@ -63,6 +65,7 @@ public class PlayerPortalEvent extends PlayerTeleportEvent {
*
* @return the Travel Agent used (or not) in this event
*/
@NotNull
public TravelAgent getPortalTravelAgent() {
return this.travelAgent;
}
@@ -72,15 +75,17 @@ public class PlayerPortalEvent extends PlayerTeleportEvent {
*
* @param travelAgent the Travel Agent used (or not) in this event
*/
public void setPortalTravelAgent(TravelAgent travelAgent) {
public void setPortalTravelAgent(@NotNull TravelAgent travelAgent) {
this.travelAgent = travelAgent;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -6,6 +6,7 @@ import java.util.UUID;
import org.bukkit.Warning;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Stores details for players attempting to log in
@@ -25,11 +26,11 @@ public class PlayerPreLoginEvent extends Event {
private final UUID uniqueId;
@Deprecated
public PlayerPreLoginEvent(final String name, final InetAddress ipAddress) {
public PlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress) {
this(name, ipAddress, null);
}
public PlayerPreLoginEvent(final String name, final InetAddress ipAddress, final UUID uniqueId) {
public PlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId) {
this.result = Result.ALLOWED;
this.message = "";
this.name = name;
@@ -42,6 +43,7 @@ public class PlayerPreLoginEvent extends Event {
*
* @return Current Result of the login
*/
@NotNull
public Result getResult() {
return result;
}
@@ -51,7 +53,7 @@ public class PlayerPreLoginEvent extends Event {
*
* @param result New result to set
*/
public void setResult(final Result result) {
public void setResult(@NotNull final Result result) {
this.result = result;
}
@@ -61,6 +63,7 @@ public class PlayerPreLoginEvent extends Event {
*
* @return Current kick message
*/
@NotNull
public String getKickMessage() {
return message;
}
@@ -70,7 +73,7 @@ public class PlayerPreLoginEvent extends Event {
*
* @param message New kick message
*/
public void setKickMessage(final String message) {
public void setKickMessage(@NotNull final String message) {
this.message = message;
}
@@ -88,7 +91,7 @@ public class PlayerPreLoginEvent extends Event {
* @param result New result for disallowing the player
* @param message Kick message to display to the user
*/
public void disallow(final Result result, final String message) {
public void disallow(@NotNull final Result result, @NotNull final String message) {
this.result = result;
this.message = message;
}
@@ -98,6 +101,7 @@ public class PlayerPreLoginEvent extends Event {
*
* @return the player's name
*/
@NotNull
public String getName() {
return name;
}
@@ -107,10 +111,12 @@ public class PlayerPreLoginEvent extends Event {
*
* @return The IP address
*/
@NotNull
public InetAddress getAddress() {
return ipAddress;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
@@ -121,10 +127,12 @@ public class PlayerPreLoginEvent extends Event {
*
* @return The unique ID
*/
@NotNull
public UUID getUniqueId() {
return uniqueId;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player leaves a server
@@ -10,7 +11,7 @@ public class PlayerQuitEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private String quitMessage;
public PlayerQuitEvent(final Player who, final String quitMessage) {
public PlayerQuitEvent(@NotNull final Player who, @NotNull final String quitMessage) {
super(who);
this.quitMessage = quitMessage;
}
@@ -20,6 +21,7 @@ public class PlayerQuitEvent extends PlayerEvent {
*
* @return string quit message
*/
@NotNull
public String getQuitMessage() {
return quitMessage;
}
@@ -29,15 +31,17 @@ public class PlayerQuitEvent extends PlayerEvent {
*
* @param quitMessage quit message
*/
public void setQuitMessage(String quitMessage) {
public void setQuitMessage(@NotNull String quitMessage) {
this.quitMessage = quitMessage;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player discovers a new recipe in the recipe book.
@@ -15,7 +16,7 @@ public class PlayerRecipeDiscoverEvent extends PlayerEvent implements Cancellabl
private boolean cancel = false;
private final NamespacedKey recipe;
public PlayerRecipeDiscoverEvent(Player who, NamespacedKey recipe) {
public PlayerRecipeDiscoverEvent(@NotNull Player who, @NotNull NamespacedKey recipe) {
super(who);
this.recipe = recipe;
}
@@ -25,6 +26,7 @@ public class PlayerRecipeDiscoverEvent extends PlayerEvent implements Cancellabl
*
* @return the discovered recipe
*/
@NotNull
public NamespacedKey getRecipe() {
return recipe;
}
@@ -39,11 +41,13 @@ public class PlayerRecipeDiscoverEvent extends PlayerEvent implements Cancellabl
this.cancel = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -1,13 +1,14 @@
package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/**
* This is called immediately after a player registers for a plugin channel.
*/
public class PlayerRegisterChannelEvent extends PlayerChannelEvent {
public PlayerRegisterChannelEvent(final Player player, final String channel) {
public PlayerRegisterChannelEvent(@NotNull final Player player, @NotNull final String channel) {
super(player, channel);
}
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player takes action on a resource pack request sent via
@@ -12,7 +13,7 @@ public class PlayerResourcePackStatusEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final Status status;
public PlayerResourcePackStatusEvent(final Player who, Status resourcePackStatus) {
public PlayerResourcePackStatusEvent(@NotNull final Player who, @NotNull Status resourcePackStatus) {
super(who);
this.status = resourcePackStatus;
}
@@ -22,15 +23,18 @@ public class PlayerResourcePackStatusEvent extends PlayerEvent {
*
* @return the current status
*/
@NotNull
public Status getStatus() {
return status;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player respawns.
@@ -13,7 +14,7 @@ public class PlayerRespawnEvent extends PlayerEvent {
private Location respawnLocation;
private final boolean isBedSpawn;
public PlayerRespawnEvent(final Player respawnPlayer, final Location respawnLocation, final boolean isBedSpawn) {
public PlayerRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnLocation, final boolean isBedSpawn) {
super(respawnPlayer);
this.respawnLocation = respawnLocation;
this.isBedSpawn = isBedSpawn;
@@ -24,6 +25,7 @@ public class PlayerRespawnEvent extends PlayerEvent {
*
* @return Location current respawn location
*/
@NotNull
public Location getRespawnLocation() {
return this.respawnLocation;
}
@@ -33,7 +35,7 @@ public class PlayerRespawnEvent extends PlayerEvent {
*
* @param respawnLocation new location for the respawn
*/
public void setRespawnLocation(Location respawnLocation) {
public void setRespawnLocation(@NotNull Location respawnLocation) {
Validate.notNull(respawnLocation, "Respawn location can not be null");
Validate.notNull(respawnLocation.getWorld(), "Respawn world can not be null");
@@ -49,11 +51,13 @@ public class PlayerRespawnEvent extends PlayerEvent {
return this.isBedSpawn;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* This event is fired when the player activates the riptide enchantment, using
@@ -16,7 +17,7 @@ public class PlayerRiptideEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final ItemStack item;
public PlayerRiptideEvent(final Player who, final ItemStack item) {
public PlayerRiptideEvent(@NotNull final Player who, @NotNull final ItemStack item) {
super(who);
this.item = item;
}
@@ -26,15 +27,18 @@ public class PlayerRiptideEvent extends PlayerEvent {
*
* @return held enchanted item
*/
@NotNull
public ItemStack getItem() {
return item;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player shears an entity
@@ -13,7 +14,7 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable {
private boolean cancel;
private final Entity what;
public PlayerShearEntityEvent(final Player who, final Entity what) {
public PlayerShearEntityEvent(@NotNull final Player who, @NotNull final Entity what) {
super(who);
this.cancel = false;
this.what = what;
@@ -32,15 +33,18 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable {
*
* @return the entity the player is shearing
*/
@NotNull
public Entity getEntity() {
return what;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -6,6 +6,8 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a player statistic is incremented.
@@ -23,7 +25,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel
private final EntityType entityType;
private final Material material;
public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue) {
public PlayerStatisticIncrementEvent(@NotNull Player player, @NotNull Statistic statistic, int initialValue, int newValue) {
super(player);
this.statistic = statistic;
this.initialValue = initialValue;
@@ -32,7 +34,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel
this.material = null;
}
public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue, EntityType entityType) {
public PlayerStatisticIncrementEvent(@NotNull Player player, @NotNull Statistic statistic, int initialValue, int newValue, @NotNull EntityType entityType) {
super(player);
this.statistic = statistic;
this.initialValue = initialValue;
@@ -41,7 +43,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel
this.material = null;
}
public PlayerStatisticIncrementEvent(Player player, Statistic statistic, int initialValue, int newValue, Material material) {
public PlayerStatisticIncrementEvent(@NotNull Player player, @NotNull Statistic statistic, int initialValue, int newValue, @NotNull Material material) {
super(player);
this.statistic = statistic;
this.initialValue = initialValue;
@@ -55,6 +57,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel
*
* @return the incremented statistic
*/
@NotNull
public Statistic getStatistic() {
return statistic;
}
@@ -83,6 +86,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel
*
* @return the EntityType of the statistic
*/
@Nullable
public EntityType getEntityType() {
return entityType;
}
@@ -93,6 +97,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel
*
* @return the Material of the statistic
*/
@Nullable
public Material getMaterial() {
return material;
}
@@ -105,11 +110,13 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel
this.isCancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a player swap items between main hand and off hand using the
@@ -17,7 +19,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable
private ItemStack offHandItem;
private boolean cancelled;
public PlayerSwapHandItemsEvent(Player player, ItemStack mainHandItem, ItemStack offHandItem) {
public PlayerSwapHandItemsEvent(@NotNull Player player, @NotNull ItemStack mainHandItem, @NotNull ItemStack offHandItem) {
super(player);
this.mainHandItem = mainHandItem;
@@ -29,6 +31,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable
*
* @return item in the main hand
*/
@Nullable
public ItemStack getMainHandItem() {
return mainHandItem;
}
@@ -38,7 +41,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable
*
* @param mainHandItem new item in the main hand
*/
public void setMainHandItem(ItemStack mainHandItem) {
public void setMainHandItem(@Nullable ItemStack mainHandItem) {
this.mainHandItem = mainHandItem;
}
@@ -47,6 +50,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable
*
* @return item in the off hand
*/
@Nullable
public ItemStack getOffHandItem() {
return offHandItem;
}
@@ -56,7 +60,7 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable
*
* @param offHandItem new item in the off hand
*/
public void setOffHandItem(ItemStack offHandItem) {
public void setOffHandItem(@Nullable ItemStack offHandItem) {
this.offHandItem = offHandItem;
}
@@ -70,11 +74,13 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,8 @@ package org.bukkit.event.player;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Holds information for player teleport events
@@ -11,11 +13,11 @@ public class PlayerTeleportEvent extends PlayerMoveEvent {
private static final HandlerList handlers = new HandlerList();
private TeleportCause cause = TeleportCause.UNKNOWN;
public PlayerTeleportEvent(final Player player, final Location from, final Location to) {
public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) {
super(player, from, to);
}
public PlayerTeleportEvent(final Player player, final Location from, final Location to, final TeleportCause cause) {
public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TeleportCause cause) {
this(player, from, to);
this.cause = cause;
@@ -26,6 +28,7 @@ public class PlayerTeleportEvent extends PlayerMoveEvent {
*
* @return Cause of the event
*/
@NotNull
public TeleportCause getCause() {
return cause;
}
@@ -77,11 +80,13 @@ public class PlayerTeleportEvent extends PlayerMoveEvent {
UNKNOWN;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player toggles their flying state
@@ -12,7 +13,7 @@ public class PlayerToggleFlightEvent extends PlayerEvent implements Cancellable
private final boolean isFlying;
private boolean cancel = false;
public PlayerToggleFlightEvent(final Player player, final boolean isFlying) {
public PlayerToggleFlightEvent(@NotNull final Player player, final boolean isFlying) {
super(player);
this.isFlying = isFlying;
}
@@ -34,11 +35,13 @@ public class PlayerToggleFlightEvent extends PlayerEvent implements Cancellable
this.cancel = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player toggles their sneaking state
@@ -12,7 +13,7 @@ public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable {
private final boolean isSneaking;
private boolean cancel = false;
public PlayerToggleSneakEvent(final Player player, final boolean isSneaking) {
public PlayerToggleSneakEvent(@NotNull final Player player, final boolean isSneaking) {
super(player);
this.isSneaking = isSneaking;
}
@@ -34,11 +35,13 @@ public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player toggles their sprinting state
@@ -12,7 +13,7 @@ public class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable
private final boolean isSprinting;
private boolean cancel = false;
public PlayerToggleSprintEvent(final Player player, final boolean isSprinting) {
public PlayerToggleSprintEvent(@NotNull final Player player, final boolean isSprinting) {
super(player);
this.isSprinting = isSprinting;
}
@@ -34,11 +35,13 @@ public class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable
this.cancel = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.entity.EntityUnleashEvent;
import org.jetbrains.annotations.NotNull;
/**
* Called prior to an entity being unleashed due to a player's action.
@@ -12,7 +13,7 @@ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Canc
private final Player player;
private boolean cancelled = false;
public PlayerUnleashEntityEvent(Entity entity, Player player) {
public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player) {
super(entity, UnleashReason.PLAYER_UNLEASH);
this.player = player;
}
@@ -22,6 +23,7 @@ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Canc
*
* @return The player
*/
@NotNull
public Player getPlayer() {
return player;
}

View File

@@ -1,13 +1,14 @@
package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/**
* This is called immediately after a player unregisters for a plugin channel.
*/
public class PlayerUnregisterChannelEvent extends PlayerChannelEvent {
public PlayerUnregisterChannelEvent(final Player player, final String channel) {
public PlayerUnregisterChannelEvent(@NotNull final Player player, @NotNull final String channel) {
super(player, channel);
}
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
/**
* Called when the velocity of a player changes.
@@ -13,7 +14,7 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable {
private boolean cancel = false;
private Vector velocity;
public PlayerVelocityEvent(final Player player, final Vector velocity) {
public PlayerVelocityEvent(@NotNull final Player player, @NotNull final Vector velocity) {
super(player);
this.velocity = velocity;
}
@@ -31,6 +32,7 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable {
*
* @return Vector the player will get
*/
@NotNull
public Vector getVelocity() {
return velocity;
}
@@ -40,15 +42,17 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable {
*
* @param velocity The velocity vector that will be sent to the player
*/
public void setVelocity(Vector velocity) {
public void setVelocity(@NotNull Vector velocity) {
this.velocity = velocity;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}